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(ivy): instantiate dirs in correct order #23178
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {TNode} from './interfaces/node'; | ||
|
||
/** Called when directives inject each other (creating a circular dependency) */ | ||
export function throwCyclicDependencyError(token: any): never { | ||
throw new Error(`Cannot instantiate cyclic dependency! ${token}`); | ||
} | ||
|
||
/** Called when there are multiple component selectors that match a given node */ | ||
export function throwMultipleComponentError(tNode: TNode): never { | ||
throw new Error(`Multiple components match node with tagname ${tNode.tagName}`); | ||
} | ||
|
||
/** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */ | ||
export function throwErrorIfNoChangesMode( | ||
creationMode: boolean, checkNoChangesMode: boolean, oldValue: any, currValue: any): never|void { | ||
if (checkNoChangesMode) { | ||
let msg = | ||
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '${oldValue}'. Current value: '${currValue}'.`; | ||
if (creationMode) { | ||
msg += | ||
` It seems like the view has been created after its parent and its children have been dirty checked.` + | ||
` Has it been created in a change detection hook ?`; | ||
} | ||
// TODO: include debug context | ||
throw new Error(msg); | ||
} | ||
} |
Oops, something went wrong.
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.
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.
Does this information get cached so that subsequent instantiations are fast? In other words, can we rearrange the order of directives until it is the correct order?
It looks to me that every time we want to inject parent directive we will go to
searchMatchesQueuedForCreation
which will have negative perf impact. I think the logic should be something likeThere 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.
As I think you mentioned in a later comment, this is the way it already works. The directives are saved in the correct order after the first template pass, so subsequent runs will just instantiate the directives in the right order.
It's worth noting that if you are injecting a parent directive, this search flow will never be entered (even in the first template pass) because DI would have retrieved the parent bloom injector and the
injector === di
check would fail.The only time the search occurs is:
- on first template pass
- if token's bit has been added to the bottom level bloom filter during directive matching (so we know it's in this list)
- AND the directive was not already created (out of order)