File tree 4 files changed +8
-6
lines changed
4 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ Car = React.createClass
13
13
<Parts.FrontSeat />
14
14
<Parts.BackSeat />
15
15
<p className = " seat" >Which seat can I take? {@props ? .seat or ' none' }</p >
16
+ {# also, this is a comment }
16
17
</Vehicle >
17
18
` ` `
18
19
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ module.exports = class Parser
209
209
first_line : @chunkLine , first_column : @chunkColumn
210
210
211
211
cjsxComment : ->
212
- match = @chunk .match (/ ^ \{ #( . * ) \} / )
212
+ match = @chunk .match (CJSX_ESC_COMMENT )
213
213
214
214
return 0 unless match
215
215
@ addLeafNodeToActiveBranch ParseTreeLeafNode ($ .CJSX_COMMENT , match[1 ])
@@ -423,6 +423,8 @@ TAG_ATTRIBUTES = ///
423
423
424
424
PRAGMA = / ^ \s * #\s * @cjsx\s + (\S * )/ i
425
425
426
+ CJSX_ESC_COMMENT = / ^ \{ #(. * )\} /
427
+
426
428
# from coffeescript lexer
427
429
428
430
# The character code of the nasty Microsoft madness otherwise known as the BOM.
Original file line number Diff line number Diff line change @@ -83,7 +83,6 @@ class Serialiser
83
83
# to ensure line number parity
84
84
85
85
# sort children into whitespace and semantic (non whitespace) groups
86
- # this seems wrong :\
87
86
[whitespaceChildren , semanticChildren ] = children .reduce ((partitionedChildren , child ) ->
88
87
if child .type is $ .CJSX_WHITESPACE
89
88
partitionedChildren[0 ].push child
@@ -141,7 +140,7 @@ nodeSerialisers =
141
140
for child in node .children
142
141
serialisedChild = @ serialiseNode child
143
142
if child? # filter empty text nodes
144
- if WHITESPACE_ONLY .test serialisedChild
143
+ if serialisedChild . length is 0 or WHITESPACE_ONLY .test serialisedChild
145
144
accumulatedWhitespace += serialisedChild
146
145
else
147
146
serialisedChildren .push (accumulatedWhitespace + serialisedChild)
@@ -160,7 +159,7 @@ nodeSerialisers =
160
159
" #{ @reactObject } .createElement(#{ element} , #{ joinList (serialisedChildren)} )"
161
160
162
161
CJSX_COMMENT : (node ) ->
163
- " "
162
+ ' null '
164
163
165
164
CJSX_ESC : (node ) ->
166
165
childrenSerialised = node .children
Original file line number Diff line number Diff line change @@ -510,7 +510,7 @@ cjsx comment is passed through
510
510
{# i am a comment}
511
511
</Person>
512
512
##expected
513
- React.createElement(Person, null,
513
+ React.createElement(Person, null
514
514
515
515
)
516
516
##end
@@ -520,7 +520,7 @@ comment syntax can be used inline
520
520
##input
521
521
<Person>{#comment inline}</Person>
522
522
##expected
523
- React.createElement(Person, null, )
523
+ React.createElement(Person, null)
524
524
##end
525
525
526
526
##desc
You can’t perform that action at this time.
0 commit comments