Skip to content

Commit 8631cfb

Browse files
committed
feat(teleport/css-v-bind): support for getting teleported content via target
1 parent 664d2e5 commit 8631cfb

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/runtime-core/src/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ export interface ComponentInternalInstance {
582582
* For updating css vars on contained teleports
583583
* @internal
584584
*/
585-
ut?: (vars?: Record<string, string>) => void
585+
ut?: (target: RendererElement, vars?: Record<string, string>) => void
586586

587587
/**
588588
* dev only. For style v-bind hydration mismatch checks

packages/runtime-core/src/components/Teleport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ function updateCssVars(vnode: VNode, isDisabled: boolean) {
480480
if (node.nodeType === 1) node.setAttribute('data-v-owner', ctx.uid)
481481
node = node.nextSibling
482482
}
483-
ctx.ut()
483+
ctx.ut(node.target)
484484
}
485485
}
486486

packages/runtime-dom/src/helpers/useCssVars.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>): void {
2828
}
2929
/* v8 ignore stop */
3030

31-
const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
31+
const updateTeleports = (instance.ut = (
32+
target,
33+
vars = getter(instance.proxy),
34+
) => {
3235
Array.from(
33-
document.querySelectorAll(`[data-v-owner="${instance.uid}"]`),
36+
((target as Element) || document).querySelectorAll(
37+
`[data-v-owner="${instance.uid}"]`,
38+
),
3439
).forEach(node => setVarsOnNode(node, vars))
3540
})
3641

@@ -45,7 +50,7 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>): void {
4550
} else {
4651
setVarsOnVNode(instance.subTree, vars)
4752
}
48-
updateTeleports(vars)
53+
updateTeleports(document, vars)
4954
}
5055

5156
onBeforeMount(() => {

0 commit comments

Comments
 (0)