0
0
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:
Andreas Ehrencrona 2020-10-02 15:30:17 +02:00 committed by GitHub
parent e508fb7b8b
commit aa759f44fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 10 deletions

View File

@ -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);
}

View File

@ -0,0 +1 @@
<svelte:head><style></style></svelte:head>

View 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": ""
}
]
}
]
}
]
}
}