Skip to content

Commit 4db1fc0

Browse files
committed
[feat] use the standard syntax table for JSX text runs
Closes #24
1 parent a0a9cfd commit 4db1fc0

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

rjsx-mode.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ and {}-bracketed expressions. Return the parsed child."
692692

693693
((= tt rjsx-JSX-TEXT)
694694
(rjsx-maybe-message "text node: '%s'" (js2-current-token-string))
695+
(js2-record-text-property (js2-current-token-beg) (js2-current-token-end)
696+
'syntax-table (standard-syntax-table))
695697
(make-rjsx-text :value (js2-current-token-string)))
696698

697699
((= tt js2-ERROR)

rjsx-tests.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@
127127
"const C = function() { return <component abc={123}/>;\n};"
128128
:warnings-count 0)
129129

130+
(ert-deftest rjsx-syntax-table-in-text ()
131+
"Ensure JSX text sequences use the default syntax table."
132+
(ert-with-test-buffer (:name 'rjsx)
133+
(insert "const d = <div>{/* this is a comment */}This is")
134+
(save-excursion (insert "' text{ anExpression }</div>;"))
135+
(setq parse-sexp-lookup-properties t)
136+
(js2-mode--and-parse)
137+
(should (eq (syntax-class (syntax-after (point))) (syntax-class (string-to-syntax "."))))))
138+
130139
;;; Now we test all of the malformed bits:
131140

132141
(defun jsx-test--forms (forms)

0 commit comments

Comments
 (0)