-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: ensure custom element styles append correctly during prod #12777
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
🦋 Changeset detectedLatest commit: a09f81f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
What if we still used the |
Good point. Adjusted. |
If customElement is set to false, this would still make append_styles think that the styles already has been added (in prod) when mounting a web component. I might be off, but inside queue_micro_task the target is set to head/root depending on whether the root is a shadow root. What if the seen check was moved into queue_micro_task, like this? export function append_styles(anchor, css) {
queue_micro_task(() => {
var root = anchor.getRootNode();
const is_shadow_root = root instanceof ShadowRoot; // Add this line
// Move the seen check here and use the check:
if (!DEV && !is_shadow_root) {
if (seen.has(css)) return;
seen.add(css);
}
// ...and here
var target = is_shadow_root
? (root)
: (root).head ?? (root.ownerDocument).head; Then the Thanks a lot for responding quickly to the issue. |
That would defeat the object, which is to avoid creating unnecessary micro tasks |
Fixes #12776. We always need to do the check for the style, using the key to avoid doing this won't work for cases where the styles are added in their own shadow DOM – as they always need to be added.