-
Notifications
You must be signed in to change notification settings - Fork 26.5k
fix(router): avoid router initialization for non root components #12338
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
Conversation
// register a spy on a function that is called on each init | ||
const spy = spyOn(r, 'resetRootComponentType').and.callThrough(); | ||
|
||
// bootstrap the root app |
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.
Could you remove the comments? I think it is pretty clear what the test does.
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.
done.
spy.calls.reset(); | ||
|
||
// bootstrap a component that is not the root compnent | ||
appRef.bootstrap(BootstrappableComponent); |
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.
The bootstrap method returns a component ref that can be destroyed. Could you make sure it works when the first component is destroyed?
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.
done.
this works because the destroyed component is removed from ApplicationRef.components and the next bootstrapped component is at index 0 of ApplicationRef.components. I have added a test for this.
@vsavkin all done. the travis build fails because of invalid saucelab configurations :( |
Could you please squash & rebase ? |
@vicb done. |
Thanks, should be merged today. |
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. |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behavior?
If more than one component is bootstrapped the router is initialized more than once. see issues:
What is the new behavior?
Does this PR introduce a breaking change? (check one with "x")
Other information:
@vsavkin This pr only solves the mentioned issues. I'm not quite sure. But I think a more general solution would be to make sure the listener for APP_BOOTSTRAP_LISTENER is only called once.