File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed
__tests__/fixtures/comments-within-tag-body Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " htmljs-parser " : patch
3+ ---
4+
5+ Fix regression around JS style comments in the body by requiring that they are preceded by a whitespace.
Original file line number Diff line number Diff line change 16166╭─ <!-- and this is a comment -->
1717 │ │ ╰─ comment.value " and this is a comment "
1818 ╰─ ╰─ comment "<!-- and this is a comment -->"
19- 7╭─ </div>
20- │ │ │ ╰─ closeTagEnd(div)
21- │ │ ╰─ closeTagName "div"
22- │ ├─ text "\n"
23- ╰─ ╰─ closeTagStart "</"
24- 8╰─
19+ 7╭─ But this, this is not a http://comment.com
20+ ╰─ ╰─ text "\n But this, this is not a http://comment.com\n And yet this is a "
21+ 8╭─ And yet this is a //comment
22+ │ │ ╰─ comment.value "comment"
23+ ╰─ ╰─ comment "//comment"
24+ 9╭─ And also /* this is a comment */
25+ │ │ │ ╰─ comment.value " this is a comment "
26+ │ │ ╰─ comment "/* this is a comment */"
27+ ╰─ ╰─ text "\n And also "
28+ 10╭─ Because a//comment must be preceded by whitespace.
29+ ╰─ ╰─ text "\n Because a//comment must be preceded by whitespace.\n"
30+ 11╭─ </div>
31+ │ │ │ ╰─ closeTagEnd(div)
32+ │ │ ╰─ closeTagName "div"
33+ ╰─ ╰─ closeTagStart "</"
34+ 12╰─
Original file line number Diff line number Diff line change 44 /* But this is a comment */
55 And this is more text
66 <!-- and this is a comment -->
7+ But this, this is not a http://comment.com
8+ And yet this is a // comment
9+ And also /* this is a comment */
10+ Because a//comment must be preceded by whitespace.
711</div >
Original file line number Diff line number Diff line change @@ -94,7 +94,10 @@ export const HTML_CONTENT: StateDefinition<HTMLContentMeta> = {
9494 this . endText ( ) ;
9595 this . enterState ( STATE . INLINE_SCRIPT ) ;
9696 this . pos ++ ; // skip space
97- } else if ( code === CODE . FORWARD_SLASH ) {
97+ } else if (
98+ code === CODE . FORWARD_SLASH &&
99+ isWhitespaceCode ( this . lookAtCharCodeAhead ( - 1 ) )
100+ ) {
98101 // Check next character to see if we are in a comment
99102 switch ( this . lookAtCharCodeAhead ( 1 ) ) {
100103 case CODE . FORWARD_SLASH :
You can’t perform that action at this time.
0 commit comments