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

Commit0f4e6a9

Browse files
committed
fix: invoke component node create hooks before insertion
fixvuejs#7531
1 parent9084747 commit0f4e6a9

File tree

5 files changed

+8
-31
lines changed

5 files changed

+8
-31
lines changed

‎flow/options.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ declare type InternalComponentOptions = {
22
_isComponent:true;
33
parent:Component;
44
_parentVnode:VNode;
5-
_parentElm: ?Node;
6-
_refElm: ?Node;
75
render?:Function;
86
staticRenderFns?:Array<Function>
97
};
@@ -81,8 +79,6 @@ declare type ComponentOptions = {
8179
_componentTag: ?string;
8280
_scopeId: ?string;
8381
_base:Class<Component>;
84-
_parentElm: ?Node;
85-
_refElm: ?Node;
8682
};
8783

8884
declaretypePropOptions={

‎src/core/instance/init.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export function initInternalComponent (vm: Component, options: InternalComponent
7777
constparentVnode=options._parentVnode
7878
opts.parent=options.parent
7979
opts._parentVnode=parentVnode
80-
opts._parentElm=options._parentElm
81-
opts._refElm=options._refElm
8280

8381
constvnodeComponentOptions=parentVnode.componentOptions
8482
opts.propsData=vnodeComponentOptions.propsData

‎src/core/instance/lifecycle.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
6262
// based on the rendering backend used.
6363
if(!prevVnode){
6464
// initial render
65-
vm.$el=vm.__patch__(
66-
vm.$el,vnode,hydrating,false/* removeOnly */,
67-
vm.$options._parentElm,
68-
vm.$options._refElm
69-
)
70-
// no need for the ref nodes after initial patch
71-
// this prevents keeping a detached DOM tree in memory (#5851)
72-
vm.$options._parentElm=vm.$options._refElm=null
65+
vm.$el=vm.__patch__(vm.$el,vnode,hydrating,false/* removeOnly */)
7366
}else{
7467
// updates
7568
vm.$el=vm.__patch__(prevVnode,vnode)

‎src/core/vdom/create-component.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ import {
3434

3535
// inline hooks to be invoked on component VNodes during patch
3636
constcomponentVNodeHooks={
37-
init(
38-
vnode:VNodeWithData,
39-
hydrating:boolean,
40-
parentElm: ?Node,
41-
refElm: ?Node
42-
): ?boolean{
37+
init(vnode:VNodeWithData,hydrating:boolean): ?boolean{
4338
if(
4439
vnode.componentInstance&&
4540
!vnode.componentInstance._isDestroyed&&
@@ -51,9 +46,7 @@ const componentVNodeHooks = {
5146
}else{
5247
const child=vnode.componentInstance=createComponentInstanceForVnode(
5348
vnode,
54-
activeInstance,
55-
parentElm,
56-
refElm
49+
activeInstance
5750
)
5851
child.$mount(hydrating ?vnode.elm :undefined,hydrating)
5952
}
@@ -215,15 +208,11 @@ export function createComponent (
215208
exportfunctioncreateComponentInstanceForVnode(
216209
vnode:any,// we know it's MountedComponentVNode but flow doesn't
217210
parent:any,// activeInstance in lifecycle state
218-
parentElm?: ?Node,
219-
refElm?: ?Node
220211
):Component{
221212
constoptions:InternalComponentOptions={
222213
_isComponent:true,
223-
parent,
224214
_parentVnode:vnode,
225-
_parentElm:parentElm||null,
226-
_refElm:refElm||null
215+
parent
227216
}
228217
// check inline-template render functions
229218
constinlineTemplate=vnode.data.inlineTemplate

‎src/core/vdom/patch.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,15 @@ export function createPatchFunction (backend) {
212212
if(isDef(i)){
213213
constisReactivated=isDef(vnode.componentInstance)&&i.keepAlive
214214
if(isDef(i=i.hook)&&isDef(i=i.init)){
215-
i(vnode,false/* hydrating */,parentElm,refElm)
215+
i(vnode,false/* hydrating */)
216216
}
217217
// after calling the init hook, if the vnode is a child component
218218
// it should've created a child instance and mounted it. the child
219219
// component also has set the placeholder vnode's elm.
220220
// in that case we can just return the element and be done.
221221
if(isDef(vnode.componentInstance)){
222222
initComponent(vnode,insertedVnodeQueue)
223+
insert(parentElm,vnode.elm,refElm)
223224
if(isTrue(isReactivated)){
224225
reactivateComponent(vnode,insertedVnodeQueue,parentElm,refElm)
225226
}
@@ -681,7 +682,7 @@ export function createPatchFunction (backend) {
681682
}
682683
}
683684

684-
returnfunctionpatch(oldVnode,vnode,hydrating,removeOnly,parentElm,refElm){
685+
returnfunctionpatch(oldVnode,vnode,hydrating,removeOnly){
685686
if(isUndef(vnode)){
686687
if(isDef(oldVnode))invokeDestroyHook(oldVnode)
687688
return
@@ -693,7 +694,7 @@ export function createPatchFunction (backend) {
693694
if(isUndef(oldVnode)){
694695
// empty mount (likely as component), create new root element
695696
isInitialPatch=true
696-
createElm(vnode,insertedVnodeQueue,parentElm,refElm)
697+
createElm(vnode,insertedVnodeQueue)
697698
}else{
698699
constisRealElement=isDef(oldVnode.nodeType)
699700
if(!isRealElement&&sameVnode(oldVnode,vnode)){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp