Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
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
6 changes: 3 additions & 3 deletions 6 packages/compiler/src/ml_parser/html_tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let TAG_DEFINITIONS!: {[key: string]: HtmlTagDefinition};
export function getHtmlTagDefinition(tagName: string): HtmlTagDefinition {
if (!TAG_DEFINITIONS) {
DEFAULT_TAG_DEFINITION = new HtmlTagDefinition({canSelfClose: true});
TAG_DEFINITIONS = {
TAG_DEFINITIONS = Object.assign(Object.create(null), {
Copy link
Member Author

@crisbeto crisbeto Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way to fix the issue is to check with hasOwnProperty before each lookup. I went with this approach, because it only needs to happen once when we construct the object, rather than every time we look up a tag name.

'base': new HtmlTagDefinition({isVoid: true}),
'meta': new HtmlTagDefinition({isVoid: true}),
'area': new HtmlTagDefinition({isVoid: true}),
Expand Down Expand Up @@ -142,10 +142,10 @@ export function getHtmlTagDefinition(tagName: string): HtmlTagDefinition {
}),
'textarea': new HtmlTagDefinition(
{contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true}),
};
});

new DomElementSchemaRegistry().allKnownElementNames().forEach(knownTagName => {
if (!TAG_DEFINITIONS.hasOwnProperty(knownTagName) && getNsPrefix(knownTagName) === null) {
if (!TAG_DEFINITIONS[knownTagName] && getNsPrefix(knownTagName) === null) {
TAG_DEFINITIONS[knownTagName] = new HtmlTagDefinition({canSelfClose: false});
}
});
Expand Down
6 changes: 6 additions & 0 deletions 6 packages/compiler/test/ml_parser/html_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ import {humanizeDom, humanizeDomSourceSpans, humanizeLineColumn, humanizeNodes}
]);
expect(parsed.errors).toEqual([]);
});

it('should parse element with JavaScript keyword tag name', () => {
expect(humanizeDom(parser.parse('<constructor></constructor>', 'TestComp'))).toEqual([
[html.Element, 'constructor', 0]
]);
});
});

describe('attributes', () => {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.