-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[fix] Removal of empty stylesheets created from transitions #7260
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] Removal of empty stylesheets created from transitions #7260
Conversation
I saw that the actions failed during |
Any updates on this PR? 👍 |
Given that this PR is attempting to patch a memory leak in a common feature (transitions), I'm hoping it would be addressed soon. |
@Conduitry it would be much appreciated getting some thoughts about this PR from some of the core Svelte-maintainers. It's my first contribution, so I am not sure how to follow this up 🤔 |
It's important to get this fixed. We shouldn't be polluting the DOM like this. This is blocking our use of Svelte transitions. We will not use Svelte transitions until this is fixed. |
Hello, i think this PR is ok, can we merge it for next version release? for now leak style tag hurt system a lot |
Co-authored-by: Yuichiro Yamashita <[email protected]>
Co-authored-by: Yuichiro Yamashita <[email protected]>
Thank you for the great help, @baseballyama, I appreciate it! Committed your suggestions 👍 |
Any updates on this? Just ran into it :) |
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 added one comment , but this is basically LGTM.
Thank you!
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.
LGTM💪
@baseballyama I've noticed something that we need to address before merging: I cannot get the test to fail anymore. Is there anything wrong with how i used the |
Could you please tell me more details? After that I updated raf.tick(0);
raf.tick(0); |
To be honest I'm not sure why it doesn't fail. If it seems to work elsewhere then I guess it's okay. I just wanted to be sure that nothing was wrong. |
Maybe you rebased master branch, that's why this PR is closed automatically. |
@MathiasWP is this branch still around? somehow couldn't clone this to test it out: https://github.com/MathiasWP/svelte/tree/style_manager-stylesheet-cleanup |
Oh, i don't think so actually! Sorry! I deleted this fork and created a new one - totally forgot that this PR was up. What can i do to solve this best for you? @tanhauhau |
probably that's why the PR was closed previously.
Maybe can see if u could recreate the branch from this commit 662faa3 ? |
I'll do this sometime this week! Any release deadline i should know about? |
let i = stylesheet.cssRules.length; | ||
while (i--) stylesheet.deleteRule(i); | ||
const { style_element } = info; | ||
detach(style_element); | ||
info.rules = {}; |
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.
This can also be removed
@tanhauhau i recreated the fix on my fork. I also removed some more code, e.g. the line i commented above. But it does not seem like the change is added in this PR. But you can fork my repo and check out the source code 👍 |
sorry im just trying to see if close and reopen fixed that 🙈 |
recreated the pull request over at #7662 |
I'm sorry for this inconvenience! It was silly of me to remove the fork, i totally forgot that it would affect this PR... |
this appears to still be an issue in 4.2.18 |
Before submitting the PR, please make sure you do the following
[feat]
,[fix]
,[chore]
, or[docs]
.Tests
npm test
and lint the project withnpm run lint
Closes
What has been changed?
The
style_manager
"cleaned up" the stylesheets it made by only clearing their rules. After clearing them, it removed them from its internal map by runningmanaged_styles.clear()
. This cleanup was not optimal - it left the style elements empty in the dom.The proposed change is to remove style-elements created by
style_manager
, instead of making them empty and letting them stay in the DOM without any references. I also refactored some of the methods from theruntime/internal/dom.ts
file that were only used by thestyle_manager
or in thedom.ts file
itself.If you want to reverse-engineer this bug yourself, then start with the
append_empty_stylesheet
method in thedom.ts
file. As long asappend_empty_stylesheet
is used, there will be bugs related to empty stylesheets. It does the following: