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,95 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
warn,
|
|
5
|
-
invokeWithErrorHandling
|
|
6
|
-
} from 'core/util/index'
|
|
7
|
-
import {
|
|
8
|
-
cached,
|
|
9
|
-
isUndef,
|
|
10
|
-
isTrue,
|
|
11
|
-
isPlainObject
|
|
12
|
-
} from 'shared/util'
|
|
13
|
-
|
|
14
|
-
const normalizeEvent = cached((name: string): {
|
|
15
|
-
name: string,
|
|
16
|
-
once: boolean,
|
|
17
|
-
capture: boolean,
|
|
18
|
-
passive: boolean,
|
|
19
|
-
handler?: Function,
|
|
20
|
-
params?: Array<any>
|
|
21
|
-
} => {
|
|
22
|
-
const passive = name.charAt(0) === '&'
|
|
23
|
-
name = passive ? name.slice(1) : name
|
|
24
|
-
const once = name.charAt(0) === '~' // Prefixed last, checked first
|
|
25
|
-
name = once ? name.slice(1) : name
|
|
26
|
-
const capture = name.charAt(0) === '!'
|
|
27
|
-
name = capture ? name.slice(1) : name
|
|
28
|
-
return {
|
|
29
|
-
name,
|
|
30
|
-
once,
|
|
31
|
-
capture,
|
|
32
|
-
passive
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
export function createFnInvoker (fns: Function | Array<Function>, vm: ?Component): Function {
|
|
37
|
-
function invoker () {
|
|
38
|
-
const fns = invoker.fns
|
|
39
|
-
if (Array.isArray(fns)) {
|
|
40
|
-
const cloned = fns.slice()
|
|
41
|
-
for (let i = 0; i < cloned.length; i++) {
|
|
42
|
-
invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`)
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
// return handler return value for single handlers
|
|
46
|
-
return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
invoker.fns = fns
|
|
50
|
-
return invoker
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function updateListeners (
|
|
54
|
-
on: Object,
|
|
55
|
-
oldOn: Object,
|
|
56
|
-
add: Function,
|
|
57
|
-
remove: Function,
|
|
58
|
-
createOnceHandler: Function,
|
|
59
|
-
vm: Component
|
|
60
|
-
) {
|
|
61
|
-
let name, def, cur, old, event
|
|
62
|
-
for (name in on) {
|
|
63
|
-
def = cur = on[name]
|
|
64
|
-
old = oldOn[name]
|
|
65
|
-
event = normalizeEvent(name)
|
|
66
|
-
/* istanbul ignore if */
|
|
67
|
-
if (__WEEX__ && isPlainObject(def)) {
|
|
68
|
-
cur = def.handler
|
|
69
|
-
event.params = def.params
|
|
70
|
-
}
|
|
71
|
-
if (isUndef(cur)) {
|
|
72
|
-
process.env.NODE_ENV !== 'production' && warn(
|
|
73
|
-
`Invalid handler for event "${event.name}": got ` + String(cur),
|
|
74
|
-
vm
|
|
75
|
-
)
|
|
76
|
-
} else if (isUndef(old)) {
|
|
77
|
-
if (isUndef(cur.fns)) {
|
|
78
|
-
cur = on[name] = createFnInvoker(cur, vm)
|
|
79
|
-
}
|
|
80
|
-
if (isTrue(event.once)) {
|
|
81
|
-
cur = on[name] = createOnceHandler(event.name, cur, event.capture)
|
|
82
|
-
}
|
|
83
|
-
add(event.name, cur, event.capture, event.passive, event.params)
|
|
84
|
-
} else if (cur !== old) {
|
|
85
|
-
old.fns = cur
|
|
86
|
-
on[name] = old
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
for (name in oldOn) {
|
|
90
|
-
if (isUndef(on[name])) {
|
|
91
|
-
event = normalizeEvent(name)
|
|
92
|
-
remove(event.name, oldOn[name], event.capture)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { remove, isDef } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
create (_: any, vnode: VNodeWithData) {
|
|
7
|
-
registerRef(vnode)
|
|
8
|
-
},
|
|
9
|
-
update (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
|
10
|
-
if (oldVnode.data.ref !== vnode.data.ref) {
|
|
11
|
-
registerRef(oldVnode, true)
|
|
12
|
-
registerRef(vnode)
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
destroy (vnode: VNodeWithData) {
|
|
16
|
-
registerRef(vnode, true)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function registerRef (vnode: VNodeWithData, isRemoval: ?boolean) {
|
|
21
|
-
const key = vnode.data.ref
|
|
22
|
-
if (!isDef(key)) return
|
|
23
|
-
|
|
24
|
-
const vm = vnode.context
|
|
25
|
-
const ref = vnode.componentInstance || vnode.elm
|
|
26
|
-
const refs = vm.$refs
|
|
27
|
-
if (isRemoval) {
|
|
28
|
-
if (Array.isArray(refs[key])) {
|
|
29
|
-
remove(refs[key], ref)
|
|
30
|
-
} else if (refs[key] === ref) {
|
|
31
|
-
refs[key] = undefined
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
if (vnode.data.refInFor) {
|
|
35
|
-
if (!Array.isArray(refs[key])) {
|
|
36
|
-
refs[key] = [ref]
|
|
37
|
-
} else if (refs[key].indexOf(ref) < 0) {
|
|
38
|
-
// $flow-disable-line
|
|
39
|
-
refs[key].push(ref)
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
refs[key] = ref
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import modules from './server/modules/index'
|
|
4
|
-
import directives from './server/directives/index'
|
|
5
|
-
import { isUnaryTag, canBeLeftOpenTag } from './compiler/util'
|
|
6
|
-
import { createBasicRenderer } from 'server/create-basic-renderer'
|
|
7
|
-
|
|
8
|
-
export default createBasicRenderer({
|
|
9
|
-
modules,
|
|
10
|
-
directives,
|
|
11
|
-
isUnaryTag,
|
|
12
|
-
canBeLeftOpenTag
|
|
13
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
process.env.VUE_ENV = 'server'
|
|
4
|
-
|
|
5
|
-
import { extend } from 'shared/util'
|
|
6
|
-
import modules from './server/modules/index'
|
|
7
|
-
import baseDirectives from './server/directives/index'
|
|
8
|
-
import { isUnaryTag, canBeLeftOpenTag } from './compiler/util'
|
|
9
|
-
|
|
10
|
-
import { createRenderer as _createRenderer } from 'server/create-renderer'
|
|
11
|
-
import { createBundleRendererCreator } from 'server/bundle-renderer/create-bundle-renderer'
|
|
12
|
-
|
|
13
|
-
export function createRenderer (options?: Object = {}): {
|
|
14
|
-
renderToString: Function,
|
|
15
|
-
renderToStream: Function
|
|
16
|
-
} {
|
|
17
|
-
return _createRenderer(extend(extend({}, options), {
|
|
18
|
-
isUnaryTag,
|
|
19
|
-
canBeLeftOpenTag,
|
|
20
|
-
modules,
|
|
21
|
-
// user can provide server-side implementations for custom directives
|
|
22
|
-
// when creating the renderer.
|
|
23
|
-
directives: extend(baseDirectives, options.directives)
|
|
24
|
-
}))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const createBundleRenderer = createBundleRendererCreator(createRenderer)
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { namespaceMap } from 'web/util/index'
|
|
4
|
-
|
|
5
|
-
export function createElement (tagName: string, vnode: VNode): Element {
|
|
6
|
-
const elm = document.createElement(tagName)
|
|
7
|
-
if (tagName !== 'select') {
|
|
8
|
-
return elm
|
|
9
|
-
}
|
|
10
|
-
// false or null will remove the attribute but undefined will not
|
|
11
|
-
if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
|
|
12
|
-
elm.setAttribute('multiple', 'multiple')
|
|
13
|
-
}
|
|
14
|
-
return elm
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function createElementNS (namespace: string, tagName: string): Element {
|
|
18
|
-
return document.createElementNS(namespaceMap[namespace], tagName)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createTextNode (text: string): Text {
|
|
22
|
-
return document.createTextNode(text)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function createComment (text: string): Comment {
|
|
26
|
-
return document.createComment(text)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function insertBefore (parentNode: Node, newNode: Node, referenceNode: Node) {
|
|
30
|
-
parentNode.insertBefore(newNode, referenceNode)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function removeChild (node: Node, child: Node) {
|
|
34
|
-
node.removeChild(child)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function appendChild (node: Node, child: Node) {
|
|
38
|
-
node.appendChild(child)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function parentNode (node: Node): ?Node {
|
|
42
|
-
return node.parentNode
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function nextSibling (node: Node): ?Node {
|
|
46
|
-
return node.nextSibling
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function tagName (node: Element): string {
|
|
50
|
-
return node.tagName
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function setTextContent (node: Node, text: string) {
|
|
54
|
-
node.textContent = text
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function setStyleScope (node: Element, scopeId: string) {
|
|
58
|
-
node.setAttribute(scopeId, '')
|
|
59
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { baseOptions } from '../compiler/options'
|
|
4
|
-
import { createCompiler } from 'server/optimizing-compiler/index'
|
|
5
|
-
|
|
6
|
-
const { compile, compileToFunctions } = createCompiler(baseOptions)
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
compile as ssrCompile,
|
|
10
|
-
compileToFunctions as ssrCompileToFunctions
|
|
11
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { looseEqual, looseIndexOf } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
// this is only applied for <select v-model> because it is the only edge case
|
|
6
|
-
// that must be done at runtime instead of compile time.
|
|
7
|
-
export default function model (node: VNodeWithData, dir: VNodeDirective) {
|
|
8
|
-
if (!node.children) return
|
|
9
|
-
const value = dir.value
|
|
10
|
-
const isMultiple = node.data.attrs && node.data.attrs.multiple
|
|
11
|
-
for (let i = 0, l = node.children.length; i < l; i++) {
|
|
12
|
-
const option = node.children[i]
|
|
13
|
-
if (option.tag === 'option') {
|
|
14
|
-
if (isMultiple) {
|
|
15
|
-
const selected =
|
|
16
|
-
Array.isArray(value) &&
|
|
17
|
-
(looseIndexOf(value, getValue(option)) > -1)
|
|
18
|
-
if (selected) {
|
|
19
|
-
setSelected(option)
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
if (looseEqual(value, getValue(option))) {
|
|
23
|
-
setSelected(option)
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getValue (option) {
|
|
32
|
-
const data = option.data || {}
|
|
33
|
-
return (
|
|
34
|
-
(data.attrs && data.attrs.value) ||
|
|
35
|
-
(data.domProps && data.domProps.value) ||
|
|
36
|
-
(option.children && option.children[0] && option.children[0].text)
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function setSelected (option) {
|
|
41
|
-
const data = option.data || (option.data = {})
|
|
42
|
-
const attrs = data.attrs || (data.attrs = {})
|
|
43
|
-
attrs.selected = ''
|
|
44
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
export default function show (node: VNodeWithData, dir: VNodeDirective) {
|
|
4
|
-
if (!dir.value) {
|
|
5
|
-
const style: any = node.data.style || (node.data.style = {})
|
|
6
|
-
if (Array.isArray(style)) {
|
|
7
|
-
style.push({ display: 'none' })
|
|
8
|
-
} else {
|
|
9
|
-
style.display = 'none'
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { escape } from '../util'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
isDef,
|
|
7
|
-
isUndef,
|
|
8
|
-
extend
|
|
9
|
-
} from 'shared/util'
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
isBooleanAttr,
|
|
13
|
-
isEnumeratedAttr,
|
|
14
|
-
isFalsyAttrValue,
|
|
15
|
-
convertEnumeratedValue
|
|
16
|
-
} from 'web/util/attrs'
|
|
17
|
-
|
|
18
|
-
import { isSSRUnsafeAttr } from 'web/server/util'
|
|
19
|
-
|
|
20
|
-
export default function renderAttrs (node: VNodeWithData): string {
|
|
21
|
-
let attrs = node.data.attrs
|
|
22
|
-
let res = ''
|
|
23
|
-
|
|
24
|
-
const opts = node.parent && node.parent.componentOptions
|
|
25
|
-
if (isUndef(opts) || opts.Ctor.options.inheritAttrs !== false) {
|
|
26
|
-
let parent = node.parent
|
|
27
|
-
while (isDef(parent)) {
|
|
28
|
-
// Stop fallthrough in case parent has inheritAttrs option set to false
|
|
29
|
-
if (parent.componentOptions && parent.componentOptions.Ctor.options.inheritAttrs === false) {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
if (isDef(parent.data) && isDef(parent.data.attrs)) {
|
|
33
|
-
attrs = extend(extend({}, attrs), parent.data.attrs)
|
|
34
|
-
}
|
|
35
|
-
parent = parent.parent
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (isUndef(attrs)) {
|
|
40
|
-
return res
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for (const key in attrs) {
|
|
44
|
-
if (isSSRUnsafeAttr(key)) {
|
|
45
|
-
continue
|
|
46
|
-
}
|
|
47
|
-
if (key === 'style') {
|
|
48
|
-
// leave it to the style module
|
|
49
|
-
continue
|
|
50
|
-
}
|
|
51
|
-
res += renderAttr(key, attrs[key])
|
|
52
|
-
}
|
|
53
|
-
return res
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function renderAttr (key: string, value: string): string {
|
|
57
|
-
if (isBooleanAttr(key)) {
|
|
58
|
-
if (!isFalsyAttrValue(value)) {
|
|
59
|
-
return ` ${key}="${key}"`
|
|
60
|
-
}
|
|
61
|
-
} else if (isEnumeratedAttr(key)) {
|
|
62
|
-
return ` ${key}="${escape(convertEnumeratedValue(key, value))}"`
|
|
63
|
-
} else if (!isFalsyAttrValue(value)) {
|
|
64
|
-
return ` ${key}="${escape(String(value))}"`
|
|
65
|
-
}
|
|
66
|
-
return ''
|
|
67
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { escape } from '../util'
|
|
4
|
-
import { genClassForVnode } from 'web/util/index'
|
|
5
|
-
|
|
6
|
-
export default function renderClass (node: VNodeWithData): ?string {
|
|
7
|
-
const classList = genClassForVnode(node)
|
|
8
|
-
if (classList !== '') {
|
|
9
|
-
return ` class="${escape(classList)}"`
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import VNode from 'core/vdom/vnode'
|
|
4
|
-
import { renderAttr } from './attrs'
|
|
5
|
-
import { isDef, isUndef, extend, toString } from 'shared/util'
|
|
6
|
-
import { propsToAttrMap, isRenderableAttr } from '../util'
|
|
7
|
-
|
|
8
|
-
export default function renderDOMProps (node: VNodeWithData): string {
|
|
9
|
-
let props = node.data.domProps
|
|
10
|
-
let res = ''
|
|
11
|
-
|
|
12
|
-
let parent = node.parent
|
|
13
|
-
while (isDef(parent)) {
|
|
14
|
-
if (parent.data && parent.data.domProps) {
|
|
15
|
-
props = extend(extend({}, props), parent.data.domProps)
|
|
16
|
-
}
|
|
17
|
-
parent = parent.parent
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (isUndef(props)) {
|
|
21
|
-
return res
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const attrs = node.data.attrs
|
|
25
|
-
for (const key in props) {
|
|
26
|
-
if (key === 'innerHTML') {
|
|
27
|
-
setText(node, props[key], true)
|
|
28
|
-
} else if (key === 'textContent') {
|
|
29
|
-
setText(node, props[key], false)
|
|
30
|
-
} else if (key === 'value' && node.tag === 'textarea') {
|
|
31
|
-
setText(node, toString(props[key]), false)
|
|
32
|
-
} else {
|
|
33
|
-
// $flow-disable-line (WTF?)
|
|
34
|
-
const attr = propsToAttrMap[key] || key.toLowerCase()
|
|
35
|
-
if (isRenderableAttr(attr) &&
|
|
36
|
-
// avoid rendering double-bound props/attrs twice
|
|
37
|
-
!(isDef(attrs) && isDef(attrs[attr]))
|
|
38
|
-
) {
|
|
39
|
-
res += renderAttr(attr, props[key])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return res
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function setText (node, text, raw) {
|
|
47
|
-
const child = new VNode(undefined, undefined, undefined, text)
|
|
48
|
-
child.raw = raw
|
|
49
|
-
node.children = [child]
|
|
50
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { escape, noUnitNumericStyleProps } from '../util'
|
|
4
|
-
import { hyphenate } from 'shared/util'
|
|
5
|
-
import { getStyle } from 'web/util/style'
|
|
6
|
-
|
|
7
|
-
export function genStyle (style: Object): string {
|
|
8
|
-
let styleText = ''
|
|
9
|
-
for (const key in style) {
|
|
10
|
-
const value = style[key]
|
|
11
|
-
const hyphenatedKey = hyphenate(key)
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
for (let i = 0, len = value.length; i < len; i++) {
|
|
14
|
-
styleText += normalizeValue(hyphenatedKey, value[i])
|
|
15
|
-
}
|
|
16
|
-
} else {
|
|
17
|
-
styleText += normalizeValue(hyphenatedKey, value)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return styleText
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function normalizeValue(key: string, value: any): string {
|
|
24
|
-
if (
|
|
25
|
-
typeof value === 'string' ||
|
|
26
|
-
(typeof value === 'number' && noUnitNumericStyleProps[key]) ||
|
|
27
|
-
value === 0
|
|
28
|
-
) {
|
|
29
|
-
return `${key}:${value};`
|
|
30
|
-
} else {
|
|
31
|
-
// invalid values
|
|
32
|
-
return ``
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default function renderStyle (vnode: VNodeWithData): ?string {
|
|
37
|
-
const styleText = genStyle(getStyle(vnode, false))
|
|
38
|
-
if (styleText !== '') {
|
|
39
|
-
return ` style=${JSON.stringify(escape(styleText))}`
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { makeMap } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
const isAttr = makeMap(
|
|
6
|
-
'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
|
|
7
|
-
'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
|
|
8
|
-
'checked,cite,class,code,codebase,color,cols,colspan,content,' +
|
|
9
|
-
'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
|
|
10
|
-
'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
|
|
11
|
-
'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
|
|
12
|
-
'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
|
|
13
|
-
'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
|
|
14
|
-
'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
|
|
15
|
-
'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
|
|
16
|
-
'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
|
|
17
|
-
'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
|
|
18
|
-
'target,title,usemap,value,width,wrap'
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/ // eslint-disable-line no-control-regex
|
|
22
|
-
export const isSSRUnsafeAttr = (name: string): boolean => {
|
|
23
|
-
return unsafeAttrCharRE.test(name)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* istanbul ignore next */
|
|
27
|
-
const isRenderableAttr = (name: string): boolean => {
|
|
28
|
-
return (
|
|
29
|
-
isAttr(name) ||
|
|
30
|
-
name.indexOf('data-') === 0 ||
|
|
31
|
-
name.indexOf('aria-') === 0
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
export { isRenderableAttr }
|
|
35
|
-
|
|
36
|
-
export const propsToAttrMap = {
|
|
37
|
-
acceptCharset: 'accept-charset',
|
|
38
|
-
className: 'class',
|
|
39
|
-
htmlFor: 'for',
|
|
40
|
-
httpEquiv: 'http-equiv'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const ESC = {
|
|
44
|
-
'<': '<',
|
|
45
|
-
'>': '>',
|
|
46
|
-
'"': '"',
|
|
47
|
-
'&': '&'
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function escape (s: string) {
|
|
51
|
-
return s.replace(/[<>"&]/g, escapeChar)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function escapeChar (a) {
|
|
55
|
-
return ESC[a] || a
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const noUnitNumericStyleProps = {
|
|
59
|
-
"animation-iteration-count": true,
|
|
60
|
-
"border-image-outset": true,
|
|
61
|
-
"border-image-slice": true,
|
|
62
|
-
"border-image-width": true,
|
|
63
|
-
"box-flex": true,
|
|
64
|
-
"box-flex-group": true,
|
|
65
|
-
"box-ordinal-group": true,
|
|
66
|
-
"column-count": true,
|
|
67
|
-
"columns": true,
|
|
68
|
-
"flex": true,
|
|
69
|
-
"flex-grow": true,
|
|
70
|
-
"flex-positive": true,
|
|
71
|
-
"flex-shrink": true,
|
|
72
|
-
"flex-negative": true,
|
|
73
|
-
"flex-order": true,
|
|
74
|
-
"grid-row": true,
|
|
75
|
-
"grid-row-end": true,
|
|
76
|
-
"grid-row-span": true,
|
|
77
|
-
"grid-row-start": true,
|
|
78
|
-
"grid-column": true,
|
|
79
|
-
"grid-column-end": true,
|
|
80
|
-
"grid-column-span": true,
|
|
81
|
-
"grid-column-start": true,
|
|
82
|
-
"font-weight": true,
|
|
83
|
-
"line-clamp": true,
|
|
84
|
-
"line-height": true,
|
|
85
|
-
"opacity": true,
|
|
86
|
-
"order": true,
|
|
87
|
-
"orphans": true,
|
|
88
|
-
"tab-size": true,
|
|
89
|
-
"widows": true,
|
|
90
|
-
"z-index": true,
|
|
91
|
-
"zoom": true,
|
|
92
|
-
// SVG
|
|
93
|
-
"fill-opacity": true,
|
|
94
|
-
"flood-opacity": true,
|
|
95
|
-
"stop-opacity": true,
|
|
96
|
-
"stroke-dasharray": true,
|
|
97
|
-
"stroke-dashoffset": true,
|
|
98
|
-
"stroke-miterlimit": true,
|
|
99
|
-
"stroke-opacity": true,
|
|
100
|
-
"stroke-width": true
|
|
101
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { addHandler, addAttr } from 'compiler/helpers'
|
|
4
|
-
import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
|
|
5
|
-
|
|
6
|
-
export default function model (
|
|
7
|
-
el: ASTElement,
|
|
8
|
-
dir: ASTDirective
|
|
9
|
-
): ?boolean {
|
|
10
|
-
if (el.tag === 'input' || el.tag === 'textarea') {
|
|
11
|
-
genDefaultModel(el, dir.value, dir.modifiers)
|
|
12
|
-
} else {
|
|
13
|
-
genComponentModel(el, dir.value, dir.modifiers)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function genDefaultModel (
|
|
18
|
-
el: ASTElement,
|
|
19
|
-
value: string,
|
|
20
|
-
modifiers: ?ASTModifiers
|
|
21
|
-
): ?boolean {
|
|
22
|
-
const { lazy, trim, number } = modifiers || {}
|
|
23
|
-
const event = lazy ? 'change' : 'input'
|
|
24
|
-
|
|
25
|
-
let valueExpression = `$event.target.attr.value${trim ? '.trim()' : ''}`
|
|
26
|
-
if (number) {
|
|
27
|
-
valueExpression = `_n(${valueExpression})`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const code = genAssignmentCode(value, valueExpression)
|
|
31
|
-
addAttr(el, 'value', `(${value})`)
|
|
32
|
-
addHandler(el, event, code, null, true)
|
|
33
|
-
}
|