Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-boats-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

fix: parsing error when `<script>` has attribute with empty value
11 changes: 11 additions & 0 deletions src/parser/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ function parseAttributeValue(
index,
};
}
if (valueFirstChar === quote) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wil id="'"(single quote in double quotes) be a problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return {
value: {
value: "",
quote,
start: startIndex,
end: index + 1,
},
index: index + 1,
};
}
const value: AttributeValueToken = {
value: valueFirstChar,
quote,
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/parser/ast/script-tag-input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<head>
<script type="text/javascript" id="" src="/some-script.js"></script>
<link href="/style.css" rel="stylesheet">
<script>console.log('foo')</script>
</head>
Loading