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,38 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Component } from 'types/component'
|
|
2
|
+
import type { ComponentOptions } from 'types/options'
|
|
3
|
+
import type { VNodeComponentOptions, VNodeData } from 'types/vnode'
|
|
2
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
3
8
|
export default class VNode {
|
|
4
|
-
tag
|
|
5
|
-
data: VNodeData |
|
|
6
|
-
children
|
|
7
|
-
text
|
|
8
|
-
elm: Node |
|
|
9
|
-
ns
|
|
10
|
-
context
|
|
11
|
-
key: string | number |
|
|
12
|
-
componentOptions
|
|
13
|
-
componentInstance
|
|
14
|
-
parent: VNode |
|
|
9
|
+
tag?: string
|
|
10
|
+
data: VNodeData | undefined
|
|
11
|
+
children?: Array<VNode> | null
|
|
12
|
+
text?: string
|
|
13
|
+
elm: Node | undefined
|
|
14
|
+
ns?: string
|
|
15
|
+
context?: Component // rendered in this component's scope
|
|
16
|
+
key: string | number | undefined
|
|
17
|
+
componentOptions?: VNodeComponentOptions
|
|
18
|
+
componentInstance?: Component // component instance
|
|
19
|
+
parent: VNode | undefined | null // component placeholder node
|
|
15
20
|
|
|
16
21
|
// strictly internal
|
|
17
|
-
raw: boolean
|
|
18
|
-
isStatic: boolean
|
|
19
|
-
isRootInsert: boolean
|
|
20
|
-
isComment: boolean
|
|
21
|
-
isCloned: boolean
|
|
22
|
-
isOnce: boolean
|
|
23
|
-
asyncFactory
|
|
24
|
-
asyncMeta: Object | void
|
|
25
|
-
isAsyncPlaceholder: boolean
|
|
26
|
-
ssrContext
|
|
27
|
-
fnContext: Component | void
|
|
28
|
-
fnOptions
|
|
29
|
-
devtoolsMeta
|
|
30
|
-
fnScopeId
|
|
22
|
+
raw: boolean // contains raw HTML? (server only)
|
|
23
|
+
isStatic: boolean // hoisted static node
|
|
24
|
+
isRootInsert: boolean // necessary for enter transition check
|
|
25
|
+
isComment: boolean // empty comment placeholder?
|
|
26
|
+
isCloned: boolean // is a cloned node?
|
|
27
|
+
isOnce: boolean // is a v-once node?
|
|
28
|
+
asyncFactory?: Function // async component factory function
|
|
29
|
+
asyncMeta: Object | void
|
|
30
|
+
isAsyncPlaceholder: boolean
|
|
31
|
+
ssrContext?: Object | void
|
|
32
|
+
fnContext: Component | void // real context vm for functional nodes
|
|
33
|
+
fnOptions?: ComponentOptions | null // for SSR caching
|
|
34
|
+
devtoolsMeta?: Object | null // used to store functional render context for devtools
|
|
35
|
+
fnScopeId?: string | null // functional scope id support
|
|
31
36
|
|
|
32
|
-
constructor
|
|
37
|
+
constructor(
|
|
33
38
|
tag?: string,
|
|
34
39
|
data?: VNodeData,
|
|
35
|
-
children?:
|
|
40
|
+
children?: Array<VNode> | null,
|
|
36
41
|
text?: string,
|
|
37
42
|
elm?: Node,
|
|
38
43
|
context?: Component,
|
|
@@ -66,7 +71,7 @@ export default class VNode {
|
|
|
66
71
|
|
|
67
72
|
// DEPRECATED: alias for componentInstance for backwards compat.
|
|
68
73
|
/* istanbul ignore next */
|
|
69
|
-
get child
|
|
74
|
+
get child(): Component | void {
|
|
70
75
|
return this.componentInstance
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -78,7 +83,7 @@ export const createEmptyVNode = (text: string = '') => {
|
|
|
78
83
|
return node
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
export function createTextVNode
|
|
86
|
+
export function createTextVNode(val: string | number) {
|
|
82
87
|
return new VNode(undefined, undefined, undefined, String(val))
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -86,7 +91,7 @@ export function createTextVNode (val: string | number) {
|
|
|
86
91
|
// used for static nodes and slot nodes because they may be reused across
|
|
87
92
|
// multiple renders, cloning them avoids errors when DOM manipulations rely
|
|
88
93
|
// on their elm reference.
|
|
89
|
-
export function cloneVNode
|
|
94
|
+
export function cloneVNode(vnode: VNode): VNode {
|
|
90
95
|
const cloned = new VNode(
|
|
91
96
|
vnode.tag,
|
|
92
97
|
vnode.data,
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const __DEV__: boolean
|
|
2
|
+
|
|
3
|
+
interface Window {
|
|
4
|
+
__VUE_DEVTOOLS_GLOBAL_HOOK__: DevtoolsHook
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// from https://github.com/vuejs/vue-devtools/blob/bc719c95a744614f5c3693460b64dc21dfa339a8/packages/app-backend-api/src/global-hook.ts#L3
|
|
8
|
+
interface DevtoolsHook {
|
|
9
|
+
emit: (event: string, ...payload: any[]) => void
|
|
10
|
+
on: (event: string, handler: Function) => void
|
|
11
|
+
once: (event: string, handler: Function) => void
|
|
12
|
+
off: (event?: string, handler?: Function) => void
|
|
13
|
+
Vue?: any
|
|
14
|
+
// apps: AppRecordOptions[]
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import config from 'core/config'
|
|
4
2
|
import { addHandler, addProp, getBindingAttr } from 'compiler/helpers'
|
|
5
3
|
import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
|
|
4
|
+
import { ASTDirective, ASTElement, ASTModifiers } from 'types/compiler'
|
|
6
5
|
|
|
7
6
|
let warn
|
|
8
7
|
|
|
@@ -11,24 +10,24 @@ let warn
|
|
|
11
10
|
export const RANGE_TOKEN = '__r'
|
|
12
11
|
export const CHECKBOX_RADIO_TOKEN = '__c'
|
|
13
12
|
|
|
14
|
-
export default function model
|
|
13
|
+
export default function model(
|
|
15
14
|
el: ASTElement,
|
|
16
15
|
dir: ASTDirective,
|
|
17
16
|
_warn: Function
|
|
18
|
-
):
|
|
17
|
+
): boolean | undefined {
|
|
19
18
|
warn = _warn
|
|
20
19
|
const value = dir.value
|
|
21
20
|
const modifiers = dir.modifiers
|
|
22
21
|
const tag = el.tag
|
|
23
22
|
const type = el.attrsMap.type
|
|
24
23
|
|
|
25
|
-
if (
|
|
24
|
+
if (__DEV__) {
|
|
26
25
|
// inputs with type="file" are read only and setting the input's
|
|
27
26
|
// value will throw an error.
|
|
28
27
|
if (tag === 'input' && type === 'file') {
|
|
29
28
|
warn(
|
|
30
29
|
`<${el.tag} v-model="${value}" type="file">:\n` +
|
|
31
|
-
|
|
30
|
+
`File inputs are read only. Use a v-on:change listener instead.`,
|
|
32
31
|
el.rawAttrsMap['v-model']
|
|
33
32
|
)
|
|
34
33
|
}
|
|
@@ -50,12 +49,12 @@ export default function model (
|
|
|
50
49
|
genComponentModel(el, value, modifiers)
|
|
51
50
|
// component v-model doesn't need extra runtime
|
|
52
51
|
return false
|
|
53
|
-
} else if (
|
|
52
|
+
} else if (__DEV__) {
|
|
54
53
|
warn(
|
|
55
54
|
`<${el.tag} v-model="${value}">: ` +
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
`v-model is not supported on this element type. ` +
|
|
56
|
+
"If you are working with contenteditable, it's recommended to " +
|
|
57
|
+
'wrap a library dedicated for that purpose inside a custom component.',
|
|
59
58
|
el.rawAttrsMap['v-model']
|
|
60
59
|
)
|
|
61
60
|
}
|
|
@@ -64,41 +63,51 @@ export default function model (
|
|
|
64
63
|
return true
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
function genCheckboxModel
|
|
66
|
+
function genCheckboxModel(
|
|
68
67
|
el: ASTElement,
|
|
69
68
|
value: string,
|
|
70
|
-
modifiers
|
|
69
|
+
modifiers?: ASTModifiers | null
|
|
71
70
|
) {
|
|
72
71
|
const number = modifiers && modifiers.number
|
|
73
72
|
const valueBinding = getBindingAttr(el, 'value') || 'null'
|
|
74
73
|
const trueValueBinding = getBindingAttr(el, 'true-value') || 'true'
|
|
75
74
|
const falseValueBinding = getBindingAttr(el, 'false-value') || 'false'
|
|
76
|
-
addProp(
|
|
75
|
+
addProp(
|
|
76
|
+
el,
|
|
77
|
+
'checked',
|
|
77
78
|
`Array.isArray(${value})` +
|
|
78
|
-
|
|
79
|
-
trueValueBinding === 'true'
|
|
79
|
+
`?_i(${value},${valueBinding})>-1` +
|
|
80
|
+
(trueValueBinding === 'true'
|
|
80
81
|
? `:(${value})`
|
|
81
|
-
: `:_q(${value},${trueValueBinding})`
|
|
82
|
-
)
|
|
82
|
+
: `:_q(${value},${trueValueBinding})`)
|
|
83
83
|
)
|
|
84
|
-
addHandler(
|
|
84
|
+
addHandler(
|
|
85
|
+
el,
|
|
86
|
+
'change',
|
|
85
87
|
`var $$a=${value},` +
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
'$$el=$event.target,' +
|
|
89
|
+
`$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
|
|
90
|
+
'if(Array.isArray($$a)){' +
|
|
89
91
|
`var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
|
|
90
|
-
|
|
91
|
-
`if($$el.checked){$$i<0&&(${genAssignmentCode(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
'$$i=_i($$a,$$v);' +
|
|
93
|
+
`if($$el.checked){$$i<0&&(${genAssignmentCode(
|
|
94
|
+
value,
|
|
95
|
+
'$$a.concat([$$v])'
|
|
96
|
+
)})}` +
|
|
97
|
+
`else{$$i>-1&&(${genAssignmentCode(
|
|
98
|
+
value,
|
|
99
|
+
'$$a.slice(0,$$i).concat($$a.slice($$i+1))'
|
|
100
|
+
)})}` +
|
|
101
|
+
`}else{${genAssignmentCode(value, '$$c')}}`,
|
|
102
|
+
null,
|
|
103
|
+
true
|
|
95
104
|
)
|
|
96
105
|
}
|
|
97
106
|
|
|
98
|
-
function genRadioModel
|
|
107
|
+
function genRadioModel(
|
|
99
108
|
el: ASTElement,
|
|
100
109
|
value: string,
|
|
101
|
-
modifiers
|
|
110
|
+
modifiers?: ASTModifiers | null
|
|
102
111
|
) {
|
|
103
112
|
const number = modifiers && modifiers.number
|
|
104
113
|
let valueBinding = getBindingAttr(el, 'value') || 'null'
|
|
@@ -107,13 +116,14 @@ function genRadioModel (
|
|
|
107
116
|
addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true)
|
|
108
117
|
}
|
|
109
118
|
|
|
110
|
-
function genSelect
|
|
119
|
+
function genSelect(
|
|
111
120
|
el: ASTElement,
|
|
112
121
|
value: string,
|
|
113
|
-
modifiers
|
|
122
|
+
modifiers?: ASTModifiers | null
|
|
114
123
|
) {
|
|
115
124
|
const number = modifiers && modifiers.number
|
|
116
|
-
const selectedVal =
|
|
125
|
+
const selectedVal =
|
|
126
|
+
`Array.prototype.filter` +
|
|
117
127
|
`.call($event.target.options,function(o){return o.selected})` +
|
|
118
128
|
`.map(function(o){var val = "_value" in o ? o._value : o.value;` +
|
|
119
129
|
`return ${number ? '_n(val)' : 'val'}})`
|
|
@@ -124,23 +134,23 @@ function genSelect (
|
|
|
124
134
|
addHandler(el, 'change', code, null, true)
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
function genDefaultModel
|
|
137
|
+
function genDefaultModel(
|
|
128
138
|
el: ASTElement,
|
|
129
139
|
value: string,
|
|
130
|
-
modifiers
|
|
131
|
-
):
|
|
140
|
+
modifiers?: ASTModifiers | null
|
|
141
|
+
): boolean | void {
|
|
132
142
|
const type = el.attrsMap.type
|
|
133
143
|
|
|
134
144
|
// warn if v-bind:value conflicts with v-model
|
|
135
145
|
// except for inputs with v-bind:type
|
|
136
|
-
if (
|
|
146
|
+
if (__DEV__) {
|
|
137
147
|
const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value']
|
|
138
148
|
const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']
|
|
139
149
|
if (value && !typeBinding) {
|
|
140
150
|
const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'
|
|
141
151
|
warn(
|
|
142
152
|
`${binding}="${value}" conflicts with v-model on the same element ` +
|
|
143
|
-
|
|
153
|
+
'because the latter already expands to a value binding internally',
|
|
144
154
|
el.rawAttrsMap[binding]
|
|
145
155
|
)
|
|
146
156
|
}
|
|
@@ -148,11 +158,7 @@ function genDefaultModel (
|
|
|
148
158
|
|
|
149
159
|
const { lazy, number, trim } = modifiers || {}
|
|
150
160
|
const needCompositionGuard = !lazy && type !== 'range'
|
|
151
|
-
const event = lazy
|
|
152
|
-
? 'change'
|
|
153
|
-
: type === 'range'
|
|
154
|
-
? RANGE_TOKEN
|
|
155
|
-
: 'input'
|
|
161
|
+
const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input'
|
|
156
162
|
|
|
157
163
|
let valueExpression = '$event.target.value'
|
|
158
164
|
if (trim) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { addProp } from 'compiler/helpers'
|
|
2
|
+
import { ASTDirective, ASTElement } from 'types/compiler'
|
|
4
3
|
|
|
5
|
-
export default function text
|
|
4
|
+
export default function text(el: ASTElement, dir: ASTDirective) {
|
|
6
5
|
if (dir.value) {
|
|
7
6
|
addProp(el, 'textContent', `_s(${dir.value})`, dir)
|
|
8
7
|
}
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { parseText } from 'compiler/parser/text-parser'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
getBindingAttr,
|
|
7
|
-
baseWarn
|
|
8
|
-
} from 'compiler/helpers'
|
|
2
|
+
import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
|
|
3
|
+
import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
|
|
9
4
|
|
|
10
|
-
function transformNode
|
|
5
|
+
function transformNode(el: ASTElement, options: CompilerOptions) {
|
|
11
6
|
const warn = options.warn || baseWarn
|
|
12
7
|
const staticClass = getAndRemoveAttr(el, 'class')
|
|
13
|
-
if (
|
|
8
|
+
if (__DEV__ && staticClass) {
|
|
14
9
|
const res = parseText(staticClass, options.delimiters)
|
|
15
10
|
if (res) {
|
|
16
11
|
warn(
|
|
17
12
|
`class="${staticClass}": ` +
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
'Interpolation inside attributes has been removed. ' +
|
|
14
|
+
'Use v-bind or the colon shorthand instead. For example, ' +
|
|
15
|
+
'instead of <div class="{{ val }}">, use <div :class="val">.',
|
|
21
16
|
el.rawAttrsMap['class']
|
|
22
17
|
)
|
|
23
18
|
}
|
|
24
19
|
}
|
|
25
20
|
if (staticClass) {
|
|
26
|
-
el.staticClass = JSON.stringify(staticClass)
|
|
21
|
+
el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim())
|
|
27
22
|
}
|
|
28
23
|
const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
|
|
29
24
|
if (classBinding) {
|
|
@@ -31,7 +26,7 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
function genData
|
|
29
|
+
function genData(el: ASTElement): string {
|
|
35
30
|
let data = ''
|
|
36
31
|
if (el.staticClass) {
|
|
37
32
|
data += `staticClass:${el.staticClass},`
|
|
@@ -46,4 +41,4 @@ export default {
|
|
|
46
41
|
staticKeys: ['staticClass'],
|
|
47
42
|
transformNode,
|
|
48
43
|
genData
|
|
49
|
-
}
|
|
44
|
+
} as ModuleOptions
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Expand input[v-model] with dynamic type bindings into v-if-else chains
|
|
5
3
|
* Turn this:
|
|
@@ -10,11 +8,7 @@
|
|
|
10
8
|
* <input v-else :type="type" v-model="data[type]">
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
|
-
import {
|
|
14
|
-
addRawAttr,
|
|
15
|
-
getBindingAttr,
|
|
16
|
-
getAndRemoveAttr
|
|
17
|
-
} from 'compiler/helpers'
|
|
11
|
+
import { addRawAttr, getBindingAttr, getAndRemoveAttr } from 'compiler/helpers'
|
|
18
12
|
|
|
19
13
|
import {
|
|
20
14
|
processFor,
|
|
@@ -22,8 +16,9 @@ import {
|
|
|
22
16
|
addIfCondition,
|
|
23
17
|
createASTElement
|
|
24
18
|
} from 'compiler/parser/index'
|
|
19
|
+
import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
|
|
25
20
|
|
|
26
|
-
function preTransformNode
|
|
21
|
+
function preTransformNode(el: ASTElement, options: CompilerOptions) {
|
|
27
22
|
if (el.tag === 'input') {
|
|
28
23
|
const map = el.attrsMap
|
|
29
24
|
if (!map['v-model']) {
|
|
@@ -70,7 +65,7 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
|
|
|
70
65
|
addRawAttr(branch2, ':type', typeBinding)
|
|
71
66
|
processElement(branch2, options)
|
|
72
67
|
addIfCondition(branch0, {
|
|
73
|
-
exp: ifCondition
|
|
68
|
+
exp: ifCondition!,
|
|
74
69
|
block: branch2
|
|
75
70
|
})
|
|
76
71
|
|
|
@@ -85,10 +80,10 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
|
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
82
|
|
|
88
|
-
function cloneASTElement
|
|
83
|
+
function cloneASTElement(el) {
|
|
89
84
|
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
export default {
|
|
93
88
|
preTransformNode
|
|
94
|
-
}
|
|
89
|
+
} as ModuleOptions
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { parseText } from 'compiler/parser/text-parser'
|
|
4
2
|
import { parseStyleText } from 'web/util/style'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
getBindingAttr,
|
|
8
|
-
baseWarn
|
|
9
|
-
} from 'compiler/helpers'
|
|
3
|
+
import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers'
|
|
4
|
+
import { ASTElement, CompilerOptions, ModuleOptions } from 'types/compiler'
|
|
10
5
|
|
|
11
|
-
function transformNode
|
|
6
|
+
function transformNode(el: ASTElement, options: CompilerOptions) {
|
|
12
7
|
const warn = options.warn || baseWarn
|
|
13
8
|
const staticStyle = getAndRemoveAttr(el, 'style')
|
|
14
9
|
if (staticStyle) {
|
|
15
10
|
/* istanbul ignore if */
|
|
16
|
-
if (
|
|
11
|
+
if (__DEV__) {
|
|
17
12
|
const res = parseText(staticStyle, options.delimiters)
|
|
18
13
|
if (res) {
|
|
19
14
|
warn(
|
|
20
15
|
`style="${staticStyle}": ` +
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
'Interpolation inside attributes has been removed. ' +
|
|
17
|
+
'Use v-bind or the colon shorthand instead. For example, ' +
|
|
18
|
+
'instead of <div style="{{ val }}">, use <div :style="val">.',
|
|
24
19
|
el.rawAttrsMap['style']
|
|
25
20
|
)
|
|
26
21
|
}
|
|
@@ -34,7 +29,7 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
function genData
|
|
32
|
+
function genData(el: ASTElement): string {
|
|
38
33
|
let data = ''
|
|
39
34
|
if (el.staticStyle) {
|
|
40
35
|
data += `staticStyle:${el.staticStyle},`
|
|
@@ -49,4 +44,4 @@ export default {
|
|
|
49
44
|
staticKeys: ['staticStyle'],
|
|
50
45
|
transformNode,
|
|
51
46
|
genData
|
|
52
|
-
}
|
|
47
|
+
} as ModuleOptions
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
isPreTag,
|
|
5
3
|
mustUseProp,
|
|
@@ -11,6 +9,7 @@ import modules from './modules/index'
|
|
|
11
9
|
import directives from './directives/index'
|
|
12
10
|
import { genStaticKeys } from 'shared/util'
|
|
13
11
|
import { isUnaryTag, canBeLeftOpenTag } from './util'
|
|
12
|
+
import { CompilerOptions } from 'types/compiler'
|
|
14
13
|
|
|
15
14
|
export const baseOptions: CompilerOptions = {
|
|
16
15
|
expectHTML: true,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
import { makeMap } from 'shared/util'
|
|
4
2
|
|
|
5
3
|
export const isUnaryTag = makeMap(
|
|
6
4
|
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
|
|
7
|
-
|
|
5
|
+
'link,meta,param,source,track,wbr'
|
|
8
6
|
)
|
|
9
7
|
|
|
10
8
|
// Elements that you can, intentionally, leave open
|
|
@@ -17,8 +15,8 @@ export const canBeLeftOpenTag = makeMap(
|
|
|
17
15
|
// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
|
|
18
16
|
export const isNonPhrasingTag = makeMap(
|
|
19
17
|
'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
|
|
19
|
+
'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
|
|
20
|
+
'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
|
|
21
|
+
'title,tr,track'
|
|
24
22
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function compile() {}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
export { parseComponent } from 'sfc/parser'
|
|
4
2
|
export { compile, compileToFunctions } from './compiler/index'
|
|
5
|
-
export { ssrCompile, ssrCompileToFunctions } from '
|
|
3
|
+
export { ssrCompile, ssrCompileToFunctions } from 'server/compiler'
|
|
6
4
|
export { generateCodeFrame } from 'compiler/codeframe'
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
const whitespaceRE = /\s+/
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Add class with compatibility for SVG since classList is not supported on
|
|
7
5
|
* SVG elements in IE
|
|
8
6
|
*/
|
|
9
|
-
export function addClass
|
|
7
|
+
export function addClass(el: HTMLElement, cls?: string) {
|
|
10
8
|
/* istanbul ignore if */
|
|
11
9
|
if (!cls || !(cls = cls.trim())) {
|
|
12
10
|
return
|
|
@@ -31,7 +29,7 @@ export function addClass (el: HTMLElement, cls: ?string) {
|
|
|
31
29
|
* Remove class with compatibility for SVG since classList is not supported on
|
|
32
30
|
* SVG elements in IE
|
|
33
31
|
*/
|
|
34
|
-
export function removeClass
|
|
32
|
+
export function removeClass(el: HTMLElement, cls?: string) {
|
|
35
33
|
/* istanbul ignore if */
|
|
36
34
|
if (!cls || !(cls = cls.trim())) {
|
|
37
35
|
return
|
|
File without changes
|