-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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(platform-browser): remove style nodes on application destroy #13744
Conversation
c5a091e
to
6f88f60
Compare
6f88f60
to
b173921
Compare
@@ -46,5 +46,14 @@ export function main() { | |||
ssh.addStyles(['a {};', 'b {};']); | |||
expect(doc.head).toHaveText('a {};b {};'); | |||
}); | |||
|
|||
it('should remove style nodes on destroy', () => { | |||
ssh.addStyles(['a {};']); |
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.
would this work if 2 components add the same style ?
It would be added only once to the head but should not be removed when only one of the cmp is removed.
This probably requires some kind of ref counting I don't see in this PR code.
And also there should be a test.
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.
would this work if 2 components add the same style ?
It would be added only once to the head but should not be removed when only one of the cmp is removed.
not sure I'm following. My understanding is: DomSharedStylesHost
is a part of BrowserModule
so we can only have once instance per app (root module). Thus it will contain styles for all created components. And DomSharedStylesHost
will only be destroyed when root module (or platform) will be destroyed.
Even if we have multiple app with the same platform, every app will have it's own DomSharedStylesHost
. Am I wrong?
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.
may be I'm wrong (I haven't look at the impl details) but if you have 2 cmp with the same css
<cmp-one></cmp-one>
<cmp-two></cmp-two>
The css would be added only once.
However if you remove cmp-one
, the css must style remain for cmp-two
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.
I agree but I don't remove styles when component is destroyed, only when the whole app/platform 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.
Then it makes sense !
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. |
Closes #11746