Skip to content

Commit

Permalink
in v2, don't parse for interpolations in non-root style elements (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Apr 15, 2018
1 parent 1c4b166 commit bed13d2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/parse/state/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions test/runtime/samples/script-style-non-top-level/main-v2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<style>div { color: red; }</style>
<script>alert('<>');</script>
</div>

0 comments on commit bed13d2

Please sign in to comment.