Fix 3 "Illegal State" bugs in the Angular Indexer#44678
Closed
alxhub wants to merge 3 commits intoangular:masterfrom
Closed
Fix 3 "Illegal State" bugs in the Angular Indexer#44678alxhub wants to merge 3 commits intoangular:masterfrom
alxhub wants to merge 3 commits intoangular:masterfrom
Conversation
…exer
Previously, the Angular Indexer made an assumption that in any binding to
a property of an `ImplicitReceiver`, the property name begins at the start
of the binding. This is true for normal reads from `ImplicitReceiver` as
the implicit receiver has no representation in the template.
However, `ThisReceiver` inherits from `ImplicitReceiver` and _does_ have a
template representation. Such a binding looks like `{{this.foo}}`. This
commit corrects the logic of the indexer to use the `nameSpan` of the
property binding instead of its `sourceSpan` to locate the identifier.
When parsing a binding with a comment at the end of the expression, the
parser previously had logic to offset the parsed spans by the length of the
comment. This logic seemed not to serve any useful purpose, and instead
resulted in the corruption of the spans. For example, in the expression
`{{foo // comment}}`, the parser would map the parsed `foo` `PropertyRead`
node at the location of the characters 'ent' from the comment suffix.
This commit removes that logic, correcting the parsed spans of such nodes in
the presence of comments. Removing this logic does not seem to have caused
any tests to fail.
In the `Element` node of a parsed `<svg>` element, the `name` is recorded as `:svg:svg`. When the Angular Indexer ran over this element, it would attempt to find this name in the template text and fail, as the namespace portion of the name was added automatically at parse time and is of course missing from the original template. This commit changes the indexer to detect these namespaced elements and only search for the tag name.
0463510 to
3438b51
Compare
crisbeto
reviewed
Jan 10, 2022
atscott
approved these changes
Jan 10, 2022
Contributor
Contributor
|
This PR was merged into the repository by commit 92b23f4. |
atscott
pushed a commit
that referenced
this pull request
Jan 11, 2022
) When parsing a binding with a comment at the end of the expression, the parser previously had logic to offset the parsed spans by the length of the comment. This logic seemed not to serve any useful purpose, and instead resulted in the corruption of the spans. For example, in the expression `{{foo // comment}}`, the parser would map the parsed `foo` `PropertyRead` node at the location of the characters 'ent' from the comment suffix. This commit removes that logic, correcting the parsed spans of such nodes in the presence of comments. Removing this logic does not seem to have caused any tests to fail. PR Close #44678
atscott
pushed a commit
that referenced
this pull request
Jan 11, 2022
In the `Element` node of a parsed `<svg>` element, the `name` is recorded as `:svg:svg`. When the Angular Indexer ran over this element, it would attempt to find this name in the template text and fail, as the namespace portion of the name was added automatically at parse time and is of course missing from the original template. This commit changes the indexer to detect these namespaced elements and only search for the tag name. PR Close #44678
atscott
pushed a commit
that referenced
this pull request
Jan 11, 2022
…exer (#44678) Previously, the Angular Indexer made an assumption that in any binding to a property of an `ImplicitReceiver`, the property name begins at the start of the binding. This is true for normal reads from `ImplicitReceiver` as the implicit receiver has no representation in the template. However, `ThisReceiver` inherits from `ImplicitReceiver` and _does_ have a template representation. Such a binding looks like `{{this.foo}}`. This commit corrects the logic of the indexer to use the `nameSpan` of the property binding instead of its `sourceSpan` to locate the identifier. PR Close #44678
atscott
pushed a commit
that referenced
this pull request
Jan 11, 2022
) When parsing a binding with a comment at the end of the expression, the parser previously had logic to offset the parsed spans by the length of the comment. This logic seemed not to serve any useful purpose, and instead resulted in the corruption of the spans. For example, in the expression `{{foo // comment}}`, the parser would map the parsed `foo` `PropertyRead` node at the location of the characters 'ent' from the comment suffix. This commit removes that logic, correcting the parsed spans of such nodes in the presence of comments. Removing this logic does not seem to have caused any tests to fail. PR Close #44678
atscott
pushed a commit
that referenced
this pull request
Jan 11, 2022
In the `Element` node of a parsed `<svg>` element, the `name` is recorded as `:svg:svg`. When the Angular Indexer ran over this element, it would attempt to find this name in the template text and fail, as the namespace portion of the name was added automatically at parse time and is of course missing from the original template. This commit changes the indexer to detect these namespaced elements and only search for the tag name. PR Close #44678
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains 3 commits, each of which fixes a separate crash in the Angular Indexer:
thisas a receiver:{{this.foo}}{{foo // comment}}<svg></svg>Each of these templates would previously crash the indexer.