Skip to content

Commit

Permalink
fix: handle unquoted slash in attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
panyang05 committed Dec 8, 2024
1 parent b01cac9 commit 2ff8742
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/svelte/src/compiler/phases/1-parse/state/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,24 @@ function read_attribute(parser) {
let value = true;
if (parser.eat('=')) {
parser.allow_whitespace();
value = read_attribute_value(parser);
end = parser.index;

if (parser.template[parser.index] === '/') {
const char_start = parser.index;
parser.index++; // consume '/'
value = [
{
start: char_start,
end: char_start + 1,
type: 'Text',
raw: '/',
data: '/'
}
];
end = parser.index;
} else {
value = read_attribute_value(parser);
end = parser.index;
}
} else if (parser.match_regex(regex_starts_with_quote_characters)) {
e.expected_token(parser.index, '=');
}
Expand Down

0 comments on commit 2ff8742

Please sign in to comment.