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,6 +248,13 @@ export default function tag(parser: Parser) {
element.end = parser.index; element.end = parser.index;
} else if (name === 'style') { } else if (name === 'style') {
// special case // special case
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( element.children = readSequence(
parser, parser,
() => () =>
@ -255,6 +262,7 @@ export default function tag(parser: Parser) {
); );
parser.read(/<\/style>/); parser.read(/<\/style>/);
element.end = parser.index; element.end = parser.index;
}
} else { } else {
parser.stack.push(element); parser.stack.push(element);
} }

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