diff --git a/.changeset/cuddly-carrots-compete.md b/.changeset/cuddly-carrots-compete.md new file mode 100644 index 0000000..374f663 --- /dev/null +++ b/.changeset/cuddly-carrots-compete.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": patch +--- + +Comma will now always terminate a tag variable. diff --git a/src/__tests__/fixtures/comma-after-tag-variable/__snapshots__/comma-after-tag-variable.expected.txt b/src/__tests__/fixtures/comma-after-tag-variable/__snapshots__/comma-after-tag-variable.expected.txt new file mode 100644 index 0000000..11e0408 --- /dev/null +++ b/src/__tests__/fixtures/comma-after-tag-variable/__snapshots__/comma-after-tag-variable.expected.txt @@ -0,0 +1,37 @@ +1╭─ + │ ││ ││ │││╰─ openTagEnd:selfClosed "/>" + │ ││ ││ ││╰─ attrValue.value + │ ││ ││ │╰─ attrValue "=1" + │ ││ ││ ╰─ attrName + │ ││ │╰─ tagVar.value + │ ││ ╰─ tagVar "/x" + │ │╰─ tagName "let" + ╰─ ╰─ openTagStart +2╭─ + │ ││ ││ │││╰─ openTagEnd:selfClosed "/>" + │ ││ ││ ││╰─ attrValue.value + │ ││ ││ │╰─ attrValue "=1" + │ ││ ││ ╰─ attrName + │ ││ │╰─ tagVar.value + │ ││ ╰─ tagVar "/x" + │ │╰─ tagName "let" + ╰─ ╰─ openTagStart +3╭─ + │ ││ ││ │││╰─ openTagEnd:selfClosed "/>" + │ ││ ││ ││╰─ attrValue.value + │ ││ ││ │╰─ attrValue "=1" + │ ││ ││ ╰─ attrName + │ ││ │╰─ tagVar.value + │ ││ ╰─ tagVar "/x" + │ │╰─ tagName "let" + ╰─ ╰─ openTagStart +4╭─ + │ ││ ││ │││╰─ openTagEnd:selfClosed "/>" + │ ││ ││ ││╰─ attrValue.value + │ ││ ││ │╰─ attrValue "=1" + │ ││ ││ ╰─ attrName + │ ││ │╰─ tagVar.value + │ ││ ╰─ tagVar "/x" + │ │╰─ tagName "let" + ╰─ ╰─ openTagStart +5╰─ \ No newline at end of file diff --git a/src/__tests__/fixtures/comma-after-tag-variable/input.marko b/src/__tests__/fixtures/comma-after-tag-variable/input.marko new file mode 100644 index 0000000..d513219 --- /dev/null +++ b/src/__tests__/fixtures/comma-after-tag-variable/input.marko @@ -0,0 +1,4 @@ + + + + diff --git a/src/states/OPEN_TAG.ts b/src/states/OPEN_TAG.ts index 3404878..e8ae3d0 100644 --- a/src/states/OPEN_TAG.ts +++ b/src/states/OPEN_TAG.ts @@ -37,6 +37,7 @@ const CONCISE_TAG_VAR_TERMINATORS = [ CODE.OPEN_PAREN, CODE.PIPE, CODE.EQUAL, + CODE.COMMA, [CODE.COLON, CODE.EQUAL], ]; @@ -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], ];