diff --git a/.changeset/mean-buses-mate.md b/.changeset/mean-buses-mate.md new file mode 100644 index 00000000..2002a850 --- /dev/null +++ b/.changeset/mean-buses-mate.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": patch +--- + +Fixes a parse error where division is immediately followed by enclosed code. diff --git a/src/__tests__/fixtures/attr-method-shorthand/__snapshots__/attr-method-shorthand.expected.txt b/src/__tests__/fixtures/attr-method-shorthand/__snapshots__/attr-method-shorthand.expected.txt index 7356978f..b00ae74a 100644 --- a/src/__tests__/fixtures/attr-method-shorthand/__snapshots__/attr-method-shorthand.expected.txt +++ b/src/__tests__/fixtures/attr-method-shorthand/__snapshots__/attr-method-shorthand.expected.txt @@ -173,6 +173,18 @@ ╰─ ╰─ tagName "foo" 59├─ console.log("hello"); 60├─ event.preventDefault(); -61╭─ } - │ ├─ closeTagEnd(foo) - ╰─ ╰─ openTagEnd \ No newline at end of file +61├─ } +62╭─ + ╰─ ╰─ openTagEnd +63╭─ + │ ││ │││ ││ ╰─ openTagEnd:selfClosed "/>" + │ ││ │││ │╰─ attrMethod.body.value " c / (d) " + │ ││ │││ ╰─ attrMethod.body "{ c / (d) }" + │ ││ ││╰─ attrMethod.params.value + │ ││ │├─ attrMethod.params "()" + │ ││ │╰─ attrMethod "() { c / (d) }" + │ ││ ╰─ attrName + │ │╰─ tagName + │ ├─ closeTagEnd(foo) + ╰─ ╰─ openTagStart +64╰─ \ No newline at end of file diff --git a/src/__tests__/fixtures/attr-method-shorthand/input.marko b/src/__tests__/fixtures/attr-method-shorthand/input.marko index 89cc975e..ee5b3fb9 100644 --- a/src/__tests__/fixtures/attr-method-shorthand/input.marko +++ b/src/__tests__/fixtures/attr-method-shorthand/input.marko @@ -58,4 +58,6 @@ foo(event) { foo (event) { console.log("hello"); event.preventDefault(); -} \ No newline at end of file +} + + diff --git a/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt b/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt index 3c041919..b896f48b 100644 --- a/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt +++ b/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt @@ -1032,4 +1032,11 @@ │ ││├─ attrValue "= async function (x) { console.log(\"y\") }" │ ││╰─ attrName │ │╰─ tagName + ╰─ ╰─ openTagStart +128╭─ + │ │││ │ ╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrValue.value "x / (y[z])" + │ ││├─ attrValue "= x / (y[z])" + │ ││╰─ attrName + │ │╰─ tagName ╰─ ╰─ openTagStart \ No newline at end of file diff --git a/src/__tests__/fixtures/attr-operators-space-between/input.marko b/src/__tests__/fixtures/attr-operators-space-between/input.marko index af2fb653..178a17c6 100644 --- a/src/__tests__/fixtures/attr-operators-space-between/input.marko +++ b/src/__tests__/fixtures/attr-operators-space-between/input.marko @@ -124,4 +124,5 @@ a = async function (x) { console.log("y") } a { console.log("y") } a/> { console.log("y") } a/> - \ No newline at end of file + + \ No newline at end of file diff --git a/src/states/EXPRESSION.ts b/src/states/EXPRESSION.ts index 3c8a8dce..da05cc4b 100644 --- a/src/states/EXPRESSION.ts +++ b/src/states/EXPRESSION.ts @@ -90,6 +90,7 @@ export const EXPRESSION: StateDefinition = { default: { if (canFollowDivision(this.getPreviousNonWhitespaceCharCode())) { this.pos++; + this.forward = 0; this.consumeWhitespace(); } else { this.enterState(STATE.REGULAR_EXPRESSION);