Skip to content

Commit 204875e

Browse files
helixbassGeoffreyBooth
authored andcommitted
handle triple-quoted JSX attribute values
1 parent ed6733d commit 204875e

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

lib/coffeescript/nodes.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ exports.JSXAttribute = class JSXAttribute extends Base
17121712
@value =
17131713
if value?
17141714
value = value.base
1715-
if value instanceof StringLiteral
1715+
if value instanceof StringLiteral and not value.shouldGenerateTemplateLiteral()
17161716
value
17171717
else
17181718
new JSXExpressionContainer value
@@ -5150,13 +5150,13 @@ exports.Parens = class Parens extends Base
51505150
#### StringWithInterpolations
51515151

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

51565156
@fromStringLiteral: (stringLiteral) ->
51575157
updatedString = stringLiteral.withoutQuotesInLocationData()
51585158
updatedStringValue = new Value(updatedString).withLocationDataFrom updatedString
5159-
new StringWithInterpolations Block.wrap([updatedStringValue]), quote: stringLiteral.quote
5159+
new StringWithInterpolations Block.wrap([updatedStringValue]), quote: stringLiteral.quote, jsxAttribute: stringLiteral.jsxAttribute
51605160
.withLocationDataFrom stringLiteral
51615161

51625162
children: ['body']

test/jsx.coffee

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,3 +946,24 @@ test '“Adjacent” tags on separate lines should still compile', ->
946946
return <b />;
947947
});
948948
'''
949+
950+
test '#5352: triple-quoted non-interpolated attribute values', ->
951+
eqJS '''
952+
<div a="""
953+
b
954+
c
955+
""" />
956+
''', '''
957+
<div a={`b
958+
c`} />;
959+
'''
960+
961+
eqJS """
962+
<div a='''
963+
b
964+
c
965+
''' />
966+
""", '''
967+
<div a={`b
968+
c`} />;
969+
'''

0 commit comments

Comments
 (0)