FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: report comments before a comma-continued concise attr line by DylanPiercey · Pull Request #250 · marko-js/htmljs-parser · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .marko  (1) .md  (2) .ts  (1) .txt  (2) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions .changeset/concise-attr-line-comments.md
This file contains hidden or 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
---

Report the comments on the lines before a comma-continued concise attr line through `onOpenTagComment`. They were skipped without an event, so consumers dropped them.
This file contains hidden or 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,12 @@
---
type: dx
impact: low
effort: low
site: bench.ts
---

# Install the COMPARE build with pnpm in the bench

`COMPARE=<ref> pnpm run bench` clones the ref and runs `npm ci && npm run --if-present build` in it, but the repo only has a `pnpm-lock.yaml`, so `npm ci` exits with `EUSAGE` and the comparison never runs. Run `pnpm install --frozen-lockfile && pnpm run build` instead. Because the clone's directory is created before the install, a failed run also leaves it behind, and the next run sees it and skips the install, then fails to import the unbuilt `dist`. Only treat the clone as ready once its build has finished.

Check: `rm -rf "$TMPDIR/htmljs-bench-main" /tmp/htmljs-bench-main; COMPARE=main GREP=attr-comma pnpm run bench` fails with `The npm ci command can only install with an existing package-lock.json`.
This file contains hidden or 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
Expand Up @@ -4,12 +4,16 @@
│ │ │╰─ attrValue.value "bar"
│ │ ╰─ attrValue "=bar"
╰─ ╰─ attrName "foo"
3├─ // comment
3╭─ // comment
│ │ ╰─ openTagComment.value " comment"
╰─ ╰─ openTagComment "// comment"
4╭─ ,bar=baz
│ │ │╰─ attrValue.value "baz"
│ │ ╰─ attrValue "=baz"
╰─ ╰─ attrName "bar"
5├─ /* block */
5╭─ /* block */
│ │ ╰─ openTagComment.value " block "
╰─ ╰─ openTagComment "/* block */"
6╭─ ,qux=qux
│ │ │╰─ attrValue.value "qux"
│ │ ╰─ attrValue "=qux"
Expand Down
This file contains hidden or 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
Expand Up @@ -11,6 +11,19 @@
│ ├─ closeTagEnd(div)
│ ├─ openTagEnd
╰─ ╰─ tagName "span"
3╭─
3╭─ input
│ ├─ closeTagEnd(span)
│ ├─ openTagEnd
╰─ ╰─ closeTagEnd(span)
╰─ ╰─ tagName "input"
4╭─ // e
│ │ ╰─ openTagComment.value " e"
╰─ ╰─ openTagComment "// e"
5╭─ /* f */
│ │ ╰─ openTagComment.value " f "
╰─ ╰─ openTagComment "/* f */"
6╭─ ,type="text"
│ │ │╰─ attrValue.value "\"text\""
│ │ ╰─ attrValue "=\"text\""
╰─ ╰─ attrName "type"
7╭─
╰─ ╰─ openTagEnd
This file contains hidden or 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,2 +1,6 @@
div /* c */ a=1
span // d
input
// e
/* f */
,type="text"
6 changes: 3 additions & 3 deletions src/states/OPEN_TAG.ts
This file contains hidden or 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
Expand Up @@ -131,10 +131,10 @@ export const OPEN_TAG: StateDefinition<OpenTagMeta> = {
}
}

// comma continues the open tag with another line attribute
// comma continues the open tag with another line attribute, so
// the comments before it are parsed as part of the open tag
if (data.charCodeAt(cur) === CODE.COMMA) {
this.pos = cur + 1;
this.consumeWhitespace();
this.pos += len;
continue;
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL