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
|
@@ -5,21 +5,21 @@ import { warn, makeMap, isNative } from '../util/index'
|
|
|
5
5
|
|
|
6
6
|
let initProxy
|
|
7
7
|
|
|
8
|
-
if (
|
|
8
|
+
if (__DEV__) {
|
|
9
9
|
const allowedGlobals = makeMap(
|
|
10
10
|
'Infinity,undefined,NaN,isFinite,isNaN,' +
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
|
12
|
+
'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
|
|
13
|
+
'require' // for Webpack/Browserify
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
const warnNonPresent = (target, key) => {
|
|
17
17
|
warn(
|
|
18
18
|
`Property or method "${key}" is not defined on the instance but ` +
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
'referenced during render. Make sure that this property is reactive, ' +
|
|
20
|
+
'either in the data option, or for class-based components, by ' +
|
|
21
|
+
'initializing the property. ' +
|
|
22
|
+
'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
|
|
23
23
|
target
|
|
24
24
|
)
|
|
25
25
|
}
|
|
@@ -27,22 +27,25 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
27
27
|
const warnReservedPrefix = (target, key) => {
|
|
28
28
|
warn(
|
|
29
29
|
`Property "${key}" must be accessed with "$data.${key}" because ` +
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
|
|
31
|
+
'prevent conflicts with Vue internals. ' +
|
|
32
|
+
'See: https://vuejs.org/v2/api/#data',
|
|
33
33
|
target
|
|
34
34
|
)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const hasProxy =
|
|
38
|
-
typeof Proxy !== 'undefined' && isNative(Proxy)
|
|
37
|
+
const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy)
|
|
39
38
|
|
|
40
39
|
if (hasProxy) {
|
|
41
|
-
const isBuiltInModifier = makeMap(
|
|
40
|
+
const isBuiltInModifier = makeMap(
|
|
41
|
+
'stop,prevent,self,ctrl,shift,alt,meta,exact'
|
|
42
|
+
)
|
|
42
43
|
config.keyCodes = new Proxy(config.keyCodes, {
|
|
43
|
-
set
|
|
44
|
+
set(target, key: string, value) {
|
|
44
45
|
if (isBuiltInModifier(key)) {
|
|
45
|
-
warn(
|
|
46
|
+
warn(
|
|
47
|
+
`Avoid overwriting built-in modifier in config.keyCodes: .${key}`
|
|
48
|
+
)
|
|
46
49
|
return false
|
|
47
50
|
} else {
|
|
48
51
|
target[key] = value
|
|
@@ -53,10 +56,13 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
const hasHandler = {
|
|
56
|
-
has
|
|
59
|
+
has(target, key) {
|
|
57
60
|
const has = key in target
|
|
58
|
-
const isAllowed =
|
|
59
|
-
(
|
|
61
|
+
const isAllowed =
|
|
62
|
+
allowedGlobals(key) ||
|
|
63
|
+
(typeof key === 'string' &&
|
|
64
|
+
key.charAt(0) === '_' &&
|
|
65
|
+
!(key in target.$data))
|
|
60
66
|
if (!has && !isAllowed) {
|
|
61
67
|
if (key in target.$data) warnReservedPrefix(target, key)
|
|
62
68
|
else warnNonPresent(target, key)
|
|
@@ -66,7 +72,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
const getHandler = {
|
|
69
|
-
get
|
|
75
|
+
get(target, key) {
|
|
70
76
|
if (typeof key === 'string' && !(key in target)) {
|
|
71
77
|
if (key in target.$data) warnReservedPrefix(target, key)
|
|
72
78
|
else warnNonPresent(target, key)
|
|
@@ -75,13 +81,12 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
initProxy = function initProxy
|
|
84
|
+
initProxy = function initProxy(vm) {
|
|
79
85
|
if (hasProxy) {
|
|
80
86
|
// determine which proxy handler to use
|
|
81
87
|
const options = vm.$options
|
|
82
|
-
const handlers =
|
|
83
|
-
? getHandler
|
|
84
|
-
: hasHandler
|
|
88
|
+
const handlers =
|
|
89
|
+
options.render && options.render._withStripped ? getHandler : hasHandler
|
|
85
90
|
vm._renderProxy = new Proxy(vm, handlers)
|
|
86
91
|
} else {
|
|
87
92
|
vm._renderProxy = vm
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
// helper to process dynamic keys for dynamic arguments in v-bind and v-on.
|
|
4
2
|
// For example, the following template:
|
|
5
3
|
//
|
|
@@ -11,12 +9,15 @@
|
|
|
11
9
|
|
|
12
10
|
import { warn } from 'core/util/debug'
|
|
13
11
|
|
|
14
|
-
export function bindDynamicKeys
|
|
12
|
+
export function bindDynamicKeys(
|
|
13
|
+
baseObj: Record<string, any>,
|
|
14
|
+
values: Array<any>
|
|
15
|
+
): Object {
|
|
15
16
|
for (let i = 0; i < values.length; i += 2) {
|
|
16
17
|
const key = values[i]
|
|
17
18
|
if (typeof key === 'string' && key) {
|
|
18
19
|
baseObj[values[i]] = values[i + 1]
|
|
19
|
-
} else if (
|
|
20
|
+
} else if (__DEV__ && key !== '' && key !== null) {
|
|
20
21
|
// null is a special value for explicitly removing a binding
|
|
21
22
|
warn(
|
|
22
23
|
`Invalid value for dynamic directive argument (expected string or null): ${key}`,
|
|
@@ -30,6 +31,6 @@ export function bindDynamicKeys (baseObj: Object, values: Array<any>): Object {
|
|
|
30
31
|
// helper to dynamically append modifier runtime markers to event names.
|
|
31
32
|
// ensure only append when value is already string, otherwise it will be cast
|
|
32
33
|
// to string and cause the type check to miss.
|
|
33
|
-
export function prependModifier
|
|
34
|
+
export function prependModifier(value: any, symbol: string): any {
|
|
34
35
|
return typeof value === 'string' ? symbol + value : value
|
|
35
36
|
}
|
package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts}
RENAMED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { warn, extend, isPlainObject } from 'core/util/index'
|
|
2
|
+
import type { VNodeData } from 'types/vnode'
|
|
4
3
|
|
|
5
|
-
export function bindObjectListeners
|
|
4
|
+
export function bindObjectListeners(data: any, value: any): VNodeData {
|
|
6
5
|
if (value) {
|
|
7
6
|
if (!isPlainObject(value)) {
|
|
8
|
-
|
|
9
|
-
'v-on without argument expects an Object value',
|
|
10
|
-
this
|
|
11
|
-
)
|
|
7
|
+
__DEV__ && warn('v-on without argument expects an Object value', this)
|
|
12
8
|
} else {
|
|
13
|
-
const on = data.on = data.on ? extend({}, data.on) : {}
|
|
9
|
+
const on = (data.on = data.on ? extend({}, data.on) : {})
|
|
14
10
|
for (const key in value) {
|
|
15
11
|
const existing = on[key]
|
|
16
12
|
const ours = value[key]
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import config from 'core/config'
|
|
4
2
|
|
|
5
3
|
import {
|
|
@@ -8,13 +6,15 @@ import {
|
|
|
8
6
|
toObject,
|
|
9
7
|
isReservedAttribute,
|
|
10
8
|
camelize,
|
|
11
|
-
hyphenate
|
|
9
|
+
hyphenate,
|
|
10
|
+
isArray
|
|
12
11
|
} from 'core/util/index'
|
|
12
|
+
import type { VNodeData } from 'types/vnode'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Runtime helper for merging v-bind="object" into a VNode's data.
|
|
16
16
|
*/
|
|
17
|
-
export function bindObjectProps
|
|
17
|
+
export function bindObjectProps(
|
|
18
18
|
data: any,
|
|
19
19
|
tag: string,
|
|
20
20
|
value: any,
|
|
@@ -23,27 +23,22 @@ export function bindObjectProps (
|
|
|
23
23
|
): VNodeData {
|
|
24
24
|
if (value) {
|
|
25
25
|
if (!isObject(value)) {
|
|
26
|
-
|
|
27
|
-
'v-bind without argument expects an Object or Array value',
|
|
28
|
-
this
|
|
29
|
-
)
|
|
26
|
+
__DEV__ &&
|
|
27
|
+
warn('v-bind without argument expects an Object or Array value', this)
|
|
30
28
|
} else {
|
|
31
|
-
if (
|
|
29
|
+
if (isArray(value)) {
|
|
32
30
|
value = toObject(value)
|
|
33
31
|
}
|
|
34
32
|
let hash
|
|
35
33
|
for (const key in value) {
|
|
36
|
-
if (
|
|
37
|
-
key === 'class' ||
|
|
38
|
-
key === 'style' ||
|
|
39
|
-
isReservedAttribute(key)
|
|
40
|
-
) {
|
|
34
|
+
if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
|
|
41
35
|
hash = data
|
|
42
36
|
} else {
|
|
43
37
|
const type = data.attrs && data.attrs.type
|
|
44
|
-
hash =
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
hash =
|
|
39
|
+
asProp || config.mustUseProp(tag, type, key)
|
|
40
|
+
? data.domProps || (data.domProps = {})
|
|
41
|
+
: data.attrs || (data.attrs = {})
|
|
47
42
|
}
|
|
48
43
|
const camelizedKey = camelize(key)
|
|
49
44
|
const hyphenatedKey = hyphenate(key)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import config from 'core/config'
|
|
4
|
-
import { hyphenate } from 'shared/util'
|
|
2
|
+
import { hyphenate, isArray } from 'shared/util'
|
|
5
3
|
|
|
6
|
-
function isKeyNotMatch<T>
|
|
7
|
-
if (
|
|
4
|
+
function isKeyNotMatch<T>(expect: T | Array<T>, actual: T): boolean {
|
|
5
|
+
if (isArray(expect)) {
|
|
8
6
|
return expect.indexOf(actual) === -1
|
|
9
7
|
} else {
|
|
10
8
|
return expect !== actual
|
|
@@ -16,13 +14,13 @@ function isKeyNotMatch<T> (expect: T | Array<T>, actual: T): boolean {
|
|
|
16
14
|
* exposed as Vue.prototype._k
|
|
17
15
|
* passing in eventKeyName as last argument separately for backwards compat
|
|
18
16
|
*/
|
|
19
|
-
export function checkKeyCodes
|
|
17
|
+
export function checkKeyCodes(
|
|
20
18
|
eventKeyCode: number,
|
|
21
19
|
key: string,
|
|
22
20
|
builtInKeyCode?: number | Array<number>,
|
|
23
21
|
eventKeyName?: string,
|
|
24
22
|
builtInKeyName?: string | Array<string>
|
|
25
|
-
):
|
|
23
|
+
): boolean | null | undefined {
|
|
26
24
|
const mappedKeyCode = config.keyCodes[key] || builtInKeyCode
|
|
27
25
|
if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
|
|
28
26
|
return isKeyNotMatch(builtInKeyName, eventKeyName)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { toNumber, toString, looseEqual, looseIndexOf } from 'shared/util'
|
|
4
2
|
import { createTextVNode, createEmptyVNode } from 'core/vdom/vnode'
|
|
5
3
|
import { renderList } from './render-list'
|
|
@@ -12,7 +10,7 @@ import { bindObjectListeners } from './bind-object-listeners'
|
|
|
12
10
|
import { resolveScopedSlots } from './resolve-scoped-slots'
|
|
13
11
|
import { bindDynamicKeys, prependModifier } from './bind-dynamic-keys'
|
|
14
12
|
|
|
15
|
-
export function installRenderHelpers
|
|
13
|
+
export function installRenderHelpers(target: any) {
|
|
16
14
|
target._o = markOnce
|
|
17
15
|
target._n = toNumber
|
|
18
16
|
target._s = toString
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { isObject, isDef, hasSymbol } from 'core/util/index'
|
|
1
|
+
import { isObject, isDef, hasSymbol, isArray } from 'core/util/index'
|
|
2
|
+
import VNode from 'core/vdom/vnode'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Runtime helper for rendering v-for lists.
|
|
7
6
|
*/
|
|
8
|
-
export function renderList
|
|
7
|
+
export function renderList(
|
|
9
8
|
val: any,
|
|
10
|
-
render: (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
9
|
+
render: (val: any, keyOrIndex: string | number, index?: number) => VNode
|
|
10
|
+
): Array<VNode> | null {
|
|
11
|
+
let ret: Array<VNode> | null = null,
|
|
12
|
+
i,
|
|
13
|
+
l,
|
|
14
|
+
keys,
|
|
15
|
+
key
|
|
16
|
+
if (isArray(val) || typeof val === 'string') {
|
|
18
17
|
ret = new Array(val.length)
|
|
19
18
|
for (i = 0, l = val.length; i < l; i++) {
|
|
20
19
|
ret[i] = render(val[i], i)
|
|
@@ -45,6 +44,6 @@ export function renderList (
|
|
|
45
44
|
if (!isDef(ret)) {
|
|
46
45
|
ret = []
|
|
47
46
|
}
|
|
48
|
-
(ret
|
|
47
|
+
;(ret as any)._isVList = true
|
|
49
48
|
return ret
|
|
50
49
|
}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { extend, warn, isObject } from 'core/util/index'
|
|
1
|
+
import { extend, warn, isObject, isFunction } from 'core/util/index'
|
|
2
|
+
import VNode from 'core/vdom/vnode'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Runtime helper for rendering <slot>
|
|
7
6
|
*/
|
|
8
|
-
export function renderSlot
|
|
7
|
+
export function renderSlot(
|
|
9
8
|
name: string,
|
|
10
|
-
fallbackRender:
|
|
11
|
-
props:
|
|
12
|
-
bindObject:
|
|
13
|
-
):
|
|
9
|
+
fallbackRender: ((() => Array<VNode>) | Array<VNode>) | null,
|
|
10
|
+
props: Record<string, any> | null,
|
|
11
|
+
bindObject: object | null
|
|
12
|
+
): Array<VNode> | null {
|
|
14
13
|
const scopedSlotFn = this.$scopedSlots[name]
|
|
15
14
|
let nodes
|
|
16
15
|
if (scopedSlotFn) {
|
|
17
16
|
// scoped slot
|
|
18
17
|
props = props || {}
|
|
19
18
|
if (bindObject) {
|
|
20
|
-
if (
|
|
19
|
+
if (__DEV__ && !isObject(bindObject)) {
|
|
21
20
|
warn('slot v-bind without argument expects an Object', this)
|
|
22
21
|
}
|
|
23
22
|
props = extend(extend({}, bindObject), props)
|
|
24
23
|
}
|
|
25
24
|
nodes =
|
|
26
25
|
scopedSlotFn(props) ||
|
|
27
|
-
(
|
|
26
|
+
(isFunction(fallbackRender) ? fallbackRender() : fallbackRender)
|
|
28
27
|
} else {
|
|
29
28
|
nodes =
|
|
30
29
|
this.$slots[name] ||
|
|
31
|
-
(
|
|
30
|
+
(isFunction(fallbackRender) ? fallbackRender() : fallbackRender)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
const target = props && props.slot
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import VNode from 'core/vdom/vnode'
|
|
2
|
+
import { isArray } from 'core/util'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Runtime helper for rendering static trees.
|
|
5
6
|
*/
|
|
6
|
-
export function renderStatic
|
|
7
|
+
export function renderStatic(
|
|
7
8
|
index: number,
|
|
8
9
|
isInFor: boolean
|
|
9
10
|
): VNode | Array<VNode> {
|
|
@@ -28,7 +29,7 @@ export function renderStatic (
|
|
|
28
29
|
* Runtime helper for v-once.
|
|
29
30
|
* Effectively it means marking the node as static with a unique key.
|
|
30
31
|
*/
|
|
31
|
-
export function markOnce
|
|
32
|
+
export function markOnce(
|
|
32
33
|
tree: VNode | Array<VNode>,
|
|
33
34
|
index: number,
|
|
34
35
|
key: string
|
|
@@ -37,12 +38,8 @@ export function markOnce (
|
|
|
37
38
|
return tree
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
function markStatic
|
|
41
|
-
tree
|
|
42
|
-
key: string,
|
|
43
|
-
isOnce: boolean
|
|
44
|
-
) {
|
|
45
|
-
if (Array.isArray(tree)) {
|
|
41
|
+
function markStatic(tree: VNode | Array<VNode>, key: string, isOnce: boolean) {
|
|
42
|
+
if (isArray(tree)) {
|
|
46
43
|
for (let i = 0; i < tree.length; i++) {
|
|
47
44
|
if (tree[i] && typeof tree[i] !== 'string') {
|
|
48
45
|
markStaticNode(tree[i], `${key}_${i}`, isOnce)
|
|
@@ -53,7 +50,7 @@ function markStatic (
|
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
function markStaticNode
|
|
53
|
+
function markStaticNode(node, key, isOnce) {
|
|
57
54
|
node.isStatic = true
|
|
58
55
|
node.key = key
|
|
59
56
|
node.isOnce = isOnce
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { identity, resolveAsset } from 'core/util/index'
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Runtime helper for resolving filters
|
|
7
5
|
*/
|
|
8
|
-
export function resolveFilter
|
|
6
|
+
export function resolveFilter(id: string): Function {
|
|
9
7
|
return resolveAsset(this.$options, 'filters', id, true) || identity
|
|
10
8
|
}
|
package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts}
RENAMED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ScopedSlotsData } from 'types/vnode'
|
|
2
|
+
import { isArray } from 'core/util'
|
|
2
3
|
|
|
3
|
-
export function resolveScopedSlots
|
|
4
|
-
fns: ScopedSlotsData,
|
|
5
|
-
res?:
|
|
4
|
+
export function resolveScopedSlots(
|
|
5
|
+
fns: ScopedSlotsData,
|
|
6
|
+
res?: Record<string, any>,
|
|
6
7
|
// the following are added in 2.6
|
|
7
8
|
hasDynamicKeys?: boolean,
|
|
8
9
|
contentHashKey?: number
|
|
9
|
-
): { [key: string]: Function
|
|
10
|
+
): { $stable: boolean } & { [key: string]: Function } {
|
|
10
11
|
res = res || { $stable: !hasDynamicKeys }
|
|
11
12
|
for (let i = 0; i < fns.length; i++) {
|
|
12
13
|
const slot = fns[i]
|
|
13
|
-
if (
|
|
14
|
+
if (isArray(slot)) {
|
|
14
15
|
resolveScopedSlots(slot, res, hasDynamicKeys)
|
|
15
16
|
} else if (slot) {
|
|
16
17
|
// marker for reverse proxying v-slot without scope on this.$slots
|
|
18
|
+
// @ts-expect-error
|
|
17
19
|
if (slot.proxy) {
|
|
20
|
+
// @ts-expect-error
|
|
18
21
|
slot.fn.proxy = true
|
|
19
22
|
}
|
|
20
23
|
res[slot.key] = slot.fn
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
if (contentHashKey) {
|
|
24
|
-
(res
|
|
27
|
+
;(res as any).$key = contentHashKey
|
|
25
28
|
}
|
|
26
|
-
return res
|
|
29
|
+
return res as any
|
|
27
30
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import type VNode from 'core/vdom/vnode'
|
|
2
|
+
import type { Component } from 'types/component'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Runtime helper for resolving raw children VNodes into a slot object.
|
|
7
6
|
*/
|
|
8
|
-
export function resolveSlots
|
|
9
|
-
children:
|
|
10
|
-
context:
|
|
7
|
+
export function resolveSlots(
|
|
8
|
+
children: Array<VNode> | null | undefined,
|
|
9
|
+
context: Component | null
|
|
11
10
|
): { [key: string]: Array<VNode> } {
|
|
12
11
|
if (!children || !children.length) {
|
|
13
12
|
return {}
|
|
14
13
|
}
|
|
15
|
-
const slots = {}
|
|
14
|
+
const slots: Record<string, any> = {}
|
|
16
15
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
17
16
|
const child = children[i]
|
|
18
17
|
const data = child.data
|
|
@@ -22,18 +21,20 @@ export function resolveSlots (
|
|
|
22
21
|
}
|
|
23
22
|
// named slots should only be respected if the vnode was rendered in the
|
|
24
23
|
// same context.
|
|
25
|
-
if (
|
|
26
|
-
|
|
24
|
+
if (
|
|
25
|
+
(child.context === context || child.fnContext === context) &&
|
|
26
|
+
data &&
|
|
27
|
+
data.slot != null
|
|
27
28
|
) {
|
|
28
29
|
const name = data.slot
|
|
29
|
-
const slot =
|
|
30
|
+
const slot = slots[name] || (slots[name] = [])
|
|
30
31
|
if (child.tag === 'template') {
|
|
31
32
|
slot.push.apply(slot, child.children || [])
|
|
32
33
|
} else {
|
|
33
34
|
slot.push(child)
|
|
34
35
|
}
|
|
35
36
|
} else {
|
|
36
|
-
(slots.default || (slots.default = [])).push(child)
|
|
37
|
+
;(slots.default || (slots.default = [])).push(child)
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
// ignore slots that contains only whitespace
|
|
@@ -45,6 +46,6 @@ export function resolveSlots (
|
|
|
45
46
|
return slots
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function isWhitespace
|
|
49
|
+
function isWhitespace(node: VNode): boolean {
|
|
49
50
|
return (node.isComment && !node.asyncFactory) || node.text === ' '
|
|
50
51
|
}
|