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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import VNode, { cloneVNode } from './vnode'
|
|
4
2
|
import { createElement } from './create-element'
|
|
5
3
|
import { resolveInject } from '../instance/inject'
|
|
@@ -12,17 +10,20 @@ import {
|
|
|
12
10
|
isDef,
|
|
13
11
|
isTrue,
|
|
14
12
|
hasOwn,
|
|
13
|
+
isArray,
|
|
15
14
|
camelize,
|
|
16
15
|
emptyObject,
|
|
17
16
|
validateProp
|
|
18
17
|
} from '../util/index'
|
|
18
|
+
import type { Component } from 'types/component'
|
|
19
|
+
import type { VNodeData } from 'types/vnode'
|
|
19
20
|
|
|
20
|
-
export function FunctionalRenderContext
|
|
21
|
+
export function FunctionalRenderContext(
|
|
21
22
|
data: VNodeData,
|
|
22
23
|
props: Object,
|
|
23
|
-
children:
|
|
24
|
+
children: Array<VNode> | undefined,
|
|
24
25
|
parent: Component,
|
|
25
|
-
Ctor:
|
|
26
|
+
Ctor: typeof Component
|
|
26
27
|
) {
|
|
27
28
|
const options = Ctor.options
|
|
28
29
|
// ensure the createElement function in functional components
|
|
@@ -30,14 +31,13 @@ export function FunctionalRenderContext (
|
|
|
30
31
|
let contextVm
|
|
31
32
|
if (hasOwn(parent, '_uid')) {
|
|
32
33
|
contextVm = Object.create(parent)
|
|
33
|
-
// $flow-disable-line
|
|
34
34
|
contextVm._original = parent
|
|
35
35
|
} else {
|
|
36
36
|
// the context vm passed in is a functional context as well.
|
|
37
37
|
// in this case we want to make sure we are able to get a hold to the
|
|
38
38
|
// real context instance.
|
|
39
39
|
contextVm = parent
|
|
40
|
-
//
|
|
40
|
+
// @ts-ignore
|
|
41
41
|
parent = parent._original
|
|
42
42
|
}
|
|
43
43
|
const isCompiled = isTrue(options._compiled)
|
|
@@ -52,19 +52,20 @@ export function FunctionalRenderContext (
|
|
|
52
52
|
this.slots = () => {
|
|
53
53
|
if (!this.$slots) {
|
|
54
54
|
normalizeScopedSlots(
|
|
55
|
+
parent,
|
|
55
56
|
data.scopedSlots,
|
|
56
|
-
this.$slots = resolveSlots(children, parent)
|
|
57
|
+
(this.$slots = resolveSlots(children, parent))
|
|
57
58
|
)
|
|
58
59
|
}
|
|
59
60
|
return this.$slots
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
Object.defineProperty(this, 'scopedSlots',
|
|
63
|
+
Object.defineProperty(this, 'scopedSlots', {
|
|
63
64
|
enumerable: true,
|
|
64
|
-
get
|
|
65
|
-
return normalizeScopedSlots(data.scopedSlots, this.slots())
|
|
65
|
+
get() {
|
|
66
|
+
return normalizeScopedSlots(parent, data.scopedSlots, this.slots())
|
|
66
67
|
}
|
|
67
|
-
}
|
|
68
|
+
} as any)
|
|
68
69
|
|
|
69
70
|
// support for compiled functional template
|
|
70
71
|
if (isCompiled) {
|
|
@@ -72,31 +73,36 @@ export function FunctionalRenderContext (
|
|
|
72
73
|
this.$options = options
|
|
73
74
|
// pre-resolve slots for renderSlot()
|
|
74
75
|
this.$slots = this.slots()
|
|
75
|
-
this.$scopedSlots = normalizeScopedSlots(
|
|
76
|
+
this.$scopedSlots = normalizeScopedSlots(
|
|
77
|
+
parent,
|
|
78
|
+
data.scopedSlots,
|
|
79
|
+
this.$slots
|
|
80
|
+
)
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
if (options._scopeId) {
|
|
79
84
|
this._c = (a, b, c, d) => {
|
|
80
85
|
const vnode = createElement(contextVm, a, b, c, d, needNormalization)
|
|
81
|
-
if (vnode && !
|
|
86
|
+
if (vnode && !isArray(vnode)) {
|
|
82
87
|
vnode.fnScopeId = options._scopeId
|
|
83
88
|
vnode.fnContext = parent
|
|
84
89
|
}
|
|
85
90
|
return vnode
|
|
86
91
|
}
|
|
87
92
|
} else {
|
|
88
|
-
this._c = (a, b, c, d) =>
|
|
93
|
+
this._c = (a, b, c, d) =>
|
|
94
|
+
createElement(contextVm, a, b, c, d, needNormalization)
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
installRenderHelpers(FunctionalRenderContext.prototype)
|
|
93
99
|
|
|
94
|
-
export function createFunctionalComponent
|
|
95
|
-
Ctor:
|
|
96
|
-
propsData:
|
|
100
|
+
export function createFunctionalComponent(
|
|
101
|
+
Ctor: typeof Component,
|
|
102
|
+
propsData: Object | undefined,
|
|
97
103
|
data: VNodeData,
|
|
98
104
|
contextVm: Component,
|
|
99
|
-
children
|
|
105
|
+
children?: Array<VNode>
|
|
100
106
|
): VNode | Array<VNode> | void {
|
|
101
107
|
const options = Ctor.options
|
|
102
108
|
const props = {}
|
|
@@ -121,34 +127,53 @@ export function createFunctionalComponent (
|
|
|
121
127
|
const vnode = options.render.call(null, renderContext._c, renderContext)
|
|
122
128
|
|
|
123
129
|
if (vnode instanceof VNode) {
|
|
124
|
-
return cloneAndMarkFunctionalResult(
|
|
125
|
-
|
|
130
|
+
return cloneAndMarkFunctionalResult(
|
|
131
|
+
vnode,
|
|
132
|
+
data,
|
|
133
|
+
renderContext.parent,
|
|
134
|
+
options,
|
|
135
|
+
renderContext
|
|
136
|
+
)
|
|
137
|
+
} else if (isArray(vnode)) {
|
|
126
138
|
const vnodes = normalizeChildren(vnode) || []
|
|
127
139
|
const res = new Array(vnodes.length)
|
|
128
140
|
for (let i = 0; i < vnodes.length; i++) {
|
|
129
|
-
res[i] = cloneAndMarkFunctionalResult(
|
|
141
|
+
res[i] = cloneAndMarkFunctionalResult(
|
|
142
|
+
vnodes[i],
|
|
143
|
+
data,
|
|
144
|
+
renderContext.parent,
|
|
145
|
+
options,
|
|
146
|
+
renderContext
|
|
147
|
+
)
|
|
130
148
|
}
|
|
131
149
|
return res
|
|
132
150
|
}
|
|
133
151
|
}
|
|
134
152
|
|
|
135
|
-
function cloneAndMarkFunctionalResult
|
|
153
|
+
function cloneAndMarkFunctionalResult(
|
|
154
|
+
vnode,
|
|
155
|
+
data,
|
|
156
|
+
contextVm,
|
|
157
|
+
options,
|
|
158
|
+
renderContext
|
|
159
|
+
) {
|
|
136
160
|
// #7817 clone node before setting fnContext, otherwise if the node is reused
|
|
137
161
|
// (e.g. it was from a cached normal slot) the fnContext causes named slots
|
|
138
162
|
// that should not be matched to match.
|
|
139
163
|
const clone = cloneVNode(vnode)
|
|
140
164
|
clone.fnContext = contextVm
|
|
141
165
|
clone.fnOptions = options
|
|
142
|
-
if (
|
|
143
|
-
(clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
|
|
166
|
+
if (__DEV__) {
|
|
167
|
+
;(clone.devtoolsMeta = clone.devtoolsMeta || ({} as any)).renderContext =
|
|
168
|
+
renderContext
|
|
144
169
|
}
|
|
145
170
|
if (data.slot) {
|
|
146
|
-
(clone.data || (clone.data = {})).slot = data.slot
|
|
171
|
+
;(clone.data || (clone.data = {})).slot = data.slot
|
|
147
172
|
}
|
|
148
173
|
return clone
|
|
149
174
|
}
|
|
150
175
|
|
|
151
|
-
function mergeProps
|
|
176
|
+
function mergeProps(to, from) {
|
|
152
177
|
for (const key in from) {
|
|
153
178
|
to[camelize(key)] = from[key]
|
|
154
179
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
tip,
|
|
5
3
|
hasOwn,
|
|
@@ -8,12 +6,14 @@ import {
|
|
|
8
6
|
hyphenate,
|
|
9
7
|
formatComponentName
|
|
10
8
|
} from 'core/util/index'
|
|
9
|
+
import type { Component } from 'types/component'
|
|
10
|
+
import type { VNodeData } from 'types/vnode'
|
|
11
11
|
|
|
12
|
-
export function extractPropsFromVNodeData
|
|
12
|
+
export function extractPropsFromVNodeData(
|
|
13
13
|
data: VNodeData,
|
|
14
|
-
Ctor:
|
|
14
|
+
Ctor: typeof Component,
|
|
15
15
|
tag?: string
|
|
16
|
-
):
|
|
16
|
+
): object | undefined {
|
|
17
17
|
// we are only extracting raw values here.
|
|
18
18
|
// validation and default values are handled in the child
|
|
19
19
|
// component itself.
|
|
@@ -26,32 +26,32 @@ export function extractPropsFromVNodeData (
|
|
|
26
26
|
if (isDef(attrs) || isDef(props)) {
|
|
27
27
|
for (const key in propOptions) {
|
|
28
28
|
const altKey = hyphenate(key)
|
|
29
|
-
if (
|
|
29
|
+
if (__DEV__) {
|
|
30
30
|
const keyInLowerCase = key.toLowerCase()
|
|
31
|
-
if (
|
|
32
|
-
key !== keyInLowerCase &&
|
|
33
|
-
attrs && hasOwn(attrs, keyInLowerCase)
|
|
34
|
-
) {
|
|
31
|
+
if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
|
|
35
32
|
tip(
|
|
36
33
|
`Prop "${keyInLowerCase}" is passed to component ` +
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
`${formatComponentName(
|
|
35
|
+
// @ts-expect-error tag is string
|
|
36
|
+
tag || Ctor
|
|
37
|
+
)}, but the declared prop name is` +
|
|
38
|
+
` "${key}". ` +
|
|
39
|
+
`Note that HTML attributes are case-insensitive and camelCased ` +
|
|
40
|
+
`props need to use their kebab-case equivalents when using in-DOM ` +
|
|
41
|
+
`templates. You should probably use "${altKey}" instead of "${key}".`
|
|
42
42
|
)
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
checkProp(res, props, key, altKey, true) ||
|
|
46
|
-
|
|
46
|
+
checkProp(res, attrs, key, altKey, false)
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return res
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function checkProp
|
|
52
|
+
function checkProp(
|
|
53
53
|
res: Object,
|
|
54
|
-
hash:
|
|
54
|
+
hash: Object | undefined,
|
|
55
55
|
key: string,
|
|
56
56
|
altKey: string,
|
|
57
57
|
preserve: boolean
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { isDef } from 'shared/util'
|
|
1
|
+
import { isDef, isArray } from 'shared/util'
|
|
2
|
+
import VNode from '../vnode'
|
|
4
3
|
import { isAsyncPlaceholder } from './is-async-placeholder'
|
|
5
4
|
|
|
6
|
-
export function getFirstComponentChild
|
|
7
|
-
|
|
5
|
+
export function getFirstComponentChild(
|
|
6
|
+
children?: Array<VNode>
|
|
7
|
+
): VNode | undefined {
|
|
8
|
+
if (isArray(children)) {
|
|
8
9
|
for (let i = 0; i < children.length; i++) {
|
|
9
10
|
const c = children[i]
|
|
10
11
|
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import VNode from '../vnode'
|
|
4
2
|
import { createFnInvoker } from './update-listeners'
|
|
5
3
|
import { remove, isDef, isUndef, isTrue } from 'shared/util'
|
|
6
4
|
|
|
7
|
-
export function mergeVNodeHook
|
|
5
|
+
export function mergeVNodeHook(
|
|
6
|
+
def: Record<string, any>,
|
|
7
|
+
hookKey: string,
|
|
8
|
+
hook: Function
|
|
9
|
+
) {
|
|
8
10
|
if (def instanceof VNode) {
|
|
9
|
-
def = def.data
|
|
11
|
+
def = def.data!.hook || (def.data!.hook = {})
|
|
10
12
|
}
|
|
11
13
|
let invoker
|
|
12
14
|
const oldHook = def[hookKey]
|
|
13
15
|
|
|
14
|
-
function wrappedHook
|
|
16
|
+
function wrappedHook() {
|
|
15
17
|
hook.apply(this, arguments)
|
|
16
18
|
// important: remove merged hook to ensure it's called only once
|
|
17
19
|
// and prevent memory leak
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import VNode, { createTextVNode } from 'core/vdom/vnode'
|
|
4
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isFalse,
|
|
4
|
+
isTrue,
|
|
5
|
+
isArray,
|
|
6
|
+
isDef,
|
|
7
|
+
isUndef,
|
|
8
|
+
isPrimitive
|
|
9
|
+
} from 'shared/util'
|
|
5
10
|
|
|
6
11
|
// The template compiler attempts to minimize the need for normalization by
|
|
7
12
|
// statically analyzing the template at compile time.
|
|
@@ -15,9 +20,9 @@ import { isFalse, isTrue, isDef, isUndef, isPrimitive } from 'shared/util'
|
|
|
15
20
|
// normalization is needed - if any child is an Array, we flatten the whole
|
|
16
21
|
// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
|
|
17
22
|
// because functional components already normalize their own children.
|
|
18
|
-
export function simpleNormalizeChildren
|
|
23
|
+
export function simpleNormalizeChildren(children: any) {
|
|
19
24
|
for (let i = 0; i < children.length; i++) {
|
|
20
|
-
if (
|
|
25
|
+
if (isArray(children[i])) {
|
|
21
26
|
return Array.prototype.concat.apply([], children)
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -28,20 +33,23 @@ export function simpleNormalizeChildren (children: any) {
|
|
|
28
33
|
// e.g. <template>, <slot>, v-for, or when the children is provided by user
|
|
29
34
|
// with hand-written render functions / JSX. In such cases a full normalization
|
|
30
35
|
// is needed to cater to all possible types of children values.
|
|
31
|
-
export function normalizeChildren
|
|
36
|
+
export function normalizeChildren(children: any): Array<VNode> | undefined {
|
|
32
37
|
return isPrimitive(children)
|
|
33
38
|
? [createTextVNode(children)]
|
|
34
|
-
:
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
: isArray(children)
|
|
40
|
+
? normalizeArrayChildren(children)
|
|
41
|
+
: undefined
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
function isTextNode
|
|
44
|
+
function isTextNode(node): boolean {
|
|
40
45
|
return isDef(node) && isDef(node.text) && isFalse(node.isComment)
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
function normalizeArrayChildren
|
|
44
|
-
|
|
48
|
+
function normalizeArrayChildren(
|
|
49
|
+
children: any,
|
|
50
|
+
nestedIndex?: string
|
|
51
|
+
): Array<VNode> {
|
|
52
|
+
const res: VNode[] = []
|
|
45
53
|
let i, c, lastIndex, last
|
|
46
54
|
for (i = 0; i < children.length; i++) {
|
|
47
55
|
c = children[i]
|
|
@@ -49,12 +57,12 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
|
|
|
49
57
|
lastIndex = res.length - 1
|
|
50
58
|
last = res[lastIndex]
|
|
51
59
|
// nested
|
|
52
|
-
if (
|
|
60
|
+
if (isArray(c)) {
|
|
53
61
|
if (c.length > 0) {
|
|
54
62
|
c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`)
|
|
55
63
|
// merge adjacent text nodes
|
|
56
64
|
if (isTextNode(c[0]) && isTextNode(last)) {
|
|
57
|
-
res[lastIndex] = createTextVNode(last.text +
|
|
65
|
+
res[lastIndex] = createTextVNode(last.text + c[0].text)
|
|
58
66
|
c.shift()
|
|
59
67
|
}
|
|
60
68
|
res.push.apply(res, c)
|
|
@@ -75,10 +83,12 @@ function normalizeArrayChildren (children: any, nestedIndex?: string): Array<VNo
|
|
|
75
83
|
res[lastIndex] = createTextVNode(last.text + c.text)
|
|
76
84
|
} else {
|
|
77
85
|
// default key for nested array children (likely generated by v-for)
|
|
78
|
-
if (
|
|
86
|
+
if (
|
|
87
|
+
isTrue(children._isVList) &&
|
|
79
88
|
isDef(c.tag) &&
|
|
80
89
|
isUndef(c.key) &&
|
|
81
|
-
isDef(nestedIndex)
|
|
90
|
+
isDef(nestedIndex)
|
|
91
|
+
) {
|
|
82
92
|
c.key = `__vlist${nestedIndex}_${i}__`
|
|
83
93
|
}
|
|
84
94
|
res.push(c)
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { def } from 'core/util/lang'
|
|
4
2
|
import { normalizeChildren } from 'core/vdom/helpers/normalize-children'
|
|
5
|
-
import { emptyObject } from 'shared/util'
|
|
3
|
+
import { emptyObject, isArray } from 'shared/util'
|
|
6
4
|
import { isAsyncPlaceholder } from './is-async-placeholder'
|
|
5
|
+
import type VNode from '../vnode'
|
|
6
|
+
import { Component } from 'types/component'
|
|
7
|
+
import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
|
|
7
8
|
|
|
8
|
-
export function normalizeScopedSlots
|
|
9
|
+
export function normalizeScopedSlots(
|
|
10
|
+
ownerVm: Component,
|
|
9
11
|
slots: { [key: string]: Function } | void,
|
|
10
|
-
normalSlots: { [key: string]:
|
|
11
|
-
prevSlots?: { [key: string]: Function } | void
|
|
12
|
+
normalSlots: { [key: string]: VNode[] }
|
|
12
13
|
): any {
|
|
13
14
|
let res
|
|
15
|
+
const prevSlots = ownerVm.$scopedSlots
|
|
14
16
|
const hasNormalSlots = Object.keys(normalSlots).length > 0
|
|
15
17
|
const isStable = slots ? !!slots.$stable : !hasNormalSlots
|
|
16
18
|
const key = slots && slots.$key
|
|
@@ -34,7 +36,7 @@ export function normalizeScopedSlots (
|
|
|
34
36
|
res = {}
|
|
35
37
|
for (const key in slots) {
|
|
36
38
|
if (slots[key] && key[0] !== '$') {
|
|
37
|
-
res[key] = normalizeScopedSlot(normalSlots, key, slots[key])
|
|
39
|
+
res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, slots[key])
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -47,7 +49,7 @@ export function normalizeScopedSlots (
|
|
|
47
49
|
// avoriaz seems to mock a non-extensible $scopedSlots object
|
|
48
50
|
// and when that is passed down this would cause an error
|
|
49
51
|
if (slots && Object.isExtensible(slots)) {
|
|
50
|
-
|
|
52
|
+
slots._normalized = res
|
|
51
53
|
}
|
|
52
54
|
def(res, '$stable', isStable)
|
|
53
55
|
def(res, '$key', key)
|
|
@@ -55,17 +57,21 @@ export function normalizeScopedSlots (
|
|
|
55
57
|
return res
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
function normalizeScopedSlot(normalSlots, key, fn) {
|
|
60
|
+
function normalizeScopedSlot(vm, normalSlots, key, fn) {
|
|
59
61
|
const normalized = function () {
|
|
62
|
+
const cur = currentInstance
|
|
63
|
+
setCurrentInstance(vm)
|
|
60
64
|
let res = arguments.length ? fn.apply(null, arguments) : fn({})
|
|
61
|
-
res =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
res =
|
|
66
|
+
res && typeof res === 'object' && !isArray(res)
|
|
67
|
+
? [res] // single vnode
|
|
68
|
+
: normalizeChildren(res)
|
|
69
|
+
const vnode: VNode | null = res && res[0]
|
|
70
|
+
setCurrentInstance(cur)
|
|
71
|
+
return res &&
|
|
72
|
+
(!vnode ||
|
|
73
|
+
(res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
|
|
74
|
+
? undefined
|
|
69
75
|
: res
|
|
70
76
|
}
|
|
71
77
|
// this is a slot using the new v-slot syntax without scope. although it is
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
warn,
|
|
5
3
|
once,
|
|
@@ -12,27 +10,24 @@ import {
|
|
|
12
10
|
remove
|
|
13
11
|
} from 'core/util/index'
|
|
14
12
|
|
|
15
|
-
import { createEmptyVNode } from 'core/vdom/vnode'
|
|
13
|
+
import VNode, { createEmptyVNode } from 'core/vdom/vnode'
|
|
16
14
|
import { currentRenderingInstance } from 'core/instance/render'
|
|
15
|
+
import type { VNodeData } from 'types/vnode'
|
|
16
|
+
import type { Component } from 'types/component'
|
|
17
17
|
|
|
18
|
-
function ensureCtor
|
|
19
|
-
if (
|
|
20
|
-
comp.__esModule ||
|
|
21
|
-
(hasSymbol && comp[Symbol.toStringTag] === 'Module')
|
|
22
|
-
) {
|
|
18
|
+
function ensureCtor(comp: any, base) {
|
|
19
|
+
if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
|
|
23
20
|
comp = comp.default
|
|
24
21
|
}
|
|
25
|
-
return isObject(comp)
|
|
26
|
-
? base.extend(comp)
|
|
27
|
-
: comp
|
|
22
|
+
return isObject(comp) ? base.extend(comp) : comp
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
export function createAsyncPlaceholder
|
|
25
|
+
export function createAsyncPlaceholder(
|
|
31
26
|
factory: Function,
|
|
32
|
-
data:
|
|
27
|
+
data: VNodeData | undefined,
|
|
33
28
|
context: Component,
|
|
34
|
-
children:
|
|
35
|
-
tag
|
|
29
|
+
children: Array<VNode> | undefined,
|
|
30
|
+
tag?: string
|
|
36
31
|
): VNode {
|
|
37
32
|
const node = createEmptyVNode()
|
|
38
33
|
node.asyncFactory = factory
|
|
@@ -40,10 +35,10 @@ export function createAsyncPlaceholder (
|
|
|
40
35
|
return node
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
export function resolveAsyncComponent
|
|
44
|
-
factory:
|
|
45
|
-
baseCtor:
|
|
46
|
-
):
|
|
38
|
+
export function resolveAsyncComponent(
|
|
39
|
+
factory: { (...args: any[]): any; [keye: string]: any },
|
|
40
|
+
baseCtor: typeof Component
|
|
41
|
+
): typeof Component | void {
|
|
47
42
|
if (isTrue(factory.error) && isDef(factory.errorComp)) {
|
|
48
43
|
return factory.errorComp
|
|
49
44
|
}
|
|
@@ -63,16 +58,16 @@ export function resolveAsyncComponent (
|
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
if (owner && !isDef(factory.owners)) {
|
|
66
|
-
const owners = factory.owners = [owner]
|
|
61
|
+
const owners = (factory.owners = [owner])
|
|
67
62
|
let sync = true
|
|
68
|
-
let timerLoading = null
|
|
69
|
-
let timerTimeout = null
|
|
63
|
+
let timerLoading: number | null = null
|
|
64
|
+
let timerTimeout: number | null = null
|
|
70
65
|
|
|
71
|
-
|
|
66
|
+
owner.$on('hook:destroyed', () => remove(owners, owner))
|
|
72
67
|
|
|
73
68
|
const forceRender = (renderCompleted: boolean) => {
|
|
74
69
|
for (let i = 0, l = owners.length; i < l; i++) {
|
|
75
|
-
|
|
70
|
+
owners[i].$forceUpdate()
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
if (renderCompleted) {
|
|
@@ -88,7 +83,7 @@ export function resolveAsyncComponent (
|
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
|
|
91
|
-
const resolve = once((res: Object |
|
|
86
|
+
const resolve = once((res: Object | Component) => {
|
|
92
87
|
// cache resolved
|
|
93
88
|
factory.resolved = ensureCtor(res, baseCtor)
|
|
94
89
|
// invoke callbacks only if this is not a synchronous resolve
|
|
@@ -101,10 +96,11 @@ export function resolveAsyncComponent (
|
|
|
101
96
|
})
|
|
102
97
|
|
|
103
98
|
const reject = once(reason => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
__DEV__ &&
|
|
100
|
+
warn(
|
|
101
|
+
`Failed to resolve async component: ${String(factory)}` +
|
|
102
|
+
(reason ? `\nReason: ${reason}` : '')
|
|
103
|
+
)
|
|
108
104
|
if (isDef(factory.errorComp)) {
|
|
109
105
|
factory.error = true
|
|
110
106
|
forceRender(true)
|
|
@@ -131,6 +127,7 @@ export function resolveAsyncComponent (
|
|
|
131
127
|
if (res.delay === 0) {
|
|
132
128
|
factory.loading = true
|
|
133
129
|
} else {
|
|
130
|
+
// @ts-expect-error NodeJS timeout type
|
|
134
131
|
timerLoading = setTimeout(() => {
|
|
135
132
|
timerLoading = null
|
|
136
133
|
if (isUndef(factory.resolved) && isUndef(factory.error)) {
|
|
@@ -142,14 +139,11 @@ export function resolveAsyncComponent (
|
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
if (isDef(res.timeout)) {
|
|
142
|
+
// @ts-expect-error NodeJS timeout type
|
|
145
143
|
timerTimeout = setTimeout(() => {
|
|
146
144
|
timerTimeout = null
|
|
147
145
|
if (isUndef(factory.resolved)) {
|
|
148
|
-
reject(
|
|
149
|
-
process.env.NODE_ENV !== 'production'
|
|
150
|
-
? `timeout (${res.timeout}ms)`
|
|
151
|
-
: null
|
|
152
|
-
)
|
|
146
|
+
reject(__DEV__ ? `timeout (${res.timeout}ms)` : null)
|
|
153
147
|
}
|
|
154
148
|
}, res.timeout)
|
|
155
149
|
}
|
|
@@ -158,8 +152,6 @@ export function resolveAsyncComponent (
|
|
|
158
152
|
|
|
159
153
|
sync = false
|
|
160
154
|
// return in case resolved synchronously
|
|
161
|
-
return factory.loading
|
|
162
|
-
? factory.loadingComp
|
|
163
|
-
: factory.resolved
|
|
155
|
+
return factory.loading ? factory.loadingComp : factory.resolved
|
|
164
156
|
}
|
|
165
157
|
}
|