Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commit0b16927

Browse files
haoqunjiangyyx990803
authored andcommitted
fix(transition): check existence ofel.parentNode (vuejs#8422)
fixvuejs#8199* fix(transition): check existence of `el.parentNode`If the new parentNode gets a `textContent` or `innerHTML` property duringpatching, the `transition` node would have been detached early, which means`el.parentNode` no longer exists.* fix(vdom): should not reuse nodes with `textContent` / `innerHTML` props
1 parent8f04135 commit0b16927

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

‎src/core/vdom/patch.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,20 @@ export const emptyNode = new VNode('', {}, [])
3232

3333
consthooks=['create','activate','update','remove','destroy']
3434

35+
functionchildrenIgnored(vnode){
36+
returnvnode&&vnode.data&&vnode.data.domProps&&(
37+
vnode.data.domProps.innerHTML||vnode.data.domProps.textContent
38+
)
39+
}
40+
3541
functionsameVnode(a,b){
3642
return(
3743
a.key===b.key&&(
3844
(
3945
a.tag===b.tag&&
4046
a.isComment===b.isComment&&
4147
isDef(a.data)===isDef(b.data)&&
48+
!childrenIgnored(a)&&!childrenIgnored(b)&&
4249
sameInputType(a,b)
4350
)||(
4451
isTrue(a.isAsyncPlaceholder)&&

‎src/platforms/web/runtime/modules/transition.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
251251
return
252252
}
253253
// record leaving element
254-
if(!vnode.data.show){
254+
if(!vnode.data.show&&el.parentNode){
255255
(el.parentNode._pending||(el.parentNode._pending={}))[(vnode.key:any)]=vnode
256256
}
257257
beforeLeave&&beforeLeave(el)

‎test/unit/features/transition/transition.spec.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,5 +1167,27 @@ if (!isIE9) {
11671167
expect(vm.$el.innerHTML).toBe('<!---->')
11681168
}).then(done)
11691169
})
1170+
1171+
// #8199
1172+
it('should not throw error when replaced by v-html contents',(done)=>{
1173+
constvm=newVue({
1174+
template:`
1175+
<div>
1176+
<div v-if="ok" :class="ok">
1177+
<transition>
1178+
<span>a</span>
1179+
</transition>
1180+
</div>
1181+
<div v-else v-html="ok"></div>
1182+
</div>
1183+
`,
1184+
data:{ok:true}
1185+
}).$mount(el)
1186+
1187+
vm.ok=false
1188+
waitForUpdate(()=>{
1189+
expect(vm.$el.children[0].innerHTML).toBe('false')
1190+
}).then(done)
1191+
})
11701192
})
11711193
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp