Skip to content

Commit

Permalink
fix: positions wrong with multiple quasis in tag name
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Apr 5, 2022
1 parent 02208cd commit a3122dd
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
1╭─ <${x}(y)/>
│ │ ││ ╰─ openTagEnd:selfClosed "/>"
│ │ │─ tagArgs.value
│ │ │╰─ tagName.quasis[1]
│ │ ╰─ tagArgs "(y)"
│ │ │─ tagArgs.value
│ │ ├─ tagArgs "(y)"
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${x}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${x}"
2╭─ <${x}|y|/>
│ │ ││ ╰─ openTagEnd:selfClosed "/>"
│ │ │─ tagParams.value
│ │ │╰─ tagName.quasis[1]
│ │ ╰─ tagParams "|y|"
│ │ │─ tagParams.value
│ │ ├─ tagParams "|y|"
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${x}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${x}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1╭─ ${test} foo=123
│ │ │ ││ ├─ closeTag(${test})
│ │ │ ││ ╰─ openTagEnd
│ │ │ │╰─ attrValue.value "123"
│ │ │ ╰─ attrValue "=123"
│ │ ─ attrName "foo"
│ │ ╰─ tagName.quasis[1]
│ │ │ ││ ├─ closeTag(${test})
│ │ │ ││ ╰─ openTagEnd
│ │ │ │╰─ attrValue.value "123"
│ │ │ ╰─ attrValue "=123"
│ │ │╰─ attrName "foo"
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${test}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${test}"
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
1╭─ <${test} foo=123/>
│ │ │ ││ ╰─ openTagEnd:selfClosed "/>"
│ │ │ │╰─ attrValue.value "123"
│ │ │ ╰─ attrValue "=123"
│ │ ─ attrName "foo"
│ │ ╰─ tagName.quasis[1]
│ │ │ ││ ╰─ openTagEnd:selfClosed "/>"
│ │ │ │╰─ attrValue.value "123"
│ │ │ ╰─ attrValue "=123"
│ │ │╰─ attrName "foo"
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${test}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${test}"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1╭─ .bar${data.foo}
│ ││ │ │╰─ tagShorthandClass.quasis[1]
│ ││ │ ├─ closeTag()
│ ││ │ ╰─ openTagEnd
│ ││ │ ├─ openTagEnd
│ ││ │ ╰─ tagShorthandClass.quasis[1]
│ ││ ╰─ tagShorthandClass.expressions[0] "${data.foo}"
│ │╰─ tagShorthandClass.quasis[0] "bar"
│ ├─ tagShorthandClass ".bar${data.foo}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1╭─ .${data.foo}-bar
│ ││ ├─ closeTag()
│ ││ ╰─ openTagEnd
│ ││ ╰─ tagShorthandClass.quasis[1] "bar"
│ ││ ├─ closeTag()
│ ││ ╰─ openTagEnd
│ ││ ╰─ tagShorthandClass.quasis[1] "-bar"
│ │├─ tagShorthandClass.expressions[0] "${data.foo}"
│ │╰─ tagShorthandClass.quasis[0]
│ ├─ tagShorthandClass ".${data.foo}-bar"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1╭─ span.${data.foo}
│ │ ││ │╰─ tagShorthandClass.quasis[1]
│ │ ││ ├─ closeTag(span)
│ │ ││ ╰─ openTagEnd
│ │ ││ ├─ openTagEnd
│ │ ││ ╰─ tagShorthandClass.quasis[1]
│ │ │├─ tagShorthandClass.expressions[0] "${data.foo}"
│ │ │╰─ tagShorthandClass.quasis[0]
│ │ ╰─ tagShorthandClass ".${data.foo}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1╭─ #bar${data.foo}
│ ││ │ │╰─ tagShorthandId.quasis[1]
│ ││ │ ├─ closeTag()
│ ││ │ ╰─ openTagEnd
│ ││ │ ├─ openTagEnd
│ ││ │ ╰─ tagShorthandId.quasis[1]
│ ││ ╰─ tagShorthandId.expressions[0] "${data.foo}"
│ │╰─ tagShorthandId.quasis[0] "bar"
│ ├─ tagShorthandId "#bar${data.foo}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1╭─ #${data.foo}-bar
│ ││ ├─ closeTag()
│ ││ ╰─ openTagEnd
│ ││ ╰─ tagShorthandId.quasis[1] "bar"
│ ││ ├─ closeTag()
│ ││ ╰─ openTagEnd
│ ││ ╰─ tagShorthandId.quasis[1] "-bar"
│ │├─ tagShorthandId.expressions[0] "${data.foo}"
│ │╰─ tagShorthandId.quasis[0]
│ ├─ tagShorthandId "#${data.foo}-bar"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1╭─ span#${data.foo}
│ │ ││ │╰─ tagShorthandId.quasis[1]
│ │ ││ ├─ closeTag(span)
│ │ ││ ╰─ openTagEnd
│ │ ││ ├─ openTagEnd
│ │ ││ ╰─ tagShorthandId.quasis[1]
│ │ │├─ tagShorthandId.expressions[0] "${data.foo}"
│ │ │╰─ tagShorthandId.quasis[0]
│ │ ╰─ tagShorthandId "#${data.foo}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
1╭─ <foo-${bar} hello="world">
│ │ │ │ ││ ╰─ openTagEnd
│ │ │ │ │╰─ attrValue.value "\"world\""
│ │ │ │ ╰─ attrValue "=\"world\""
│ │ │ ─ attrName "hello"
│ │ │ ╰─ tagName.quasis[1]
│ │ │ │ ││ ╰─ openTagEnd
│ │ │ │ │╰─ attrValue.value "\"world\""
│ │ │ │ ╰─ attrValue "=\"world\""
│ │ │ │╰─ attrName "hello"
│ │ │ ╰─ tagName.quasis[1]
│ │ ╰─ tagName.expressions[0] "${bar}"
│ ├─ tagName.quasis[0] "foo-"
╰─ ╰─ tagName "foo-${bar}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1╭─ <foo-${bar}-baz>
│ │ │ ╰─ openTagEnd
│ │ │ ╰─ tagName.quasis[1] "baz"
│ │ │ ╰─ openTagEnd
│ │ │ ╰─ tagName.quasis[1] "-baz"
│ │ ╰─ tagName.expressions[0] "${bar}"
│ ├─ tagName.quasis[0] "foo-"
╰─ ╰─ tagName "foo-${bar}-baz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1╭─ <foo-${bar}>
│ │ │ ╰─ openTagEnd
│ │ │ ├─ openTagEnd
│ │ │ ╰─ tagName.quasis[1]
│ │ ╰─ tagName.expressions[0] "${bar}"
│ ├─ tagName.quasis[0] "foo-"
╰─ ╰─ tagName "foo-${bar}"
2╭─ </>
│ │ ╰─ closeTag(foo-${bar}).value
│ ├─ text "\n"
│ ├─ tagName.quasis[1]
╰─ ╰─ closeTag(foo-${bar}) "</>"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1╭─ <${foo}-bar>
│ │ ╰─ openTagEnd
│ │ ╰─ tagName.quasis[1] "bar"
│ │ ╰─ openTagEnd
│ │ ╰─ tagName.quasis[1] "-bar"
│ ├─ tagName.expressions[0] "${foo}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${foo}-bar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
│ │ ││ ││ ╰─ closeTag(${myTagName}).value
│ │ ││ │╰─ closeTag(${myTagName}) "</>"
│ │ ││ ╰─ openTagEnd
│ │ │─ tagShorthandId.quasis[0] "foo"
│ │ │╰─ tagName.quasis[1]
│ │ ╰─ tagShorthandId "#foo"
│ │ │─ tagShorthandId.quasis[0] "foo"
│ │ ├─ tagShorthandId "#foo"
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${myTagName}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${myTagName}"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1╭─ <${foo}>
│ │ ╰─ openTagEnd
│ │ ├─ openTagEnd
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${foo}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${foo}"
2╭─ </>
│ │ ╰─ closeTag(${foo}).value
│ ├─ text "\n"
│ ├─ tagName.quasis[1]
╰─ ╰─ closeTag(${foo}) "</>"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1╭─ <${foo}>
│ │ ╰─ openTagEnd
│ │ ├─ openTagEnd
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${foo}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${foo}"
2╭─ </${foo}>
│ │ ╰─ closeTag(${foo}).value "${foo}"
│ ├─ text "\n"
│ ├─ tagName.quasis[1]
╰─ ╰─ closeTag(${foo}) "</${foo}>"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
1╭─ <${foo}/someVar>
│ │ ││ ╰─ openTagEnd
│ │ │─ tagVar.value "someVar"
│ │ │╰─ tagName.quasis[1]
│ │ ╰─ tagVar "/someVar"
│ │ │─ tagVar.value "someVar"
│ │ ├─ tagVar "/someVar"
│ │ ╰─ tagName.quasis[1]
│ ├─ tagName.expressions[0] "${foo}"
│ ├─ tagName.quasis[0]
╰─ ╰─ tagName "${foo}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1╭─ <div.hello-${world}-again/>
│ │ ││ │ │ ╰─ openTagEnd:selfClosed "/>"
│ │ ││ │ ╰─ tagShorthandClass.quasis[1] "-again"
│ │ ││ ╰─ tagShorthandClass.expressions[0] "${world}"
│ │ │╰─ tagShorthandClass.quasis[0] "hello-"
│ │ ╰─ tagShorthandClass ".hello-${world}-again"
╰─ ╰─ tagName "div"
1 change: 1 addition & 0 deletions src/__tests__/fixtures/testing/input.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div.hello-${world}-again/>
2 changes: 1 addition & 1 deletion src/states/TAG_NAME.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const TAG_NAME: StateDefinition<TagNameMeta> = {
const { quasis, expressions } = tagName;
const start = child.start - 2; // include ${
const end = ++this.pos; // include }
const nextStart = end + 1;
const nextStart = end;
expressions.push({
start,
end,
Expand Down

0 comments on commit a3122dd

Please sign in to comment.