Merge pull request #1342 from sveltejs/v2-remove-non-root-style-interpolation

in v2, don't parse for interpolations in non-root style elements
pull/1345/head
Rich Harris 7 years ago committed by GitHub
commit 85c8054fa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -248,13 +248,21 @@ export default function tag(parser: Parser) {
element.end = parser.index;
} else if (name === 'style') {
// special case
element.children = readSequence(
parser,
() =>
parser.template.slice(parser.index, parser.index + 8) === '</style>'
);
parser.read(/<\/style>/);
element.end = parser.index;
if (parser.v2) {
const start = parser.index;
const data = parser.readUntil(/<\/style>/);
const end = parser.index;
element.children.push({ start, end, type: 'Text', data });
parser.eat('</style>', true);
} else {
element.children = readSequence(
parser,
() =>
parser.template.slice(parser.index, parser.index + 8) === '</style>'
);
parser.read(/<\/style>/);
element.end = parser.index;
}
} else {
parser.stack.push(element);
}

@ -0,0 +1,4 @@
<div>
<style>div { color: red; }</style>
<script>alert('<>');</script>
</div>
Loading…
Cancel
Save