Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/v2/annotated-source/nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,7 @@ <h3 id="jsx">JSX</h3>
@value =
<span class="hljs-keyword">if</span> value?
value = value.base
<span class="hljs-keyword">if</span> value <span class="hljs-keyword">instanceof</span> StringLiteral
<span class="hljs-keyword">if</span> value <span class="hljs-keyword">instanceof</span> StringLiteral <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> value.shouldGenerateTemplateLiteral()
value
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">new</span> JSXExpressionContainer value
Expand Down Expand Up @@ -9327,13 +9327,13 @@ <h3 id="stringwithinterpolations">StringWithInterpolations</h3>

<div class="content"><div class='highlight'><pre>
<span class="hljs-built_in">exports</span>.StringWithInterpolations = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">StringWithInterpolations</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Base</span></span>
constructor: <span class="hljs-function"><span class="hljs-params">(@body, {@quote, @startQuote} = {})</span> -&gt;</span>
constructor: <span class="hljs-function"><span class="hljs-params">(@body, {@quote, @startQuote, @jsxAttribute} = {})</span> -&gt;</span>
super()

@fromStringLiteral: <span class="hljs-function"><span class="hljs-params">(stringLiteral)</span> -&gt;</span>
updatedString = stringLiteral.withoutQuotesInLocationData()
updatedStringValue = <span class="hljs-keyword">new</span> Value(updatedString).withLocationDataFrom updatedString
<span class="hljs-keyword">new</span> StringWithInterpolations Block.wrap([updatedStringValue]), quote: stringLiteral.quote
<span class="hljs-keyword">new</span> StringWithInterpolations Block.wrap([updatedStringValue]), quote: stringLiteral.quote, jsxAttribute: stringLiteral.jsxAttribute
.withLocationDataFrom stringLiteral

children: [<span class="hljs-string">&#x27;body&#x27;</span>]</pre></div></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/v2/browser-compiler-legacy/coffeescript.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/v2/browser-compiler-modern/coffeescript.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions docs/v2/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -27004,6 +27004,27 @@ <h2>Another heading</h2>
});
'''

test '#5352: triple-quoted non-interpolated attribute values', ->
eqJS '''
<div a="""
b
c
""" />
''', '''
<div a={`b
c`} />;
'''

eqJS """
<div a='''
b
c
''' />
""", '''
<div a={`b
c`} />;
'''

</script>
<script type="text/x-literate-coffeescript" class="test" id="literate">
# Literate CoffeeScript Test
Expand Down
2 changes: 1 addition & 1 deletion lib/coffeescript-browser-compiler-legacy/coffeescript.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/coffeescript-browser-compiler-modern/coffeescript.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions lib/coffeescript/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ exports.JSXAttribute = class JSXAttribute extends Base
@value =
if value?
value = value.base
if value instanceof StringLiteral
if value instanceof StringLiteral and not value.shouldGenerateTemplateLiteral()
value
else
new JSXExpressionContainer value
Expand Down Expand Up @@ -5150,13 +5150,13 @@ exports.Parens = class Parens extends Base
#### StringWithInterpolations

exports.StringWithInterpolations = class StringWithInterpolations extends Base
constructor: (@body, {@quote, @startQuote} = {}) ->
constructor: (@body, {@quote, @startQuote, @jsxAttribute} = {}) ->
super()

@fromStringLiteral: (stringLiteral) ->
updatedString = stringLiteral.withoutQuotesInLocationData()
updatedStringValue = new Value(updatedString).withLocationDataFrom updatedString
new StringWithInterpolations Block.wrap([updatedStringValue]), quote: stringLiteral.quote
new StringWithInterpolations Block.wrap([updatedStringValue]), quote: stringLiteral.quote, jsxAttribute: stringLiteral.jsxAttribute
.withLocationDataFrom stringLiteral

children: ['body']
Expand Down
21 changes: 21 additions & 0 deletions test/jsx.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -946,3 +946,24 @@ test '“Adjacent” tags on separate lines should still compile', ->
return <b />;
});
'''

test '#5352: triple-quoted non-interpolated attribute values', ->
eqJS '''
<div a="""
b
c
""" />
''', '''
<div a={`b
c`} />;
'''

eqJS """
<div a='''
b
c
''' />
""", '''
<div a={`b
c`} />;
'''