Description
Vue version
3.4.15, 3.5.12
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-qg9sjb?file=src%2Fcomponents%2FHelloWorld.vue
Steps to reproduce
- Mount vue app inside shadow root (manually or using custom elements feature of vue).
- Setup element with a class and put it to teleport (teleport target should be outside current component tree, but inside shadow tree)
- Set some css properties of the class to
v-bind
values in SFC of component containing teleport
In the linked example I set an element with class v-bind-fail
to have red background using v-bind. But it is white.
What is expected?
v-bind
styles are applied to teleported dom element.
What is actually happening?
v-bind
styles are not applied to teleported dom element.
System Info
No response
Any additional comments?
v-bind
is implemented using var(--some-hash)
custom properties. Values for those provided by inline style attributes. When some part of a component is inside teleport tag those style attributes duplicated there. At least normally so. When teleport target is inside shadow dom styles aren't duplicated.
From my perspective v-bind implementation expects teleport to be used with selectors only, but it can be used with HTMLElement
variable which can point to shadow tree element. It seems v-bind
implementation uses something similar to document.querySelector
to apply variables to teleported parts of the tree. And it fails to locate elements in the shadow tree.