New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(compiler): avoid error in template parser for tag names that can occur in object prototype #52225
Conversation
…occur in object prototype Fixes that the compiler was throwing an error if an element tag name is the same as a built-in prototype property (e.g. `constructor` or `toString`). The problem was that we were storing the tag names in an object literal with the `Object` prototype. These changes resolve the issue by creating an object without a prototype. Fixes angular#52224.
@@ -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), { |
There was a problem hiding this comment.
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.
@crisbeto it looks like it doesn't merge cleanly into 16.2 - any objections to re-targetting it to RC ? Then you could open a separate PR targeting 16.2 (or just not have this fix in 16.x ???) |
It's fixing a bit of an edge case so I'm fine with targeting it to the RC. |
This PR was merged into the repository by commit 302ab34. |
…occur in object prototype (#52225) Fixes that the compiler was throwing an error if an element tag name is the same as a built-in prototype property (e.g. `constructor` or `toString`). The problem was that we were storing the tag names in an object literal with the `Object` prototype. These changes resolve the issue by creating an object without a prototype. Fixes #52224. PR Close #52225
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…occur in object prototype (angular#52225) Fixes that the compiler was throwing an error if an element tag name is the same as a built-in prototype property (e.g. `constructor` or `toString`). The problem was that we were storing the tag names in an object literal with the `Object` prototype. These changes resolve the issue by creating an object without a prototype. Fixes angular#52224. PR Close angular#52225
Fixes that the compiler was throwing an error if an element tag name is the same as a built-in prototype property (e.g.
constructor
ortoString
). The problem was that we were storing the tag names in an object literal with theObject
prototype. These changes resolve the issue by creating an object without a prototype.Fixes #52224.