fix(compiler): avoid error in template parser for tag names that can occur in object prototype#52225
fix(compiler): avoid error in template parser for tag names that can occur in object prototype#52225crisbeto wants to merge 1 commit intoangular:mainfrom
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.
| 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.
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.
constructorortoString). The problem was that we were storing the tag names in an object literal with theObjectprototype. These changes resolve the issue by creating an object without a prototype.Fixes #52224.