Skip to content

Commit 0d7210b

Browse files
authored
fix: tag variable not terminated on concise mode text delimiter (#150)
* fix: tag variable not terminated on concise mode text delimiter
1 parent cfa3483 commit 0d7210b

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

.changeset/lovely-chefs-pump.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"htmljs-parser": patch
3+
---
4+
5+
Fix issue with tag variable not terminated on concise mode text delimiter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1╭─ style/style --
2+
│ │ ││ ╰─ openTagEnd
3+
│ │ │╰─ tagVar.value "style"
4+
│ │ ╰─ tagVar "/style"
5+
╰─ ╰─ tagName "style"
6+
2╭─ header {
7+
╰─ ╰─ text "\n header {\n color: green\n }\n"
8+
3├─ color: green
9+
4├─ }
10+
5╭─
11+
╰─ ╰─ closeTagEnd(style)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
style/style --
2+
header {
3+
color: green
4+
}

src/__tests__/main.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ for (const entry of fs.readdirSync(FIXTURES)) {
176176
onOpenTagEnd(range) {
177177
if (range.selfClosed) tagStack.pop();
178178
else
179-
switch (tagStack.at(-1)!.type) {
179+
switch (tagStack[tagStack.length - 1]!.type) {
180180
case TagType.statement:
181181
case TagType.void:
182182
tagStack.pop();

src/states/OPEN_TAG.ts

+2
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ function shouldTerminateConciseTagVar(code: number, data: string, pos: number) {
478478
case CODE.SEMICOLON:
479479
case CODE.OPEN_ANGLE_BRACKET:
480480
return true;
481+
case CODE.HYPHEN:
482+
return data.charCodeAt(pos + 1) === CODE.HYPHEN;
481483
case CODE.COLON:
482484
return data.charCodeAt(pos + 1) === CODE.EQUAL;
483485
default:

0 commit comments

Comments
 (0)