-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exclude member expressions from unary operator check
- Loading branch information
1 parent
c5bbf11
commit 1f2c9b0
Showing
4 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"htmljs-parser": patch | ||
--- | ||
|
||
When parsing unenclosed expressions we look backwards for unary operators preceded by a word break. This caused a false positive when a member expression was found with the operator name, eg `input.new`. Now we ensure that these operators are not in a member expression like this. |
18 changes: 18 additions & 0 deletions
18
...fixtures/unary-as-member-expression/__snapshots__/unary-as-member-expression.expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
1╭─ div a=class Test extends Other { hello() {} } | ||
│ │ ││╰─ attrValue.value "class Test extends Other { hello() {} }" | ||
│ │ │╰─ attrValue "=class Test extends Other { hello() {} }" | ||
│ │ ╰─ attrName | ||
╰─ ╰─ tagName "div" | ||
2╭─ div a=input.class Test extends Other { hello() {} } | ||
│ │ │││ │ │ │ │ ├─ closeTag(div) | ||
│ │ │││ │ │ │ │ ╰─ openTagEnd | ||
│ │ │││ │ │ │ ╰─ attrName "{ hello() {} }" | ||
│ │ │││ │ │ ╰─ attrName "Other" | ||
│ │ │││ │ ╰─ attrName "extends" | ||
│ │ │││ ╰─ attrName "Test" | ||
│ │ ││╰─ attrValue.value "input.class" | ||
│ │ │╰─ attrValue "=input.class" | ||
│ │ ╰─ attrName | ||
│ ├─ closeTag(div) | ||
│ ├─ openTagEnd | ||
╰─ ╰─ tagName "div" |
2 changes: 2 additions & 0 deletions
2
src/__tests__/fixtures/unary-as-member-expression/input.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
div a=class Test extends Other { hello() {} } | ||
div a=input.class Test extends Other { hello() {} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters