Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/compiler/src/template_parser/template_preparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const LINK_ELEMENT = 'link';
const LINK_STYLE_REL_ATTR = 'rel';
const LINK_STYLE_HREF_ATTR = 'href';
const LINK_STYLE_REL_VALUE = 'stylesheet';
const STYLE_ELEMENTS: ReadonlySet<string> = new Set([':svg:style', 'style']);
const STYLE_ELEMENT = 'style';
const SCRIPT_ELEMENTS: ReadonlySet<string> = new Set([':svg:script', 'script']);
const NG_NON_BINDABLE_ATTR = 'ngNonBindable';
const NG_PROJECT_AS = 'ngProjectAs';
Expand Down Expand Up @@ -50,7 +50,7 @@ export function preparseElement(ast: html.Element): PreparsedElement {
let type = PreparsedElementType.OTHER;
if (isNgContent(nodeName)) {
type = PreparsedElementType.NG_CONTENT;
} else if (STYLE_ELEMENTS.has(nodeName)) {
} else if (STYLE_ELEMENT === nodeName) {
type = PreparsedElementType.STYLE;
} else if (SCRIPT_ELEMENTS.has(nodeName)) {
type = PreparsedElementType.SCRIPT;
Expand Down
10 changes: 9 additions & 1 deletion packages/compiler/test/render3/r3_template_transform_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,14 +895,22 @@ describe('R3 template transform', () => {
});
});

describe('Ignored elements', () => {
describe('<script> and <style> elements', () => {
it('should ignore <script> elements', () => {
expectFromHtml('<script></script>a').toEqual([['Text', 'a']]);
});

it('should ignore <style> elements', () => {
expectFromHtml('<style></style>a').toEqual([['Text', 'a']]);
});

it('should not ignore namespaced SVG <style> elements', () => {
expectFromHtml('<svg><style>.a { fill: none; }</style></svg>').toEqual([
['Element', ':svg:svg'],
['Element', ':svg:style'],
['Text', '.a { fill: none; }'],
]);
});
});

describe('<link rel="stylesheet">', () => {
Expand Down
Loading