Skip to content

Commit

Permalink
fix: comma will now always terminate a tag variable
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jul 26, 2022
1 parent b1e68a3 commit 19eceaa
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-carrots-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"htmljs-parser": patch
---

Comma will now always terminate a tag variable.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1╭─ <let/x,y=1/>
│ ││ ││ │││╰─ openTagEnd:selfClosed "/>"
│ ││ ││ ││╰─ attrValue.value
│ ││ ││ │╰─ attrValue "=1"
│ ││ ││ ╰─ attrName
│ ││ │╰─ tagVar.value
│ ││ ╰─ tagVar "/x"
│ │╰─ tagName "let"
╰─ ╰─ openTagStart
2╭─ <let/x ,y=1/>
│ ││ ││ │││╰─ openTagEnd:selfClosed "/>"
│ ││ ││ ││╰─ attrValue.value
│ ││ ││ │╰─ attrValue "=1"
│ ││ ││ ╰─ attrName
│ ││ │╰─ tagVar.value
│ ││ ╰─ tagVar "/x"
│ │╰─ tagName "let"
╰─ ╰─ openTagStart
3╭─ <let/x, y=1/>
│ ││ ││ │││╰─ openTagEnd:selfClosed "/>"
│ ││ ││ ││╰─ attrValue.value
│ ││ ││ │╰─ attrValue "=1"
│ ││ ││ ╰─ attrName
│ ││ │╰─ tagVar.value
│ ││ ╰─ tagVar "/x"
│ │╰─ tagName "let"
╰─ ╰─ openTagStart
4╭─ <let/x , y=1/>
│ ││ ││ │││╰─ openTagEnd:selfClosed "/>"
│ ││ ││ ││╰─ attrValue.value
│ ││ ││ │╰─ attrValue "=1"
│ ││ ││ ╰─ attrName
│ ││ │╰─ tagVar.value
│ ││ ╰─ tagVar "/x"
│ │╰─ tagName "let"
╰─ ╰─ openTagStart
5╰─
4 changes: 4 additions & 0 deletions src/__tests__/fixtures/comma-after-tag-variable/input.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<let/x,y=1/>
<let/x ,y=1/>
<let/x, y=1/>
<let/x , y=1/>
2 changes: 2 additions & 0 deletions src/states/OPEN_TAG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const CONCISE_TAG_VAR_TERMINATORS = [
CODE.OPEN_PAREN,
CODE.PIPE,
CODE.EQUAL,
CODE.COMMA,
[CODE.COLON, CODE.EQUAL],
];

Expand All @@ -45,6 +46,7 @@ const HTML_TAG_VAR_TERMINATORS = [
CODE.OPEN_PAREN,
CODE.PIPE,
CODE.EQUAL,
CODE.COMMA,
[CODE.COLON, CODE.EQUAL],
[CODE.FORWARD_SLASH, CODE.CLOSE_ANGLE_BRACKET],
];
Expand Down

0 comments on commit 19eceaa

Please sign in to comment.