vuetify: [Bug Report] Weird behaviour inside shadow DOM
Versions and Environment
Vuetify: 1.5.14 Vue: 2.6.10 Browsers: Google Chrome OS: Linux x86_64
Steps to reproduce
- Render vuetify inside shadow dom
- Functionality becomes very limited, such as:
- Cannot focus for text fields
- Menuable items cannot be attached to
VApp - Menuable items cannot be attached by selectors
Expected Behavior
Clicking on the text field should show that the text field is focused
The select list should work even without attach property
Actual Behavior
The text field does not react on clicks or activating via tab
The select list does not open without attach property
Reproduction Link
https://codepen.io/anon/pen/rEjXRj
Other comments
Possible culprit:
document.activeElementinside ofonFocusinVTextFielddoes not work in shadow domdocument.querySelectordoes not work in shadow dom
Possible solutions:
- calculate actual root with
getRootNode(might require polyfill on Edge and IE11) - track
VAppand usequerySelectordirectly on theVAppelement
I could not find any workarounds that vuetify can offer for this issue at this moment.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (10 by maintainers)
There are no plans currently to support web components
See also #4075, #5054, #6203
There are other consideration than only the use of
document. For example, the use ofremcss units will prevent overriding the font-size of elements inside the shadow dom.I don’t expect the Vuetify team to implement these changes in Vuetify 2.x (although it would be nice). But you guys should consider this when writing Vuetify 3. IMO, a proper framework should not assume that it is the only think running on the page and allow to be scoped to a particular DOM element.
In the meantime, what you can do is:
This will break if there is more than one instance of Vuetify running on the page.
I don’t know if this helps but I managed to find a way to move all of the Vuetify styles from
<head>to shadow DOM.Add style-loader to webpack config, with these options:
Then, in your main.js file or whatever it’s called, use javascript to move the styles to shadow DOM:
Some parts from the code above are taken from @matthieusieben’s comment.
@TheInvoker Been wrapped up with a big release, but I’m actually hoping to take a stab at it on Sunday. Happy to collaborate on it if you’d like