-
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.
feat: add new parser events and rename 'onTagName' to 'onOpenTagName'. (
#114)
- Loading branch information
1 parent
b79698c
commit 14f3499
Showing
238 changed files
with
3,707 additions
and
3,016 deletions.
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,7 @@ | ||
--- | ||
"htmljs-parser": major | ||
--- | ||
|
||
Rename `onTagName` to `onOpenTagName`. | ||
Add a new `onOpenTagStart` event (before `onOpenTagName`). | ||
Split the `onCloseTag` event into three new events: `onClosetTagStart`, `onCloseTagName` & `onCloseTagEnd`). |
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
82 changes: 44 additions & 38 deletions
82
src/__tests__/fixtures/argument-and-params/__snapshots__/argument-and-params.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 |
---|---|---|
@@ -1,44 +1,50 @@ | ||
1╭─ <${x}(y)/> | ||
│ │ ││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │╰─ tagArgs.value | ||
│ │ ├─ tagArgs "(y)" | ||
│ │ ╰─ tagName.quasis[1] | ||
│ ├─ tagName.expressions[0] "${x}" | ||
│ ├─ tagName.quasis[0] | ||
╰─ ╰─ tagName "${x}" | ||
│ ││ ││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │╰─ tagArgs.value | ||
│ ││ ├─ tagArgs "(y)" | ||
│ ││ ╰─ tagName.quasis[1] | ||
│ │├─ tagName.expressions[0] "${x}" | ||
│ │├─ tagName.quasis[0] | ||
│ │╰─ tagName "${x}" | ||
╰─ ╰─ openTagStart | ||
2╭─ <${x}|y|/> | ||
│ │ ││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │╰─ tagParams.value | ||
│ │ ├─ tagParams "|y|" | ||
│ │ ╰─ tagName.quasis[1] | ||
│ ├─ tagName.expressions[0] "${x}" | ||
│ ├─ tagName.quasis[0] | ||
╰─ ╰─ tagName "${x}" | ||
│ ││ ││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │╰─ tagParams.value | ||
│ ││ ├─ tagParams "|y|" | ||
│ ││ ╰─ tagName.quasis[1] | ||
│ │├─ tagName.expressions[0] "${x}" | ||
│ │├─ tagName.quasis[0] | ||
│ │╰─ tagName "${x}" | ||
╰─ ╰─ openTagStart | ||
3╭─ <tag.x(y)/> | ||
│ │ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │││╰─ tagArgs.value | ||
│ │ ││╰─ tagArgs "(y)" | ||
│ │ │╰─ tagShorthandClass.quasis[0] | ||
│ │ ╰─ tagShorthandClass ".x" | ||
╰─ ╰─ tagName "tag" | ||
│ ││ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │││╰─ tagArgs.value | ||
│ ││ ││╰─ tagArgs "(y)" | ||
│ ││ │╰─ tagShorthandClass.quasis[0] | ||
│ ││ ╰─ tagShorthandClass ".x" | ||
│ │╰─ tagName "tag" | ||
╰─ ╰─ openTagStart | ||
4╭─ <tag.x|y|/> | ||
│ │ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │││╰─ tagParams.value | ||
│ │ ││╰─ tagParams "|y|" | ||
│ │ │╰─ tagShorthandClass.quasis[0] | ||
│ │ ╰─ tagShorthandClass ".x" | ||
╰─ ╰─ tagName "tag" | ||
│ ││ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │││╰─ tagParams.value | ||
│ ││ ││╰─ tagParams "|y|" | ||
│ ││ │╰─ tagShorthandClass.quasis[0] | ||
│ ││ ╰─ tagShorthandClass ".x" | ||
│ │╰─ tagName "tag" | ||
╰─ ╰─ openTagStart | ||
5╭─ <tag#x(y)/> | ||
│ │ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │││╰─ tagArgs.value | ||
│ │ ││╰─ tagArgs "(y)" | ||
│ │ │╰─ tagShorthandId.quasis[0] | ||
│ │ ╰─ tagShorthandId "#x" | ||
╰─ ╰─ tagName "tag" | ||
│ ││ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │││╰─ tagArgs.value | ||
│ ││ ││╰─ tagArgs "(y)" | ||
│ ││ │╰─ tagShorthandId.quasis[0] | ||
│ ││ ╰─ tagShorthandId "#x" | ||
│ │╰─ tagName "tag" | ||
╰─ ╰─ openTagStart | ||
6╭─ <tag#x|y|/> | ||
│ │ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │││╰─ tagParams.value | ||
│ │ ││╰─ tagParams "|y|" | ||
│ │ │╰─ tagShorthandId.quasis[0] | ||
│ │ ╰─ tagShorthandId "#x" | ||
╰─ ╰─ tagName "tag" | ||
│ ││ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │││╰─ tagParams.value | ||
│ ││ ││╰─ tagParams "|y|" | ||
│ ││ │╰─ tagShorthandId.quasis[0] | ||
│ ││ ╰─ tagShorthandId "#x" | ||
│ │╰─ tagName "tag" | ||
╰─ ╰─ openTagStart |
16 changes: 9 additions & 7 deletions
16
.../argument-attr-extra-whitespace/__snapshots__/argument-attr-extra-whitespace.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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
1╭─ <div if (x > y)> | ||
│ │ │ ││ ╰─ openTagEnd | ||
│ │ │ │╰─ attrArgs.value "x > y" | ||
│ │ │ ╰─ attrArgs "(x > y)" | ||
│ │ ╰─ attrName "if" | ||
╰─ ╰─ tagName "div" | ||
│ ││ │ ││ ╰─ openTagEnd | ||
│ ││ │ │╰─ attrArgs.value "x > y" | ||
│ ││ │ ╰─ attrArgs "(x > y)" | ||
│ ││ ╰─ attrName "if" | ||
│ │╰─ tagName "div" | ||
╰─ ╰─ openTagStart | ||
2╭─ </div> | ||
│ │ ╰─ closeTag(div).value "div" | ||
│ │ │ ╰─ closeTagEnd(div) | ||
│ │ ╰─ closeTagName "div" | ||
│ ├─ text "\n" | ||
╰─ ╰─ closeTag(div) "</div>" | ||
╰─ ╰─ closeTagStart "</" | ||
3╰─ |
11 changes: 6 additions & 5 deletions
11
...tests__/fixtures/argument-attr-multiple/__snapshots__/argument-attr-multiple.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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
1╭─ <div for(var i = 0; i < 10; i++) (nonsense!)></div> | ||
│ │ │ ││ ╰─ error(INVALID_ATTRIBUTE_ARGUMENT:An attribute can only have one set of arguments) "nonsense!" | ||
│ │ │ │╰─ attrArgs.value "var i = 0; i < 10; i++" | ||
│ │ │ ╰─ attrArgs "(var i = 0; i < 10; i++)" | ||
│ │ ╰─ attrName "for" | ||
╰─ ╰─ tagName "div" | ||
│ ││ │ ││ ╰─ error(INVALID_ATTRIBUTE_ARGUMENT:An attribute can only have one set of arguments) "nonsense!" | ||
│ ││ │ │╰─ attrArgs.value "var i = 0; i < 10; i++" | ||
│ ││ │ ╰─ attrArgs "(var i = 0; i < 10; i++)" | ||
│ ││ ╰─ attrName "for" | ||
│ │╰─ tagName "div" | ||
╰─ ╰─ openTagStart |
16 changes: 9 additions & 7 deletions
16
src/__tests__/fixtures/argument-attr/__snapshots__/argument-attr.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
1╭─ <div if(x > y)></div> | ||
│ │ │ ││ ││ ╰─ closeTag(div).value "div" | ||
│ │ │ ││ │╰─ closeTag(div) "</div>" | ||
│ │ │ ││ ╰─ openTagEnd | ||
│ │ │ │╰─ attrArgs.value "x > y" | ||
│ │ │ ╰─ attrArgs "(x > y)" | ||
│ │ ╰─ attrName "if" | ||
╰─ ╰─ tagName "div" | ||
│ ││ │ ││ ││ │ ╰─ closeTagEnd(div) | ||
│ ││ │ ││ ││ ╰─ closeTagName "div" | ||
│ ││ │ ││ │╰─ closeTagStart "</" | ||
│ ││ │ ││ ╰─ openTagEnd | ||
│ ││ │ │╰─ attrArgs.value "x > y" | ||
│ ││ │ ╰─ attrArgs "(x > y)" | ||
│ ││ ╰─ attrName "if" | ||
│ │╰─ tagName "div" | ||
╰─ ╰─ openTagStart |
20 changes: 11 additions & 9 deletions
20
src/__tests__/fixtures/argument-tag-attr/__snapshots__/argument-tag-attr.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
1╭─ <for(var i = 0; i < 10; i++) if(x > y)></for> | ||
│ │ ││ │ ││ ││ ╰─ closeTag(for).value "for" | ||
│ │ ││ │ ││ │╰─ closeTag(for) "</for>" | ||
│ │ ││ │ ││ ╰─ openTagEnd | ||
│ │ ││ │ │╰─ attrArgs.value "x > y" | ||
│ │ ││ │ ╰─ attrArgs "(x > y)" | ||
│ │ ││ ╰─ attrName "if" | ||
│ │ │╰─ tagArgs.value "var i = 0; i < 10; i++" | ||
│ │ ╰─ tagArgs "(var i = 0; i < 10; i++)" | ||
╰─ ╰─ tagName "for" | ||
│ ││ ││ │ ││ ││ │ ╰─ closeTagEnd(for) | ||
│ ││ ││ │ ││ ││ ╰─ closeTagName "for" | ||
│ ││ ││ │ ││ │╰─ closeTagStart "</" | ||
│ ││ ││ │ ││ ╰─ openTagEnd | ||
│ ││ ││ │ │╰─ attrArgs.value "x > y" | ||
│ ││ ││ │ ╰─ attrArgs "(x > y)" | ||
│ ││ ││ ╰─ attrName "if" | ||
│ ││ │╰─ tagArgs.value "var i = 0; i < 10; i++" | ||
│ ││ ╰─ tagArgs "(var i = 0; i < 10; i++)" | ||
│ │╰─ tagName "for" | ||
╰─ ╰─ openTagStart |
14 changes: 8 additions & 6 deletions
14
src/__tests__/fixtures/argument-tag-complex/__snapshots__/argument-tag-complex.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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
1╭─ <for (x in ["Hello ${name}!", "(World)"])></for> | ||
│ │ ││ ││ ╰─ closeTag(for).value "for" | ||
│ │ ││ │╰─ closeTag(for) "</for>" | ||
│ │ ││ ╰─ openTagEnd | ||
│ │ │╰─ tagArgs.value "x in [\"Hello ${name}!\", \"(World)\"]" | ||
│ │ ╰─ tagArgs "(x in [\"Hello ${name}!\", \"(World)\"])" | ||
╰─ ╰─ tagName "for" | ||
│ ││ ││ ││ │ ╰─ closeTagEnd(for) | ||
│ ││ ││ ││ ╰─ closeTagName "for" | ||
│ ││ ││ │╰─ closeTagStart "</" | ||
│ ││ ││ ╰─ openTagEnd | ||
│ ││ │╰─ tagArgs.value "x in [\"Hello ${name}!\", \"(World)\"]" | ||
│ ││ ╰─ tagArgs "(x in [\"Hello ${name}!\", \"(World)\"])" | ||
│ │╰─ tagName "for" | ||
╰─ ╰─ openTagStart |
14 changes: 8 additions & 6 deletions
14
...es/argument-tag-extra-whitespace/__snapshots__/argument-tag-extra-whitespace.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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
1╭─ <for (x in y)></for> | ||
│ │ ││ ││ ╰─ closeTag(for).value "for" | ||
│ │ ││ │╰─ closeTag(for) "</for>" | ||
│ │ ││ ╰─ openTagEnd | ||
│ │ │╰─ tagArgs.value "x in y" | ||
│ │ ╰─ tagArgs "(x in y)" | ||
╰─ ╰─ tagName "for" | ||
│ ││ ││ ││ │ ╰─ closeTagEnd(for) | ||
│ ││ ││ ││ ╰─ closeTagName "for" | ||
│ ││ ││ │╰─ closeTagStart "</" | ||
│ ││ ││ ╰─ openTagEnd | ||
│ ││ │╰─ tagArgs.value "x in y" | ||
│ ││ ╰─ tagArgs "(x in y)" | ||
│ │╰─ tagName "for" | ||
╰─ ╰─ openTagStart |
9 changes: 5 additions & 4 deletions
9
...__tests__/fixtures/argument-tag-multiple/__snapshots__/argument-tag-multiple.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
1╭─ <for(var i = 0; i < 10; i++) (nonsense!)></for> | ||
│ │ ││ ╰─ error(INVALID_TAG_ARGUMENT:A tag can only have one argument) | ||
│ │ │╰─ tagArgs.value "var i = 0; i < 10; i++" | ||
│ │ ╰─ tagArgs "(var i = 0; i < 10; i++)" | ||
╰─ ╰─ tagName "for" | ||
│ ││ ││ ╰─ error(INVALID_TAG_ARGUMENT:A tag can only have one argument) | ||
│ ││ │╰─ tagArgs.value "var i = 0; i < 10; i++" | ||
│ ││ ╰─ tagArgs "(var i = 0; i < 10; i++)" | ||
│ │╰─ tagName "for" | ||
╰─ ╰─ openTagStart |
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
32 changes: 18 additions & 14 deletions
32
src/__tests__/fixtures/argument-tag/__snapshots__/argument-tag.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 |
---|---|---|
@@ -1,18 +1,22 @@ | ||
1╭─ <for(x in y)></for> | ||
│ │ ││ ││ ╰─ closeTag(for).value "for" | ||
│ │ ││ │╰─ closeTag(for) "</for>" | ||
│ │ ││ ╰─ openTagEnd | ||
│ │ │╰─ tagArgs.value "x in y" | ||
│ │ ╰─ tagArgs "(x in y)" | ||
╰─ ╰─ tagName "for" | ||
│ ││ ││ ││ │ ╰─ closeTagEnd(for) | ||
│ ││ ││ ││ ╰─ closeTagName "for" | ||
│ ││ ││ │╰─ closeTagStart "</" | ||
│ ││ ││ ╰─ openTagEnd | ||
│ ││ │╰─ tagArgs.value "x in y" | ||
│ ││ ╰─ tagArgs "(x in y)" | ||
│ │╰─ tagName "for" | ||
╰─ ╰─ openTagStart | ||
2╭─ <ab('c')/> | ||
│ │ ││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │ │╰─ tagArgs.value "'c'" | ||
│ │ ╰─ tagArgs "('c')" | ||
╰─ ╰─ tagName "ab" | ||
│ ││ ││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││ │╰─ tagArgs.value "'c'" | ||
│ ││ ╰─ tagArgs "('c')" | ||
│ │╰─ tagName "ab" | ||
╰─ ╰─ openTagStart | ||
3╭─ <a('b')/> | ||
│ │││ ╰─ openTagEnd:selfClosed "/>" | ||
│ ││╰─ tagArgs.value "'b'" | ||
│ │╰─ tagArgs "('b')" | ||
╰─ ╰─ tagName | ||
│ ││││ ╰─ openTagEnd:selfClosed "/>" | ||
│ │││╰─ tagArgs.value "'b'" | ||
│ ││╰─ tagArgs "('b')" | ||
│ │╰─ tagName | ||
╰─ ╰─ openTagStart | ||
4╰─ |
Oops, something went wrong.