Skip to content

Commit 9eb7984

Browse files
committed
fix: prevent Teleport attrs fallthrough by ensuring its nodes are always an array
1 parent 4223dac commit 9eb7984

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/runtime-vapor/__tests__/componentAttrs.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe('attribute fallthrough', () => {
330330
expect(`Extraneous non-emits event listeners`).toHaveBeenWarned()
331331
})
332332

333-
it.todo('should warn when fallthrough fails on teleport root node', () => {
333+
it('should warn when fallthrough fails on teleport root node', () => {
334334
const Parent = {
335335
render() {
336336
return createComponent(Child, { class: () => 'parent' })
@@ -340,7 +340,6 @@ describe('attribute fallthrough', () => {
340340
const root = document.createElement('div')
341341
const Child = defineVaporComponent({
342342
render() {
343-
// return h(Teleport, { to: root }, h('div'))
344343
return createComponent(
345344
VaporTeleport,
346345
{ to: () => root },
@@ -352,7 +351,6 @@ describe('attribute fallthrough', () => {
352351
})
353352

354353
document.body.appendChild(root)
355-
// render(h(Parent), root)
356354
define(Parent).render()
357355

358356
expect(`Extraneous non-props attributes (class)`).toHaveBeenWarned()

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,16 @@ export class TeleportFragment extends VaporFragment {
130130
private handleChildrenUpdate(children: Block): void {
131131
// not mounted yet
132132
if (!this.parent || isHydrating) {
133-
this.nodes = children
133+
// Teleport nodes are always an array, preventing attrs fallthrough
134+
// consistent with VDOM Teleport behavior.
135+
this.nodes = [children]
134136
return
135137
}
136138

137139
// teardown previous nodes
138140
remove(this.nodes, this.mountContainer!)
139141
// mount new nodes
140-
insert((this.nodes = children), this.mountContainer!, this.mountAnchor!)
142+
insert((this.nodes = [children]), this.mountContainer!, this.mountAnchor!)
141143
}
142144

143145
private handlePropsUpdate(): void {

0 commit comments

Comments
 (0)