polish(teleport): do not warn missing target when teleport is disabled (#2021)

This commit is contained in:
HcySunYang
2020-09-02 09:05:51 +08:00
committed by GitHub
parent 0d0970f9cd
commit 93b8ff94a4
2 changed files with 33 additions and 3 deletions

View File

@@ -179,6 +179,36 @@ describe('renderer: teleport', () => {
)
})
test('should work when using template ref as target', async () => {
const root = nodeOps.createElement('div')
const target = ref(null)
const disabled = ref(true)
const App = {
setup() {
return () =>
h(Fragment, [
h('div', { ref: target }),
h(
Teleport,
{ to: target.value, disabled: disabled.value },
h('div', 'teleported')
)
])
}
}
render(h(App), root)
expect(serializeInner(root)).toMatchInlineSnapshot(
`"<div></div><!--teleport start--><div>teleported</div><!--teleport end-->"`
)
disabled.value = false
await nextTick()
expect(serializeInner(root)).toMatchInlineSnapshot(
`"<div><div>teleported</div></div><!--teleport start--><!--teleport end-->"`
)
})
test('disabled', () => {
const target = nodeOps.createElement('div')
const root = nodeOps.createElement('div')