Skip to content

Commit

Permalink
fix: tag variable not terminated on concise mode text delimiter (#150)
Browse files Browse the repository at this point in the history
* fix: tag variable not terminated on concise mode text delimiter
  • Loading branch information
DylanPiercey committed Feb 13, 2023
1 parent cfa3483 commit 0d7210b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lovely-chefs-pump.md
@@ -0,0 +1,5 @@
---
"htmljs-parser": patch
---

Fix issue with tag variable not terminated on concise mode text delimiter
@@ -0,0 +1,11 @@
1╭─ style/style --
│ │ ││ ╰─ openTagEnd
│ │ │╰─ tagVar.value "style"
│ │ ╰─ tagVar "/style"
╰─ ╰─ tagName "style"
2╭─ header {
╰─ ╰─ text "\n header {\n color: green\n }\n"
3├─ color: green
4├─ }
5╭─
╰─ ╰─ closeTagEnd(style)
@@ -0,0 +1,4 @@
style/style --
header {
color: green
}
2 changes: 1 addition & 1 deletion src/__tests__/main.test.ts
Expand Up @@ -176,7 +176,7 @@ for (const entry of fs.readdirSync(FIXTURES)) {
onOpenTagEnd(range) {
if (range.selfClosed) tagStack.pop();
else
switch (tagStack.at(-1)!.type) {
switch (tagStack[tagStack.length - 1]!.type) {
case TagType.statement:
case TagType.void:
tagStack.pop();
Expand Down
2 changes: 2 additions & 0 deletions src/states/OPEN_TAG.ts
Expand Up @@ -478,6 +478,8 @@ function shouldTerminateConciseTagVar(code: number, data: string, pos: number) {
case CODE.SEMICOLON:
case CODE.OPEN_ANGLE_BRACKET:
return true;
case CODE.HYPHEN:
return data.charCodeAt(pos + 1) === CODE.HYPHEN;
case CODE.COLON:
return data.charCodeAt(pos + 1) === CODE.EQUAL;
default:
Expand Down

0 comments on commit 0d7210b

Please sign in to comment.