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

fix(runtime-core): handle disabled teleport with updateCssVars #12113

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/Teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ function updateCssVars(vnode: VNode) {
// code path here can assume browser environment.
const ctx = vnode.ctx
if (ctx && ctx.ut) {
let node = vnode.targetStart
let node = vnode.targetStart || (vnode.children as VNode[])[0].el!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the proper fix. For disabled teleport the begining node should be vnode.el and the end node should be vnode.anchor.
So the proper fix might be

let node,anchor
if(isDisabled){
  node=vnode.el
  anchor=vnode.anchor
}else{
  node=vnode.targetStart
  anchor=vnode.targetAnchor
}
while (node && node !== anchor) {
 //...
}

while (node && node !== vnode.targetAnchor) {
if (node.nodeType === 1) node.setAttribute('data-v-owner', ctx.uid)
node = node.nextSibling
Expand Down
1 change: 1 addition & 0 deletions packages/runtime-dom/__tests__/helpers/useCssVars.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ describe('useCssVars', () => {
expect(() => render(h(App), root)).not.toThrow(TypeError)
await nextTick()
expect(target.children.length).toBe(0)
expect(root.children[0].outerHTML.includes('data-v-owner')).toBe(true)
})

test('with string style', async () => {
Expand Down