vue 2.6.13 → 2.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -295
- package/compiler-sfc/index.d.ts +1 -0
- package/compiler-sfc/index.js +1 -0
- package/compiler-sfc/index.mjs +1 -0
- package/compiler-sfc/package.json +5 -0
- package/dist/vue.common.dev.js +11481 -11946
- package/dist/vue.common.prod.js +8 -3
- package/dist/vue.esm.browser.js +11321 -12011
- package/dist/vue.esm.browser.min.js +8 -3
- package/dist/vue.esm.js +11476 -11984
- package/dist/vue.js +11484 -11949
- package/dist/vue.min.js +8 -3
- package/dist/vue.runtime.common.dev.js +8427 -8421
- package/dist/vue.runtime.common.prod.js +8 -3
- package/dist/vue.runtime.esm.js +8436 -8454
- package/dist/vue.runtime.js +8430 -8424
- package/dist/vue.runtime.min.js +8 -3
- package/package.json +88 -111
- package/packages/compiler-sfc/dist/compiler-sfc.js +7 -0
- package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
- package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
- package/packages/compiler-sfc/package.json +30 -0
- package/src/compiler/{codeframe.js → codeframe.ts} +9 -7
- package/src/compiler/codegen/{events.js → events.ts} +21 -41
- package/src/compiler/codegen/{index.js → index.ts} +146 -136
- package/src/compiler/{create-compiler.js → create-compiler.ts} +26 -18
- package/src/compiler/directives/bind.ts +9 -0
- package/src/compiler/directives/{index.js → index.ts} +0 -2
- package/src/compiler/directives/{model.js → model.ts} +15 -18
- package/src/compiler/directives/{on.js → on.ts} +3 -4
- package/src/compiler/{error-detector.js → error-detector.ts} +61 -31
- package/src/compiler/{helpers.js → helpers.ts} +73 -61
- package/src/compiler/{index.js → index.ts} +2 -3
- package/src/compiler/{optimizer.js → optimizer.ts} +30 -23
- package/src/compiler/parser/{entity-decoder.js → entity-decoder.ts} +1 -3
- package/src/compiler/parser/{filter-parser.js → filter-parser.ts} +43 -24
- package/src/compiler/parser/{html-parser.js → html-parser.ts} +50 -29
- package/src/compiler/parser/{index.js → index.ts} +190 -172
- package/src/compiler/parser/{text-parser.js → text-parser.ts} +8 -9
- package/src/compiler/{to-function.js → to-function.ts} +27 -22
- package/src/core/components/{index.js → index.ts} +0 -0
- package/src/core/components/{keep-alive.js → keep-alive.ts} +42 -30
- package/src/core/{config.js → config.ts} +28 -30
- package/src/core/global-api/{assets.js → assets.ts} +8 -7
- package/src/core/global-api/{extend.js → extend.ts} +10 -13
- package/src/core/global-api/{index.js → index.ts} +4 -5
- package/src/core/global-api/{mixin.js → mixin.ts} +2 -3
- package/src/core/global-api/use.ts +23 -0
- package/src/core/{index.js → index.ts} +1 -1
- package/src/core/instance/{events.js → events.ts} +41 -24
- package/src/core/instance/{index.js → index.ts} +9 -5
- package/src/core/instance/{init.js → init.ts} +26 -15
- package/src/core/instance/inject.ts +72 -0
- package/src/core/instance/{lifecycle.js → lifecycle.ts} +86 -44
- package/src/core/instance/{proxy.js → proxy.ts} +29 -24
- package/src/core/instance/render-helpers/{bind-dynamic-keys.js → bind-dynamic-keys.ts} +6 -5
- package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts} +4 -8
- package/src/core/instance/render-helpers/{bind-object-props.js → bind-object-props.ts} +12 -17
- package/src/core/instance/render-helpers/{check-keycodes.js → check-keycodes.ts} +5 -7
- package/src/core/instance/render-helpers/{index.js → index.ts} +1 -3
- package/src/core/instance/render-helpers/{render-list.js → render-list.ts} +12 -13
- package/src/core/instance/render-helpers/{render-slot.js → render-slot.ts} +10 -11
- package/src/core/instance/render-helpers/{render-static.js → render-static.ts} +7 -10
- package/src/core/instance/render-helpers/{resolve-filter.js → resolve-filter.ts} +1 -3
- package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts} +11 -8
- package/src/core/instance/render-helpers/{resolve-slots.js → resolve-slots.ts} +12 -11
- package/src/core/instance/{render.js → render.ts} +66 -29
- package/src/core/instance/{state.js → state.ts} +100 -83
- package/src/core/observer/{array.js → array.ts} +11 -2
- package/src/core/observer/{dep.js → dep.ts} +37 -15
- package/src/core/observer/{index.js → index.ts} +137 -71
- package/src/core/observer/{scheduler.js → scheduler.ts} +42 -43
- package/src/core/observer/{traverse.js → traverse.ts} +10 -7
- package/src/core/observer/{watcher.js → watcher.ts} +88 -60
- package/src/core/util/{debug.js → debug.ts} +38 -34
- package/src/core/util/{env.js → env.ts} +27 -30
- package/src/core/util/{error.js → error.ts} +12 -14
- package/src/core/util/{index.js → index.ts} +0 -2
- package/src/core/util/{lang.js → lang.ts} +6 -7
- package/src/core/util/{next-tick.js → next-tick.ts} +16 -10
- package/src/core/util/{options.js → options.ts} +119 -114
- package/src/core/util/{perf.js → perf.ts} +5 -1
- package/src/core/util/{props.js → props.ts} +54 -50
- package/src/core/vdom/{create-component.js → create-component.ts} +51 -50
- package/src/core/vdom/{create-element.js → create-element.ts} +49 -43
- package/src/core/vdom/{create-functional-component.js → create-functional-component.ts} +52 -27
- package/src/core/vdom/helpers/{extract-props.js → extract-props.ts} +18 -18
- package/src/core/vdom/helpers/{get-first-component-child.js → get-first-component-child.ts} +6 -5
- package/src/core/vdom/helpers/{index.js → index.ts} +0 -2
- package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
- package/src/core/vdom/helpers/{merge-hook.js → merge-hook.ts} +7 -5
- package/src/core/vdom/helpers/{normalize-children.js → normalize-children.ts} +26 -16
- package/src/core/vdom/helpers/{normalize-scoped-slots.js → normalize-scoped-slots.ts} +23 -17
- package/src/core/vdom/helpers/{resolve-async-component.js → resolve-async-component.ts} +29 -37
- package/src/core/vdom/helpers/update-listeners.ts +101 -0
- package/src/core/vdom/modules/{directives.js → directives.ts} +20 -14
- package/src/core/vdom/modules/index.ts +4 -0
- package/src/core/vdom/modules/template-ref.ts +96 -0
- package/src/core/vdom/{patch.js → patch.ts} +239 -138
- package/src/core/vdom/{vnode.js → vnode.ts} +36 -31
- package/src/global.d.ts +15 -0
- package/src/platforms/web/compiler/directives/html.ts +8 -0
- package/src/platforms/web/compiler/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/compiler/directives/{model.js → model.ts} +47 -41
- package/src/platforms/web/compiler/directives/{text.js → text.ts} +2 -3
- package/src/platforms/web/compiler/{index.js → index.ts} +0 -2
- package/src/platforms/web/compiler/modules/{class.js → class.ts} +10 -15
- package/src/platforms/web/compiler/modules/{index.js → index.ts} +1 -5
- package/src/platforms/web/compiler/modules/{model.js → model.ts} +6 -11
- package/src/platforms/web/compiler/modules/{style.js → style.ts} +9 -14
- package/src/platforms/web/compiler/{options.js → options.ts} +1 -2
- package/src/platforms/web/compiler/{util.js → util.ts} +5 -7
- package/src/platforms/web/entry-compiler-sfc.ts +1 -0
- package/src/platforms/web/{entry-compiler.js → entry-compiler.ts} +1 -3
- package/src/platforms/web/{entry-runtime.js → entry-runtime-esm.ts} +2 -2
- package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
- package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
- package/src/platforms/web/entry-runtime.ts +7 -0
- package/src/platforms/web/runtime/{class-util.js → class-util.ts} +2 -4
- package/src/platforms/web/runtime/components/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/components/{transition-group.js → transition-group.ts} +59 -46
- package/src/platforms/web/runtime/components/{transition.js → transition.ts} +43 -36
- package/src/platforms/web/runtime/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/directives/{model.js → model.ts} +22 -21
- package/src/platforms/web/runtime/directives/{show.js → show.ts} +11 -10
- package/src/platforms/web/runtime/{index.js → index.ts} +9 -10
- package/src/platforms/web/runtime/modules/{attrs.js → attrs.ts} +12 -16
- package/src/platforms/web/runtime/modules/{class.js → class.ts} +7 -18
- package/src/platforms/web/runtime/modules/{dom-props.js → dom-props.ts} +24 -17
- package/src/platforms/web/runtime/modules/{events.js → events.ts} +22 -15
- package/src/platforms/web/runtime/modules/{index.js → index.ts} +1 -8
- package/src/platforms/web/runtime/modules/{style.js → style.ts} +24 -13
- package/src/platforms/web/runtime/modules/{transition.js → transition.ts} +61 -63
- package/src/platforms/web/runtime/node-ops.ts +66 -0
- package/src/platforms/web/runtime/{patch.js → patch.ts} +0 -2
- package/src/platforms/web/runtime/{transition-util.js → transition-util.ts} +63 -38
- package/src/platforms/web/{entry-runtime-with-compiler.js → runtime-with-compiler.ts} +28 -19
- package/src/platforms/web/util/{attrs.js → attrs.ts} +18 -14
- package/src/platforms/web/util/{class.js → class.ts} +23 -21
- package/src/platforms/web/util/{compat.js → compat.ts} +4 -4
- package/src/platforms/web/util/{element.js → element.ts} +21 -22
- package/src/platforms/web/util/{index.js → index.ts} +2 -6
- package/src/platforms/web/util/{style.js → style.ts} +12 -12
- package/src/sfc/{parser.js → parser.ts} +18 -15
- package/src/shared/{constants.js → constants.ts} +2 -6
- package/src/shared/{util.js → util.ts} +78 -55
- package/src/types/compiler.ts +224 -0
- package/src/types/component.ts +209 -0
- package/src/types/global-api.ts +37 -0
- package/src/types/modules.d.ts +15 -0
- package/src/types/options.ts +120 -0
- package/src/types/ssr.ts +27 -0
- package/src/types/utils.ts +3 -0
- package/src/types/vnode.ts +127 -0
- package/src/v3/apiInject.ts +66 -0
- package/src/v3/apiLifecycle.ts +53 -0
- package/src/v3/apiSetup.ts +161 -0
- package/src/v3/apiWatch.ts +355 -0
- package/src/v3/currentInstance.ts +23 -0
- package/src/v3/debug.ts +21 -0
- package/src/v3/h.ts +18 -0
- package/src/v3/index.ts +77 -0
- package/src/v3/reactivity/computed.ts +100 -0
- package/src/v3/reactivity/effect.ts +20 -0
- package/src/v3/reactivity/effectScope.ts +134 -0
- package/src/v3/reactivity/operations.ts +14 -0
- package/src/v3/reactivity/reactive.ts +123 -0
- package/src/v3/reactivity/readonly.ts +121 -0
- package/src/v3/reactivity/ref.ts +249 -0
- package/types/index.d.ts +10 -13
- package/types/options.d.ts +265 -132
- package/types/plugin.d.ts +4 -4
- package/types/umd.d.ts +47 -27
- package/types/v3-generated.d.ts +389 -0
- package/types/v3.d.ts +16 -0
- package/types/vnode.d.ts +70 -57
- package/types/vue.d.ts +292 -88
- package/dist/README.md +0 -122
- package/src/compiler/directives/bind.js +0 -11
- package/src/core/global-api/use.js +0 -23
- package/src/core/instance/inject.js +0 -73
- package/src/core/vdom/helpers/is-async-placeholder.js +0 -5
- package/src/core/vdom/helpers/update-listeners.js +0 -95
- package/src/core/vdom/modules/index.js +0 -7
- package/src/core/vdom/modules/ref.js +0 -45
- package/src/platforms/web/compiler/directives/html.js +0 -9
- package/src/platforms/web/entry-server-basic-renderer.js +0 -13
- package/src/platforms/web/entry-server-renderer.js +0 -27
- package/src/platforms/web/runtime/node-ops.js +0 -59
- package/src/platforms/web/server/compiler.js +0 -11
- package/src/platforms/web/server/directives/index.js +0 -7
- package/src/platforms/web/server/directives/model.js +0 -44
- package/src/platforms/web/server/directives/show.js +0 -12
- package/src/platforms/web/server/modules/attrs.js +0 -67
- package/src/platforms/web/server/modules/class.js +0 -11
- package/src/platforms/web/server/modules/dom-props.js +0 -50
- package/src/platforms/web/server/modules/index.js +0 -11
- package/src/platforms/web/server/modules/style.js +0 -41
- package/src/platforms/web/server/util.js +0 -101
- package/src/platforms/weex/compiler/directives/index.js +0 -5
- package/src/platforms/weex/compiler/directives/model.js +0 -33
- package/src/platforms/weex/compiler/index.js +0 -52
- package/src/platforms/weex/compiler/modules/append.js +0 -27
- package/src/platforms/weex/compiler/modules/class.js +0 -74
- package/src/platforms/weex/compiler/modules/index.js +0 -13
- package/src/platforms/weex/compiler/modules/props.js +0 -37
- package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +0 -13
- package/src/platforms/weex/compiler/modules/recycle-list/component.js +0 -16
- package/src/platforms/weex/compiler/modules/recycle-list/index.js +0 -60
- package/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js +0 -50
- package/src/platforms/weex/compiler/modules/recycle-list/text.js +0 -23
- package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +0 -21
- package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +0 -33
- package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +0 -63
- package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +0 -25
- package/src/platforms/weex/compiler/modules/recycle-list/v-once.js +0 -19
- package/src/platforms/weex/compiler/modules/style.js +0 -87
- package/src/platforms/weex/entry-compiler.js +0 -2
- package/src/platforms/weex/entry-framework.js +0 -187
- package/src/platforms/weex/entry-runtime-factory.js +0 -6
- package/src/platforms/weex/runtime/components/index.js +0 -9
- package/src/platforms/weex/runtime/components/richtext.js +0 -82
- package/src/platforms/weex/runtime/components/transition-group.js +0 -148
- package/src/platforms/weex/runtime/components/transition.js +0 -9
- package/src/platforms/weex/runtime/directives/index.js +0 -2
- package/src/platforms/weex/runtime/index.js +0 -42
- package/src/platforms/weex/runtime/modules/attrs.js +0 -44
- package/src/platforms/weex/runtime/modules/class.js +0 -76
- package/src/platforms/weex/runtime/modules/events.js +0 -54
- package/src/platforms/weex/runtime/modules/index.js +0 -13
- package/src/platforms/weex/runtime/modules/style.js +0 -84
- package/src/platforms/weex/runtime/modules/transition.js +0 -270
- package/src/platforms/weex/runtime/node-ops.js +0 -91
- package/src/platforms/weex/runtime/patch.js +0 -16
- package/src/platforms/weex/runtime/recycle-list/render-component-template.js +0 -34
- package/src/platforms/weex/runtime/recycle-list/virtual-component.js +0 -136
- package/src/platforms/weex/runtime/text-node.js +0 -9
- package/src/platforms/weex/util/element.js +0 -52
- package/src/platforms/weex/util/index.js +0 -40
- package/src/platforms/weex/util/parser.js +0 -60
- package/src/server/bundle-renderer/create-bundle-renderer.js +0 -151
- package/src/server/bundle-renderer/create-bundle-runner.js +0 -150
- package/src/server/bundle-renderer/source-map-support.js +0 -45
- package/src/server/create-basic-renderer.js +0 -37
- package/src/server/create-renderer.js +0 -152
- package/src/server/optimizing-compiler/codegen.js +0 -264
- package/src/server/optimizing-compiler/index.js +0 -20
- package/src/server/optimizing-compiler/modules.js +0 -124
- package/src/server/optimizing-compiler/optimizer.js +0 -141
- package/src/server/optimizing-compiler/runtime-helpers.js +0 -150
- package/src/server/render-context.js +0 -130
- package/src/server/render-stream.js +0 -95
- package/src/server/render.js +0 -437
- package/src/server/template-renderer/create-async-file-mapper.js +0 -57
- package/src/server/template-renderer/index.js +0 -277
- package/src/server/template-renderer/parse-template.js +0 -42
- package/src/server/template-renderer/template-stream.js +0 -82
- package/src/server/util.js +0 -18
- package/src/server/webpack-plugin/client.js +0 -65
- package/src/server/webpack-plugin/server.js +0 -66
- package/src/server/webpack-plugin/util.js +0 -34
- package/src/server/write.js +0 -50
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import VNode, { cloneVNode } from './vnode'
|
|
14
14
|
import config from '../config'
|
|
15
15
|
import { SSR_ATTR } from 'shared/constants'
|
|
16
|
-
import { registerRef } from './modules/ref'
|
|
16
|
+
import { registerRef } from './modules/template-ref'
|
|
17
17
|
import { traverse } from '../observer/traverse'
|
|
18
18
|
import { activeInstance } from '../instance/lifecycle'
|
|
19
19
|
import { isTextInputType } from 'web/util/element'
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
isDef,
|
|
24
24
|
isUndef,
|
|
25
25
|
isTrue,
|
|
26
|
+
isArray,
|
|
26
27
|
makeMap,
|
|
27
28
|
isRegExp,
|
|
28
29
|
isPrimitive
|
|
@@ -32,32 +33,27 @@ export const emptyNode = new VNode('', {}, [])
|
|
|
32
33
|
|
|
33
34
|
const hooks = ['create', 'activate', 'update', 'remove', 'destroy']
|
|
34
35
|
|
|
35
|
-
function sameVnode
|
|
36
|
+
function sameVnode(a, b) {
|
|
36
37
|
return (
|
|
37
38
|
a.key === b.key &&
|
|
38
|
-
a.asyncFactory === b.asyncFactory &&
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
) || (
|
|
45
|
-
isTrue(a.isAsyncPlaceholder) &&
|
|
46
|
-
isUndef(b.asyncFactory.error)
|
|
47
|
-
)
|
|
48
|
-
)
|
|
39
|
+
a.asyncFactory === b.asyncFactory &&
|
|
40
|
+
((a.tag === b.tag &&
|
|
41
|
+
a.isComment === b.isComment &&
|
|
42
|
+
isDef(a.data) === isDef(b.data) &&
|
|
43
|
+
sameInputType(a, b)) ||
|
|
44
|
+
(isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error)))
|
|
49
45
|
)
|
|
50
46
|
}
|
|
51
47
|
|
|
52
|
-
function sameInputType
|
|
48
|
+
function sameInputType(a, b) {
|
|
53
49
|
if (a.tag !== 'input') return true
|
|
54
50
|
let i
|
|
55
|
-
const typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type
|
|
56
|
-
const typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type
|
|
57
|
-
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
|
|
51
|
+
const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type
|
|
52
|
+
const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type
|
|
53
|
+
return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB))
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
function createKeyToOldIdx
|
|
56
|
+
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
61
57
|
let i, key
|
|
62
58
|
const map = {}
|
|
63
59
|
for (i = beginIdx; i <= endIdx; ++i) {
|
|
@@ -67,9 +63,9 @@ function createKeyToOldIdx (children, beginIdx, endIdx) {
|
|
|
67
63
|
return map
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
export function createPatchFunction
|
|
66
|
+
export function createPatchFunction(backend) {
|
|
71
67
|
let i, j
|
|
72
|
-
const cbs = {}
|
|
68
|
+
const cbs: any = {}
|
|
73
69
|
|
|
74
70
|
const { modules, nodeOps } = backend
|
|
75
71
|
|
|
@@ -82,12 +78,12 @@ export function createPatchFunction (backend) {
|
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
function emptyNodeAt
|
|
81
|
+
function emptyNodeAt(elm) {
|
|
86
82
|
return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
|
|
87
83
|
}
|
|
88
84
|
|
|
89
|
-
function createRmCb
|
|
90
|
-
function remove
|
|
85
|
+
function createRmCb(childElm, listeners) {
|
|
86
|
+
function remove() {
|
|
91
87
|
if (--remove.listeners === 0) {
|
|
92
88
|
removeNode(childElm)
|
|
93
89
|
}
|
|
@@ -96,7 +92,7 @@ export function createPatchFunction (backend) {
|
|
|
96
92
|
return remove
|
|
97
93
|
}
|
|
98
94
|
|
|
99
|
-
function removeNode
|
|
95
|
+
function removeNode(el) {
|
|
100
96
|
const parent = nodeOps.parentNode(el)
|
|
101
97
|
// element may have already been removed due to v-html / v-text
|
|
102
98
|
if (isDef(parent)) {
|
|
@@ -104,7 +100,7 @@ export function createPatchFunction (backend) {
|
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
|
|
107
|
-
function isUnknownElement
|
|
103
|
+
function isUnknownElement(vnode, inVPre) {
|
|
108
104
|
return (
|
|
109
105
|
!inVPre &&
|
|
110
106
|
!vnode.ns &&
|
|
@@ -122,14 +118,14 @@ export function createPatchFunction (backend) {
|
|
|
122
118
|
|
|
123
119
|
let creatingElmInVPre = 0
|
|
124
120
|
|
|
125
|
-
function createElm
|
|
121
|
+
function createElm(
|
|
126
122
|
vnode,
|
|
127
123
|
insertedVnodeQueue,
|
|
128
|
-
parentElm,
|
|
129
|
-
refElm,
|
|
130
|
-
nested,
|
|
131
|
-
ownerArray,
|
|
132
|
-
index
|
|
124
|
+
parentElm?: any,
|
|
125
|
+
refElm?: any,
|
|
126
|
+
nested?: any,
|
|
127
|
+
ownerArray?: any,
|
|
128
|
+
index?: any
|
|
133
129
|
) {
|
|
134
130
|
if (isDef(vnode.elm) && isDef(ownerArray)) {
|
|
135
131
|
// This vnode was used in a previous render!
|
|
@@ -149,15 +145,17 @@ export function createPatchFunction (backend) {
|
|
|
149
145
|
const children = vnode.children
|
|
150
146
|
const tag = vnode.tag
|
|
151
147
|
if (isDef(tag)) {
|
|
152
|
-
if (
|
|
148
|
+
if (__DEV__) {
|
|
153
149
|
if (data && data.pre) {
|
|
154
150
|
creatingElmInVPre++
|
|
155
151
|
}
|
|
156
152
|
if (isUnknownElement(vnode, creatingElmInVPre)) {
|
|
157
153
|
warn(
|
|
158
|
-
'Unknown custom element: <' +
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
'Unknown custom element: <' +
|
|
155
|
+
tag +
|
|
156
|
+
'> - did you ' +
|
|
157
|
+
'register the component correctly? For recursive components, ' +
|
|
158
|
+
'make sure to provide the "name" option.',
|
|
161
159
|
vnode.context
|
|
162
160
|
)
|
|
163
161
|
}
|
|
@@ -168,34 +166,13 @@ export function createPatchFunction (backend) {
|
|
|
168
166
|
: nodeOps.createElement(tag, vnode)
|
|
169
167
|
setScope(vnode)
|
|
170
168
|
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
// List items can be optimized to use children-first insertion
|
|
175
|
-
// with append="tree".
|
|
176
|
-
const appendAsTree = isDef(data) && isTrue(data.appendAsTree)
|
|
177
|
-
if (!appendAsTree) {
|
|
178
|
-
if (isDef(data)) {
|
|
179
|
-
invokeCreateHooks(vnode, insertedVnodeQueue)
|
|
180
|
-
}
|
|
181
|
-
insert(parentElm, vnode.elm, refElm)
|
|
182
|
-
}
|
|
183
|
-
createChildren(vnode, children, insertedVnodeQueue)
|
|
184
|
-
if (appendAsTree) {
|
|
185
|
-
if (isDef(data)) {
|
|
186
|
-
invokeCreateHooks(vnode, insertedVnodeQueue)
|
|
187
|
-
}
|
|
188
|
-
insert(parentElm, vnode.elm, refElm)
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
createChildren(vnode, children, insertedVnodeQueue)
|
|
192
|
-
if (isDef(data)) {
|
|
193
|
-
invokeCreateHooks(vnode, insertedVnodeQueue)
|
|
194
|
-
}
|
|
195
|
-
insert(parentElm, vnode.elm, refElm)
|
|
169
|
+
createChildren(vnode, children, insertedVnodeQueue)
|
|
170
|
+
if (isDef(data)) {
|
|
171
|
+
invokeCreateHooks(vnode, insertedVnodeQueue)
|
|
196
172
|
}
|
|
173
|
+
insert(parentElm, vnode.elm, refElm)
|
|
197
174
|
|
|
198
|
-
if (
|
|
175
|
+
if (__DEV__ && data && data.pre) {
|
|
199
176
|
creatingElmInVPre--
|
|
200
177
|
}
|
|
201
178
|
} else if (isTrue(vnode.isComment)) {
|
|
@@ -207,11 +184,11 @@ export function createPatchFunction (backend) {
|
|
|
207
184
|
}
|
|
208
185
|
}
|
|
209
186
|
|
|
210
|
-
function createComponent
|
|
187
|
+
function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
|
|
211
188
|
let i = vnode.data
|
|
212
189
|
if (isDef(i)) {
|
|
213
190
|
const isReactivated = isDef(vnode.componentInstance) && i.keepAlive
|
|
214
|
-
if (isDef(i = i.hook) && isDef(i = i.init)) {
|
|
191
|
+
if (isDef((i = i.hook)) && isDef((i = i.init))) {
|
|
215
192
|
i(vnode, false /* hydrating */)
|
|
216
193
|
}
|
|
217
194
|
// after calling the init hook, if the vnode is a child component
|
|
@@ -229,9 +206,12 @@ export function createPatchFunction (backend) {
|
|
|
229
206
|
}
|
|
230
207
|
}
|
|
231
208
|
|
|
232
|
-
function initComponent
|
|
209
|
+
function initComponent(vnode, insertedVnodeQueue) {
|
|
233
210
|
if (isDef(vnode.data.pendingInsert)) {
|
|
234
|
-
insertedVnodeQueue.push.apply(
|
|
211
|
+
insertedVnodeQueue.push.apply(
|
|
212
|
+
insertedVnodeQueue,
|
|
213
|
+
vnode.data.pendingInsert
|
|
214
|
+
)
|
|
235
215
|
vnode.data.pendingInsert = null
|
|
236
216
|
}
|
|
237
217
|
vnode.elm = vnode.componentInstance.$el
|
|
@@ -247,7 +227,7 @@ export function createPatchFunction (backend) {
|
|
|
247
227
|
}
|
|
248
228
|
}
|
|
249
229
|
|
|
250
|
-
function reactivateComponent
|
|
230
|
+
function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
|
|
251
231
|
let i
|
|
252
232
|
// hack for #4339: a reactivated component with inner transition
|
|
253
233
|
// does not trigger because the inner node's created hooks are not called
|
|
@@ -256,7 +236,7 @@ export function createPatchFunction (backend) {
|
|
|
256
236
|
let innerNode = vnode
|
|
257
237
|
while (innerNode.componentInstance) {
|
|
258
238
|
innerNode = innerNode.componentInstance._vnode
|
|
259
|
-
if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
|
|
239
|
+
if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
|
|
260
240
|
for (i = 0; i < cbs.activate.length; ++i) {
|
|
261
241
|
cbs.activate[i](emptyNode, innerNode)
|
|
262
242
|
}
|
|
@@ -269,7 +249,7 @@ export function createPatchFunction (backend) {
|
|
|
269
249
|
insert(parentElm, vnode.elm, refElm)
|
|
270
250
|
}
|
|
271
251
|
|
|
272
|
-
function insert
|
|
252
|
+
function insert(parent, elm, ref) {
|
|
273
253
|
if (isDef(parent)) {
|
|
274
254
|
if (isDef(ref)) {
|
|
275
255
|
if (nodeOps.parentNode(ref) === parent) {
|
|
@@ -281,27 +261,35 @@ export function createPatchFunction (backend) {
|
|
|
281
261
|
}
|
|
282
262
|
}
|
|
283
263
|
|
|
284
|
-
function createChildren
|
|
285
|
-
if (
|
|
286
|
-
if (
|
|
264
|
+
function createChildren(vnode, children, insertedVnodeQueue) {
|
|
265
|
+
if (isArray(children)) {
|
|
266
|
+
if (__DEV__) {
|
|
287
267
|
checkDuplicateKeys(children)
|
|
288
268
|
}
|
|
289
269
|
for (let i = 0; i < children.length; ++i) {
|
|
290
|
-
createElm(
|
|
270
|
+
createElm(
|
|
271
|
+
children[i],
|
|
272
|
+
insertedVnodeQueue,
|
|
273
|
+
vnode.elm,
|
|
274
|
+
null,
|
|
275
|
+
true,
|
|
276
|
+
children,
|
|
277
|
+
i
|
|
278
|
+
)
|
|
291
279
|
}
|
|
292
280
|
} else if (isPrimitive(vnode.text)) {
|
|
293
281
|
nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)))
|
|
294
282
|
}
|
|
295
283
|
}
|
|
296
284
|
|
|
297
|
-
function isPatchable
|
|
285
|
+
function isPatchable(vnode) {
|
|
298
286
|
while (vnode.componentInstance) {
|
|
299
287
|
vnode = vnode.componentInstance._vnode
|
|
300
288
|
}
|
|
301
289
|
return isDef(vnode.tag)
|
|
302
290
|
}
|
|
303
291
|
|
|
304
|
-
function invokeCreateHooks
|
|
292
|
+
function invokeCreateHooks(vnode, insertedVnodeQueue) {
|
|
305
293
|
for (let i = 0; i < cbs.create.length; ++i) {
|
|
306
294
|
cbs.create[i](emptyNode, vnode)
|
|
307
295
|
}
|
|
@@ -315,64 +303,81 @@ export function createPatchFunction (backend) {
|
|
|
315
303
|
// set scope id attribute for scoped CSS.
|
|
316
304
|
// this is implemented as a special case to avoid the overhead
|
|
317
305
|
// of going through the normal attribute patching process.
|
|
318
|
-
function setScope
|
|
306
|
+
function setScope(vnode) {
|
|
319
307
|
let i
|
|
320
|
-
if (isDef(i = vnode.fnScopeId)) {
|
|
308
|
+
if (isDef((i = vnode.fnScopeId))) {
|
|
321
309
|
nodeOps.setStyleScope(vnode.elm, i)
|
|
322
310
|
} else {
|
|
323
311
|
let ancestor = vnode
|
|
324
312
|
while (ancestor) {
|
|
325
|
-
if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
|
|
313
|
+
if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
|
|
326
314
|
nodeOps.setStyleScope(vnode.elm, i)
|
|
327
315
|
}
|
|
328
316
|
ancestor = ancestor.parent
|
|
329
317
|
}
|
|
330
318
|
}
|
|
331
319
|
// for slot content they should also get the scopeId from the host instance.
|
|
332
|
-
if (
|
|
320
|
+
if (
|
|
321
|
+
isDef((i = activeInstance)) &&
|
|
333
322
|
i !== vnode.context &&
|
|
334
323
|
i !== vnode.fnContext &&
|
|
335
|
-
isDef(i = i.$options._scopeId)
|
|
324
|
+
isDef((i = i.$options._scopeId))
|
|
336
325
|
) {
|
|
337
326
|
nodeOps.setStyleScope(vnode.elm, i)
|
|
338
327
|
}
|
|
339
328
|
}
|
|
340
329
|
|
|
341
|
-
function addVnodes
|
|
330
|
+
function addVnodes(
|
|
331
|
+
parentElm,
|
|
332
|
+
refElm,
|
|
333
|
+
vnodes,
|
|
334
|
+
startIdx,
|
|
335
|
+
endIdx,
|
|
336
|
+
insertedVnodeQueue
|
|
337
|
+
) {
|
|
342
338
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
343
|
-
createElm(
|
|
339
|
+
createElm(
|
|
340
|
+
vnodes[startIdx],
|
|
341
|
+
insertedVnodeQueue,
|
|
342
|
+
parentElm,
|
|
343
|
+
refElm,
|
|
344
|
+
false,
|
|
345
|
+
vnodes,
|
|
346
|
+
startIdx
|
|
347
|
+
)
|
|
344
348
|
}
|
|
345
349
|
}
|
|
346
350
|
|
|
347
|
-
function invokeDestroyHook
|
|
351
|
+
function invokeDestroyHook(vnode) {
|
|
348
352
|
let i, j
|
|
349
353
|
const data = vnode.data
|
|
350
354
|
if (isDef(data)) {
|
|
351
|
-
if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode)
|
|
355
|
+
if (isDef((i = data.hook)) && isDef((i = i.destroy))) i(vnode)
|
|
352
356
|
for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode)
|
|
353
357
|
}
|
|
354
|
-
if (isDef(i = vnode.children)) {
|
|
358
|
+
if (isDef((i = vnode.children))) {
|
|
355
359
|
for (j = 0; j < vnode.children.length; ++j) {
|
|
356
360
|
invokeDestroyHook(vnode.children[j])
|
|
357
361
|
}
|
|
358
362
|
}
|
|
359
363
|
}
|
|
360
364
|
|
|
361
|
-
function removeVnodes
|
|
365
|
+
function removeVnodes(vnodes, startIdx, endIdx) {
|
|
362
366
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
363
367
|
const ch = vnodes[startIdx]
|
|
364
368
|
if (isDef(ch)) {
|
|
365
369
|
if (isDef(ch.tag)) {
|
|
366
370
|
removeAndInvokeRemoveHook(ch)
|
|
367
371
|
invokeDestroyHook(ch)
|
|
368
|
-
} else {
|
|
372
|
+
} else {
|
|
373
|
+
// Text node
|
|
369
374
|
removeNode(ch.elm)
|
|
370
375
|
}
|
|
371
376
|
}
|
|
372
377
|
}
|
|
373
378
|
}
|
|
374
379
|
|
|
375
|
-
function removeAndInvokeRemoveHook
|
|
380
|
+
function removeAndInvokeRemoveHook(vnode, rm?: any) {
|
|
376
381
|
if (isDef(rm) || isDef(vnode.data)) {
|
|
377
382
|
let i
|
|
378
383
|
const listeners = cbs.remove.length + 1
|
|
@@ -385,13 +390,17 @@ export function createPatchFunction (backend) {
|
|
|
385
390
|
rm = createRmCb(vnode.elm, listeners)
|
|
386
391
|
}
|
|
387
392
|
// recursively invoke hooks on child component root node
|
|
388
|
-
if (
|
|
393
|
+
if (
|
|
394
|
+
isDef((i = vnode.componentInstance)) &&
|
|
395
|
+
isDef((i = i._vnode)) &&
|
|
396
|
+
isDef(i.data)
|
|
397
|
+
) {
|
|
389
398
|
removeAndInvokeRemoveHook(i, rm)
|
|
390
399
|
}
|
|
391
400
|
for (i = 0; i < cbs.remove.length; ++i) {
|
|
392
401
|
cbs.remove[i](vnode, rm)
|
|
393
402
|
}
|
|
394
|
-
if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
|
|
403
|
+
if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
|
|
395
404
|
i(vnode, rm)
|
|
396
405
|
} else {
|
|
397
406
|
rm()
|
|
@@ -401,7 +410,13 @@ export function createPatchFunction (backend) {
|
|
|
401
410
|
}
|
|
402
411
|
}
|
|
403
412
|
|
|
404
|
-
function updateChildren
|
|
413
|
+
function updateChildren(
|
|
414
|
+
parentElm,
|
|
415
|
+
oldCh,
|
|
416
|
+
newCh,
|
|
417
|
+
insertedVnodeQueue,
|
|
418
|
+
removeOnly
|
|
419
|
+
) {
|
|
405
420
|
let oldStartIdx = 0
|
|
406
421
|
let newStartIdx = 0
|
|
407
422
|
let oldEndIdx = oldCh.length - 1
|
|
@@ -417,7 +432,7 @@ export function createPatchFunction (backend) {
|
|
|
417
432
|
// during leaving transitions
|
|
418
433
|
const canMove = !removeOnly
|
|
419
434
|
|
|
420
|
-
if (
|
|
435
|
+
if (__DEV__) {
|
|
421
436
|
checkDuplicateKeys(newCh)
|
|
422
437
|
}
|
|
423
438
|
|
|
@@ -427,39 +442,100 @@ export function createPatchFunction (backend) {
|
|
|
427
442
|
} else if (isUndef(oldEndVnode)) {
|
|
428
443
|
oldEndVnode = oldCh[--oldEndIdx]
|
|
429
444
|
} else if (sameVnode(oldStartVnode, newStartVnode)) {
|
|
430
|
-
patchVnode(
|
|
445
|
+
patchVnode(
|
|
446
|
+
oldStartVnode,
|
|
447
|
+
newStartVnode,
|
|
448
|
+
insertedVnodeQueue,
|
|
449
|
+
newCh,
|
|
450
|
+
newStartIdx
|
|
451
|
+
)
|
|
431
452
|
oldStartVnode = oldCh[++oldStartIdx]
|
|
432
453
|
newStartVnode = newCh[++newStartIdx]
|
|
433
454
|
} else if (sameVnode(oldEndVnode, newEndVnode)) {
|
|
434
|
-
patchVnode(
|
|
455
|
+
patchVnode(
|
|
456
|
+
oldEndVnode,
|
|
457
|
+
newEndVnode,
|
|
458
|
+
insertedVnodeQueue,
|
|
459
|
+
newCh,
|
|
460
|
+
newEndIdx
|
|
461
|
+
)
|
|
435
462
|
oldEndVnode = oldCh[--oldEndIdx]
|
|
436
463
|
newEndVnode = newCh[--newEndIdx]
|
|
437
|
-
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
438
|
-
|
|
439
|
-
|
|
464
|
+
} else if (sameVnode(oldStartVnode, newEndVnode)) {
|
|
465
|
+
// Vnode moved right
|
|
466
|
+
patchVnode(
|
|
467
|
+
oldStartVnode,
|
|
468
|
+
newEndVnode,
|
|
469
|
+
insertedVnodeQueue,
|
|
470
|
+
newCh,
|
|
471
|
+
newEndIdx
|
|
472
|
+
)
|
|
473
|
+
canMove &&
|
|
474
|
+
nodeOps.insertBefore(
|
|
475
|
+
parentElm,
|
|
476
|
+
oldStartVnode.elm,
|
|
477
|
+
nodeOps.nextSibling(oldEndVnode.elm)
|
|
478
|
+
)
|
|
440
479
|
oldStartVnode = oldCh[++oldStartIdx]
|
|
441
480
|
newEndVnode = newCh[--newEndIdx]
|
|
442
|
-
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
443
|
-
|
|
444
|
-
|
|
481
|
+
} else if (sameVnode(oldEndVnode, newStartVnode)) {
|
|
482
|
+
// Vnode moved left
|
|
483
|
+
patchVnode(
|
|
484
|
+
oldEndVnode,
|
|
485
|
+
newStartVnode,
|
|
486
|
+
insertedVnodeQueue,
|
|
487
|
+
newCh,
|
|
488
|
+
newStartIdx
|
|
489
|
+
)
|
|
490
|
+
canMove &&
|
|
491
|
+
nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm)
|
|
445
492
|
oldEndVnode = oldCh[--oldEndIdx]
|
|
446
493
|
newStartVnode = newCh[++newStartIdx]
|
|
447
494
|
} else {
|
|
448
|
-
if (isUndef(oldKeyToIdx))
|
|
495
|
+
if (isUndef(oldKeyToIdx))
|
|
496
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx)
|
|
449
497
|
idxInOld = isDef(newStartVnode.key)
|
|
450
498
|
? oldKeyToIdx[newStartVnode.key]
|
|
451
499
|
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx)
|
|
452
|
-
if (isUndef(idxInOld)) {
|
|
453
|
-
|
|
500
|
+
if (isUndef(idxInOld)) {
|
|
501
|
+
// New element
|
|
502
|
+
createElm(
|
|
503
|
+
newStartVnode,
|
|
504
|
+
insertedVnodeQueue,
|
|
505
|
+
parentElm,
|
|
506
|
+
oldStartVnode.elm,
|
|
507
|
+
false,
|
|
508
|
+
newCh,
|
|
509
|
+
newStartIdx
|
|
510
|
+
)
|
|
454
511
|
} else {
|
|
455
512
|
vnodeToMove = oldCh[idxInOld]
|
|
456
513
|
if (sameVnode(vnodeToMove, newStartVnode)) {
|
|
457
|
-
patchVnode(
|
|
514
|
+
patchVnode(
|
|
515
|
+
vnodeToMove,
|
|
516
|
+
newStartVnode,
|
|
517
|
+
insertedVnodeQueue,
|
|
518
|
+
newCh,
|
|
519
|
+
newStartIdx
|
|
520
|
+
)
|
|
458
521
|
oldCh[idxInOld] = undefined
|
|
459
|
-
canMove &&
|
|
522
|
+
canMove &&
|
|
523
|
+
nodeOps.insertBefore(
|
|
524
|
+
parentElm,
|
|
525
|
+
vnodeToMove.elm,
|
|
526
|
+
oldStartVnode.elm
|
|
527
|
+
)
|
|
460
528
|
} else {
|
|
461
529
|
// same key but different element. treat as new element
|
|
462
|
-
createElm(
|
|
530
|
+
createElm(
|
|
531
|
+
newStartVnode,
|
|
532
|
+
insertedVnodeQueue,
|
|
533
|
+
parentElm,
|
|
534
|
+
oldStartVnode.elm,
|
|
535
|
+
false,
|
|
536
|
+
newCh,
|
|
537
|
+
newStartIdx
|
|
538
|
+
)
|
|
463
539
|
}
|
|
464
540
|
}
|
|
465
541
|
newStartVnode = newCh[++newStartIdx]
|
|
@@ -467,13 +543,20 @@ export function createPatchFunction (backend) {
|
|
|
467
543
|
}
|
|
468
544
|
if (oldStartIdx > oldEndIdx) {
|
|
469
545
|
refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm
|
|
470
|
-
addVnodes(
|
|
546
|
+
addVnodes(
|
|
547
|
+
parentElm,
|
|
548
|
+
refElm,
|
|
549
|
+
newCh,
|
|
550
|
+
newStartIdx,
|
|
551
|
+
newEndIdx,
|
|
552
|
+
insertedVnodeQueue
|
|
553
|
+
)
|
|
471
554
|
} else if (newStartIdx > newEndIdx) {
|
|
472
555
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx)
|
|
473
556
|
}
|
|
474
557
|
}
|
|
475
558
|
|
|
476
|
-
function checkDuplicateKeys
|
|
559
|
+
function checkDuplicateKeys(children) {
|
|
477
560
|
const seenKeys = {}
|
|
478
561
|
for (let i = 0; i < children.length; i++) {
|
|
479
562
|
const vnode = children[i]
|
|
@@ -491,20 +574,20 @@ export function createPatchFunction (backend) {
|
|
|
491
574
|
}
|
|
492
575
|
}
|
|
493
576
|
|
|
494
|
-
function findIdxInOld
|
|
577
|
+
function findIdxInOld(node, oldCh, start, end) {
|
|
495
578
|
for (let i = start; i < end; i++) {
|
|
496
579
|
const c = oldCh[i]
|
|
497
580
|
if (isDef(c) && sameVnode(node, c)) return i
|
|
498
581
|
}
|
|
499
582
|
}
|
|
500
583
|
|
|
501
|
-
function patchVnode
|
|
584
|
+
function patchVnode(
|
|
502
585
|
oldVnode,
|
|
503
586
|
vnode,
|
|
504
587
|
insertedVnodeQueue,
|
|
505
588
|
ownerArray,
|
|
506
589
|
index,
|
|
507
|
-
removeOnly
|
|
590
|
+
removeOnly?: any
|
|
508
591
|
) {
|
|
509
592
|
if (oldVnode === vnode) {
|
|
510
593
|
return
|
|
@@ -515,7 +598,7 @@ export function createPatchFunction (backend) {
|
|
|
515
598
|
vnode = ownerArray[index] = cloneVNode(vnode)
|
|
516
599
|
}
|
|
517
600
|
|
|
518
|
-
const elm = vnode.elm = oldVnode.elm
|
|
601
|
+
const elm = (vnode.elm = oldVnode.elm)
|
|
519
602
|
|
|
520
603
|
if (isTrue(oldVnode.isAsyncPlaceholder)) {
|
|
521
604
|
if (isDef(vnode.asyncFactory.resolved)) {
|
|
@@ -530,7 +613,8 @@ export function createPatchFunction (backend) {
|
|
|
530
613
|
// note we only do this if the vnode is cloned -
|
|
531
614
|
// if the new node is not cloned it means the render functions have been
|
|
532
615
|
// reset by the hot-reload-api and we need to do a proper re-render.
|
|
533
|
-
if (
|
|
616
|
+
if (
|
|
617
|
+
isTrue(vnode.isStatic) &&
|
|
534
618
|
isTrue(oldVnode.isStatic) &&
|
|
535
619
|
vnode.key === oldVnode.key &&
|
|
536
620
|
(isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
|
|
@@ -541,7 +625,7 @@ export function createPatchFunction (backend) {
|
|
|
541
625
|
|
|
542
626
|
let i
|
|
543
627
|
const data = vnode.data
|
|
544
|
-
if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
|
|
628
|
+
if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
|
|
545
629
|
i(oldVnode, vnode)
|
|
546
630
|
}
|
|
547
631
|
|
|
@@ -549,13 +633,14 @@ export function createPatchFunction (backend) {
|
|
|
549
633
|
const ch = vnode.children
|
|
550
634
|
if (isDef(data) && isPatchable(vnode)) {
|
|
551
635
|
for (i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode)
|
|
552
|
-
if (isDef(i = data.hook) && isDef(i = i.update)) i(oldVnode, vnode)
|
|
636
|
+
if (isDef((i = data.hook)) && isDef((i = i.update))) i(oldVnode, vnode)
|
|
553
637
|
}
|
|
554
638
|
if (isUndef(vnode.text)) {
|
|
555
639
|
if (isDef(oldCh) && isDef(ch)) {
|
|
556
|
-
if (oldCh !== ch)
|
|
640
|
+
if (oldCh !== ch)
|
|
641
|
+
updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly)
|
|
557
642
|
} else if (isDef(ch)) {
|
|
558
|
-
if (
|
|
643
|
+
if (__DEV__) {
|
|
559
644
|
checkDuplicateKeys(ch)
|
|
560
645
|
}
|
|
561
646
|
if (isDef(oldVnode.text)) nodeOps.setTextContent(elm, '')
|
|
@@ -569,11 +654,11 @@ export function createPatchFunction (backend) {
|
|
|
569
654
|
nodeOps.setTextContent(elm, vnode.text)
|
|
570
655
|
}
|
|
571
656
|
if (isDef(data)) {
|
|
572
|
-
if (isDef(i = data.hook) && isDef(i = i.postpatch)) i(oldVnode, vnode)
|
|
657
|
+
if (isDef((i = data.hook)) && isDef((i = i.postpatch))) i(oldVnode, vnode)
|
|
573
658
|
}
|
|
574
659
|
}
|
|
575
660
|
|
|
576
|
-
function invokeInsertHook
|
|
661
|
+
function invokeInsertHook(vnode, queue, initial) {
|
|
577
662
|
// delay insert hooks for component root nodes, invoke them after the
|
|
578
663
|
// element is really inserted
|
|
579
664
|
if (isTrue(initial) && isDef(vnode.parent)) {
|
|
@@ -593,7 +678,7 @@ export function createPatchFunction (backend) {
|
|
|
593
678
|
const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key')
|
|
594
679
|
|
|
595
680
|
// Note: this is a browser-only function so we can assume elms are DOM nodes.
|
|
596
|
-
function hydrate
|
|
681
|
+
function hydrate(elm, vnode, insertedVnodeQueue, inVPre?: boolean) {
|
|
597
682
|
let i
|
|
598
683
|
const { tag, data, children } = vnode
|
|
599
684
|
inVPre = inVPre || (data && data.pre)
|
|
@@ -604,14 +689,15 @@ export function createPatchFunction (backend) {
|
|
|
604
689
|
return true
|
|
605
690
|
}
|
|
606
691
|
// assert node match
|
|
607
|
-
if (
|
|
692
|
+
if (__DEV__) {
|
|
608
693
|
if (!assertNodeMatch(elm, vnode, inVPre)) {
|
|
609
694
|
return false
|
|
610
695
|
}
|
|
611
696
|
}
|
|
612
697
|
if (isDef(data)) {
|
|
613
|
-
if (isDef(i = data.hook) && isDef(i = i.init))
|
|
614
|
-
|
|
698
|
+
if (isDef((i = data.hook)) && isDef((i = i.init)))
|
|
699
|
+
i(vnode, true /* hydrating */)
|
|
700
|
+
if (isDef((i = vnode.componentInstance))) {
|
|
615
701
|
// child component. it should have hydrated its own tree.
|
|
616
702
|
initComponent(vnode, insertedVnodeQueue)
|
|
617
703
|
return true
|
|
@@ -624,10 +710,15 @@ export function createPatchFunction (backend) {
|
|
|
624
710
|
createChildren(vnode, children, insertedVnodeQueue)
|
|
625
711
|
} else {
|
|
626
712
|
// v-html and domProps: innerHTML
|
|
627
|
-
if (
|
|
713
|
+
if (
|
|
714
|
+
isDef((i = data)) &&
|
|
715
|
+
isDef((i = i.domProps)) &&
|
|
716
|
+
isDef((i = i.innerHTML))
|
|
717
|
+
) {
|
|
628
718
|
if (i !== elm.innerHTML) {
|
|
629
719
|
/* istanbul ignore if */
|
|
630
|
-
if (
|
|
720
|
+
if (
|
|
721
|
+
__DEV__ &&
|
|
631
722
|
typeof console !== 'undefined' &&
|
|
632
723
|
!hydrationBailed
|
|
633
724
|
) {
|
|
@@ -643,7 +734,10 @@ export function createPatchFunction (backend) {
|
|
|
643
734
|
let childrenMatch = true
|
|
644
735
|
let childNode = elm.firstChild
|
|
645
736
|
for (let i = 0; i < children.length; i++) {
|
|
646
|
-
if (
|
|
737
|
+
if (
|
|
738
|
+
!childNode ||
|
|
739
|
+
!hydrate(childNode, children[i], insertedVnodeQueue, inVPre)
|
|
740
|
+
) {
|
|
647
741
|
childrenMatch = false
|
|
648
742
|
break
|
|
649
743
|
}
|
|
@@ -653,13 +747,18 @@ export function createPatchFunction (backend) {
|
|
|
653
747
|
// longer than the virtual children list.
|
|
654
748
|
if (!childrenMatch || childNode) {
|
|
655
749
|
/* istanbul ignore if */
|
|
656
|
-
if (
|
|
750
|
+
if (
|
|
751
|
+
__DEV__ &&
|
|
657
752
|
typeof console !== 'undefined' &&
|
|
658
753
|
!hydrationBailed
|
|
659
754
|
) {
|
|
660
755
|
hydrationBailed = true
|
|
661
756
|
console.warn('Parent: ', elm)
|
|
662
|
-
console.warn(
|
|
757
|
+
console.warn(
|
|
758
|
+
'Mismatching childNodes vs. VNodes: ',
|
|
759
|
+
elm.childNodes,
|
|
760
|
+
children
|
|
761
|
+
)
|
|
663
762
|
}
|
|
664
763
|
return false
|
|
665
764
|
}
|
|
@@ -686,25 +785,27 @@ export function createPatchFunction (backend) {
|
|
|
686
785
|
return true
|
|
687
786
|
}
|
|
688
787
|
|
|
689
|
-
function assertNodeMatch
|
|
788
|
+
function assertNodeMatch(node, vnode, inVPre) {
|
|
690
789
|
if (isDef(vnode.tag)) {
|
|
691
|
-
return
|
|
692
|
-
|
|
693
|
-
vnode
|
|
790
|
+
return (
|
|
791
|
+
vnode.tag.indexOf('vue-component') === 0 ||
|
|
792
|
+
(!isUnknownElement(vnode, inVPre) &&
|
|
793
|
+
vnode.tag.toLowerCase() ===
|
|
794
|
+
(node.tagName && node.tagName.toLowerCase()))
|
|
694
795
|
)
|
|
695
796
|
} else {
|
|
696
797
|
return node.nodeType === (vnode.isComment ? 8 : 3)
|
|
697
798
|
}
|
|
698
799
|
}
|
|
699
800
|
|
|
700
|
-
return function patch
|
|
801
|
+
return function patch(oldVnode, vnode, hydrating, removeOnly) {
|
|
701
802
|
if (isUndef(vnode)) {
|
|
702
803
|
if (isDef(oldVnode)) invokeDestroyHook(oldVnode)
|
|
703
804
|
return
|
|
704
805
|
}
|
|
705
806
|
|
|
706
807
|
let isInitialPatch = false
|
|
707
|
-
const insertedVnodeQueue = []
|
|
808
|
+
const insertedVnodeQueue: any[] = []
|
|
708
809
|
|
|
709
810
|
if (isUndef(oldVnode)) {
|
|
710
811
|
// empty mount (likely as component), create new root element
|
|
@@ -728,13 +829,13 @@ export function createPatchFunction (backend) {
|
|
|
728
829
|
if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
|
|
729
830
|
invokeInsertHook(vnode, insertedVnodeQueue, true)
|
|
730
831
|
return oldVnode
|
|
731
|
-
} else if (
|
|
832
|
+
} else if (__DEV__) {
|
|
732
833
|
warn(
|
|
733
834
|
'The client-side rendered virtual DOM tree is not matching ' +
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
835
|
+
'server-rendered content. This is likely caused by incorrect ' +
|
|
836
|
+
'HTML markup, for example nesting block-level elements inside ' +
|
|
837
|
+
'<p>, or missing <tbody>. Bailing hydration and performing ' +
|
|
838
|
+
'full client-side render.'
|
|
738
839
|
)
|
|
739
840
|
}
|
|
740
841
|
}
|