Skip to content
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

Attach a stylesheet manually to scoped style tag removes all the scoped styling #3298

Open
adityabhanu opened this issue Dec 16, 2024 · 0 comments

Comments

@adityabhanu
Copy link

adityabhanu commented Dec 16, 2024

Current behavior:

I am using Material UI for developing a web component. I an using emotion CacheProvider to scope the styles to shadow dom.
Now when I attached an external stylesheet to emotion scoped style tag manually in the DOM itself, it removed all the scoped styling for all MUI components.

**<style data-emotion="scoped" data-s=""></style><link rel="stylesheet" **
href="https://my.website.com/Content/styles/css/my.css?v=1.0.0.0">

However, if it is attached programmatically through code, it doesn't affect the scoped styles.

link.rel = 'stylesheet';
link.href = 'https://my.newholland.com/Content/MyNewHolland/css/nh.css?v=1.0.0.0';
shadow.appendChild(link);

Also if I add the link tag to another element maybe just below it scoped styles remains intact

To reproduce:

This is a very weird issue for me. I am attaching a video for you to see how you can reproduce this issue.

emotionissue.pptx

Environment information:

"react": "^18.3.1",
"react-dom": "^18.3.1"
"@emotion/cache": "^11.13.5",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.1.2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant