Skip to content

Commit 4423821

Browse files
committed
fix: parsing error when <script> has attribute with empty value
1 parent 534e885 commit 4423821

File tree

6 files changed

+1725
-0
lines changed

6 files changed

+1725
-0
lines changed

src/parser/html.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ function parseAttributeValue(
157157
index,
158158
};
159159
}
160+
if (valueFirstChar === quote) {
161+
return {
162+
value: {
163+
value: "",
164+
quote,
165+
start: startIndex,
166+
end: index + 1,
167+
},
168+
index: index + 1,
169+
};
170+
}
160171
const value: AttributeValueToken = {
161172
value: valueFirstChar,
162173
quote,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<head>
2+
<script type="text/javascript" id="" src="/some-script.js"></script>
3+
<link href="/style.css" rel="stylesheet">
4+
<script>console.log('foo')</script>
5+
</head>

0 commit comments

Comments
 (0)