-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Error in _injectChildStyle when shadowRoot is disabled in CustomElementApi #12630
Comments
Please follow the issue requirement and provide a minimal runnable reproduction |
Hello @edison1105 , Thank you for looking into this. I understand that you were unable to reproduce the issue using the defineCustomElement function. However, in our case, we are extending the VueElement class directly in order to inject global styles into the web component something that should, in theory, work similarly to defineCustomElement but appears to behave differently in practice. Here are more details:
If anyone has insight into potential internal differences between defineCustomElement and directly extending VueElement or knows of any additional hooks we might need to implement your advice would be greatly appreciated. Thank you very much for your time and assistance! |
Please try to provide a minimal runnable reproduction for a further look. |
I was able to reproduce the issue, and it turns out it specifically occurs when the component used to register the custom element is compiled with the customElement property during the build process. |
@seperez-ncl |
Vue version
3.5.13
Link to minimal reproduction
codesandbox.io/p/live/442d0220-8af3-45b5-b2ed-2ab21cf088d8
Steps to reproduce
1- Create a Vue component with child component inside with scoped styles. using the Custom Element API.
2- Disable Shadow DOM.
3- Open the browser console and observe the shadowRoot error when _injectChildStyle runs.
What is expected?
When the shadowRoot option is disabled (or otherwise omitted) and child components have their own styles, Vue should inject (or refrain from injecting) those styles without throwing console errors.
What is actually happening?
Currently, when shadowRoot is disabled, the _injectChildStyle function attempts to apply child styles to a Shadow DOM. Since shadowRoot does not exist, a console error occurs indicating it cannot access shadowRoot or its methods.
System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: