-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Document state should determine whether the CSS has been added #554
Comments
I think this seems like a reasonable enough change. I've pushed a branch but haven't opened a PR yet. |
Agree with this in principle. Would using an |
Thanks. I suppose the real comparison is this one: https://jsperf.com/getelementbyid-vs-qs-id-vs-qs-attr Seems conclusive! |
Good find. Thanks guys for your consideration! I am looking forward to a perfect REPL experience once this is resolved. :-) |
Always check whether we need to add CSS
Svelte components add their stylesheets to
document.head
once per component type. Whether the stylesheet has already been added is currently determined by a private variableadded_css
inside the component module. While in most cases, this flag should be accurate, this is not always the case in the REPL (see svelte.technology#93) and possibly other environments as well. I believe it is more correct to attach some kind of identifier to the style element and then query the document.head element to determine whether it already exists. In my opinion, the accuracy of this approach is well worth the performance hit.The text was updated successfully, but these errors were encountered: