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; element.end = parser.index;
} else if (name === 'style') { } else if (name === 'style') {
// special case // special case
element.children = readSequence( if (parser.v2) {
parser, const start = parser.index;
() => const data = parser.readUntil(/<\/style>/);
parser.template.slice(parser.index, parser.index + 8) === '</style>' const end = parser.index;
); element.children.push({ start, end, type: 'Text', data });
parser.read(/<\/style>/); parser.eat('</style>', true);
element.end = parser.index; } else {
element.children = readSequence(
parser,
() =>
parser.template.slice(parser.index, parser.index + 8) === '</style>'
);
parser.read(/<\/style>/);
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