diff --git a/src/parser.coffee b/src/parser.coffee
index a5818c5..ff63468 100644
--- a/src/parser.coffee
+++ b/src/parser.coffee
@@ -31,6 +31,7 @@ module.exports = class Parser
) or
@cjsxStart() or
@cjsxAttribute() or
+ @cjsxComment() or
@cjsxEscape() or
@cjsxUnescape() or
@cjsxEnd() or
@@ -207,6 +208,13 @@ module.exports = class Parser
"Invalid attribute #{input} in CJSX tag #{@peekActiveState(2).value}",
first_line: @chunkLine, first_column: @chunkColumn
+ cjsxComment: ->
+ match = @chunk.match(/^\{#(.*)\}/)
+
+ return 0 unless match
+ @addLeafNodeToActiveBranch ParseTreeLeafNode($.CJSX_COMMENT, match[1])
+ return match[0].length
+
cjsxEscape: ->
return 0 unless @chunk.charAt(0) is '{' and
@currentState() in [$.CJSX_EL, $.CJSX_ATTR_PAIR]
diff --git a/src/serialiser.coffee b/src/serialiser.coffee
index 9a9515f..484e65b 100644
--- a/src/serialiser.coffee
+++ b/src/serialiser.coffee
@@ -157,6 +157,9 @@ nodeSerialisers =
element = node.value
"#{@reactObject}.createElement(#{element}, #{joinList(serialisedChildren)})"
+ CJSX_COMMENT: (node) ->
+ ""
+
CJSX_ESC: (node) ->
childrenSerialised = node.children
.map((child) => @serialiseNode child)
diff --git a/src/symbols.coffee b/src/symbols.coffee
index f1d97e5..3b9aa50 100644
--- a/src/symbols.coffee
+++ b/src/symbols.coffee
@@ -26,6 +26,7 @@ module.exports =
# they're just names for use in debugging
CJSX_START: 'CJSX_START'
CJSX_END: 'CJSX_END'
+ CJSX_COMMENT: 'CJSX_COMMENT'
CJSX_ESC_START: 'CJSX_ESC_START'
CJSX_ESC_END: 'CJSX_ESC_END'
CJSX_PRAGMA: 'CJSX_PRAGMA'
diff --git a/test/output-testcases.txt b/test/output-testcases.txt
index d627540..de2a7cf 100644
--- a/test/output-testcases.txt
+++ b/test/output-testcases.txt
@@ -477,6 +477,52 @@ React.createElement(Person, null, """
""")
##end
+##desc
+empty node is handled as expected
+##input
+
+
+##expected
+React.createElement(Person, null
+)
+##end
+
+##desc
+cs comment at start of cjsx escape
+##input
+
+{# i am a comment
+ "i am a string"
+}
+
+##expected
+React.createElement(Person, null,
+(# i am a comment
+ "i am a string"
+)
+)
+##end
+
+##desc
+cjsx comment is passed through
+##input
+
+{# i am a comment}
+
+##expected
+React.createElement(Person, null,
+
+)
+##end
+
+##desc
+comment syntax can be used inline
+##input
+{#comment inline}
+##expected
+React.createElement(Person, null, )
+##end
+
##desc
string within cjsx is ignored by parser and escaped
##input