mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
add missing end AST property to non-top-level <style> tags (#5487)
This commit is contained in:
parent
e508fb7b8b
commit
aa759f44fc
@ -223,21 +223,14 @@ export default function tag(parser: Parser) {
|
||||
);
|
||||
parser.read(/<\/textarea>/);
|
||||
element.end = parser.index;
|
||||
} else if (name === 'script') {
|
||||
} else if (name === 'script' || name === 'style') {
|
||||
// special case
|
||||
const start = parser.index;
|
||||
const data = parser.read_until(/<\/script>/);
|
||||
const data = parser.read_until(new RegExp(`</${name}>`));
|
||||
const end = parser.index;
|
||||
element.children.push({ start, end, type: 'Text', data });
|
||||
parser.eat('</script>', true);
|
||||
parser.eat(`</${name}>`, true);
|
||||
element.end = parser.index;
|
||||
} else if (name === 'style') {
|
||||
// special case
|
||||
const start = parser.index;
|
||||
const data = parser.read_until(/<\/style>/);
|
||||
const end = parser.index;
|
||||
element.children.push({ start, end, type: 'Text', data });
|
||||
parser.eat('</style>', true);
|
||||
} else {
|
||||
parser.stack.push(element);
|
||||
}
|
||||
|
1
test/parser/samples/style-inside-head/input.svelte
Normal file
1
test/parser/samples/style-inside-head/input.svelte
Normal file
@ -0,0 +1 @@
|
||||
<svelte:head><style></style></svelte:head>
|
33
test/parser/samples/style-inside-head/output.json
Normal file
33
test/parser/samples/style-inside-head/output.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"html": {
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"type": "Fragment",
|
||||
"children": [
|
||||
{
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"type": "Head",
|
||||
"name": "svelte:head",
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"start": 13,
|
||||
"end": 28,
|
||||
"type": "Element",
|
||||
"name": "style",
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"start": 20,
|
||||
"end": 20,
|
||||
"type": "Text",
|
||||
"data": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user