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,24 +1,25 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { warn } from './debug'
|
|
4
2
|
import { observe, toggleObserving, shouldObserve } from '../observer/index'
|
|
5
3
|
import {
|
|
6
4
|
hasOwn,
|
|
5
|
+
isArray,
|
|
7
6
|
isObject,
|
|
7
|
+
isFunction,
|
|
8
8
|
toRawType,
|
|
9
9
|
hyphenate,
|
|
10
10
|
capitalize,
|
|
11
11
|
isPlainObject
|
|
12
12
|
} from 'shared/util'
|
|
13
|
+
import type { Component } from 'types/component'
|
|
13
14
|
|
|
14
15
|
type PropOptions = {
|
|
15
|
-
type: Function | Array<Function> | null
|
|
16
|
-
default: any
|
|
17
|
-
required
|
|
18
|
-
validator
|
|
19
|
-
}
|
|
16
|
+
type: Function | Array<Function> | null
|
|
17
|
+
default: any
|
|
18
|
+
required?: boolean
|
|
19
|
+
validator?: Function
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
export function validateProp
|
|
22
|
+
export function validateProp(
|
|
22
23
|
key: string,
|
|
23
24
|
propOptions: Object,
|
|
24
25
|
propsData: Object,
|
|
@@ -51,11 +52,7 @@ export function validateProp (
|
|
|
51
52
|
observe(value)
|
|
52
53
|
toggleObserving(prevShouldObserve)
|
|
53
54
|
}
|
|
54
|
-
if (
|
|
55
|
-
process.env.NODE_ENV !== 'production' &&
|
|
56
|
-
// skip validation for weex recycle-list child component props
|
|
57
|
-
!(__WEEX__ && isObject(value) && ('@binding' in value))
|
|
58
|
-
) {
|
|
55
|
+
if (__DEV__) {
|
|
59
56
|
assertProp(prop, key, value, vm, absent)
|
|
60
57
|
}
|
|
61
58
|
return value
|
|
@@ -64,24 +61,32 @@ export function validateProp (
|
|
|
64
61
|
/**
|
|
65
62
|
* Get the default value of a prop.
|
|
66
63
|
*/
|
|
67
|
-
function getPropDefaultValue
|
|
64
|
+
function getPropDefaultValue(
|
|
65
|
+
vm: Component | undefined,
|
|
66
|
+
prop: PropOptions,
|
|
67
|
+
key: string
|
|
68
|
+
): any {
|
|
68
69
|
// no default, return undefined
|
|
69
70
|
if (!hasOwn(prop, 'default')) {
|
|
70
71
|
return undefined
|
|
71
72
|
}
|
|
72
73
|
const def = prop.default
|
|
73
74
|
// warn against non-factory defaults for Object & Array
|
|
74
|
-
if (
|
|
75
|
+
if (__DEV__ && isObject(def)) {
|
|
75
76
|
warn(
|
|
76
|
-
'Invalid default value for prop "' +
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
'Invalid default value for prop "' +
|
|
78
|
+
key +
|
|
79
|
+
'": ' +
|
|
80
|
+
'Props with type Object/Array must use a factory function ' +
|
|
81
|
+
'to return the default value.',
|
|
79
82
|
vm
|
|
80
83
|
)
|
|
81
84
|
}
|
|
82
85
|
// the raw prop value was also undefined from previous render,
|
|
83
86
|
// return previous default value to avoid unnecessary watcher trigger
|
|
84
|
-
if (
|
|
87
|
+
if (
|
|
88
|
+
vm &&
|
|
89
|
+
vm.$options.propsData &&
|
|
85
90
|
vm.$options.propsData[key] === undefined &&
|
|
86
91
|
vm._props[key] !== undefined
|
|
87
92
|
) {
|
|
@@ -89,7 +94,7 @@ function getPropDefaultValue (vm: ?Component, prop: PropOptions, key: string): a
|
|
|
89
94
|
}
|
|
90
95
|
// call factory function for non-Function types
|
|
91
96
|
// a value is Function if its prototype is function even across different execution context
|
|
92
|
-
return
|
|
97
|
+
return isFunction(def) && getType(prop.type) !== 'Function'
|
|
93
98
|
? def.call(vm)
|
|
94
99
|
: def
|
|
95
100
|
}
|
|
@@ -97,28 +102,25 @@ function getPropDefaultValue (vm: ?Component, prop: PropOptions, key: string): a
|
|
|
97
102
|
/**
|
|
98
103
|
* Assert whether a prop is valid.
|
|
99
104
|
*/
|
|
100
|
-
function assertProp
|
|
105
|
+
function assertProp(
|
|
101
106
|
prop: PropOptions,
|
|
102
107
|
name: string,
|
|
103
108
|
value: any,
|
|
104
|
-
vm
|
|
105
|
-
absent
|
|
109
|
+
vm?: Component,
|
|
110
|
+
absent?: boolean
|
|
106
111
|
) {
|
|
107
112
|
if (prop.required && absent) {
|
|
108
|
-
warn(
|
|
109
|
-
'Missing required prop: "' + name + '"',
|
|
110
|
-
vm
|
|
111
|
-
)
|
|
113
|
+
warn('Missing required prop: "' + name + '"', vm)
|
|
112
114
|
return
|
|
113
115
|
}
|
|
114
116
|
if (value == null && !prop.required) {
|
|
115
117
|
return
|
|
116
118
|
}
|
|
117
119
|
let type = prop.type
|
|
118
|
-
let valid = !type || type === true
|
|
119
|
-
const expectedTypes = []
|
|
120
|
+
let valid = !type || (type as any) === true
|
|
121
|
+
const expectedTypes: string[] = []
|
|
120
122
|
if (type) {
|
|
121
|
-
if (!
|
|
123
|
+
if (!isArray(type)) {
|
|
122
124
|
type = [type]
|
|
123
125
|
}
|
|
124
126
|
for (let i = 0; i < type.length && !valid; i++) {
|
|
@@ -130,10 +132,7 @@ function assertProp (
|
|
|
130
132
|
|
|
131
133
|
const haveExpectedTypes = expectedTypes.some(t => t)
|
|
132
134
|
if (!valid && haveExpectedTypes) {
|
|
133
|
-
warn(
|
|
134
|
-
getInvalidTypeMessage(name, value, expectedTypes),
|
|
135
|
-
vm
|
|
136
|
-
)
|
|
135
|
+
warn(getInvalidTypeMessage(name, value, expectedTypes), vm)
|
|
137
136
|
return
|
|
138
137
|
}
|
|
139
138
|
const validator = prop.validator
|
|
@@ -149,9 +148,13 @@ function assertProp (
|
|
|
149
148
|
|
|
150
149
|
const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/
|
|
151
150
|
|
|
152
|
-
function assertType
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
function assertType(
|
|
152
|
+
value: any,
|
|
153
|
+
type: Function,
|
|
154
|
+
vm?: Component
|
|
155
|
+
): {
|
|
156
|
+
valid: boolean
|
|
157
|
+
expectedType: string
|
|
155
158
|
} {
|
|
156
159
|
let valid
|
|
157
160
|
const expectedType = getType(type)
|
|
@@ -165,13 +168,13 @@ function assertType (value: any, type: Function, vm: ?Component): {
|
|
|
165
168
|
} else if (expectedType === 'Object') {
|
|
166
169
|
valid = isPlainObject(value)
|
|
167
170
|
} else if (expectedType === 'Array') {
|
|
168
|
-
valid =
|
|
171
|
+
valid = isArray(value)
|
|
169
172
|
} else {
|
|
170
173
|
try {
|
|
171
174
|
valid = value instanceof type
|
|
172
|
-
} catch (e) {
|
|
173
|
-
warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm)
|
|
174
|
-
valid = false
|
|
175
|
+
} catch (e: any) {
|
|
176
|
+
warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm)
|
|
177
|
+
valid = false
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
return {
|
|
@@ -187,17 +190,17 @@ const functionTypeCheckRE = /^\s*function (\w+)/
|
|
|
187
190
|
* because a simple equality check will fail when running
|
|
188
191
|
* across different vms / iframes.
|
|
189
192
|
*/
|
|
190
|
-
function getType
|
|
193
|
+
function getType(fn) {
|
|
191
194
|
const match = fn && fn.toString().match(functionTypeCheckRE)
|
|
192
195
|
return match ? match[1] : ''
|
|
193
196
|
}
|
|
194
197
|
|
|
195
|
-
function isSameType
|
|
198
|
+
function isSameType(a, b) {
|
|
196
199
|
return getType(a) === getType(b)
|
|
197
200
|
}
|
|
198
201
|
|
|
199
|
-
function getTypeIndex
|
|
200
|
-
if (!
|
|
202
|
+
function getTypeIndex(type, expectedTypes): number {
|
|
203
|
+
if (!isArray(expectedTypes)) {
|
|
201
204
|
return isSameType(expectedTypes, type) ? 0 : -1
|
|
202
205
|
}
|
|
203
206
|
for (let i = 0, len = expectedTypes.length; i < len; i++) {
|
|
@@ -208,8 +211,9 @@ function getTypeIndex (type, expectedTypes): number {
|
|
|
208
211
|
return -1
|
|
209
212
|
}
|
|
210
213
|
|
|
211
|
-
function getInvalidTypeMessage
|
|
212
|
-
let message =
|
|
214
|
+
function getInvalidTypeMessage(name, value, expectedTypes) {
|
|
215
|
+
let message =
|
|
216
|
+
`Invalid prop: type check failed for prop "${name}".` +
|
|
213
217
|
` Expected ${expectedTypes.map(capitalize).join(', ')}`
|
|
214
218
|
const expectedType = expectedTypes[0]
|
|
215
219
|
const receivedType = toRawType(value)
|
|
@@ -230,7 +234,7 @@ function getInvalidTypeMessage (name, value, expectedTypes) {
|
|
|
230
234
|
return message
|
|
231
235
|
}
|
|
232
236
|
|
|
233
|
-
function styleValue
|
|
237
|
+
function styleValue(value, type) {
|
|
234
238
|
if (type === 'String') {
|
|
235
239
|
return `"${value}"`
|
|
236
240
|
} else if (type === 'Number') {
|
|
@@ -241,10 +245,10 @@ function styleValue (value, type) {
|
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
const EXPLICABLE_TYPES = ['string', 'number', 'boolean']
|
|
244
|
-
function isExplicable
|
|
248
|
+
function isExplicable(value) {
|
|
245
249
|
return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem)
|
|
246
250
|
}
|
|
247
251
|
|
|
248
|
-
function isBoolean
|
|
252
|
+
function isBoolean(...args) {
|
|
249
253
|
return args.some(elem => elem.toLowerCase() === 'boolean')
|
|
250
254
|
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import VNode from './vnode'
|
|
2
|
+
import { isArray } from 'core/util'
|
|
4
3
|
import { resolveConstructorOptions } from 'core/instance/init'
|
|
5
4
|
import { queueActivatedComponent } from 'core/observer/scheduler'
|
|
6
5
|
import { createFunctionalComponent } from './create-functional-component'
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
warn,
|
|
10
|
-
isDef,
|
|
11
|
-
isUndef,
|
|
12
|
-
isTrue,
|
|
13
|
-
isObject
|
|
14
|
-
} from '../util/index'
|
|
7
|
+
import { warn, isDef, isUndef, isTrue, isObject } from '../util/index'
|
|
15
8
|
|
|
16
9
|
import {
|
|
17
10
|
resolveAsyncComponent,
|
|
@@ -27,14 +20,17 @@ import {
|
|
|
27
20
|
deactivateChildComponent
|
|
28
21
|
} from '../instance/lifecycle'
|
|
29
22
|
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
import type {
|
|
24
|
+
MountedComponentVNode,
|
|
25
|
+
VNodeData,
|
|
26
|
+
VNodeWithData
|
|
27
|
+
} from 'types/vnode'
|
|
28
|
+
import type { Component } from 'types/component'
|
|
29
|
+
import type { ComponentOptions, InternalComponentOptions } from 'types/options'
|
|
34
30
|
|
|
35
31
|
// inline hooks to be invoked on component VNodes during patch
|
|
36
32
|
const componentVNodeHooks = {
|
|
37
|
-
init
|
|
33
|
+
init(vnode: VNodeWithData, hydrating: boolean): boolean | void {
|
|
38
34
|
if (
|
|
39
35
|
vnode.componentInstance &&
|
|
40
36
|
!vnode.componentInstance._isDestroyed &&
|
|
@@ -44,17 +40,17 @@ const componentVNodeHooks = {
|
|
|
44
40
|
const mountedNode: any = vnode // work around flow
|
|
45
41
|
componentVNodeHooks.prepatch(mountedNode, mountedNode)
|
|
46
42
|
} else {
|
|
47
|
-
const child = vnode.componentInstance = createComponentInstanceForVnode(
|
|
43
|
+
const child = (vnode.componentInstance = createComponentInstanceForVnode(
|
|
48
44
|
vnode,
|
|
49
45
|
activeInstance
|
|
50
|
-
)
|
|
46
|
+
))
|
|
51
47
|
child.$mount(hydrating ? vnode.elm : undefined, hydrating)
|
|
52
48
|
}
|
|
53
49
|
},
|
|
54
50
|
|
|
55
|
-
prepatch
|
|
51
|
+
prepatch(oldVnode: MountedComponentVNode, vnode: MountedComponentVNode) {
|
|
56
52
|
const options = vnode.componentOptions
|
|
57
|
-
const child = vnode.componentInstance = oldVnode.componentInstance
|
|
53
|
+
const child = (vnode.componentInstance = oldVnode.componentInstance)
|
|
58
54
|
updateChildComponent(
|
|
59
55
|
child,
|
|
60
56
|
options.propsData, // updated props
|
|
@@ -64,7 +60,7 @@ const componentVNodeHooks = {
|
|
|
64
60
|
)
|
|
65
61
|
},
|
|
66
62
|
|
|
67
|
-
insert
|
|
63
|
+
insert(vnode: MountedComponentVNode) {
|
|
68
64
|
const { context, componentInstance } = vnode
|
|
69
65
|
if (!componentInstance._isMounted) {
|
|
70
66
|
componentInstance._isMounted = true
|
|
@@ -84,7 +80,7 @@ const componentVNodeHooks = {
|
|
|
84
80
|
}
|
|
85
81
|
},
|
|
86
82
|
|
|
87
|
-
destroy
|
|
83
|
+
destroy(vnode: MountedComponentVNode) {
|
|
88
84
|
const { componentInstance } = vnode
|
|
89
85
|
if (!componentInstance._isDestroyed) {
|
|
90
86
|
if (!vnode.data.keepAlive) {
|
|
@@ -98,11 +94,11 @@ const componentVNodeHooks = {
|
|
|
98
94
|
|
|
99
95
|
const hooksToMerge = Object.keys(componentVNodeHooks)
|
|
100
96
|
|
|
101
|
-
export function createComponent
|
|
102
|
-
Ctor:
|
|
103
|
-
data:
|
|
97
|
+
export function createComponent(
|
|
98
|
+
Ctor: typeof Component | Function | ComponentOptions | void,
|
|
99
|
+
data: VNodeData | undefined,
|
|
104
100
|
context: Component,
|
|
105
|
-
children
|
|
101
|
+
children?: Array<VNode>,
|
|
106
102
|
tag?: string
|
|
107
103
|
): VNode | Array<VNode> | void {
|
|
108
104
|
if (isUndef(Ctor)) {
|
|
@@ -113,13 +109,13 @@ export function createComponent (
|
|
|
113
109
|
|
|
114
110
|
// plain options object: turn it into a constructor
|
|
115
111
|
if (isObject(Ctor)) {
|
|
116
|
-
Ctor = baseCtor.extend(Ctor)
|
|
112
|
+
Ctor = baseCtor.extend(Ctor as typeof Component)
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
// if at this stage it's not a constructor or an async component factory,
|
|
120
116
|
// reject.
|
|
121
117
|
if (typeof Ctor !== 'function') {
|
|
122
|
-
if (
|
|
118
|
+
if (__DEV__) {
|
|
123
119
|
warn(`Invalid Component definition: ${String(Ctor)}`, context)
|
|
124
120
|
}
|
|
125
121
|
return
|
|
@@ -127,6 +123,7 @@ export function createComponent (
|
|
|
127
123
|
|
|
128
124
|
// async component
|
|
129
125
|
let asyncFactory
|
|
126
|
+
// @ts-expect-error
|
|
130
127
|
if (isUndef(Ctor.cid)) {
|
|
131
128
|
asyncFactory = Ctor
|
|
132
129
|
Ctor = resolveAsyncComponent(asyncFactory, baseCtor)
|
|
@@ -134,13 +131,7 @@ export function createComponent (
|
|
|
134
131
|
// return a placeholder node for async component, which is rendered
|
|
135
132
|
// as a comment node but preserves all the raw information for the node.
|
|
136
133
|
// the information will be used for async server-rendering and hydration.
|
|
137
|
-
return createAsyncPlaceholder(
|
|
138
|
-
asyncFactory,
|
|
139
|
-
data,
|
|
140
|
-
context,
|
|
141
|
-
children,
|
|
142
|
-
tag
|
|
143
|
-
)
|
|
134
|
+
return createAsyncPlaceholder(asyncFactory, data, context, children, tag)
|
|
144
135
|
}
|
|
145
136
|
}
|
|
146
137
|
|
|
@@ -148,19 +139,28 @@ export function createComponent (
|
|
|
148
139
|
|
|
149
140
|
// resolve constructor options in case global mixins are applied after
|
|
150
141
|
// component constructor creation
|
|
151
|
-
resolveConstructorOptions(Ctor)
|
|
142
|
+
resolveConstructorOptions(Ctor as typeof Component)
|
|
152
143
|
|
|
153
144
|
// transform component v-model data into props & events
|
|
154
145
|
if (isDef(data.model)) {
|
|
146
|
+
// @ts-expect-error
|
|
155
147
|
transformModel(Ctor.options, data)
|
|
156
148
|
}
|
|
157
149
|
|
|
158
150
|
// extract props
|
|
151
|
+
// @ts-expect-error
|
|
159
152
|
const propsData = extractPropsFromVNodeData(data, Ctor, tag)
|
|
160
153
|
|
|
161
154
|
// functional component
|
|
155
|
+
// @ts-expect-error
|
|
162
156
|
if (isTrue(Ctor.options.functional)) {
|
|
163
|
-
return createFunctionalComponent(
|
|
157
|
+
return createFunctionalComponent(
|
|
158
|
+
Ctor as typeof Component,
|
|
159
|
+
propsData,
|
|
160
|
+
data,
|
|
161
|
+
context,
|
|
162
|
+
children
|
|
163
|
+
)
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// extract listeners, since these needs to be treated as
|
|
@@ -170,6 +170,7 @@ export function createComponent (
|
|
|
170
170
|
// so it gets processed during parent component patch.
|
|
171
171
|
data.on = data.nativeOn
|
|
172
172
|
|
|
173
|
+
// @ts-expect-error
|
|
173
174
|
if (isTrue(Ctor.options.abstract)) {
|
|
174
175
|
// abstract components do not keep anything
|
|
175
176
|
// other than props & listeners & slot
|
|
@@ -186,30 +187,29 @@ export function createComponent (
|
|
|
186
187
|
installComponentHooks(data)
|
|
187
188
|
|
|
188
189
|
// return a placeholder vnode
|
|
190
|
+
// @ts-expect-error
|
|
189
191
|
const name = Ctor.options.name || tag
|
|
190
192
|
const vnode = new VNode(
|
|
193
|
+
// @ts-expect-error
|
|
191
194
|
`vue-component-${Ctor.cid}${name ? `-${name}` : ''}`,
|
|
192
|
-
data,
|
|
195
|
+
data,
|
|
196
|
+
undefined,
|
|
197
|
+
undefined,
|
|
198
|
+
undefined,
|
|
199
|
+
context,
|
|
200
|
+
// @ts-expect-error
|
|
193
201
|
{ Ctor, propsData, listeners, tag, children },
|
|
194
202
|
asyncFactory
|
|
195
203
|
)
|
|
196
204
|
|
|
197
|
-
// Weex specific: invoke recycle-list optimized @render function for
|
|
198
|
-
// extracting cell-slot template.
|
|
199
|
-
// https://github.com/Hanks10100/weex-native-directive/tree/master/component
|
|
200
|
-
/* istanbul ignore if */
|
|
201
|
-
if (__WEEX__ && isRecyclableComponent(vnode)) {
|
|
202
|
-
return renderRecyclableComponentTemplate(vnode)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
205
|
return vnode
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
export function createComponentInstanceForVnode
|
|
208
|
+
export function createComponentInstanceForVnode(
|
|
209
209
|
// we know it's MountedComponentVNode but flow doesn't
|
|
210
210
|
vnode: any,
|
|
211
211
|
// activeInstance in lifecycle state
|
|
212
|
-
parent
|
|
212
|
+
parent?: any
|
|
213
213
|
): Component {
|
|
214
214
|
const options: InternalComponentOptions = {
|
|
215
215
|
_isComponent: true,
|
|
@@ -225,19 +225,20 @@ export function createComponentInstanceForVnode (
|
|
|
225
225
|
return new vnode.componentOptions.Ctor(options)
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
function installComponentHooks
|
|
228
|
+
function installComponentHooks(data: VNodeData) {
|
|
229
229
|
const hooks = data.hook || (data.hook = {})
|
|
230
230
|
for (let i = 0; i < hooksToMerge.length; i++) {
|
|
231
231
|
const key = hooksToMerge[i]
|
|
232
232
|
const existing = hooks[key]
|
|
233
233
|
const toMerge = componentVNodeHooks[key]
|
|
234
|
+
// @ts-expect-error
|
|
234
235
|
if (existing !== toMerge && !(existing && existing._merged)) {
|
|
235
236
|
hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
|
|
240
|
-
function mergeHook
|
|
241
|
+
function mergeHook(f1: any, f2: any): Function {
|
|
241
242
|
const merged = (a, b) => {
|
|
242
243
|
// flow complains about extra args which is why we use any
|
|
243
244
|
f1(a, b)
|
|
@@ -249,7 +250,7 @@ function mergeHook (f1: any, f2: any): Function {
|
|
|
249
250
|
|
|
250
251
|
// transform component v-model info (value and callback) into
|
|
251
252
|
// prop and event handler respectively.
|
|
252
|
-
function transformModel
|
|
253
|
+
function transformModel(options, data: any) {
|
|
253
254
|
const prop = (options.model && options.model.prop) || 'value'
|
|
254
255
|
const event = (options.model && options.model.event) || 'input'
|
|
255
256
|
;(data.attrs || (data.attrs = {}))[prop] = data.model.value
|
|
@@ -258,7 +259,7 @@ function transformModel (options, data: any) {
|
|
|
258
259
|
const callback = data.model.callback
|
|
259
260
|
if (isDef(existing)) {
|
|
260
261
|
if (
|
|
261
|
-
|
|
262
|
+
isArray(existing)
|
|
262
263
|
? existing.indexOf(callback) === -1
|
|
263
264
|
: existing !== callback
|
|
264
265
|
) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import config from '../config'
|
|
4
2
|
import VNode, { createEmptyVNode } from './vnode'
|
|
5
3
|
import { createComponent } from './create-component'
|
|
@@ -9,23 +7,24 @@ import {
|
|
|
9
7
|
warn,
|
|
10
8
|
isDef,
|
|
11
9
|
isUndef,
|
|
10
|
+
isArray,
|
|
12
11
|
isTrue,
|
|
13
12
|
isObject,
|
|
14
13
|
isPrimitive,
|
|
15
|
-
resolveAsset
|
|
14
|
+
resolveAsset,
|
|
15
|
+
isFunction
|
|
16
16
|
} from '../util/index'
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from './helpers/index'
|
|
18
|
+
import { normalizeChildren, simpleNormalizeChildren } from './helpers/index'
|
|
19
|
+
import type { Component } from 'types/component'
|
|
20
|
+
import type { VNodeData } from 'types/vnode'
|
|
22
21
|
|
|
23
22
|
const SIMPLE_NORMALIZE = 1
|
|
24
23
|
const ALWAYS_NORMALIZE = 2
|
|
25
24
|
|
|
26
25
|
// wrapper function for providing a more flexible interface
|
|
27
26
|
// without getting yelled at by flow
|
|
28
|
-
export function createElement
|
|
27
|
+
export function createElement(
|
|
29
28
|
context: Component,
|
|
30
29
|
tag: any,
|
|
31
30
|
data: any,
|
|
@@ -33,7 +32,7 @@ export function createElement (
|
|
|
33
32
|
normalizationType: any,
|
|
34
33
|
alwaysNormalize: boolean
|
|
35
34
|
): VNode | Array<VNode> {
|
|
36
|
-
if (
|
|
35
|
+
if (isArray(data) || isPrimitive(data)) {
|
|
37
36
|
normalizationType = children
|
|
38
37
|
children = data
|
|
39
38
|
data = undefined
|
|
@@ -44,19 +43,21 @@ export function createElement (
|
|
|
44
43
|
return _createElement(context, tag, data, children, normalizationType)
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
export function _createElement
|
|
46
|
+
export function _createElement(
|
|
48
47
|
context: Component,
|
|
49
|
-
tag?: string |
|
|
48
|
+
tag?: string | Component | Function | Object,
|
|
50
49
|
data?: VNodeData,
|
|
51
50
|
children?: any,
|
|
52
51
|
normalizationType?: number
|
|
53
52
|
): VNode | Array<VNode> {
|
|
54
|
-
if (isDef(data) && isDef((data
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
if (isDef(data) && isDef((data as any).__ob__)) {
|
|
54
|
+
__DEV__ &&
|
|
55
|
+
warn(
|
|
56
|
+
`Avoid using observed data object as vnode data: ${JSON.stringify(
|
|
57
|
+
data
|
|
58
|
+
)}\n` + 'Always create fresh vnode data objects in each render!',
|
|
59
|
+
context
|
|
60
|
+
)
|
|
60
61
|
return createEmptyVNode()
|
|
61
62
|
}
|
|
62
63
|
// object syntax in v-bind
|
|
@@ -68,21 +69,15 @@ export function _createElement (
|
|
|
68
69
|
return createEmptyVNode()
|
|
69
70
|
}
|
|
70
71
|
// warn against non-primitive key
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!__WEEX__ || !('@binding' in data.key)) {
|
|
75
|
-
warn(
|
|
76
|
-
'Avoid using non-primitive value as key, ' +
|
|
72
|
+
if (__DEV__ && isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
|
|
73
|
+
warn(
|
|
74
|
+
'Avoid using non-primitive value as key, ' +
|
|
77
75
|
'use string/number value instead.',
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
76
|
+
context
|
|
77
|
+
)
|
|
81
78
|
}
|
|
82
79
|
// support single function children as default scoped slot
|
|
83
|
-
if (
|
|
84
|
-
typeof children[0] === 'function'
|
|
85
|
-
) {
|
|
80
|
+
if (isArray(children) && isFunction(children[0])) {
|
|
86
81
|
data = data || {}
|
|
87
82
|
data.scopedSlots = { default: children[0] }
|
|
88
83
|
children.length = 0
|
|
@@ -98,33 +93,42 @@ export function _createElement (
|
|
|
98
93
|
ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag)
|
|
99
94
|
if (config.isReservedTag(tag)) {
|
|
100
95
|
// platform built-in elements
|
|
101
|
-
if (
|
|
96
|
+
if (
|
|
97
|
+
__DEV__ &&
|
|
98
|
+
isDef(data) &&
|
|
99
|
+
isDef(data.nativeOn) &&
|
|
100
|
+
data.tag !== 'component'
|
|
101
|
+
) {
|
|
102
102
|
warn(
|
|
103
103
|
`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`,
|
|
104
104
|
context
|
|
105
105
|
)
|
|
106
106
|
}
|
|
107
107
|
vnode = new VNode(
|
|
108
|
-
config.parsePlatformTagName(tag),
|
|
109
|
-
|
|
108
|
+
config.parsePlatformTagName(tag),
|
|
109
|
+
data,
|
|
110
|
+
children,
|
|
111
|
+
undefined,
|
|
112
|
+
undefined,
|
|
113
|
+
context
|
|
110
114
|
)
|
|
111
|
-
} else if (
|
|
115
|
+
} else if (
|
|
116
|
+
(!data || !data.pre) &&
|
|
117
|
+
isDef((Ctor = resolveAsset(context.$options, 'components', tag)))
|
|
118
|
+
) {
|
|
112
119
|
// component
|
|
113
120
|
vnode = createComponent(Ctor, data, context, children, tag)
|
|
114
121
|
} else {
|
|
115
122
|
// unknown or unlisted namespaced elements
|
|
116
123
|
// check at runtime because it may get assigned a namespace when its
|
|
117
124
|
// parent normalizes children
|
|
118
|
-
vnode = new VNode(
|
|
119
|
-
tag, data, children,
|
|
120
|
-
undefined, undefined, context
|
|
121
|
-
)
|
|
125
|
+
vnode = new VNode(tag, data, children, undefined, undefined, context)
|
|
122
126
|
}
|
|
123
127
|
} else {
|
|
124
128
|
// direct component options / constructor
|
|
125
|
-
vnode = createComponent(tag, data, context, children)
|
|
129
|
+
vnode = createComponent(tag as any, data, context, children)
|
|
126
130
|
}
|
|
127
|
-
if (
|
|
131
|
+
if (isArray(vnode)) {
|
|
128
132
|
return vnode
|
|
129
133
|
} else if (isDef(vnode)) {
|
|
130
134
|
if (isDef(ns)) applyNS(vnode, ns)
|
|
@@ -135,7 +139,7 @@ export function _createElement (
|
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
|
|
138
|
-
function applyNS
|
|
142
|
+
function applyNS(vnode, ns, force?: boolean) {
|
|
139
143
|
vnode.ns = ns
|
|
140
144
|
if (vnode.tag === 'foreignObject') {
|
|
141
145
|
// use default namespace inside foreignObject
|
|
@@ -145,8 +149,10 @@ function applyNS (vnode, ns, force) {
|
|
|
145
149
|
if (isDef(vnode.children)) {
|
|
146
150
|
for (let i = 0, l = vnode.children.length; i < l; i++) {
|
|
147
151
|
const child = vnode.children[i]
|
|
148
|
-
if (
|
|
149
|
-
|
|
152
|
+
if (
|
|
153
|
+
isDef(child.tag) &&
|
|
154
|
+
(isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))
|
|
155
|
+
) {
|
|
150
156
|
applyNS(child, ns, force)
|
|
151
157
|
}
|
|
152
158
|
}
|
|
@@ -156,7 +162,7 @@ function applyNS (vnode, ns, force) {
|
|
|
156
162
|
// ref #5318
|
|
157
163
|
// necessary to ensure parent re-render when deep bindings like :style and
|
|
158
164
|
// :class are used on slot nodes
|
|
159
|
-
function registerDeepBindings
|
|
165
|
+
function registerDeepBindings(data) {
|
|
160
166
|
if (isObject(data.style)) {
|
|
161
167
|
traverse(data.style)
|
|
162
168
|
}
|