From 1762a66204d4856e0725f09f12e4da16f403bf09 Mon Sep 17 00:00:00 2001
From: Evan You Backers via Patreon
@@ -310,7 +311,6 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
- Luca Borghini
- kazuya kawaguchi
- Keisuke KITA
-- Jack Barham
- Santa Cruz
- Simon East
- Benjamin Listwon
@@ -336,8 +336,8 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
- Edithvale
- Intevation GmbH
- Luiz Eduardo Tanure Bacelar
+- Chengzhi Yin
- Zoran Knezevic
-- Pascal Germain
- Pierre Vanhulst
- Jon Hobbs-Smith
- Akiho Nagao
@@ -359,7 +359,6 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
- Guilherme S L de Souza
- Rob Yedlin
- Daniel Waghorn
-- Eric Githinji
- Chih-Hsuan, Fan
- Jordan Oroshiba
- Cliff Hess
@@ -377,7 +376,6 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
- Alexander Weiher
- Daniel Cook
- Shinya Katayama
-- Brendan Long
- Jere Sjöroos
- Wakana Seki
- David Ang
@@ -402,7 +400,6 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
- Chris Calo
- Milan Zivkovic
- Christo Crampton
-- Jason Rys
- Johnny Austin
- Aaron Hung
- Soichiro Isshiki
@@ -410,8 +407,7 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
- Rob Mellett
- Abraham Arango
- Marko Bošković
-- Chris Lind
-- Andrej
+- Andrej Noskaj
- Ed Linklater
- Garion Herman
- Chris Bemister
diff --git a/README.md b/README.md
index f6c0880b996..90324104b6b 100644
--- a/README.md
+++ b/README.md
@@ -74,17 +74,7 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
Platinum Sponsors (China)
-
-
-
+
-
-
-
-
-
-
-
- Gold Sponsors
From 6cc070063bd211229dff5108c99f7d11b6778550 Mon Sep 17 00:00:00 2001
From: Evan You
+
+
+
+ |
+
+
+
+
+ |
+
-
+
+
+
+
+ |
+
+
+
+
+ |
+
{{msg}}
(#8965)
fix #8950
---
src/compiler/parser/html-parser.js | 2 +-
test/unit/modules/compiler/parser.spec.js | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/compiler/parser/html-parser.js b/src/compiler/parser/html-parser.js
index e4925f38d34..b0ef2d649e8 100644
--- a/src/compiler/parser/html-parser.js
+++ b/src/compiler/parser/html-parser.js
@@ -106,7 +106,7 @@ export function parseHTML (html, options) {
const startTagMatch = parseStartTag()
if (startTagMatch) {
handleStartTag(startTagMatch)
- if (shouldIgnoreFirstNewline(lastTag, html)) {
+ if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
advance(1)
}
continue
diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js
index bc4285b9eb8..07d6148225c 100644
--- a/test/unit/modules/compiler/parser.spec.js
+++ b/test/unit/modules/compiler/parser.spec.js
@@ -667,6 +667,15 @@ describe('parser', () => {
expect(pre2.children[0].text).toBe('\nabc')
})
+ it('keep first newline after unary tag in ', () => {
+ const options = extend({}, baseOptions)
+ const ast = parse('abc\ndef
', options)
+ expect(ast.children[1].type).toBe(1)
+ expect(ast.children[1].tag).toBe('input')
+ expect(ast.children[2].type).toBe(3)
+ expect(ast.children[2].text).toBe('\ndef')
+ })
+
it('forgivingly handle < in plain text', () => {
const options = extend({}, baseOptions)
const ast = parse('1 < 2 < 3
', options)
From a7658e03a16dc507f0abeba41aee705f773727d0 Mon Sep 17 00:00:00 2001
From: Kael
Date: Sat, 1 Dec 2018 10:04:05 +1100
Subject: [PATCH 016/553] fix(data): skip recursive call if values are
identical (#8967)
---
src/core/util/options.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/core/util/options.js b/src/core/util/options.js
index 2906ddd1910..fc7826dc01d 100644
--- a/src/core/util/options.js
+++ b/src/core/util/options.js
@@ -55,7 +55,11 @@ function mergeData (to: Object, from: ?Object): Object {
fromVal = from[key]
if (!hasOwn(to, key)) {
set(to, key, fromVal)
- } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
+ } else if (
+ toVal !== fromVal &&
+ isPlainObject(toVal) &&
+ isPlainObject(fromVal)
+ ) {
mergeData(toVal, fromVal)
}
}
From 613cb52bf3e5fd6caee0a94fab953ac9fdd37924 Mon Sep 17 00:00:00 2001
From: Alexey Tirman
Date: Sat, 1 Dec 2018 02:06:24 +0300
Subject: [PATCH 017/553] polish: improve invalid method warning with type info
(#8974)
close #8017
---
src/core/instance/state.js | 6 +++---
test/unit/features/options/methods.spec.js | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/core/instance/state.js b/src/core/instance/state.js
index 948dc08bc5d..9fec53f6262 100644
--- a/src/core/instance/state.js
+++ b/src/core/instance/state.js
@@ -257,9 +257,9 @@ function initMethods (vm: Component, methods: Object) {
const props = vm.$options.props
for (const key in methods) {
if (process.env.NODE_ENV !== 'production') {
- if (methods[key] == null) {
+ if (typeof methods[key] !== 'function') {
warn(
- `Method "${key}" has an undefined value in the component definition. ` +
+ `Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
`Did you reference the function correctly?`,
vm
)
@@ -277,7 +277,7 @@ function initMethods (vm: Component, methods: Object) {
)
}
}
- vm[key] = methods[key] == null ? noop : bind(methods[key], vm)
+ vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm)
}
}
diff --git a/test/unit/features/options/methods.spec.js b/test/unit/features/options/methods.spec.js
index 34f9ee88fc6..f1e5fc68b27 100644
--- a/test/unit/features/options/methods.spec.js
+++ b/test/unit/features/options/methods.spec.js
@@ -19,13 +19,13 @@ describe('Options methods', () => {
expect(vm.a).toBe(2)
})
- it('should warn undefined methods', () => {
+ it('should warn methods of not function type', () => {
new Vue({
methods: {
- hello: undefined
+ hello: {}
}
})
- expect(`Method "hello" has an undefined value in the component definition`).toHaveBeenWarned()
+ expect('Method "hello" has type "object" in the component definition').toHaveBeenWarned()
})
it('should warn methods conflicting with data', () => {
From c711ec189aaf46399756e34d933ba5e0b6576c36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=8B=BC=E6=97=8F=E5=B0=8F=E7=8B=88?= <1340641314@qq.com>
Date: Sat, 1 Dec 2018 12:27:24 +0800
Subject: [PATCH 018/553] fix(types): support chain call for Vue.use and
Vue.mixin (#8595)
---
flow/global-api.js | 4 ++--
test/unit/features/global-api/mixin.spec.js | 5 +++++
test/unit/features/global-api/use.spec.js | 5 +++++
types/test/vue-test.ts | 9 +++++++++
types/vue.d.ts | 6 +++---
5 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/flow/global-api.js b/flow/global-api.js
index 0b2efb23ac3..eab244c22bb 100644
--- a/flow/global-api.js
+++ b/flow/global-api.js
@@ -8,8 +8,8 @@ declare interface GlobalAPI {
set: (target: Object | Array, key: string | number, value: T) => T;
delete: (target: Object| Array, key: string | number) => void;
nextTick: (fn: Function, context?: Object) => void | Promise<*>;
- use: (plugin: Function | Object) => void;
- mixin: (mixin: Object) => void;
+ use: (plugin: Function | Object) => GlobalAPI;
+ mixin: (mixin: Object) => GlobalAPI;
compile: (template: string) => { render: Function, staticRenderFns: Array };
directive: (id: string, def?: Function | Object) => Function | Object | void;
diff --git a/test/unit/features/global-api/mixin.spec.js b/test/unit/features/global-api/mixin.spec.js
index bcf962402c2..0b83773a5d4 100644
--- a/test/unit/features/global-api/mixin.spec.js
+++ b/test/unit/features/global-api/mixin.spec.js
@@ -162,4 +162,9 @@ describe('Global API: mixin', () => {
expect(base).toHaveBeenCalled()
expect(injected).toHaveBeenCalled()
})
+
+ // #8595
+ it('chain call', () => {
+ expect(Vue.mixin({})).toBe(Vue)
+ })
})
diff --git a/test/unit/features/global-api/use.spec.js b/test/unit/features/global-api/use.spec.js
index 00053f808a7..d54ff0750f3 100644
--- a/test/unit/features/global-api/use.spec.js
+++ b/test/unit/features/global-api/use.spec.js
@@ -49,4 +49,9 @@ describe('Global API: use', () => {
expect(Vue.options.directives['plugin-test']).toBeUndefined()
expect(Ctor2.options.directives['plugin-test']).toBe(def)
})
+
+ // #8595
+ it('chain call', () => {
+ expect(Vue.use(() => {})).toBe(Vue)
+ })
})
diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts
index 326969c1637..6fe0e56182c 100644
--- a/types/test/vue-test.ts
+++ b/types/test/vue-test.ts
@@ -97,6 +97,15 @@ class Test extends Vue {
this.use;
this.mixin(Test);
this.compile("{{ message }}");
+ this
+ .use(() => {
+
+ })
+ .use(() => {
+
+ })
+ .mixin({})
+ .mixin({});
}
}
diff --git a/types/vue.d.ts b/types/vue.d.ts
index 179fb5fe38e..29667ead1f6 100644
--- a/types/vue.d.ts
+++ b/types/vue.d.ts
@@ -111,9 +111,9 @@ export interface VueConstructor {
component(id: string, definition: FunctionalComponentOptions>): ExtendedVue;
component(id: string, definition?: ComponentOptions): ExtendedVue;
- use(plugin: PluginObject | PluginFunction, options?: T): void;
- use(plugin: PluginObject | PluginFunction, ...options: any[]): void;
- mixin(mixin: VueConstructor | ComponentOptions): void;
+ use(plugin: PluginObject | PluginFunction, options?: T): this;
+ use(plugin: PluginObject | PluginFunction, ...options: any[]): this;
+ mixin(mixin: VueConstructor | ComponentOptions): this;
compile(template: string): {
render(createElement: typeof Vue.prototype.$createElement): VNode;
staticRenderFns: (() => VNode)[];
From ac217d2472bb92ce901ef1f46595b44a1b5d1a18 Mon Sep 17 00:00:00 2001
From: st-sloth
Date: Sat, 1 Dec 2018 09:28:29 +0500
Subject: [PATCH 019/553] fix(types): fix `renderError`arguments type (#8636)
fix #8635
---
types/options.d.ts | 2 +-
types/test/options-test.ts | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/types/options.d.ts b/types/options.d.ts
index bd96b6476d3..7d5861d1722 100644
--- a/types/options.d.ts
+++ b/types/options.d.ts
@@ -70,7 +70,7 @@ export interface ComponentOptions<
template?: string;
// hack is for funcitonal component type inference, should not used in user code
render?(createElement: CreateElement, hack: RenderContext): VNode;
- renderError?: (h: () => VNode, err: Error) => VNode;
+ renderError?(createElement: CreateElement, err: Error): VNode;
staticRenderFns?: ((createElement: CreateElement) => VNode)[];
beforeCreate?(this: V): void;
diff --git a/types/test/options-test.ts b/types/test/options-test.ts
index 1c6ecff6daa..8755564c2a3 100644
--- a/types/test/options-test.ts
+++ b/types/test/options-test.ts
@@ -202,6 +202,9 @@ Vue.component('component', {
[createElement("div", "message")]
]);
},
+ renderError(createElement, err) {
+ return createElement('pre', { style: { color: 'red' }}, err.stack)
+ },
staticRenderFns: [],
beforeCreate() {
From 0ba79e2588309ba386f570ed84d372611c4dd165 Mon Sep 17 00:00:00 2001
From: nel215
Date: Fri, 30 Nov 2018 20:28:52 -0800
Subject: [PATCH 020/553] fix(types): accept `number` type as key on
Vue.set/delete (#8707) (#8709)
---
types/test/vue-test.ts | 2 ++
types/vue.d.ts | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts
index 6fe0e56182c..72390b083b1 100644
--- a/types/test/vue-test.ts
+++ b/types/test/vue-test.ts
@@ -87,8 +87,10 @@ class Test extends Vue {
this.nextTick(() => {});
this.nextTick().then(() => {});
this.set({}, "", "");
+ this.set({}, 1, "");
this.set([true, false, true], 1, true);
this.delete({}, "");
+ this.delete({}, 1);
this.delete([true, false], 0);
this.directive("", {bind() {}});
this.filter("", (value: number) => value);
diff --git a/types/vue.d.ts b/types/vue.d.ts
index 29667ead1f6..44a892ead3b 100644
--- a/types/vue.d.ts
+++ b/types/vue.d.ts
@@ -91,9 +91,9 @@ export interface VueConstructor {
nextTick(callback: () => void, context?: any[]): void;
nextTick(): Promise
- set(object: object, key: string, value: T): T;
+ set(object: object, key: string | number, value: T): T;
set(array: T[], key: number, value: T): T;
- delete(object: object, key: string): void;
+ delete(object: object, key: string | number): void;
delete(array: T[], key: number): void;
directive(
From 3cd4af4af0a8a67f5887d5fc967147d433c8612c Mon Sep 17 00:00:00 2001
From: Kaoru Hagihara
Date: Sat, 1 Dec 2018 13:30:31 +0900
Subject: [PATCH 021/553] fix(types): support typing $el as SVGElement (#8809)
---
types/test/vue-test.ts | 1 +
types/vue.d.ts | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts
index 72390b083b1..d9a8379a83f 100644
--- a/types/test/vue-test.ts
+++ b/types/test/vue-test.ts
@@ -19,6 +19,7 @@ class Test extends Vue {
}
// test property reification
+ $el!: HTMLElement | SVGElement;
$refs!: {
vue: Vue,
element: HTMLInputElement,
diff --git a/types/vue.d.ts b/types/vue.d.ts
index 44a892ead3b..3832f2c9e41 100644
--- a/types/vue.d.ts
+++ b/types/vue.d.ts
@@ -21,7 +21,7 @@ export interface CreateElement {
}
export interface Vue {
- readonly $el: HTMLElement;
+ readonly $el: Element;
readonly $options: ComponentOptions;
readonly $parent: Vue;
readonly $root: Vue;
From 76443803e8878dc13a31ebed119abfd31573e7f1 Mon Sep 17 00:00:00 2001
From: thenickname
Date: Sat, 1 Dec 2018 05:31:45 +0100
Subject: [PATCH 022/553] Typings: Improve $slots and $scopedSlots type to
prevent unchecked access to undefined (#8946)
* fix(types): Declare $scopedSlots as potentially undefined to enable stricter TS checks
* fix(types): Fix tests
* fix(types): declare $slots option as potentially undefined
declare $slots option as potentially undefined to enable stricter TS checks
---
types/test/options-test.ts | 6 +++---
types/vue.d.ts | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/types/test/options-test.ts b/types/test/options-test.ts
index 8755564c2a3..6c817e23d19 100644
--- a/types/test/options-test.ts
+++ b/types/test/options-test.ts
@@ -304,8 +304,8 @@ Vue.component('component-with-scoped-slot', {
child: {
render (this: Vue, h: CreateElement) {
return h('div', [
- this.$scopedSlots['default']({ msg: 'hi' }),
- this.$scopedSlots['item']({ msg: 'hello' })
+ this.$scopedSlots['default']!({ msg: 'hi' }),
+ this.$scopedSlots['item']!({ msg: 'hello' })
])
}
}
@@ -314,7 +314,7 @@ Vue.component('component-with-scoped-slot', {
Vue.component('narrow-array-of-vnode-type', {
render (h): VNode {
- const slot = this.$scopedSlots.default({})
+ const slot = this.$scopedSlots.default!({})
if (typeof slot !== 'string') {
const first = slot[0]
if (!Array.isArray(first) && typeof first !== 'string') {
diff --git a/types/vue.d.ts b/types/vue.d.ts
index 3832f2c9e41..ba8e68e942e 100644
--- a/types/vue.d.ts
+++ b/types/vue.d.ts
@@ -27,8 +27,8 @@ export interface Vue {
readonly $root: Vue;
readonly $children: Vue[];
readonly $refs: { [key: string]: Vue | Element | Vue[] | Element[] };
- readonly $slots: { [key: string]: VNode[] };
- readonly $scopedSlots: { [key: string]: ScopedSlot };
+ readonly $slots: { [key: string]: VNode[] | undefined };
+ readonly $scopedSlots: { [key: string]: ScopedSlot | undefined };
readonly $isServer: boolean;
readonly $data: Record;
readonly $props: Record;
From 97086f365808a040f6cf1ddb12e2b3f63d7769bf Mon Sep 17 00:00:00 2001
From: hugoazevedosoares
Date: Sat, 1 Dec 2018 02:41:27 -0200
Subject: [PATCH 023/553] fix(types): fix vm.$once argument type (#8995)
vm.$once should accept an event or array of events as first parameter.
fix #8983
---
types/vue.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/types/vue.d.ts b/types/vue.d.ts
index ba8e68e942e..39967963e8d 100644
--- a/types/vue.d.ts
+++ b/types/vue.d.ts
@@ -53,7 +53,7 @@ export interface Vue {
options?: WatchOptions
): (() => void);
$on(event: string | string[], callback: Function): this;
- $once(event: string, callback: Function): this;
+ $once(event: string | string[], callback: Function): this;
$off(event?: string | string[], callback?: Function): this;
$emit(event: string, ...args: any[]): this;
$nextTick(callback: (this: this) => void): void;
From 1129d184482720bb52fa61f0a309645b7caaddd9 Mon Sep 17 00:00:00 2001
From: Joseph Anglada
Date: Sat, 1 Dec 2018 00:57:26 -0400
Subject: [PATCH 024/553] refactor: reduce if-else nesting, coalesce conditions
(#9060)
---
src/core/instance/render.js | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/core/instance/render.js b/src/core/instance/render.js
index 70fb2c0e57a..be12d726034 100644
--- a/src/core/instance/render.js
+++ b/src/core/instance/render.js
@@ -86,15 +86,11 @@ export function renderMixin (Vue: Class) {
// return error render result,
// or previous vnode to prevent render error causing blank component
/* istanbul ignore else */
- if (process.env.NODE_ENV !== 'production') {
- if (vm.$options.renderError) {
- try {
- vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
- } catch (e) {
- handleError(e, vm, `renderError`)
- vnode = vm._vnode
- }
- } else {
+ if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
+ try {
+ vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
+ } catch (e) {
+ handleError(e, vm, `renderError`)
vnode = vm._vnode
}
} else {
From 05e8bcfe5d308f280f3640df96bd170fbcf1a9b5 Mon Sep 17 00:00:00 2001
From: Jay Fong
Date: Sat, 1 Dec 2018 12:58:29 +0800
Subject: [PATCH 025/553] fix: fix server env detection in wechat mini program
(#9075)
---
src/core/util/env.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/util/env.js b/src/core/util/env.js
index 07cadd9cf9a..a79cb8d5333 100644
--- a/src/core/util/env.js
+++ b/src/core/util/env.js
@@ -41,7 +41,7 @@ export const isServerRendering = () => {
if (!inBrowser && !inWeex && typeof global !== 'undefined') {
// detect presence of vue-server-renderer and avoid
// Webpack shimming the process
- _isServer = global['process'].env.VUE_ENV === 'server'
+ _isServer = global['process'] && global['process'].env.VUE_ENV === 'server'
} else {
_isServer = false
}
From f43ae6d151de3ab00a5fbd1bb5fd3fabf454de85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julian=20R=C3=BCth?=
Date: Sat, 1 Dec 2018 05:58:58 +0100
Subject: [PATCH 026/553] chore(typo): fix typo (#9085)
---
types/options.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/types/options.d.ts b/types/options.d.ts
index 7d5861d1722..f6d92b97a16 100644
--- a/types/options.d.ts
+++ b/types/options.d.ts
@@ -68,7 +68,7 @@ export interface ComponentOptions<
el?: Element | string;
template?: string;
- // hack is for funcitonal component type inference, should not used in user code
+ // hack is for functional component type inference, should not be used in user code
render?(createElement: CreateElement, hack: RenderContext): VNode;
renderError?(createElement: CreateElement, err: Error): VNode;
staticRenderFns?: ((createElement: CreateElement) => VNode)[];
From 33e669b22f69a1f9c9147528360fe0bba85534f0 Mon Sep 17 00:00:00 2001
From: sqal
Date: Sat, 1 Dec 2018 06:05:13 +0100
Subject: [PATCH 027/553] fix(ssr): computed properties should pass vm as first
argument in ssr (#9090)
fix #8977
---
src/core/instance/state.js | 10 ++++++++--
test/ssr/ssr-string.spec.js | 18 ++++++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/core/instance/state.js b/src/core/instance/state.js
index 9fec53f6262..cc1401a3353 100644
--- a/src/core/instance/state.js
+++ b/src/core/instance/state.js
@@ -216,13 +216,13 @@ export function defineComputed (
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
- : userDef
+ : createGetterInvoker(userDef)
sharedPropertyDefinition.set = noop
} else {
sharedPropertyDefinition.get = userDef.get
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
- : userDef.get
+ : createGetterInvoker(userDef.get)
: noop
sharedPropertyDefinition.set = userDef.set || noop
}
@@ -253,6 +253,12 @@ function createComputedGetter (key) {
}
}
+function createGetterInvoker(fn) {
+ return function computedGetter () {
+ return fn.call(this, this)
+ }
+}
+
function initMethods (vm: Component, methods: Object) {
const props = vm.$options.props
for (const key in methods) {
diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js
index abf91526dd1..a84c7267e08 100644
--- a/test/ssr/ssr-string.spec.js
+++ b/test/ssr/ssr-string.spec.js
@@ -1076,6 +1076,24 @@ describe('SSR: renderToString', () => {
})
})
+ // #8977
+ it('should call computed properties with vm as first argument', done => {
+ renderToString(new Vue({
+ data: {
+ firstName: 'Evan',
+ lastName: 'You'
+ },
+ computed: {
+ fullName: ({ firstName, lastName }) => `${firstName} ${lastName}`,
+ },
+ template: '{{ fullName }}',
+ }), (err, result) => {
+ expect(err).toBeNull()
+ expect(result).toContain('Evan You')
+ done()
+ })
+ })
+
it('return Promise', done => {
renderToString(new Vue({
template: `{{ foo }}`,
From b111de486b1bdc747fe0f5795fe22697d151bb8c Mon Sep 17 00:00:00 2001
From: Mitar
Date: Fri, 30 Nov 2018 21:07:46 -0800
Subject: [PATCH 028/553] fix: make sure global state is restored in the case
of an exception in macrotask callback (#9093)
---
src/core/util/next-tick.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/core/util/next-tick.js b/src/core/util/next-tick.js
index 07a9e841843..cc066ed86f6 100644
--- a/src/core/util/next-tick.js
+++ b/src/core/util/next-tick.js
@@ -81,9 +81,11 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
export function withMacroTask (fn: Function): Function {
return fn._withTask || (fn._withTask = function () {
useMacroTask = true
- const res = fn.apply(null, arguments)
- useMacroTask = false
- return res
+ try {
+ return fn.apply(null, arguments)
+ } finally {
+ useMacroTask = false
+ }
})
}
From b0ccb8618382b6ee143d68cf4498d6b3ec18aa81 Mon Sep 17 00:00:00 2001
From: James George
Date: Sat, 1 Dec 2018 10:53:58 +0530
Subject: [PATCH 029/553] chore: rephrase comment (#9100)
---
types/vue.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/types/vue.d.ts b/types/vue.d.ts
index 39967963e8d..349c3432908 100644
--- a/types/vue.d.ts
+++ b/types/vue.d.ts
@@ -79,7 +79,7 @@ export interface VueConfiguration {
export interface VueConstructor {
new (options?: ThisTypedComponentOptionsWithArrayProps): CombinedVueInstance>;
- // ideally, the return type should just contains Props, not Record. But TS requires Base constructors must all have the same return type.
+ // ideally, the return type should just contain Props, not Record. But TS requires to have Base constructors with the same return type.
new (options?: ThisTypedComponentOptionsWithRecordProps): CombinedVueInstance>;
new (options?: ComponentOptions): CombinedVueInstance>;
From 0d62bb84ffa1af7a4826aecc11c429c7a020645c Mon Sep 17 00:00:00 2001
From: ysj16 <504427021@qq.com>
Date: Sat, 1 Dec 2018 13:24:30 +0800
Subject: [PATCH 030/553] fix: actually disable dep collection when invoking
lifecycle hooks (#9095)
fix #9046
---
src/core/observer/dep.js | 9 ++++----
.../instance/methods-lifecycle.spec.js | 21 +++++++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/core/observer/dep.js b/src/core/observer/dep.js
index 1dd37783490..d344aff9445 100644
--- a/src/core/observer/dep.js
+++ b/src/core/observer/dep.js
@@ -55,11 +55,12 @@ export default class Dep {
Dep.target = null
const targetStack = []
-export function pushTarget (_target: ?Watcher) {
- if (Dep.target) targetStack.push(Dep.target)
- Dep.target = _target
+export function pushTarget (target: ?Watcher) {
+ targetStack.push(target)
+ Dep.target = target
}
export function popTarget () {
- Dep.target = targetStack.pop()
+ targetStack.pop()
+ Dep.target = targetStack[targetStack.length - 1]
}
diff --git a/test/unit/features/instance/methods-lifecycle.spec.js b/test/unit/features/instance/methods-lifecycle.spec.js
index 71525be2f0b..1e424a5c9be 100644
--- a/test/unit/features/instance/methods-lifecycle.spec.js
+++ b/test/unit/features/instance/methods-lifecycle.spec.js
@@ -1,4 +1,5 @@
import Vue from 'vue'
+import Dep from 'core/observer/dep'
describe('Instance methods lifecycle', () => {
describe('$mount', () => {
@@ -32,6 +33,26 @@ describe('Instance methods lifecycle', () => {
expect(vm.$el.tagName).toBe('DIV')
expect(vm.$el.textContent).toBe('hi')
})
+
+ it('Dep.target should be undefined in lifecycle', () => {
+ const vm = new Vue({
+ template: ' ',
+ components: {
+ myComponent: {
+ template: 'hi',
+ mounted () {
+ const _msg = this.msg
+ expect(Dep.target).toBe(undefined)
+ },
+ computed: {
+ msg () {
+ return 1
+ }
+ }
+ }
+ }
+ }).$mount()
+ })
})
describe('$destroy', () => {
From 0b31647c41b0c916d40b962723b1de06672d0e01 Mon Sep 17 00:00:00 2001
From: Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com>
Date: Sat, 1 Dec 2018 08:29:37 +0300
Subject: [PATCH 031/553] chore: fix grammar in core/observer/index.js comments
(#9116)
---
src/core/observer/index.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/observer/index.js b/src/core/observer/index.js
index b9ef4b8a41a..545adb64025 100644
--- a/src/core/observer/index.js
+++ b/src/core/observer/index.js
@@ -37,7 +37,7 @@ export function toggleObserving (value: boolean) {
export class Observer {
value: any;
dep: Dep;
- vmCount: number; // number of vms that has this object as root $data
+ vmCount: number; // number of vms that have this object as root $data
constructor (value: any) {
this.value = value
@@ -57,7 +57,7 @@ export class Observer {
}
/**
- * Walk through each property and convert them into
+ * Walk through all properties and convert them into
* getter/setters. This method should only be called when
* value type is Object.
*/
@@ -81,7 +81,7 @@ export class Observer {
// helpers
/**
- * Augment an target Object or Array by intercepting
+ * Augment a target Object or Array by intercepting
* the prototype chain using __proto__
*/
function protoAugment (target, src: Object) {
@@ -91,7 +91,7 @@ function protoAugment (target, src: Object) {
}
/**
- * Augment an target Object or Array by defining
+ * Augment a target Object or Array by defining
* hidden properties.
*/
/* istanbul ignore next */
From ef8524ab7db8d64ac449ce74f5858aa9d91357ad Mon Sep 17 00:00:00 2001
From: Subhash
Date: Sat, 1 Dec 2018 11:03:59 +0530
Subject: [PATCH 032/553] fix(compiler): wrap scoped slots v-if conditions in
parens (#9119)
fix #9114
---
src/compiler/codegen/index.js | 2 +-
test/unit/modules/compiler/codegen.spec.js | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/compiler/codegen/index.js b/src/compiler/codegen/index.js
index f75d6300f66..d5b0aa09bd0 100644
--- a/src/compiler/codegen/index.js
+++ b/src/compiler/codegen/index.js
@@ -367,7 +367,7 @@ function genScopedSlot (
const fn = `function(${String(el.slotScope)}){` +
`return ${el.tag === 'template'
? el.if
- ? `${el.if}?${genChildren(el, state) || 'undefined'}:undefined`
+ ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
: genChildren(el, state) || 'undefined'
: genElement(el, state)
}}`
diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js
index 0758142ed27..57caa60ada1 100644
--- a/test/unit/modules/compiler/codegen.spec.js
+++ b/test/unit/modules/compiler/codegen.spec.js
@@ -208,6 +208,17 @@ describe('codegen', () => {
)
})
+ it('generate scoped slot with multiline v-if', () => {
+ assertCodegen(
+ '{{ bar }} ',
+ `with(this){return _c('foo',{scopedSlots:_u([{key:"default",fn:function(bar){return (\nshow\n)?[_v(_s(bar))]:undefined}}])})}`
+ )
+ assertCodegen(
+ '{{ bar }} ',
+ `with(this){return _c(\'foo\',{scopedSlots:_u([{key:"foo",fn:function(bar){return (\nshow\n)?_c(\'div\',{},[_v(_s(bar))]):_e()}}])})}`
+ )
+ })
+
it('generate class binding', () => {
// static
assertCodegen(
From 097f6229dffc34af452b106ad2a3b58845588807 Mon Sep 17 00:00:00 2001
From: Evan You
Date: Sat, 1 Dec 2018 17:05:36 -0500
Subject: [PATCH 033/553] fix(core): avoid mutating original children when
cloning vnode
The on-demand clone strategy introduced in 956756b mutates the owner
array of the cloned vnode. This causes the newly cloned vnode to be
destroyed when the parent node is destroyed. This is fixed by cloning
the children array when cloning a vnode.
fix #7975
---
src/core/vdom/vnode.js | 5 +-
.../features/component/component-slot.spec.js | 54 +++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/src/core/vdom/vnode.js b/src/core/vdom/vnode.js
index 0e3e2e9e635..bdc17e9f974 100644
--- a/src/core/vdom/vnode.js
+++ b/src/core/vdom/vnode.js
@@ -90,7 +90,10 @@ export function cloneVNode (vnode: VNode): VNode {
const cloned = new VNode(
vnode.tag,
vnode.data,
- vnode.children,
+ // #7975
+ // clone children array to avoid mutating original in case of cloning
+ // a child.
+ vnode.children && vnode.children.slice(),
vnode.text,
vnode.elm,
vnode.context,
diff --git a/test/unit/features/component/component-slot.spec.js b/test/unit/features/component/component-slot.spec.js
index e667a46ef89..75b5254601c 100644
--- a/test/unit/features/component/component-slot.spec.js
+++ b/test/unit/features/component/component-slot.spec.js
@@ -886,4 +886,58 @@ describe('Component slot', () => {
expect(vm.$el.textContent).toBe('foo')
}).then(done)
})
+
+ // #7975
+ it('should update named slot correctly when its position in the tree changed', done => {
+ const ChildComponent = {
+ template: '{{ message }}',
+ props: ['message']
+ }
+ let parentVm
+ const ParentComponent = {
+ template: `
+
+
+
+
+
+
+
+
+ `,
+ data () {
+ return {
+ alter: true
+ }
+ },
+ mounted () {
+ parentVm = this
+ }
+ }
+ const vm = new Vue({
+ template: `
+
+
+
+
+
+ `,
+ components: {
+ ChildComponent,
+ ParentComponent
+ },
+ data () {
+ return {
+ message: 1
+ }
+ }
+ }).$mount()
+ expect(vm.$el.firstChild.innerHTML).toBe('1')
+ parentVm.alter = false
+ waitForUpdate(() => {
+ vm.message = 2
+ }).then(() => {
+ expect(vm.$el.firstChild.innerHTML).toBe('2')
+ }).then(done)
+ })
})
From 530ca1b2db315fbd0e360807b2031d26665c5d3d Mon Sep 17 00:00:00 2001
From: Evan You
Date: Sat, 1 Dec 2018 21:07:18 -0500
Subject: [PATCH 034/553] fix(core): properly handle reused vnodes
This also removes the restrictions on rendering the same slot multiple
times.
close #7913
---
.../instance/render-helpers/render-slot.js | 14 +---
src/core/instance/render.js | 8 ---
src/core/vdom/patch.js | 26 +++++--
.../features/component/component-slot.spec.js | 70 ++++++++++---------
4 files changed, 56 insertions(+), 62 deletions(-)
diff --git a/src/core/instance/render-helpers/render-slot.js b/src/core/instance/render-helpers/render-slot.js
index a58daa74e62..52221f4bbc8 100644
--- a/src/core/instance/render-helpers/render-slot.js
+++ b/src/core/instance/render-helpers/render-slot.js
@@ -26,19 +26,7 @@ export function renderSlot (
}
nodes = scopedSlotFn(props) || fallback
} else {
- const slotNodes = this.$slots[name]
- // warn duplicate slot usage
- if (slotNodes) {
- if (process.env.NODE_ENV !== 'production' && slotNodes._rendered) {
- warn(
- `Duplicate presence of slot "${name}" found in the same render tree ` +
- `- this will likely cause render errors.`,
- this
- )
- }
- slotNodes._rendered = true
- }
- nodes = slotNodes || fallback
+ nodes = this.$slots[name] || fallback
}
const target = props && props.slot
diff --git a/src/core/instance/render.js b/src/core/instance/render.js
index be12d726034..def4be6db68 100644
--- a/src/core/instance/render.js
+++ b/src/core/instance/render.js
@@ -62,14 +62,6 @@ export function renderMixin (Vue: Class) {
const vm: Component = this
const { render, _parentVnode } = vm.$options
- // reset _rendered flag on slots for duplicate slot check
- if (process.env.NODE_ENV !== 'production') {
- for (const key in vm.$slots) {
- // $flow-disable-line
- vm.$slots[key]._rendered = false
- }
- }
-
if (_parentVnode) {
vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject
}
diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js
index 8857294b8f7..7e58bced6ac 100644
--- a/src/core/vdom/patch.js
+++ b/src/core/vdom/patch.js
@@ -434,20 +434,20 @@ export function createPatchFunction (backend) {
} else if (isUndef(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx]
} else if (sameVnode(oldStartVnode, newStartVnode)) {
- patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue)
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx)
oldStartVnode = oldCh[++oldStartIdx]
newStartVnode = newCh[++newStartIdx]
} else if (sameVnode(oldEndVnode, newEndVnode)) {
- patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue)
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx)
oldEndVnode = oldCh[--oldEndIdx]
newEndVnode = newCh[--newEndIdx]
} else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
- patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue)
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx)
canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm))
oldStartVnode = oldCh[++oldStartIdx]
newEndVnode = newCh[--newEndIdx]
} else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
- patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue)
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx)
canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm)
oldEndVnode = oldCh[--oldEndIdx]
newStartVnode = newCh[++newStartIdx]
@@ -461,7 +461,7 @@ export function createPatchFunction (backend) {
} else {
vnodeToMove = oldCh[idxInOld]
if (sameVnode(vnodeToMove, newStartVnode)) {
- patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue)
+ patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx)
oldCh[idxInOld] = undefined
canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm)
} else {
@@ -505,11 +505,23 @@ export function createPatchFunction (backend) {
}
}
- function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
+ function patchVnode (
+ oldVnode,
+ vnode,
+ insertedVnodeQueue,
+ ownerArray,
+ index,
+ removeOnly
+ ) {
if (oldVnode === vnode) {
return
}
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
+ // clone reused vnode
+ vnode = ownerArray[index] = cloneVNode(vnode)
+ }
+
const elm = vnode.elm = oldVnode.elm
if (isTrue(oldVnode.isAsyncPlaceholder)) {
@@ -709,7 +721,7 @@ export function createPatchFunction (backend) {
const isRealElement = isDef(oldVnode.nodeType)
if (!isRealElement && sameVnode(oldVnode, vnode)) {
// patch existing root node
- patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly)
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly)
} else {
if (isRealElement) {
// mounting to a real element
diff --git a/test/unit/features/component/component-slot.spec.js b/test/unit/features/component/component-slot.spec.js
index 75b5254601c..28dafad437a 100644
--- a/test/unit/features/component/component-slot.spec.js
+++ b/test/unit/features/component/component-slot.spec.js
@@ -482,44 +482,46 @@ describe('Component slot', () => {
}).then(done)
})
- it('warn duplicate slots', () => {
- new Vue({
- template: `
-
- foo
- bar
-
- `,
- components: {
- test: {
- template: `
-
-
- `
- }
- }
- }).$mount()
- expect('Duplicate presence of slot "default"').toHaveBeenWarned()
- expect('Duplicate presence of slot "a"').toHaveBeenWarned()
- })
-
- it('should not warn valid conditional slots', () => {
- new Vue({
- template: `
-
- foo
-
- `,
+ it('should support duplicate slots', done => {
+ const vm = new Vue({
+ template: `
+
+ {{ n }}
+
+ `,
+ data: {
+ n: 1
+ },
components: {
- test: {
- template: `
-
-
- `
+ foo: {
+ data() {
+ return { ok: true }
+ },
+ template: `
+
+
+
+
+
+ `
}
}
}).$mount()
- expect('Duplicate presence of slot "default"').not.toHaveBeenWarned()
+ expect(vm.$el.innerHTML).toBe(`1 1 1
`)
+ vm.n++
+ waitForUpdate(() => {
+ expect(vm.$el.innerHTML).toBe(`2 2 2
`)
+ vm.n++
+ }).then(() => {
+ expect(vm.$el.innerHTML).toBe(`3 3 3
`)
+ vm.$refs.foo.ok = false
+ }).then(() => {
+ expect(vm.$el.innerHTML).toBe(`3 3
`)
+ vm.n++
+ vm.$refs.foo.ok = true
+ }).then(() => {
+ expect(vm.$el.innerHTML).toBe(`4 4 4
`)
+ }).then(done)
})
// #3518
From 19c33a7e4072b03069f803263ed0c49feb5f73a9 Mon Sep 17 00:00:00 2001
From: laoxiong
Date: Mon, 3 Dec 2018 00:32:59 +0800
Subject: [PATCH 035/553] fix(v-on): correctly remove once listener (#8036)
fix #8032
---
src/core/instance/events.js | 20 ++++++++++-----
src/core/vdom/helpers/update-listeners.js | 14 ++++++++--
src/platforms/web/runtime/modules/events.js | 6 ++---
src/platforms/weex/runtime/modules/events.js | 25 ++++++++----------
test/unit/features/directives/on.spec.js | 27 ++++++++++++++++++++
5 files changed, 65 insertions(+), 27 deletions(-)
diff --git a/src/core/instance/events.js b/src/core/instance/events.js
index dbf45633eae..8225bdecb8e 100644
--- a/src/core/instance/events.js
+++ b/src/core/instance/events.js
@@ -21,25 +21,31 @@ export function initEvents (vm: Component) {
let target: any
-function add (event, fn, once) {
- if (once) {
- target.$once(event, fn)
- } else {
- target.$on(event, fn)
- }
+function add (event, fn) {
+ target.$on(event, fn)
}
function remove (event, fn) {
target.$off(event, fn)
}
+function createOnceHandler (event, fn) {
+ const _target = target
+ return function onceHandler () {
+ const res = fn.apply(null, arguments)
+ if (res !== null) {
+ _target.$off(event, onceHandler)
+ }
+ }
+}
+
export function updateComponentListeners (
vm: Component,
listeners: Object,
oldListeners: ?Object
) {
target = vm
- updateListeners(listeners, oldListeners || {}, add, remove, vm)
+ updateListeners(listeners, oldListeners || {}, add, remove, createOnceHandler, vm)
target = undefined
}
diff --git a/src/core/vdom/helpers/update-listeners.js b/src/core/vdom/helpers/update-listeners.js
index 11c5a2cd2f8..df58727f12b 100644
--- a/src/core/vdom/helpers/update-listeners.js
+++ b/src/core/vdom/helpers/update-listeners.js
@@ -1,7 +1,13 @@
/* @flow */
import { warn } from 'core/util/index'
-import { cached, isUndef, isPlainObject } from 'shared/util'
+
+import {
+ cached,
+ isUndef,
+ isTrue,
+ isPlainObject
+} from 'shared/util'
const normalizeEvent = cached((name: string): {
name: string,
@@ -47,6 +53,7 @@ export function updateListeners (
oldOn: Object,
add: Function,
remove: Function,
+ createOnceHandler: Function,
vm: Component
) {
let name, def, cur, old, event
@@ -68,7 +75,10 @@ export function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur)
}
- add(event.name, cur, event.once, event.capture, event.passive, event.params)
+ if (isTrue(event.once)) {
+ cur = on[name] = createOnceHandler(event.name, cur, event.capture)
+ }
+ add(event.name, cur, event.capture, event.passive, event.params)
} else if (cur !== old) {
old.fns = cur
on[name] = old
diff --git a/src/platforms/web/runtime/modules/events.js b/src/platforms/web/runtime/modules/events.js
index 1e71b667286..e89a38d82c9 100644
--- a/src/platforms/web/runtime/modules/events.js
+++ b/src/platforms/web/runtime/modules/events.js
@@ -28,7 +28,7 @@ function normalizeEvents (on) {
let target: any
-function createOnceHandler (handler, event, capture) {
+function createOnceHandler (event, handler, capture) {
const _target = target // save current target element in closure
return function onceHandler () {
const res = handler.apply(null, arguments)
@@ -41,12 +41,10 @@ function createOnceHandler (handler, event, capture) {
function add (
event: string,
handler: Function,
- once: boolean,
capture: boolean,
passive: boolean
) {
handler = withMacroTask(handler)
- if (once) handler = createOnceHandler(handler, event, capture)
target.addEventListener(
event,
handler,
@@ -77,7 +75,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
const oldOn = oldVnode.data.on || {}
target = vnode.elm
normalizeEvents(on)
- updateListeners(on, oldOn, add, remove, vnode.context)
+ updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context)
target = undefined
}
diff --git a/src/platforms/weex/runtime/modules/events.js b/src/platforms/weex/runtime/modules/events.js
index a3f9e25a0ac..c34719483a8 100755
--- a/src/platforms/weex/runtime/modules/events.js
+++ b/src/platforms/weex/runtime/modules/events.js
@@ -4,10 +4,19 @@ import { updateListeners } from 'core/vdom/helpers/update-listeners'
let target: any
+function createOnceHandler (event, handler, capture) {
+ const _target = target // save current target element in closure
+ return function onceHandler () {
+ const res = handler.apply(null, arguments)
+ if (res !== null) {
+ remove(event, onceHandler, capture, _target)
+ }
+ }
+}
+
function add (
event: string,
handler: Function,
- once: boolean,
capture: boolean,
passive?: boolean,
params?: Array
@@ -16,18 +25,6 @@ function add (
console.log('Weex do not support event in bubble phase.')
return
}
- if (once) {
- const oldHandler = handler
- const _target = target // save current target element in closure
- handler = function (ev) {
- const res = arguments.length === 1
- ? oldHandler(ev)
- : oldHandler.apply(null, arguments)
- if (res !== null) {
- remove(event, null, null, _target)
- }
- }
- }
target.addEvent(event, handler, params)
}
@@ -47,7 +44,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
const on = vnode.data.on || {}
const oldOn = oldVnode.data.on || {}
target = vnode.elm
- updateListeners(on, oldOn, add, remove, vnode.context)
+ updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context)
target = undefined
}
diff --git a/test/unit/features/directives/on.spec.js b/test/unit/features/directives/on.spec.js
index 3973c41cb26..807ad5777c8 100644
--- a/test/unit/features/directives/on.spec.js
+++ b/test/unit/features/directives/on.spec.js
@@ -895,4 +895,31 @@ describe('Directive v-on', () => {
}).$mount()
expect(`v-on without argument expects an Object value`).toHaveBeenWarned()
})
+
+ it('should correctly remove once listener', done => {
+ const vm = new Vue({
+ template: `
+
+
+ a
+
+
+ b
+
+
+ `,
+ data: {
+ ok: true
+ },
+ methods: {
+ foo: spy
+ }
+ }).$mount()
+
+ vm.ok = false
+ waitForUpdate(() => {
+ triggerEvent(vm.$el.childNodes[0], 'click')
+ expect(spy.calls.count()).toBe(0)
+ }).then(done)
+ })
})
From e4b1b57fd7117a19cdb376dcb156606e0cc32a94 Mon Sep 17 00:00:00 2001
From: Evan You
Date: Sun, 2 Dec 2018 12:31:16 -0500
Subject: [PATCH 036/553] fix(ssr): adjust call stack size defer threshold
fix #8545
---
src/server/render-context.js | 91 ++++++++++++++++++------------------
src/server/write.js | 2 +-
2 files changed, 46 insertions(+), 47 deletions(-)
diff --git a/src/server/render-context.js b/src/server/render-context.js
index b23cbd0fd64..3da91d0abca 100644
--- a/src/server/render-context.js
+++ b/src/server/render-context.js
@@ -66,55 +66,54 @@ export class RenderContext {
}
next () {
- const lastState = this.renderStates[this.renderStates.length - 1]
- if (isUndef(lastState)) {
- return this.done()
- }
- /* eslint-disable no-case-declarations */
- switch (lastState.type) {
- case 'Element':
- case 'Fragment':
- const { children, total } = lastState
- const rendered = lastState.rendered++
- if (rendered < total) {
- this.renderNode(children[rendered], false, this)
- } else {
+ // eslint-disable-next-line
+ while (true) {
+ const lastState = this.renderStates[this.renderStates.length - 1]
+ if (isUndef(lastState)) {
+ return this.done()
+ }
+ /* eslint-disable no-case-declarations */
+ switch (lastState.type) {
+ case 'Element':
+ case 'Fragment':
+ const { children, total } = lastState
+ const rendered = lastState.rendered++
+ if (rendered < total) {
+ return this.renderNode(children[rendered], false, this)
+ } else {
+ this.renderStates.pop()
+ if (lastState.type === 'Element') {
+ return this.write(lastState.endTag, this.next)
+ }
+ }
+ break
+ case 'Component':
this.renderStates.pop()
- if (lastState.type === 'Element') {
- this.write(lastState.endTag, this.next)
+ this.activeInstance = lastState.prevActive
+ break
+ case 'ComponentWithCache':
+ this.renderStates.pop()
+ const { buffer, bufferIndex, componentBuffer, key } = lastState
+ const result = {
+ html: buffer[bufferIndex],
+ components: componentBuffer[bufferIndex]
+ }
+ this.cache.set(key, result)
+ if (bufferIndex === 0) {
+ // this is a top-level cached component,
+ // exit caching mode.
+ this.write.caching = false
} else {
- this.next()
+ // parent component is also being cached,
+ // merge self into parent's result
+ buffer[bufferIndex - 1] += result.html
+ const prev = componentBuffer[bufferIndex - 1]
+ result.components.forEach(c => prev.add(c))
}
- }
- break
- case 'Component':
- this.renderStates.pop()
- this.activeInstance = lastState.prevActive
- this.next()
- break
- case 'ComponentWithCache':
- this.renderStates.pop()
- const { buffer, bufferIndex, componentBuffer, key } = lastState
- const result = {
- html: buffer[bufferIndex],
- components: componentBuffer[bufferIndex]
- }
- this.cache.set(key, result)
- if (bufferIndex === 0) {
- // this is a top-level cached component,
- // exit caching mode.
- this.write.caching = false
- } else {
- // parent component is also being cached,
- // merge self into parent's result
- buffer[bufferIndex - 1] += result.html
- const prev = componentBuffer[bufferIndex - 1]
- result.components.forEach(c => prev.add(c))
- }
- buffer.length = bufferIndex
- componentBuffer.length = bufferIndex
- this.next()
- break
+ buffer.length = bufferIndex
+ componentBuffer.length = bufferIndex
+ break
+ }
}
}
}
diff --git a/src/server/write.js b/src/server/write.js
index e642081852c..9d81d2a8e04 100644
--- a/src/server/write.js
+++ b/src/server/write.js
@@ -1,6 +1,6 @@
/* @flow */
-const MAX_STACK_DEPTH = 1000
+const MAX_STACK_DEPTH = 900
const noop = _ => _
const defer = typeof process !== 'undefined' && process.nextTick
From aca17b4064bf5017506d77e9f5bf286cfe926ae1 Mon Sep 17 00:00:00 2001
From: Haoqun Jiang
Date: Mon, 3 Dec 2018 05:00:06 +0800
Subject: [PATCH 037/553] ci: add regression test for popular libraries in
Vue.js ecosystem (#8608)
---
.circleci/config.yml | 49 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 064192b36d6..ab8973c4acf 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -62,6 +62,16 @@ jobs:
- run: npm run test:ssr
- run: npm run test:weex
+ trigger-regression-test:
+ <<: *defaults
+ steps:
+ - run:
+ command: |
+ curl --user ${CIRCLE_TOKEN}: \
+ --data build_parameters[CIRCLE_JOB]=update \
+ --data build_parameters[VUE_REVISION]=${CIRCLE_SHA1} \
+ https://circleci.com/api/v1.1/project/github/vuejs/regression-testing/tree/master
+
workflows:
version: 2
install-and-parallel-test:
@@ -79,3 +89,42 @@ workflows:
- test-ssr-weex:
requires:
- install
+ - trigger-regression-test:
+ filters:
+ branches:
+ only:
+ - regression-test
+ requires:
+ - test-cover
+ - lint-flow-types
+ - test-e2e
+ - test-ssr-weex
+ weekly_regression_test:
+ triggers:
+ - schedule:
+ # At 13:00 UTC (9:00 EDT) on every Monday
+ cron: "0 13 * * 1"
+ filters:
+ branches:
+ only:
+ dev
+ jobs:
+ - install
+ - test-cover:
+ requires:
+ - install
+ - lint-flow-types:
+ requires:
+ - install
+ - test-e2e:
+ requires:
+ - install
+ - test-ssr-weex:
+ requires:
+ - install
+ - trigger-regression-test:
+ requires:
+ - test-cover
+ - lint-flow-types
+ - test-e2e
+ - test-ssr-weex
From 307835284a326569ea12c4a22c7dcb8f36d2d8ca Mon Sep 17 00:00:00 2001
From: ggtmtmgg
Date: Mon, 3 Dec 2018 06:01:19 +0900
Subject: [PATCH 038/553] fix(ssr): resolve server directives the same as on
client (#9129)
fix #8961
---
src/server/render.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/server/render.js b/src/server/render.js
index 592a6175c5f..965b64febbb 100644
--- a/src/server/render.js
+++ b/src/server/render.js
@@ -3,6 +3,7 @@
import { escape } from 'web/server/util'
import { SSR_ATTR } from 'shared/constants'
import { RenderContext } from './render-context'
+import { resolveAsset } from 'core/util/options'
import { generateComponentTrace } from 'core/util/debug'
import { ssrCompileToFunctions } from 'web/server/compiler'
import { installSSRHelpers } from './optimizing-compiler/runtime-helpers'
@@ -324,11 +325,13 @@ function renderStartingTag (node: VNode, context) {
if (dirs) {
for (let i = 0; i < dirs.length; i++) {
const name = dirs[i].name
- const dirRenderer = directives[name]
- if (dirRenderer && name !== 'show') {
- // directives mutate the node's data
- // which then gets rendered by modules
- dirRenderer(node, dirs[i])
+ if (name !== 'show') {
+ const dirRenderer = resolveAsset(context, 'directives', name, true)
+ if (dirRenderer) {
+ // directives mutate the node's data
+ // which then gets rendered by modules
+ dirRenderer(node, dirs[i])
+ }
}
}
}
From fe194dd5d812249bed5c15ad1d16551599b029dd Mon Sep 17 00:00:00 2001
From: Evan You
Date: Sun, 2 Dec 2018 16:12:52 -0500
Subject: [PATCH 039/553] build: build v2.5.18-beta.0
---
dist/vue.common.js | 889 +-
dist/vue.esm.js | 889 +-
dist/vue.js | 19573 ++++++++--------
dist/vue.min.js | 4 +-
dist/vue.runtime.common.js | 757 +-
dist/vue.runtime.esm.js | 757 +-
dist/vue.runtime.js | 13947 +++++------
dist/vue.runtime.min.js | 4 +-
packages/vue-server-renderer/basic.js | 14621 ++++++------
packages/vue-server-renderer/build.js | 793 +-
packages/vue-server-renderer/client-plugin.js | 28 +-
packages/vue-server-renderer/package.json | 2 +-
packages/vue-server-renderer/server-plugin.js | 14 +-
packages/vue-template-compiler/browser.js | 9574 ++++----
packages/vue-template-compiler/build.js | 426 +-
packages/vue-template-compiler/package.json | 2 +-
16 files changed, 31255 insertions(+), 31025 deletions(-)
diff --git a/dist/vue.common.js b/dist/vue.common.js
index 0b8d12d2e5e..c0203d1b635 100644
--- a/dist/vue.common.js
+++ b/dist/vue.common.js
@@ -1,5 +1,5 @@
/*!
- * Vue.js v2.5.17-beta.0
+ * Vue.js v2.5.18-beta.0
* (c) 2014-2018 Evan You
* Released under the MIT License.
*/
@@ -9,8 +9,8 @@
var emptyObject = Object.freeze({});
-// these helpers produces better vm code in JS engines due to their
-// explicitness and function inlining
+// These helpers produce better VM code in JS engines due to their
+// explicitness and function inlining.
function isUndef (v) {
return v === undefined || v === null
}
@@ -28,7 +28,7 @@ function isFalse (v) {
}
/**
- * Check if value is primitive
+ * Check if value is primitive.
*/
function isPrimitive (value) {
return (
@@ -50,7 +50,7 @@ function isObject (obj) {
}
/**
- * Get the raw type string of a value e.g. [object Object]
+ * Get the raw type string of a value, e.g., [object Object].
*/
var _toString = Object.prototype.toString;
@@ -90,7 +90,7 @@ function toString (val) {
}
/**
- * Convert a input value to a number for persistence.
+ * Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
function toNumber (val) {
@@ -122,12 +122,12 @@ function makeMap (
var isBuiltInTag = makeMap('slot,component', true);
/**
- * Check if a attribute is a reserved attribute.
+ * Check if an attribute is a reserved attribute.
*/
var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
/**
- * Remove an item from an array
+ * Remove an item from an array.
*/
function remove (arr, item) {
if (arr.length) {
@@ -139,7 +139,7 @@ function remove (arr, item) {
}
/**
- * Check whether the object has the property.
+ * Check whether an object has the property.
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
@@ -181,11 +181,11 @@ var hyphenate = cached(function (str) {
});
/**
- * Simple bind polyfill for environments that do not support it... e.g.
- * PhantomJS 1.x. Technically we don't need this anymore since native bind is
- * now more performant in most browsers, but removing it would be breaking for
- * code that was able to run in PhantomJS 1.x, so this must be kept for
- * backwards compatibility.
+ * Simple bind polyfill for environments that do not support it,
+ * e.g., PhantomJS 1.x. Technically, we don't need this anymore
+ * since native bind is now performant enough in most browsers.
+ * But removing it would mean breaking code that was able to run in
+ * PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/* istanbul ignore next */
@@ -247,10 +247,12 @@ function toObject (arr) {
return res
}
+/* eslint-disable no-unused-vars */
+
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
- * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
+ * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
function noop (a, b, c) {}
@@ -259,13 +261,15 @@ function noop (a, b, c) {}
*/
var no = function (a, b, c) { return false; };
+/* eslint-enable no-unused-vars */
+
/**
- * Return same value
+ * Return the same value.
*/
var identity = function (_) { return _; };
/**
- * Generate a static keys string from compiler modules.
+ * Generate a string containing static keys from compiler modules.
*/
function genStaticKeys (modules) {
return modules.reduce(function (keys, m) {
@@ -289,6 +293,8 @@ function looseEqual (a, b) {
return a.length === b.length && a.every(function (e, i) {
return looseEqual(e, b[i])
})
+ } else if (a instanceof Date && b instanceof Date) {
+ return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) {
var keysA = Object.keys(a);
var keysB = Object.keys(b);
@@ -310,6 +316,11 @@ function looseEqual (a, b) {
}
}
+/**
+ * Return the first index at which a loosely equal value can be
+ * found in the array (if value is a plain object, the array must
+ * contain an object of the same shape), or -1 if it is not present.
+ */
function looseIndexOf (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val)) { return i }
@@ -354,6 +365,8 @@ var LIFECYCLE_HOOKS = [
/* */
+
+
var config = ({
/**
* Option merge strategies (used in core/util/options)
@@ -436,11 +449,17 @@ var config = ({
*/
mustUseProp: no,
+ /**
+ * Perform updates asynchronously. Intended to be used by Vue Test Utils
+ * This will significantly reduce performance if set to false.
+ */
+ async: true,
+
/**
* Exposed for legacy reasons
*/
_lifecycleHooks: LIFECYCLE_HOOKS
-})
+});
/* */
@@ -525,7 +544,7 @@ var isServerRendering = function () {
if (!inBrowser && !inWeex && typeof global !== 'undefined') {
// detect presence of vue-server-renderer and avoid
// Webpack shimming the process
- _isServer = global['process'].env.VUE_ENV === 'server';
+ _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
} else {
_isServer = false;
}
@@ -552,7 +571,7 @@ if (typeof Set !== 'undefined' && isNative(Set)) {
_Set = Set;
} else {
// a non-standard Set polyfill that only works with primitive keys.
- _Set = (function () {
+ _Set = /*@__PURE__*/(function () {
function Set () {
this.set = Object.create(null);
}
@@ -666,7 +685,6 @@ if (process.env.NODE_ENV !== 'production') {
/* */
-
var uid = 0;
/**
@@ -695,6 +713,12 @@ Dep.prototype.depend = function depend () {
Dep.prototype.notify = function notify () {
// stabilize the subscriber list first
var subs = this.subs.slice();
+ if (process.env.NODE_ENV !== 'production' && !config.async) {
+ // subs aren't sorted in scheduler if not running async
+ // we need to sort them now to make sure they fire in correct
+ // order
+ subs.sort(function (a, b) { return a.id - b.id; });
+ }
for (var i = 0, l = subs.length; i < l; i++) {
subs[i].update();
}
@@ -706,13 +730,14 @@ Dep.prototype.notify = function notify () {
Dep.target = null;
var targetStack = [];
-function pushTarget (_target) {
- if (Dep.target) { targetStack.push(Dep.target); }
- Dep.target = _target;
+function pushTarget (target) {
+ targetStack.push(target);
+ Dep.target = target;
}
function popTarget () {
- Dep.target = targetStack.pop();
+ targetStack.pop();
+ Dep.target = targetStack[targetStack.length - 1];
}
/* */
@@ -783,7 +808,10 @@ function cloneVNode (vnode) {
var cloned = new VNode(
vnode.tag,
vnode.data,
- vnode.children,
+ // #7975
+ // clone children array to avoid mutating original in case of cloning
+ // a child.
+ vnode.children && vnode.children.slice(),
vnode.text,
vnode.elm,
vnode.context,
@@ -875,10 +903,11 @@ var Observer = function Observer (value) {
this.vmCount = 0;
def(value, '__ob__', this);
if (Array.isArray(value)) {
- var augment = hasProto
- ? protoAugment
- : copyAugment;
- augment(value, arrayMethods, arrayKeys);
+ if (hasProto) {
+ protoAugment(value, arrayMethods);
+ } else {
+ copyAugment(value, arrayMethods, arrayKeys);
+ }
this.observeArray(value);
} else {
this.walk(value);
@@ -886,14 +915,14 @@ var Observer = function Observer (value) {
};
/**
- * Walk through each property and convert them into
+ * Walk through all properties and convert them into
* getter/setters. This method should only be called when
* value type is Object.
*/
Observer.prototype.walk = function walk (obj) {
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
- defineReactive(obj, keys[i]);
+ defineReactive$$1(obj, keys[i]);
}
};
@@ -909,17 +938,17 @@ Observer.prototype.observeArray = function observeArray (items) {
// helpers
/**
- * Augment an target Object or Array by intercepting
+ * Augment a target Object or Array by intercepting
* the prototype chain using __proto__
*/
-function protoAugment (target, src, keys) {
+function protoAugment (target, src) {
/* eslint-disable no-proto */
target.__proto__ = src;
/* eslint-enable no-proto */
}
/**
- * Augment an target Object or Array by defining
+ * Augment a target Object or Array by defining
* hidden properties.
*/
/* istanbul ignore next */
@@ -960,7 +989,7 @@ function observe (value, asRootData) {
/**
* Define a reactive property on an Object.
*/
-function defineReactive (
+function defineReactive$$1 (
obj,
key,
val,
@@ -1008,6 +1037,8 @@ function defineReactive (
if (process.env.NODE_ENV !== 'production' && customSetter) {
customSetter();
}
+ // #7981: for accessor properties without setter
+ if (getter && !setter) { return }
if (setter) {
setter.call(obj, newVal);
} else {
@@ -1051,7 +1082,7 @@ function set (target, key, val) {
target[key] = val;
return val
}
- defineReactive(ob.value, key, val);
+ defineReactive$$1(ob.value, key, val);
ob.dep.notify();
return val
}
@@ -1138,7 +1169,11 @@ function mergeData (to, from) {
fromVal = from[key];
if (!hasOwn(to, key)) {
set(to, key, fromVal);
- } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
+ } else if (
+ toVal !== fromVal &&
+ isPlainObject(toVal) &&
+ isPlainObject(fromVal)
+ ) {
mergeData(toVal, fromVal);
}
}
@@ -1461,15 +1496,22 @@ function mergeOptions (
normalizeProps(child, vm);
normalizeInject(child, vm);
normalizeDirectives(child);
- var extendsFrom = child.extends;
- if (extendsFrom) {
- parent = mergeOptions(parent, extendsFrom, vm);
- }
- if (child.mixins) {
- for (var i = 0, l = child.mixins.length; i < l; i++) {
- parent = mergeOptions(parent, child.mixins[i], vm);
+
+ // Apply extends and mixins on the child options,
+ // but only if it is a raw options object that isn't
+ // the result of another mergeOptions call.
+ // Only merged options has the _base property.
+ if (!child._base) {
+ if (child.extends) {
+ parent = mergeOptions(parent, child.extends, vm);
+ }
+ if (child.mixins) {
+ for (var i = 0, l = child.mixins.length; i < l; i++) {
+ parent = mergeOptions(parent, child.mixins[i], vm);
+ }
}
}
+
var options = {};
var key;
for (key in parent) {
@@ -1522,6 +1564,8 @@ function resolveAsset (
/* */
+
+
function validateProp (
key,
propOptions,
@@ -1558,7 +1602,7 @@ function validateProp (
if (
process.env.NODE_ENV !== 'production' &&
// skip validation for weex recycle-list child component props
- !(false && isObject(value) && ('@binding' in value))
+ !(false)
) {
assertProp(prop, key, value, vm, absent);
}
@@ -1631,11 +1675,10 @@ function assertProp (
valid = assertedType.valid;
}
}
+
if (!valid) {
warn(
- "Invalid prop: type check failed for prop \"" + name + "\"." +
- " Expected " + (expectedTypes.map(capitalize).join(', ')) +
- ", got " + (toRawType(value)) + ".",
+ getInvalidTypeMessage(name, value, expectedTypes),
vm
);
return
@@ -1702,6 +1745,49 @@ function getTypeIndex (type, expectedTypes) {
return -1
}
+function getInvalidTypeMessage (name, value, expectedTypes) {
+ var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
+ " Expected " + (expectedTypes.map(capitalize).join(', '));
+ var expectedType = expectedTypes[0];
+ var receivedType = toRawType(value);
+ var expectedValue = styleValue(value, expectedType);
+ var receivedValue = styleValue(value, receivedType);
+ // check if we need to specify expected value
+ if (expectedTypes.length === 1 &&
+ isExplicable(expectedType) &&
+ !isBoolean(expectedType, receivedType)) {
+ message += " with value " + expectedValue;
+ }
+ message += ", got " + receivedType + " ";
+ // check if we need to specify received value
+ if (isExplicable(receivedType)) {
+ message += "with value " + receivedValue + ".";
+ }
+ return message
+}
+
+function styleValue (value, type) {
+ if (type === 'String') {
+ return ("\"" + value + "\"")
+ } else if (type === 'Number') {
+ return ("" + (Number(value)))
+ } else {
+ return ("" + value)
+ }
+}
+
+function isExplicable (value) {
+ var explicitTypes = ['string', 'number', 'boolean'];
+ return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
+}
+
+function isBoolean () {
+ var args = [], len = arguments.length;
+ while ( len-- ) args[ len ] = arguments[ len ];
+
+ return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
+}
+
/* */
function handleError (err, vm, info) {
@@ -1748,7 +1834,6 @@ function logError (err, vm, info) {
}
/* */
-/* globals MessageChannel */
var callbacks = [];
var pending = false;
@@ -1826,9 +1911,11 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
function withMacroTask (fn) {
return fn._withTask || (fn._withTask = function () {
useMacroTask = true;
- var res = fn.apply(null, arguments);
- useMacroTask = false;
- return res
+ try {
+ return fn.apply(null, arguments)
+ } finally {
+ useMacroTask = false;
+ }
})
}
@@ -1909,6 +1996,16 @@ if (process.env.NODE_ENV !== 'production') {
);
};
+ var warnReservedPrefix = function (target, key) {
+ warn(
+ "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
+ 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
+ 'prevent conflicts with Vue internals' +
+ 'See: https://vuejs.org/v2/api/#data',
+ target
+ );
+ };
+
var hasProxy =
typeof Proxy !== 'undefined' && isNative(Proxy);
@@ -1930,9 +2027,11 @@ if (process.env.NODE_ENV !== 'production') {
var hasHandler = {
has: function has (target, key) {
var has = key in target;
- var isAllowed = allowedGlobals(key) || (typeof key === 'string' && key.charAt(0) === '_');
+ var isAllowed = allowedGlobals(key) ||
+ (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
if (!has && !isAllowed) {
- warnNonPresent(target, key);
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
}
return has || !isAllowed
}
@@ -1941,7 +2040,8 @@ if (process.env.NODE_ENV !== 'production') {
var getHandler = {
get: function get (target, key) {
if (typeof key === 'string' && !(key in target)) {
- warnNonPresent(target, key);
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
}
return target[key]
}
@@ -2039,14 +2139,14 @@ function updateListeners (
oldOn,
add,
remove$$1,
+ createOnceHandler,
vm
) {
- var name, def, cur, old, event;
+ var name, def$$1, cur, old, event;
for (name in on) {
- def = cur = on[name];
+ def$$1 = cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
- /* istanbul ignore if */
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@@ -2056,7 +2156,10 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
- add(event.name, cur, event.once, event.capture, event.passive, event.params);
+ if (isTrue(event.once)) {
+ cur = on[name] = createOnceHandler(event.name, cur, event.capture);
+ }
+ add(event.name, cur, event.capture, event.passive, event.params);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
@@ -2311,10 +2414,14 @@ function resolveAsyncComponent (
var contexts = factory.contexts = [context];
var sync = true;
- var forceRender = function () {
+ var forceRender = function (renderCompleted) {
for (var i = 0, l = contexts.length; i < l; i++) {
contexts[i].$forceUpdate();
}
+
+ if (renderCompleted) {
+ contexts.length = 0;
+ }
};
var resolve = once(function (res) {
@@ -2323,7 +2430,7 @@ function resolveAsyncComponent (
// invoke callbacks only if this is not a synchronous resolve
// (async resolves are shimmed as synchronous during SSR)
if (!sync) {
- forceRender();
+ forceRender(true);
}
});
@@ -2334,7 +2441,7 @@ function resolveAsyncComponent (
);
if (isDef(factory.errorComp)) {
factory.error = true;
- forceRender();
+ forceRender(true);
}
});
@@ -2361,7 +2468,7 @@ function resolveAsyncComponent (
setTimeout(function () {
if (isUndef(factory.resolved) && isUndef(factory.error)) {
factory.loading = true;
- forceRender();
+ forceRender(false);
}
}, res.delay || 200);
}
@@ -2424,37 +2531,41 @@ function initEvents (vm) {
var target;
-function add (event, fn, once) {
- if (once) {
- target.$once(event, fn);
- } else {
- target.$on(event, fn);
- }
+function add (event, fn) {
+ target.$on(event, fn);
}
function remove$1 (event, fn) {
target.$off(event, fn);
}
+function createOnceHandler (event, fn) {
+ var _target = target;
+ return function onceHandler () {
+ var res = fn.apply(null, arguments);
+ if (res !== null) {
+ _target.$off(event, onceHandler);
+ }
+ }
+}
+
function updateComponentListeners (
vm,
listeners,
oldListeners
) {
target = vm;
- updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
+ updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
target = undefined;
}
function eventsMixin (Vue) {
var hookRE = /^hook:/;
Vue.prototype.$on = function (event, fn) {
- var this$1 = this;
-
var vm = this;
if (Array.isArray(event)) {
for (var i = 0, l = event.length; i < l; i++) {
- this$1.$on(event[i], fn);
+ vm.$on(event[i], fn);
}
} else {
(vm._events[event] || (vm._events[event] = [])).push(fn);
@@ -2479,8 +2590,6 @@ function eventsMixin (Vue) {
};
Vue.prototype.$off = function (event, fn) {
- var this$1 = this;
-
var vm = this;
// all
if (!arguments.length) {
@@ -2490,7 +2599,7 @@ function eventsMixin (Vue) {
// array of events
if (Array.isArray(event)) {
for (var i = 0, l = event.length; i < l; i++) {
- this$1.$off(event[i], fn);
+ vm.$off(event[i], fn);
}
return vm
}
@@ -2931,7 +3040,6 @@ function callHook (vm, hook) {
/* */
-
var MAX_UPDATE_COUNT = 100;
var queue = [];
@@ -3020,7 +3128,7 @@ function callUpdatedHooks (queue) {
while (i--) {
var watcher = queue[i];
var vm = watcher.vm;
- if (vm._watcher === watcher && vm._isMounted) {
+ if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
callHook(vm, 'updated');
}
}
@@ -3067,6 +3175,11 @@ function queueWatcher (watcher) {
// queue the flush
if (!waiting) {
waiting = true;
+
+ if (process.env.NODE_ENV !== 'production' && !config.async) {
+ flushSchedulerQueue();
+ return
+ }
nextTick(flushSchedulerQueue);
}
}
@@ -3074,6 +3187,8 @@ function queueWatcher (watcher) {
/* */
+
+
var uid$1 = 0;
/**
@@ -3097,16 +3212,16 @@ var Watcher = function Watcher (
if (options) {
this.deep = !!options.deep;
this.user = !!options.user;
- this.computed = !!options.computed;
+ this.lazy = !!options.lazy;
this.sync = !!options.sync;
this.before = options.before;
} else {
- this.deep = this.user = this.computed = this.sync = false;
+ this.deep = this.user = this.lazy = this.sync = false;
}
this.cb = cb;
this.id = ++uid$1; // uid for batching
this.active = true;
- this.dirty = this.computed; // for computed watchers
+ this.dirty = this.lazy; // for lazy watchers
this.deps = [];
this.newDeps = [];
this.depIds = new _Set();
@@ -3120,7 +3235,7 @@ var Watcher = function Watcher (
} else {
this.getter = parsePath(expOrFn);
if (!this.getter) {
- this.getter = function () {};
+ this.getter = noop;
process.env.NODE_ENV !== 'production' && warn(
"Failed watching path: \"" + expOrFn + "\" " +
'Watcher only accepts simple dot-delimited paths. ' +
@@ -3129,12 +3244,9 @@ var Watcher = function Watcher (
);
}
}
- if (this.computed) {
- this.value = undefined;
- this.dep = new Dep();
- } else {
- this.value = this.get();
- }
+ this.value = this.lazy
+ ? undefined
+ : this.get();
};
/**
@@ -3182,13 +3294,11 @@ Watcher.prototype.addDep = function addDep (dep) {
* Clean up for dependency collection.
*/
Watcher.prototype.cleanupDeps = function cleanupDeps () {
- var this$1 = this;
-
var i = this.deps.length;
while (i--) {
- var dep = this$1.deps[i];
- if (!this$1.newDepIds.has(dep.id)) {
- dep.removeSub(this$1);
+ var dep = this.deps[i];
+ if (!this.newDepIds.has(dep.id)) {
+ dep.removeSub(this);
}
}
var tmp = this.depIds;
@@ -3206,27 +3316,9 @@ Watcher.prototype.cleanupDeps = function cleanupDeps () {
* Will be called when a dependency changes.
*/
Watcher.prototype.update = function update () {
- var this$1 = this;
-
/* istanbul ignore else */
- if (this.computed) {
- // A computed property watcher has two modes: lazy and activated.
- // It initializes as lazy by default, and only becomes activated when
- // it is depended on by at least one subscriber, which is typically
- // another computed property or a component's render function.
- if (this.dep.subs.length === 0) {
- // In lazy mode, we don't want to perform computations until necessary,
- // so we simply mark the watcher as dirty. The actual computation is
- // performed just-in-time in this.evaluate() when the computed property
- // is accessed.
- this.dirty = true;
- } else {
- // In activated mode, we want to proactively perform the computation
- // but only notify our subscribers when the value has indeed changed.
- this.getAndInvoke(function () {
- this$1.dep.notify();
- });
- }
+ if (this.lazy) {
+ this.dirty = true;
} else if (this.sync) {
this.run();
} else {
@@ -3240,54 +3332,47 @@ Watcher.prototype.update = function update () {
*/
Watcher.prototype.run = function run () {
if (this.active) {
- this.getAndInvoke(this.cb);
- }
-};
-
-Watcher.prototype.getAndInvoke = function getAndInvoke (cb) {
- var value = this.get();
- if (
- value !== this.value ||
- // Deep watchers and watchers on Object/Arrays should fire even
- // when the value is the same, because the value may
- // have mutated.
- isObject(value) ||
- this.deep
- ) {
- // set new value
- var oldValue = this.value;
- this.value = value;
- this.dirty = false;
- if (this.user) {
- try {
- cb.call(this.vm, value, oldValue);
- } catch (e) {
- handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ var value = this.get();
+ if (
+ value !== this.value ||
+ // Deep watchers and watchers on Object/Arrays should fire even
+ // when the value is the same, because the value may
+ // have mutated.
+ isObject(value) ||
+ this.deep
+ ) {
+ // set new value
+ var oldValue = this.value;
+ this.value = value;
+ if (this.user) {
+ try {
+ this.cb.call(this.vm, value, oldValue);
+ } catch (e) {
+ handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ }
+ } else {
+ this.cb.call(this.vm, value, oldValue);
}
- } else {
- cb.call(this.vm, value, oldValue);
}
}
};
/**
- * Evaluate and return the value of the watcher.
- * This only gets called for computed property watchers.
+ * Evaluate the value of the watcher.
+ * This only gets called for lazy watchers.
*/
Watcher.prototype.evaluate = function evaluate () {
- if (this.dirty) {
- this.value = this.get();
- this.dirty = false;
- }
- return this.value
+ this.value = this.get();
+ this.dirty = false;
};
/**
- * Depend on this watcher. Only for computed property watchers.
+ * Depend on all deps collected by this watcher.
*/
Watcher.prototype.depend = function depend () {
- if (this.dep && Dep.target) {
- this.dep.depend();
+ var i = this.deps.length;
+ while (i--) {
+ this.deps[i].depend();
}
};
@@ -3295,8 +3380,6 @@ Watcher.prototype.depend = function depend () {
* Remove self from all dependencies' subscriber list.
*/
Watcher.prototype.teardown = function teardown () {
- var this$1 = this;
-
if (this.active) {
// remove self from vm's watcher list
// this is a somewhat expensive operation so we skip it
@@ -3306,7 +3389,7 @@ Watcher.prototype.teardown = function teardown () {
}
var i = this.deps.length;
while (i--) {
- this$1.deps[i].removeSub(this$1);
+ this.deps[i].removeSub(this);
}
this.active = false;
}
@@ -3371,8 +3454,8 @@ function initProps (vm, propsOptions) {
vm
);
}
- defineReactive(props, key, value, function () {
- if (vm.$parent && !isUpdatingChildComponent) {
+ defineReactive$$1(props, key, value, function () {
+ if (!isRoot && !isUpdatingChildComponent) {
warn(
"Avoid mutating a prop directly since the value will be " +
"overwritten whenever the parent component re-renders. " +
@@ -3383,7 +3466,7 @@ function initProps (vm, propsOptions) {
}
});
} else {
- defineReactive(props, key, value);
+ defineReactive$$1(props, key, value);
}
// static props are already proxied on the component's prototype
// during Vue.extend(). We only need to proxy props defined at
@@ -3452,7 +3535,7 @@ function getData (data, vm) {
}
}
-var computedWatcherOptions = { computed: true };
+var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
// $flow-disable-line
@@ -3504,17 +3587,15 @@ function defineComputed (
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
- : userDef;
+ : createGetterInvoker(userDef);
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
- : userDef.get
- : noop;
- sharedPropertyDefinition.set = userDef.set
- ? userDef.set
+ : createGetterInvoker(userDef.get)
: noop;
+ sharedPropertyDefinition.set = userDef.set || noop;
}
if (process.env.NODE_ENV !== 'production' &&
sharedPropertyDefinition.set === noop) {
@@ -3532,19 +3613,30 @@ function createComputedGetter (key) {
return function computedGetter () {
var watcher = this._computedWatchers && this._computedWatchers[key];
if (watcher) {
- watcher.depend();
- return watcher.evaluate()
+ if (watcher.dirty) {
+ watcher.evaluate();
+ }
+ if (Dep.target) {
+ watcher.depend();
+ }
+ return watcher.value
}
}
}
+function createGetterInvoker(fn) {
+ return function computedGetter () {
+ return fn.call(this, this)
+ }
+}
+
function initMethods (vm, methods) {
var props = vm.$options.props;
for (var key in methods) {
if (process.env.NODE_ENV !== 'production') {
- if (methods[key] == null) {
+ if (typeof methods[key] !== 'function') {
warn(
- "Method \"" + key + "\" has an undefined value in the component definition. " +
+ "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
"Did you reference the function correctly?",
vm
);
@@ -3562,7 +3654,7 @@ function initMethods (vm, methods) {
);
}
}
- vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
+ vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
}
}
@@ -3604,7 +3696,7 @@ function stateMixin (Vue) {
var propsDef = {};
propsDef.get = function () { return this._props };
if (process.env.NODE_ENV !== 'production') {
- dataDef.set = function (newData) {
+ dataDef.set = function () {
warn(
'Avoid replacing instance root $data. ' +
'Use nested data properties instead.',
@@ -3634,7 +3726,11 @@ function stateMixin (Vue) {
options.user = true;
var watcher = new Watcher(vm, expOrFn, cb, options);
if (options.immediate) {
- cb.call(vm, watcher.value);
+ try {
+ cb.call(vm, watcher.value);
+ } catch (error) {
+ handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
+ }
}
return function unwatchFn () {
watcher.teardown();
@@ -3660,7 +3756,7 @@ function initInjections (vm) {
Object.keys(result).forEach(function (key) {
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
- defineReactive(vm, key, result[key], function () {
+ defineReactive$$1(vm, key, result[key], function () {
warn(
"Avoid mutating an injected value directly since the changes will be " +
"overwritten whenever the provided component re-renders. " +
@@ -3669,7 +3765,7 @@ function initInjections (vm) {
);
});
} else {
- defineReactive(vm, key, result[key]);
+ defineReactive$$1(vm, key, result[key]);
}
});
toggleObserving(true);
@@ -3773,19 +3869,7 @@ function renderSlot (
}
nodes = scopedSlotFn(props) || fallback;
} else {
- var slotNodes = this.$slots[name];
- // warn duplicate slot usage
- if (slotNodes) {
- if (process.env.NODE_ENV !== 'production' && slotNodes._rendered) {
- warn(
- "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
- "- this will likely cause render errors.",
- this
- );
- }
- slotNodes._rendered = true;
- }
- nodes = slotNodes || fallback;
+ nodes = this.$slots[name] || fallback;
}
var target = props && props.slot;
@@ -3873,12 +3957,13 @@ function bindObjectProps (
? data.domProps || (data.domProps = {})
: data.attrs || (data.attrs = {});
}
- if (!(key in hash)) {
+ var camelizedKey = camelize(key);
+ if (!(key in hash) && !(camelizedKey in hash)) {
hash[key] = value[key];
if (isSync) {
var on = data.on || (data.on = {});
- on[("update:" + key)] = function ($event) {
+ on[("update:" + camelizedKey)] = function ($event) {
value[key] = $event;
};
}
@@ -4084,24 +4169,27 @@ function createFunctionalComponent (
var vnode = options.render.call(null, renderContext._c, renderContext);
if (vnode instanceof VNode) {
- return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options)
+ return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
} else if (Array.isArray(vnode)) {
var vnodes = normalizeChildren(vnode) || [];
var res = new Array(vnodes.length);
for (var i = 0; i < vnodes.length; i++) {
- res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options);
+ res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
}
return res
}
}
-function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) {
+function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
// #7817 clone node before setting fnContext, otherwise if the node is reused
// (e.g. it was from a cached normal slot) the fnContext causes named slots
// that should not be matched to match.
var clone = cloneVNode(vnode);
clone.fnContext = contextVm;
clone.fnOptions = options;
+ if (process.env.NODE_ENV !== 'production') {
+ (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
+ }
if (data.slot) {
(clone.data || (clone.data = {})).slot = data.slot;
}
@@ -4116,21 +4204,8 @@ function mergeProps (to, from) {
/* */
-
-
-
-// Register the component hook to weex native render engine.
-// The hook will be triggered by native, not javascript.
-
-
-// Updates the state of the component to weex native render engine.
-
/* */
-// https://github.com/Hanks10100/weex-native-directive/tree/master/component
-
-// listening on native callback
-
/* */
/* */
@@ -4298,10 +4373,6 @@ function createComponent (
asyncFactory
);
- // Weex specific: invoke recycle-list optimized @render function for
- // extracting cell-slot template.
- // https://github.com/Hanks10100/weex-native-directive/tree/master/component
- /* istanbul ignore if */
return vnode
}
@@ -4349,12 +4420,21 @@ function mergeHook$1 (f1, f2) {
// prop and event handler respectively.
function transformModel (options, data) {
var prop = (options.model && options.model.prop) || 'value';
- var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
+ var event = (options.model && options.model.event) || 'input'
+ ;(data.props || (data.props = {}))[prop] = data.model.value;
var on = data.on || (data.on = {});
- if (isDef(on[event])) {
- on[event] = [data.model.callback].concat(on[event]);
+ var existing = on[event];
+ var callback = data.model.callback;
+ if (isDef(existing)) {
+ if (
+ Array.isArray(existing)
+ ? existing.indexOf(callback) === -1
+ : existing !== callback
+ ) {
+ on[event] = [callback].concat(existing);
+ }
} else {
- on[event] = data.model.callback;
+ on[event] = callback;
}
}
@@ -4442,7 +4522,7 @@ function _createElement (
config.parsePlatformTagName(tag), data, children,
undefined, undefined, context
);
- } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
+ } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
// component
vnode = createComponent(Ctor, data, context, children, tag);
} else {
@@ -4524,15 +4604,15 @@ function initRender (vm) {
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
- defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
- defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () {
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
- defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
- defineReactive(vm, '$listeners', options._parentListeners || emptyObject, null, true);
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true);
}
}
@@ -4550,14 +4630,6 @@ function renderMixin (Vue) {
var render = ref.render;
var _parentVnode = ref._parentVnode;
- // reset _rendered flag on slots for duplicate slot check
- if (process.env.NODE_ENV !== 'production') {
- for (var key in vm.$slots) {
- // $flow-disable-line
- vm.$slots[key]._rendered = false;
- }
- }
-
if (_parentVnode) {
vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject;
}
@@ -4574,15 +4646,11 @@ function renderMixin (Vue) {
// return error render result,
// or previous vnode to prevent render error causing blank component
/* istanbul ignore else */
- if (process.env.NODE_ENV !== 'production') {
- if (vm.$options.renderError) {
- try {
- vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
- } catch (e) {
- handleError(e, vm, "renderError");
- vnode = vm._vnode;
- }
- } else {
+ if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
+ try {
+ vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
+ } catch (e) {
+ handleError(e, vm, "renderError");
vnode = vm._vnode;
}
} else {
@@ -4917,6 +4985,8 @@ function initAssetRegisters (Vue) {
/* */
+
+
function getComponentName (opts) {
return opts && (opts.Ctor.options.name || opts.tag)
}
@@ -4980,10 +5050,8 @@ var KeepAlive = {
},
destroyed: function destroyed () {
- var this$1 = this;
-
- for (var key in this$1.cache) {
- pruneCacheEntry(this$1.cache, key, this$1.keys);
+ for (var key in this.cache) {
+ pruneCacheEntry(this.cache, key, this.keys);
}
},
@@ -5043,11 +5111,11 @@ var KeepAlive = {
}
return vnode || (slot && slot[0])
}
-}
+};
var builtInComponents = {
KeepAlive: KeepAlive
-}
+};
/* */
@@ -5071,7 +5139,7 @@ function initGlobalAPI (Vue) {
warn: warn,
extend: extend,
mergeOptions: mergeOptions,
- defineReactive: defineReactive
+ defineReactive: defineReactive$$1
};
Vue.set = set;
@@ -5113,7 +5181,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
value: FunctionalRenderContext
});
-Vue.version = '2.5.17-beta.0';
+Vue.version = '2.5.18-beta.0';
/* */
@@ -5391,20 +5459,19 @@ function setStyleScope (node, scopeId) {
node.setAttribute(scopeId, '');
}
-
-var nodeOps = Object.freeze({
- createElement: createElement$1,
- createElementNS: createElementNS,
- createTextNode: createTextNode,
- createComment: createComment,
- insertBefore: insertBefore,
- removeChild: removeChild,
- appendChild: appendChild,
- parentNode: parentNode,
- nextSibling: nextSibling,
- tagName: tagName,
- setTextContent: setTextContent,
- setStyleScope: setStyleScope
+var nodeOps = /*#__PURE__*/Object.freeze({
+ createElement: createElement$1,
+ createElementNS: createElementNS,
+ createTextNode: createTextNode,
+ createComment: createComment,
+ insertBefore: insertBefore,
+ removeChild: removeChild,
+ appendChild: appendChild,
+ parentNode: parentNode,
+ nextSibling: nextSibling,
+ tagName: tagName,
+ setTextContent: setTextContent,
+ setStyleScope: setStyleScope
});
/* */
@@ -5422,7 +5489,7 @@ var ref = {
destroy: function destroy (vnode) {
registerRef(vnode, true);
}
-}
+};
function registerRef (vnode, isRemoval) {
var key = vnode.data.ref;
@@ -5467,6 +5534,12 @@ var emptyNode = new VNode('', {}, []);
var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
+function childrenIgnored (vnode) {
+ return vnode && vnode.data && vnode.data.domProps && (
+ vnode.data.domProps.innerHTML || vnode.data.domProps.textContent
+ )
+}
+
function sameVnode (a, b) {
return (
a.key === b.key && (
@@ -5474,6 +5547,7 @@ function sameVnode (a, b) {
a.tag === b.tag &&
a.isComment === b.isComment &&
isDef(a.data) === isDef(b.data) &&
+ !childrenIgnored(a) && !childrenIgnored(b) &&
sameInputType(a, b)
) || (
isTrue(a.isAsyncPlaceholder) &&
@@ -5523,13 +5597,13 @@ function createPatchFunction (backend) {
}
function createRmCb (childElm, listeners) {
- function remove () {
- if (--remove.listeners === 0) {
+ function remove$$1 () {
+ if (--remove$$1.listeners === 0) {
removeNode(childElm);
}
}
- remove.listeners = listeners;
- return remove
+ remove$$1.listeners = listeners;
+ return remove$$1
}
function removeNode (el) {
@@ -5690,7 +5764,7 @@ function createPatchFunction (backend) {
function insert (parent, elm, ref$$1) {
if (isDef(parent)) {
if (isDef(ref$$1)) {
- if (ref$$1.parentNode === parent) {
+ if (nodeOps.parentNode(ref$$1) === parent) {
nodeOps.insertBefore(parent, elm, ref$$1);
}
} else {
@@ -5845,20 +5919,20 @@ function createPatchFunction (backend) {
} else if (isUndef(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode)) {
- patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode)) {
- patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
- patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
- patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
@@ -5872,7 +5946,7 @@ function createPatchFunction (backend) {
} else {
vnodeToMove = oldCh[idxInOld];
if (sameVnode(vnodeToMove, newStartVnode)) {
- patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue);
+ patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
} else {
@@ -5916,11 +5990,23 @@ function createPatchFunction (backend) {
}
}
- function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
+ function patchVnode (
+ oldVnode,
+ vnode,
+ insertedVnodeQueue,
+ ownerArray,
+ index,
+ removeOnly
+ ) {
if (oldVnode === vnode) {
return
}
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
+ // clone reused vnode
+ vnode = ownerArray[index] = cloneVNode(vnode);
+ }
+
var elm = vnode.elm = oldVnode.elm;
if (isTrue(oldVnode.isAsyncPlaceholder)) {
@@ -5961,6 +6047,9 @@ function createPatchFunction (backend) {
if (isDef(oldCh) && isDef(ch)) {
if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
} else if (isDef(ch)) {
+ if (process.env.NODE_ENV !== 'production') {
+ checkDuplicateKeys(ch);
+ }
if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
} else if (isDef(oldCh)) {
@@ -6119,7 +6208,7 @@ function createPatchFunction (backend) {
var isRealElement = isDef(oldVnode.nodeType);
if (!isRealElement && sameVnode(oldVnode, vnode)) {
// patch existing root node
- patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
} else {
if (isRealElement) {
// mounting to a real element
@@ -6215,7 +6304,7 @@ var directives = {
destroy: function unbindDirectives (vnode) {
updateDirectives(vnode, emptyNode);
}
-}
+};
function updateDirectives (oldVnode, vnode) {
if (oldVnode.data.directives || vnode.data.directives) {
@@ -6326,7 +6415,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
var baseModules = [
ref,
directives
-]
+];
/* */
@@ -6410,7 +6499,7 @@ function baseSetAttr (el, key, value) {
/* istanbul ignore if */
if (
isIE && !isIE9 &&
- el.tagName === 'TEXTAREA' &&
+ (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') &&
key === 'placeholder' && !el.__ieph
) {
var blocker = function (e) {
@@ -6428,7 +6517,7 @@ function baseSetAttr (el, key, value) {
var attrs = {
create: updateAttrs,
update: updateAttrs
-}
+};
/* */
@@ -6466,7 +6555,7 @@ function updateClass (oldVnode, vnode) {
var klass = {
create: updateClass,
update: updateClass
-}
+};
/* */
@@ -6630,6 +6719,18 @@ function addHandler (
);
}
+ // normalize click.right and click.middle since they don't actually fire
+ // this is technically browser-specific, but at least for now browsers are
+ // the only target envs that have right/middle clicks.
+ if (name === 'click') {
+ if (modifiers.right) {
+ name = 'contextmenu';
+ delete modifiers.right;
+ } else if (modifiers.middle) {
+ name = 'mouseup';
+ }
+ }
+
// check capture modifier
if (modifiers.capture) {
delete modifiers.capture;
@@ -6645,18 +6746,6 @@ function addHandler (
name = '&' + name; // mark the event as passive
}
- // normalize click.right and click.middle since they don't actually fire
- // this is technically browser-specific, but at least for now browsers are
- // the only target envs that have right/middle clicks.
- if (name === 'click') {
- if (modifiers.right) {
- name = 'contextmenu';
- delete modifiers.right;
- } else if (modifiers.middle) {
- name = 'mouseup';
- }
- }
-
var events;
if (modifiers.native) {
delete modifiers.native;
@@ -6792,12 +6881,7 @@ function genAssignmentCode (
*
*/
-var len;
-var str;
-var chr;
-var index$1;
-var expressionPos;
-var expressionEndPos;
+var len, str, chr, index$1, expressionPos, expressionEndPos;
@@ -7078,7 +7162,7 @@ function normalizeEvents (on) {
var target$1;
-function createOnceHandler (handler, event, capture) {
+function createOnceHandler$1 (event, handler, capture) {
var _target = target$1; // save current target element in closure
return function onceHandler () {
var res = handler.apply(null, arguments);
@@ -7091,12 +7175,10 @@ function createOnceHandler (handler, event, capture) {
function add$1 (
event,
handler,
- once$$1,
capture,
passive
) {
handler = withMacroTask(handler);
- if (once$$1) { handler = createOnceHandler(handler, event, capture); }
target$1.addEventListener(
event,
handler,
@@ -7127,14 +7209,14 @@ function updateDOMListeners (oldVnode, vnode) {
var oldOn = oldVnode.data.on || {};
target$1 = vnode.elm;
normalizeEvents(on);
- updateListeners(on, oldOn, add$1, remove$2, vnode.context);
+ updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
target$1 = undefined;
}
var events = {
create: updateDOMListeners,
update: updateDOMListeners
-}
+};
/* */
@@ -7228,7 +7310,7 @@ function isDirtyWithModifiers (elm, newVal) {
var domProps = {
create: updateDOMProps,
update: updateDOMProps
-}
+};
/* */
@@ -7389,10 +7471,12 @@ function updateStyle (oldVnode, vnode) {
var style = {
create: updateStyle,
update: updateStyle
-}
+};
/* */
+var whitespaceRE = /\s+/;
+
/**
* Add class with compatibility for SVG since classList is not supported on
* SVG elements in IE
@@ -7406,7 +7490,7 @@ function addClass (el, cls) {
/* istanbul ignore else */
if (el.classList) {
if (cls.indexOf(' ') > -1) {
- cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
+ cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
} else {
el.classList.add(cls);
}
@@ -7431,7 +7515,7 @@ function removeClass (el, cls) {
/* istanbul ignore else */
if (el.classList) {
if (cls.indexOf(' ') > -1) {
- cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
+ cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
} else {
el.classList.remove(cls);
}
@@ -7455,20 +7539,20 @@ function removeClass (el, cls) {
/* */
-function resolveTransition (def) {
- if (!def) {
+function resolveTransition (def$$1) {
+ if (!def$$1) {
return
}
/* istanbul ignore else */
- if (typeof def === 'object') {
+ if (typeof def$$1 === 'object') {
var res = {};
- if (def.css !== false) {
- extend(res, autoCssTransition(def.name || 'v'));
+ if (def$$1.css !== false) {
+ extend(res, autoCssTransition(def$$1.name || 'v'));
}
- extend(res, def);
+ extend(res, def$$1);
return res
- } else if (typeof def === 'string') {
- return autoCssTransition(def)
+ } else if (typeof def$$1 === 'string') {
+ return autoCssTransition(def$$1)
}
}
@@ -7571,11 +7655,12 @@ var transformRE = /\b(transform|all)(,|$)/;
function getTransitionInfo (el, expectedType) {
var styles = window.getComputedStyle(el);
- var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
- var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
+ // JSDOM may return undefined for transition properties
+ var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
+ var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
- var animationDelays = styles[animationProp + 'Delay'].split(', ');
- var animationDurations = styles[animationProp + 'Duration'].split(', ');
+ var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
+ var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
var animationTimeout = getTimeout(animationDelays, animationDurations);
var type;
@@ -7629,8 +7714,12 @@ function getTimeout (delays, durations) {
}))
}
+// Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
+// in a locale-dependent way, using a comma instead of a dot.
+// If comma is not replaced with a dot, the input will be rounded down (i.e. acting
+// as a floor function) causing unexpected behaviors
function toMs (s) {
- return Number(s.slice(0, -1)) * 1000
+ return Number(s.slice(0, -1).replace(',', '.')) * 1000
}
/* */
@@ -7862,7 +7951,7 @@ function leave (vnode, rm) {
return
}
// record leaving element
- if (!vnode.data.show) {
+ if (!vnode.data.show && el.parentNode) {
(el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
}
beforeLeave && beforeLeave(el);
@@ -7951,7 +8040,7 @@ var transition = inBrowser ? {
rm();
}
}
-} : {}
+} : {};
var platformModules = [
attrs,
@@ -7960,7 +8049,7 @@ var platformModules = [
domProps,
style,
transition
-]
+];
/* */
@@ -8171,18 +8260,15 @@ var show = {
el.style.display = el.__vOriginalDisplay;
}
}
-}
+};
var platformDirectives = {
model: directive,
show: show
-}
+};
/* */
-// Provides transition support for a single element/component.
-// supports transition mode (out-in / in-out)
-
var transitionProps = {
name: String,
appear: Boolean,
@@ -8248,6 +8334,10 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
+var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
+
+var isVShowDirective = function (d) { return d.name === 'show'; };
+
var Transition = {
name: 'transition',
props: transitionProps,
@@ -8262,7 +8352,7 @@ var Transition = {
}
// filter out text nodes (possible whitespaces)
- children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); });
+ children = children.filter(isNotTextNode);
/* istanbul ignore if */
if (!children.length) {
return
@@ -8327,7 +8417,7 @@ var Transition = {
// mark v-show
// so that the transition module can hand over the control to the directive
- if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
+ if (child.data.directives && child.data.directives.some(isVShowDirective)) {
child.data.show = true;
}
@@ -8365,21 +8455,10 @@ var Transition = {
return rawChild
}
-}
+};
/* */
-// Provides transition support for list items.
-// supports move transitions using the FLIP technique.
-
-// Because the vdom's children update algorithm is "unstable" - i.e.
-// it doesn't guarantee the relative positioning of removed elements,
-// we force transition-group to update its children into two passes:
-// in the first pass, we remove all nodes that need to be removed,
-// triggering their leaving transition; in the second pass, we insert/move
-// into the final desired state. This way in the second pass removed
-// nodes will remain where they should be.
-
var props = extend({
tag: String,
moveClass: String
@@ -8475,6 +8554,9 @@ var TransitionGroup = {
addTransitionClass(el, moveClass);
s.transform = s.WebkitTransform = s.transitionDuration = '';
el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
+ if (e && e.target !== el) {
+ return
+ }
if (!e || /transform$/.test(e.propertyName)) {
el.removeEventListener(transitionEndEvent, cb);
el._moveCb = null;
@@ -8512,7 +8594,7 @@ var TransitionGroup = {
return (this._hasMove = info.hasTransform)
}
}
-}
+};
function callPendingCbs (c) {
/* istanbul ignore if */
@@ -8545,7 +8627,7 @@ function applyTranslation (c) {
var platformComponents = {
Transition: Transition,
TransitionGroup: TransitionGroup
-}
+};
/* */
@@ -8606,7 +8688,7 @@ if (inBrowser) {
/* */
-var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
+var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
var buildRegex = cached(function (delimiters) {
@@ -8692,7 +8774,7 @@ var klass$1 = {
staticKeys: ['staticClass'],
transformNode: transformNode,
genData: genData
-}
+};
/* */
@@ -8736,7 +8818,7 @@ var style$1 = {
staticKeys: ['staticStyle'],
transformNode: transformNode$1,
genData: genData$1
-}
+};
/* */
@@ -8748,7 +8830,7 @@ var he = {
decoder.innerHTML = html;
return decoder.textContent
}
-}
+};
/* */
@@ -8777,13 +8859,6 @@ var isNonPhrasingTag = makeMap(
* Not type-checking this file because it's mostly vendor code.
*/
-/*!
- * HTML Parser By John Resig (ejohn.org)
- * Modified by Juriy "kangax" Zaytsev
- * Original code by Erik Arvidsson, Mozilla Public License
- * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
- */
-
// Regular Expressions for parsing tags and attributes
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
@@ -8798,11 +8873,6 @@ var doctype = /^]+>/i;
var comment = /^= 0; pos--) {
if (stack[pos].lowerCasedTag === lowerCasedTagName) {
break
@@ -9085,7 +9146,7 @@ function parseHTML (html, options) {
var onRE = /^@|^v-on:/;
var dirRE = /^v-|^@|^:/;
-var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/;
+var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
var stripParensRE = /^\(|\)$/g;
@@ -9270,7 +9331,8 @@ function parse (
processIfConditions(element, currentParent);
} else if (element.slotScope) { // scoped slot
currentParent.plain = false;
- var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
+ var name = element.slotTarget || '"default"'
+ ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
} else {
currentParent.children.push(element);
element.parent = currentParent;
@@ -9394,8 +9456,20 @@ function processElement (element, options) {
function processKey (el) {
var exp = getBindingAttr(el, 'key');
if (exp) {
- if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
- warn$2(" cannot be keyed. Place the key on real elements instead.");
+ if (process.env.NODE_ENV !== 'production') {
+ if (el.tag === 'template') {
+ warn$2(" cannot be keyed. Place the key on real elements instead.");
+ }
+ if (el.for) {
+ var iterator = el.iterator2 || el.iterator1;
+ var parent = el.parent;
+ if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
+ warn$2(
+ "Do not use v-for index as key on children, " +
+ "this is the same as not using keys."
+ );
+ }
+ }
}
el.key = exp;
}
@@ -9433,7 +9507,7 @@ function parseFor (exp) {
var alias = inMatch[1].trim().replace(stripParensRE, '');
var iteratorMatch = alias.match(forIteratorRE);
if (iteratorMatch) {
- res.alias = alias.replace(forIteratorRE, '');
+ res.alias = alias.replace(forIteratorRE, '').trim();
res.iterator1 = iteratorMatch[1].trim();
if (iteratorMatch[2]) {
res.iterator2 = iteratorMatch[2].trim();
@@ -9586,6 +9660,14 @@ function processAttrs (el) {
name = name.replace(bindRE, '');
value = parseFilters(value);
isProp = false;
+ if (
+ process.env.NODE_ENV !== 'production' &&
+ value.trim().length === 0
+ ) {
+ warn$2(
+ ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
+ );
+ }
if (modifiers) {
if (modifiers.prop) {
isProp = true;
@@ -9734,16 +9816,6 @@ function checkForAliasModel (el, value) {
/* */
-/**
- * Expand input[v-model] with dyanmic type bindings into v-if-else chains
- * Turn this:
- *
- * into this:
- *
- *
- *
- */
-
function preTransformNode (el, options) {
if (el.tag === 'input') {
var map = el.attrsMap;
@@ -9810,15 +9882,15 @@ function cloneASTElement (el) {
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
}
-var model$2 = {
+var model$1 = {
preTransformNode: preTransformNode
-}
+};
var modules$1 = [
klass$1,
style$1,
- model$2
-]
+ model$1
+];
/* */
@@ -9840,7 +9912,7 @@ var directives$1 = {
model: model,
text: text,
html: html
-}
+};
/* */
@@ -10037,8 +10109,7 @@ var modifierCode = {
function genHandlers (
events,
- isNative,
- warn
+ isNative
) {
var res = isNative ? 'nativeOn:{' : 'on:{';
for (var name in events) {
@@ -10066,7 +10137,6 @@ function genHandler (
if (isMethodPath || isFunctionExpression) {
return handler.value
}
- /* istanbul ignore if */
return ("function($event){" + (handler.value) + "}") // inline statement
} else {
var code = '';
@@ -10103,7 +10173,6 @@ function genHandler (
: isFunctionExpression
? ("return (" + (handler.value) + ")($event)")
: handler.value;
- /* istanbul ignore if */
return ("function($event){" + code + handlerCode + "}")
}
}
@@ -10152,10 +10221,14 @@ var baseDirectives = {
on: on,
bind: bind$1,
cloak: noop
-}
+};
/* */
+
+
+
+
var CodegenState = function CodegenState (options) {
this.options = options;
this.warn = options.warn || baseWarn;
@@ -10163,9 +10236,10 @@ var CodegenState = function CodegenState (options) {
this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
this.directives = extend(extend({}, baseDirectives), options.directives);
var isReservedTag = options.isReservedTag || no;
- this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
+ this.maybeComponent = function (el) { return !(isReservedTag(el.tag) && !el.component); };
this.onceId = 0;
this.staticRenderFns = [];
+ this.pre = false;
};
@@ -10183,6 +10257,10 @@ function generate (
}
function genElement (el, state) {
+ if (el.parent) {
+ el.pre = el.pre || el.parent.pre;
+ }
+
if (el.staticRoot && !el.staticProcessed) {
return genStatic(el, state)
} else if (el.once && !el.onceProcessed) {
@@ -10191,7 +10269,7 @@ function genElement (el, state) {
return genFor(el, state)
} else if (el.if && !el.ifProcessed) {
return genIf(el, state)
- } else if (el.tag === 'template' && !el.slotTarget) {
+ } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
return genChildren(el, state) || 'void 0'
} else if (el.tag === 'slot') {
return genSlot(el, state)
@@ -10201,7 +10279,10 @@ function genElement (el, state) {
if (el.component) {
code = genComponent(el.component, el, state);
} else {
- var data = el.plain ? undefined : genData$2(el, state);
+ var data;
+ if (!el.plain || (el.pre && state.maybeComponent(el))) {
+ data = genData$2(el, state);
+ }
var children = el.inlineTemplate ? null : genChildren(el, state, true);
code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
@@ -10217,7 +10298,15 @@ function genElement (el, state) {
// hoist static sub-trees out
function genStatic (el, state) {
el.staticProcessed = true;
+ // Some elements (templates) need to behave differently inside of a v-pre
+ // node. All pre nodes are static roots, so we can use this as a location to
+ // wrap a state change and reset it upon exiting the pre node.
+ var originalPreState = state.pre;
+ if (el.pre) {
+ state.pre = el.pre;
+ }
state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
+ state.pre = originalPreState;
return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
}
@@ -10358,10 +10447,10 @@ function genData$2 (el, state) {
}
// event handlers
if (el.events) {
- data += (genHandlers(el.events, false, state.warn)) + ",";
+ data += (genHandlers(el.events, false)) + ",";
}
if (el.nativeEvents) {
- data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
+ data += (genHandlers(el.nativeEvents, true)) + ",";
}
// slot target
// only for non-scoped slots
@@ -10453,7 +10542,7 @@ function genScopedSlot (
var fn = "function(" + (String(el.slotScope)) + "){" +
"return " + (el.tag === 'template'
? el.if
- ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
+ ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
: genChildren(el, state) || 'undefined'
: genElement(el, state)) + "}";
return ("{key:" + key + ",fn:" + fn + "}")
@@ -10491,13 +10580,16 @@ function genChildren (
el$1.tag !== 'template' &&
el$1.tag !== 'slot'
) {
- return (altGenElement || genElement)(el$1, state)
+ // because el may be a functional component and return an Array instead of a single root.
+ // In this case, just a simple normalization is needed
+ var normalizationType = state.maybeComponent(el$1) ? ",1" : "";
+ return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
}
- var normalizationType = checkSkip
+ var normalizationType$1 = checkSkip
? getNormalizationType(children, state.maybeComponent)
: 0;
var gen = altGenNode || genNode;
- return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
+ return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
}
}
@@ -10535,7 +10627,7 @@ function needsNormalization (el) {
function genNode (node, state) {
if (node.type === 1) {
return genElement(node, state)
- } if (node.type === 3 && node.isComment) {
+ } else if (node.type === 3 && node.isComment) {
return genComment(node)
} else {
return genText(node)
@@ -10708,6 +10800,8 @@ function checkExpression (exp, text, errors) {
/* */
+
+
function createFunction (code, errors) {
try {
return new Function(code)
@@ -10879,6 +10973,7 @@ var createCompiler = createCompilerCreator(function baseCompile (
/* */
var ref$1 = createCompiler(baseOptions);
+var compile = ref$1.compile;
var compileToFunctions = ref$1.compileToFunctions;
/* */
diff --git a/dist/vue.esm.js b/dist/vue.esm.js
index 0135a93ef54..a17e8548470 100644
--- a/dist/vue.esm.js
+++ b/dist/vue.esm.js
@@ -1,5 +1,5 @@
/*!
- * Vue.js v2.5.17-beta.0
+ * Vue.js v2.5.18-beta.0
* (c) 2014-2018 Evan You
* Released under the MIT License.
*/
@@ -7,8 +7,8 @@
var emptyObject = Object.freeze({});
-// these helpers produces better vm code in JS engines due to their
-// explicitness and function inlining
+// These helpers produce better VM code in JS engines due to their
+// explicitness and function inlining.
function isUndef (v) {
return v === undefined || v === null
}
@@ -26,7 +26,7 @@ function isFalse (v) {
}
/**
- * Check if value is primitive
+ * Check if value is primitive.
*/
function isPrimitive (value) {
return (
@@ -48,7 +48,7 @@ function isObject (obj) {
}
/**
- * Get the raw type string of a value e.g. [object Object]
+ * Get the raw type string of a value, e.g., [object Object].
*/
var _toString = Object.prototype.toString;
@@ -88,7 +88,7 @@ function toString (val) {
}
/**
- * Convert a input value to a number for persistence.
+ * Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
function toNumber (val) {
@@ -120,12 +120,12 @@ function makeMap (
var isBuiltInTag = makeMap('slot,component', true);
/**
- * Check if a attribute is a reserved attribute.
+ * Check if an attribute is a reserved attribute.
*/
var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
/**
- * Remove an item from an array
+ * Remove an item from an array.
*/
function remove (arr, item) {
if (arr.length) {
@@ -137,7 +137,7 @@ function remove (arr, item) {
}
/**
- * Check whether the object has the property.
+ * Check whether an object has the property.
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
@@ -179,11 +179,11 @@ var hyphenate = cached(function (str) {
});
/**
- * Simple bind polyfill for environments that do not support it... e.g.
- * PhantomJS 1.x. Technically we don't need this anymore since native bind is
- * now more performant in most browsers, but removing it would be breaking for
- * code that was able to run in PhantomJS 1.x, so this must be kept for
- * backwards compatibility.
+ * Simple bind polyfill for environments that do not support it,
+ * e.g., PhantomJS 1.x. Technically, we don't need this anymore
+ * since native bind is now performant enough in most browsers.
+ * But removing it would mean breaking code that was able to run in
+ * PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/* istanbul ignore next */
@@ -245,10 +245,12 @@ function toObject (arr) {
return res
}
+/* eslint-disable no-unused-vars */
+
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
- * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
+ * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
function noop (a, b, c) {}
@@ -257,13 +259,15 @@ function noop (a, b, c) {}
*/
var no = function (a, b, c) { return false; };
+/* eslint-enable no-unused-vars */
+
/**
- * Return same value
+ * Return the same value.
*/
var identity = function (_) { return _; };
/**
- * Generate a static keys string from compiler modules.
+ * Generate a string containing static keys from compiler modules.
*/
function genStaticKeys (modules) {
return modules.reduce(function (keys, m) {
@@ -287,6 +291,8 @@ function looseEqual (a, b) {
return a.length === b.length && a.every(function (e, i) {
return looseEqual(e, b[i])
})
+ } else if (a instanceof Date && b instanceof Date) {
+ return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) {
var keysA = Object.keys(a);
var keysB = Object.keys(b);
@@ -308,6 +314,11 @@ function looseEqual (a, b) {
}
}
+/**
+ * Return the first index at which a loosely equal value can be
+ * found in the array (if value is a plain object, the array must
+ * contain an object of the same shape), or -1 if it is not present.
+ */
function looseIndexOf (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val)) { return i }
@@ -352,6 +363,8 @@ var LIFECYCLE_HOOKS = [
/* */
+
+
var config = ({
/**
* Option merge strategies (used in core/util/options)
@@ -434,11 +447,17 @@ var config = ({
*/
mustUseProp: no,
+ /**
+ * Perform updates asynchronously. Intended to be used by Vue Test Utils
+ * This will significantly reduce performance if set to false.
+ */
+ async: true,
+
/**
* Exposed for legacy reasons
*/
_lifecycleHooks: LIFECYCLE_HOOKS
-})
+});
/* */
@@ -523,7 +542,7 @@ var isServerRendering = function () {
if (!inBrowser && !inWeex && typeof global !== 'undefined') {
// detect presence of vue-server-renderer and avoid
// Webpack shimming the process
- _isServer = global['process'].env.VUE_ENV === 'server';
+ _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
} else {
_isServer = false;
}
@@ -550,7 +569,7 @@ if (typeof Set !== 'undefined' && isNative(Set)) {
_Set = Set;
} else {
// a non-standard Set polyfill that only works with primitive keys.
- _Set = (function () {
+ _Set = /*@__PURE__*/(function () {
function Set () {
this.set = Object.create(null);
}
@@ -664,7 +683,6 @@ if (process.env.NODE_ENV !== 'production') {
/* */
-
var uid = 0;
/**
@@ -693,6 +711,12 @@ Dep.prototype.depend = function depend () {
Dep.prototype.notify = function notify () {
// stabilize the subscriber list first
var subs = this.subs.slice();
+ if (process.env.NODE_ENV !== 'production' && !config.async) {
+ // subs aren't sorted in scheduler if not running async
+ // we need to sort them now to make sure they fire in correct
+ // order
+ subs.sort(function (a, b) { return a.id - b.id; });
+ }
for (var i = 0, l = subs.length; i < l; i++) {
subs[i].update();
}
@@ -704,13 +728,14 @@ Dep.prototype.notify = function notify () {
Dep.target = null;
var targetStack = [];
-function pushTarget (_target) {
- if (Dep.target) { targetStack.push(Dep.target); }
- Dep.target = _target;
+function pushTarget (target) {
+ targetStack.push(target);
+ Dep.target = target;
}
function popTarget () {
- Dep.target = targetStack.pop();
+ targetStack.pop();
+ Dep.target = targetStack[targetStack.length - 1];
}
/* */
@@ -781,7 +806,10 @@ function cloneVNode (vnode) {
var cloned = new VNode(
vnode.tag,
vnode.data,
- vnode.children,
+ // #7975
+ // clone children array to avoid mutating original in case of cloning
+ // a child.
+ vnode.children && vnode.children.slice(),
vnode.text,
vnode.elm,
vnode.context,
@@ -873,10 +901,11 @@ var Observer = function Observer (value) {
this.vmCount = 0;
def(value, '__ob__', this);
if (Array.isArray(value)) {
- var augment = hasProto
- ? protoAugment
- : copyAugment;
- augment(value, arrayMethods, arrayKeys);
+ if (hasProto) {
+ protoAugment(value, arrayMethods);
+ } else {
+ copyAugment(value, arrayMethods, arrayKeys);
+ }
this.observeArray(value);
} else {
this.walk(value);
@@ -884,14 +913,14 @@ var Observer = function Observer (value) {
};
/**
- * Walk through each property and convert them into
+ * Walk through all properties and convert them into
* getter/setters. This method should only be called when
* value type is Object.
*/
Observer.prototype.walk = function walk (obj) {
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
- defineReactive(obj, keys[i]);
+ defineReactive$$1(obj, keys[i]);
}
};
@@ -907,17 +936,17 @@ Observer.prototype.observeArray = function observeArray (items) {
// helpers
/**
- * Augment an target Object or Array by intercepting
+ * Augment a target Object or Array by intercepting
* the prototype chain using __proto__
*/
-function protoAugment (target, src, keys) {
+function protoAugment (target, src) {
/* eslint-disable no-proto */
target.__proto__ = src;
/* eslint-enable no-proto */
}
/**
- * Augment an target Object or Array by defining
+ * Augment a target Object or Array by defining
* hidden properties.
*/
/* istanbul ignore next */
@@ -958,7 +987,7 @@ function observe (value, asRootData) {
/**
* Define a reactive property on an Object.
*/
-function defineReactive (
+function defineReactive$$1 (
obj,
key,
val,
@@ -1006,6 +1035,8 @@ function defineReactive (
if (process.env.NODE_ENV !== 'production' && customSetter) {
customSetter();
}
+ // #7981: for accessor properties without setter
+ if (getter && !setter) { return }
if (setter) {
setter.call(obj, newVal);
} else {
@@ -1049,7 +1080,7 @@ function set (target, key, val) {
target[key] = val;
return val
}
- defineReactive(ob.value, key, val);
+ defineReactive$$1(ob.value, key, val);
ob.dep.notify();
return val
}
@@ -1136,7 +1167,11 @@ function mergeData (to, from) {
fromVal = from[key];
if (!hasOwn(to, key)) {
set(to, key, fromVal);
- } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
+ } else if (
+ toVal !== fromVal &&
+ isPlainObject(toVal) &&
+ isPlainObject(fromVal)
+ ) {
mergeData(toVal, fromVal);
}
}
@@ -1459,15 +1494,22 @@ function mergeOptions (
normalizeProps(child, vm);
normalizeInject(child, vm);
normalizeDirectives(child);
- var extendsFrom = child.extends;
- if (extendsFrom) {
- parent = mergeOptions(parent, extendsFrom, vm);
- }
- if (child.mixins) {
- for (var i = 0, l = child.mixins.length; i < l; i++) {
- parent = mergeOptions(parent, child.mixins[i], vm);
+
+ // Apply extends and mixins on the child options,
+ // but only if it is a raw options object that isn't
+ // the result of another mergeOptions call.
+ // Only merged options has the _base property.
+ if (!child._base) {
+ if (child.extends) {
+ parent = mergeOptions(parent, child.extends, vm);
+ }
+ if (child.mixins) {
+ for (var i = 0, l = child.mixins.length; i < l; i++) {
+ parent = mergeOptions(parent, child.mixins[i], vm);
+ }
}
}
+
var options = {};
var key;
for (key in parent) {
@@ -1520,6 +1562,8 @@ function resolveAsset (
/* */
+
+
function validateProp (
key,
propOptions,
@@ -1556,7 +1600,7 @@ function validateProp (
if (
process.env.NODE_ENV !== 'production' &&
// skip validation for weex recycle-list child component props
- !(false && isObject(value) && ('@binding' in value))
+ !(false)
) {
assertProp(prop, key, value, vm, absent);
}
@@ -1629,11 +1673,10 @@ function assertProp (
valid = assertedType.valid;
}
}
+
if (!valid) {
warn(
- "Invalid prop: type check failed for prop \"" + name + "\"." +
- " Expected " + (expectedTypes.map(capitalize).join(', ')) +
- ", got " + (toRawType(value)) + ".",
+ getInvalidTypeMessage(name, value, expectedTypes),
vm
);
return
@@ -1700,6 +1743,49 @@ function getTypeIndex (type, expectedTypes) {
return -1
}
+function getInvalidTypeMessage (name, value, expectedTypes) {
+ var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
+ " Expected " + (expectedTypes.map(capitalize).join(', '));
+ var expectedType = expectedTypes[0];
+ var receivedType = toRawType(value);
+ var expectedValue = styleValue(value, expectedType);
+ var receivedValue = styleValue(value, receivedType);
+ // check if we need to specify expected value
+ if (expectedTypes.length === 1 &&
+ isExplicable(expectedType) &&
+ !isBoolean(expectedType, receivedType)) {
+ message += " with value " + expectedValue;
+ }
+ message += ", got " + receivedType + " ";
+ // check if we need to specify received value
+ if (isExplicable(receivedType)) {
+ message += "with value " + receivedValue + ".";
+ }
+ return message
+}
+
+function styleValue (value, type) {
+ if (type === 'String') {
+ return ("\"" + value + "\"")
+ } else if (type === 'Number') {
+ return ("" + (Number(value)))
+ } else {
+ return ("" + value)
+ }
+}
+
+function isExplicable (value) {
+ var explicitTypes = ['string', 'number', 'boolean'];
+ return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
+}
+
+function isBoolean () {
+ var args = [], len = arguments.length;
+ while ( len-- ) args[ len ] = arguments[ len ];
+
+ return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
+}
+
/* */
function handleError (err, vm, info) {
@@ -1746,7 +1832,6 @@ function logError (err, vm, info) {
}
/* */
-/* globals MessageChannel */
var callbacks = [];
var pending = false;
@@ -1824,9 +1909,11 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
function withMacroTask (fn) {
return fn._withTask || (fn._withTask = function () {
useMacroTask = true;
- var res = fn.apply(null, arguments);
- useMacroTask = false;
- return res
+ try {
+ return fn.apply(null, arguments)
+ } finally {
+ useMacroTask = false;
+ }
})
}
@@ -1907,6 +1994,16 @@ if (process.env.NODE_ENV !== 'production') {
);
};
+ var warnReservedPrefix = function (target, key) {
+ warn(
+ "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
+ 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
+ 'prevent conflicts with Vue internals' +
+ 'See: https://vuejs.org/v2/api/#data',
+ target
+ );
+ };
+
var hasProxy =
typeof Proxy !== 'undefined' && isNative(Proxy);
@@ -1928,9 +2025,11 @@ if (process.env.NODE_ENV !== 'production') {
var hasHandler = {
has: function has (target, key) {
var has = key in target;
- var isAllowed = allowedGlobals(key) || (typeof key === 'string' && key.charAt(0) === '_');
+ var isAllowed = allowedGlobals(key) ||
+ (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
if (!has && !isAllowed) {
- warnNonPresent(target, key);
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
}
return has || !isAllowed
}
@@ -1939,7 +2038,8 @@ if (process.env.NODE_ENV !== 'production') {
var getHandler = {
get: function get (target, key) {
if (typeof key === 'string' && !(key in target)) {
- warnNonPresent(target, key);
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
}
return target[key]
}
@@ -2037,14 +2137,14 @@ function updateListeners (
oldOn,
add,
remove$$1,
+ createOnceHandler,
vm
) {
- var name, def, cur, old, event;
+ var name, def$$1, cur, old, event;
for (name in on) {
- def = cur = on[name];
+ def$$1 = cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
- /* istanbul ignore if */
if (isUndef(cur)) {
process.env.NODE_ENV !== 'production' && warn(
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@@ -2054,7 +2154,10 @@ function updateListeners (
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur);
}
- add(event.name, cur, event.once, event.capture, event.passive, event.params);
+ if (isTrue(event.once)) {
+ cur = on[name] = createOnceHandler(event.name, cur, event.capture);
+ }
+ add(event.name, cur, event.capture, event.passive, event.params);
} else if (cur !== old) {
old.fns = cur;
on[name] = old;
@@ -2309,10 +2412,14 @@ function resolveAsyncComponent (
var contexts = factory.contexts = [context];
var sync = true;
- var forceRender = function () {
+ var forceRender = function (renderCompleted) {
for (var i = 0, l = contexts.length; i < l; i++) {
contexts[i].$forceUpdate();
}
+
+ if (renderCompleted) {
+ contexts.length = 0;
+ }
};
var resolve = once(function (res) {
@@ -2321,7 +2428,7 @@ function resolveAsyncComponent (
// invoke callbacks only if this is not a synchronous resolve
// (async resolves are shimmed as synchronous during SSR)
if (!sync) {
- forceRender();
+ forceRender(true);
}
});
@@ -2332,7 +2439,7 @@ function resolveAsyncComponent (
);
if (isDef(factory.errorComp)) {
factory.error = true;
- forceRender();
+ forceRender(true);
}
});
@@ -2359,7 +2466,7 @@ function resolveAsyncComponent (
setTimeout(function () {
if (isUndef(factory.resolved) && isUndef(factory.error)) {
factory.loading = true;
- forceRender();
+ forceRender(false);
}
}, res.delay || 200);
}
@@ -2422,37 +2529,41 @@ function initEvents (vm) {
var target;
-function add (event, fn, once) {
- if (once) {
- target.$once(event, fn);
- } else {
- target.$on(event, fn);
- }
+function add (event, fn) {
+ target.$on(event, fn);
}
function remove$1 (event, fn) {
target.$off(event, fn);
}
+function createOnceHandler (event, fn) {
+ var _target = target;
+ return function onceHandler () {
+ var res = fn.apply(null, arguments);
+ if (res !== null) {
+ _target.$off(event, onceHandler);
+ }
+ }
+}
+
function updateComponentListeners (
vm,
listeners,
oldListeners
) {
target = vm;
- updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
+ updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
target = undefined;
}
function eventsMixin (Vue) {
var hookRE = /^hook:/;
Vue.prototype.$on = function (event, fn) {
- var this$1 = this;
-
var vm = this;
if (Array.isArray(event)) {
for (var i = 0, l = event.length; i < l; i++) {
- this$1.$on(event[i], fn);
+ vm.$on(event[i], fn);
}
} else {
(vm._events[event] || (vm._events[event] = [])).push(fn);
@@ -2477,8 +2588,6 @@ function eventsMixin (Vue) {
};
Vue.prototype.$off = function (event, fn) {
- var this$1 = this;
-
var vm = this;
// all
if (!arguments.length) {
@@ -2488,7 +2597,7 @@ function eventsMixin (Vue) {
// array of events
if (Array.isArray(event)) {
for (var i = 0, l = event.length; i < l; i++) {
- this$1.$off(event[i], fn);
+ vm.$off(event[i], fn);
}
return vm
}
@@ -2929,7 +3038,6 @@ function callHook (vm, hook) {
/* */
-
var MAX_UPDATE_COUNT = 100;
var queue = [];
@@ -3018,7 +3126,7 @@ function callUpdatedHooks (queue) {
while (i--) {
var watcher = queue[i];
var vm = watcher.vm;
- if (vm._watcher === watcher && vm._isMounted) {
+ if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
callHook(vm, 'updated');
}
}
@@ -3065,6 +3173,11 @@ function queueWatcher (watcher) {
// queue the flush
if (!waiting) {
waiting = true;
+
+ if (process.env.NODE_ENV !== 'production' && !config.async) {
+ flushSchedulerQueue();
+ return
+ }
nextTick(flushSchedulerQueue);
}
}
@@ -3072,6 +3185,8 @@ function queueWatcher (watcher) {
/* */
+
+
var uid$1 = 0;
/**
@@ -3095,16 +3210,16 @@ var Watcher = function Watcher (
if (options) {
this.deep = !!options.deep;
this.user = !!options.user;
- this.computed = !!options.computed;
+ this.lazy = !!options.lazy;
this.sync = !!options.sync;
this.before = options.before;
} else {
- this.deep = this.user = this.computed = this.sync = false;
+ this.deep = this.user = this.lazy = this.sync = false;
}
this.cb = cb;
this.id = ++uid$1; // uid for batching
this.active = true;
- this.dirty = this.computed; // for computed watchers
+ this.dirty = this.lazy; // for lazy watchers
this.deps = [];
this.newDeps = [];
this.depIds = new _Set();
@@ -3118,7 +3233,7 @@ var Watcher = function Watcher (
} else {
this.getter = parsePath(expOrFn);
if (!this.getter) {
- this.getter = function () {};
+ this.getter = noop;
process.env.NODE_ENV !== 'production' && warn(
"Failed watching path: \"" + expOrFn + "\" " +
'Watcher only accepts simple dot-delimited paths. ' +
@@ -3127,12 +3242,9 @@ var Watcher = function Watcher (
);
}
}
- if (this.computed) {
- this.value = undefined;
- this.dep = new Dep();
- } else {
- this.value = this.get();
- }
+ this.value = this.lazy
+ ? undefined
+ : this.get();
};
/**
@@ -3180,13 +3292,11 @@ Watcher.prototype.addDep = function addDep (dep) {
* Clean up for dependency collection.
*/
Watcher.prototype.cleanupDeps = function cleanupDeps () {
- var this$1 = this;
-
var i = this.deps.length;
while (i--) {
- var dep = this$1.deps[i];
- if (!this$1.newDepIds.has(dep.id)) {
- dep.removeSub(this$1);
+ var dep = this.deps[i];
+ if (!this.newDepIds.has(dep.id)) {
+ dep.removeSub(this);
}
}
var tmp = this.depIds;
@@ -3204,27 +3314,9 @@ Watcher.prototype.cleanupDeps = function cleanupDeps () {
* Will be called when a dependency changes.
*/
Watcher.prototype.update = function update () {
- var this$1 = this;
-
/* istanbul ignore else */
- if (this.computed) {
- // A computed property watcher has two modes: lazy and activated.
- // It initializes as lazy by default, and only becomes activated when
- // it is depended on by at least one subscriber, which is typically
- // another computed property or a component's render function.
- if (this.dep.subs.length === 0) {
- // In lazy mode, we don't want to perform computations until necessary,
- // so we simply mark the watcher as dirty. The actual computation is
- // performed just-in-time in this.evaluate() when the computed property
- // is accessed.
- this.dirty = true;
- } else {
- // In activated mode, we want to proactively perform the computation
- // but only notify our subscribers when the value has indeed changed.
- this.getAndInvoke(function () {
- this$1.dep.notify();
- });
- }
+ if (this.lazy) {
+ this.dirty = true;
} else if (this.sync) {
this.run();
} else {
@@ -3238,54 +3330,47 @@ Watcher.prototype.update = function update () {
*/
Watcher.prototype.run = function run () {
if (this.active) {
- this.getAndInvoke(this.cb);
- }
-};
-
-Watcher.prototype.getAndInvoke = function getAndInvoke (cb) {
- var value = this.get();
- if (
- value !== this.value ||
- // Deep watchers and watchers on Object/Arrays should fire even
- // when the value is the same, because the value may
- // have mutated.
- isObject(value) ||
- this.deep
- ) {
- // set new value
- var oldValue = this.value;
- this.value = value;
- this.dirty = false;
- if (this.user) {
- try {
- cb.call(this.vm, value, oldValue);
- } catch (e) {
- handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ var value = this.get();
+ if (
+ value !== this.value ||
+ // Deep watchers and watchers on Object/Arrays should fire even
+ // when the value is the same, because the value may
+ // have mutated.
+ isObject(value) ||
+ this.deep
+ ) {
+ // set new value
+ var oldValue = this.value;
+ this.value = value;
+ if (this.user) {
+ try {
+ this.cb.call(this.vm, value, oldValue);
+ } catch (e) {
+ handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ }
+ } else {
+ this.cb.call(this.vm, value, oldValue);
}
- } else {
- cb.call(this.vm, value, oldValue);
}
}
};
/**
- * Evaluate and return the value of the watcher.
- * This only gets called for computed property watchers.
+ * Evaluate the value of the watcher.
+ * This only gets called for lazy watchers.
*/
Watcher.prototype.evaluate = function evaluate () {
- if (this.dirty) {
- this.value = this.get();
- this.dirty = false;
- }
- return this.value
+ this.value = this.get();
+ this.dirty = false;
};
/**
- * Depend on this watcher. Only for computed property watchers.
+ * Depend on all deps collected by this watcher.
*/
Watcher.prototype.depend = function depend () {
- if (this.dep && Dep.target) {
- this.dep.depend();
+ var i = this.deps.length;
+ while (i--) {
+ this.deps[i].depend();
}
};
@@ -3293,8 +3378,6 @@ Watcher.prototype.depend = function depend () {
* Remove self from all dependencies' subscriber list.
*/
Watcher.prototype.teardown = function teardown () {
- var this$1 = this;
-
if (this.active) {
// remove self from vm's watcher list
// this is a somewhat expensive operation so we skip it
@@ -3304,7 +3387,7 @@ Watcher.prototype.teardown = function teardown () {
}
var i = this.deps.length;
while (i--) {
- this$1.deps[i].removeSub(this$1);
+ this.deps[i].removeSub(this);
}
this.active = false;
}
@@ -3369,8 +3452,8 @@ function initProps (vm, propsOptions) {
vm
);
}
- defineReactive(props, key, value, function () {
- if (vm.$parent && !isUpdatingChildComponent) {
+ defineReactive$$1(props, key, value, function () {
+ if (!isRoot && !isUpdatingChildComponent) {
warn(
"Avoid mutating a prop directly since the value will be " +
"overwritten whenever the parent component re-renders. " +
@@ -3381,7 +3464,7 @@ function initProps (vm, propsOptions) {
}
});
} else {
- defineReactive(props, key, value);
+ defineReactive$$1(props, key, value);
}
// static props are already proxied on the component's prototype
// during Vue.extend(). We only need to proxy props defined at
@@ -3450,7 +3533,7 @@ function getData (data, vm) {
}
}
-var computedWatcherOptions = { computed: true };
+var computedWatcherOptions = { lazy: true };
function initComputed (vm, computed) {
// $flow-disable-line
@@ -3502,17 +3585,15 @@ function defineComputed (
if (typeof userDef === 'function') {
sharedPropertyDefinition.get = shouldCache
? createComputedGetter(key)
- : userDef;
+ : createGetterInvoker(userDef);
sharedPropertyDefinition.set = noop;
} else {
sharedPropertyDefinition.get = userDef.get
? shouldCache && userDef.cache !== false
? createComputedGetter(key)
- : userDef.get
- : noop;
- sharedPropertyDefinition.set = userDef.set
- ? userDef.set
+ : createGetterInvoker(userDef.get)
: noop;
+ sharedPropertyDefinition.set = userDef.set || noop;
}
if (process.env.NODE_ENV !== 'production' &&
sharedPropertyDefinition.set === noop) {
@@ -3530,19 +3611,30 @@ function createComputedGetter (key) {
return function computedGetter () {
var watcher = this._computedWatchers && this._computedWatchers[key];
if (watcher) {
- watcher.depend();
- return watcher.evaluate()
+ if (watcher.dirty) {
+ watcher.evaluate();
+ }
+ if (Dep.target) {
+ watcher.depend();
+ }
+ return watcher.value
}
}
}
+function createGetterInvoker(fn) {
+ return function computedGetter () {
+ return fn.call(this, this)
+ }
+}
+
function initMethods (vm, methods) {
var props = vm.$options.props;
for (var key in methods) {
if (process.env.NODE_ENV !== 'production') {
- if (methods[key] == null) {
+ if (typeof methods[key] !== 'function') {
warn(
- "Method \"" + key + "\" has an undefined value in the component definition. " +
+ "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
"Did you reference the function correctly?",
vm
);
@@ -3560,7 +3652,7 @@ function initMethods (vm, methods) {
);
}
}
- vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
+ vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
}
}
@@ -3602,7 +3694,7 @@ function stateMixin (Vue) {
var propsDef = {};
propsDef.get = function () { return this._props };
if (process.env.NODE_ENV !== 'production') {
- dataDef.set = function (newData) {
+ dataDef.set = function () {
warn(
'Avoid replacing instance root $data. ' +
'Use nested data properties instead.',
@@ -3632,7 +3724,11 @@ function stateMixin (Vue) {
options.user = true;
var watcher = new Watcher(vm, expOrFn, cb, options);
if (options.immediate) {
- cb.call(vm, watcher.value);
+ try {
+ cb.call(vm, watcher.value);
+ } catch (error) {
+ handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
+ }
}
return function unwatchFn () {
watcher.teardown();
@@ -3658,7 +3754,7 @@ function initInjections (vm) {
Object.keys(result).forEach(function (key) {
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
- defineReactive(vm, key, result[key], function () {
+ defineReactive$$1(vm, key, result[key], function () {
warn(
"Avoid mutating an injected value directly since the changes will be " +
"overwritten whenever the provided component re-renders. " +
@@ -3667,7 +3763,7 @@ function initInjections (vm) {
);
});
} else {
- defineReactive(vm, key, result[key]);
+ defineReactive$$1(vm, key, result[key]);
}
});
toggleObserving(true);
@@ -3771,19 +3867,7 @@ function renderSlot (
}
nodes = scopedSlotFn(props) || fallback;
} else {
- var slotNodes = this.$slots[name];
- // warn duplicate slot usage
- if (slotNodes) {
- if (process.env.NODE_ENV !== 'production' && slotNodes._rendered) {
- warn(
- "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
- "- this will likely cause render errors.",
- this
- );
- }
- slotNodes._rendered = true;
- }
- nodes = slotNodes || fallback;
+ nodes = this.$slots[name] || fallback;
}
var target = props && props.slot;
@@ -3871,12 +3955,13 @@ function bindObjectProps (
? data.domProps || (data.domProps = {})
: data.attrs || (data.attrs = {});
}
- if (!(key in hash)) {
+ var camelizedKey = camelize(key);
+ if (!(key in hash) && !(camelizedKey in hash)) {
hash[key] = value[key];
if (isSync) {
var on = data.on || (data.on = {});
- on[("update:" + key)] = function ($event) {
+ on[("update:" + camelizedKey)] = function ($event) {
value[key] = $event;
};
}
@@ -4082,24 +4167,27 @@ function createFunctionalComponent (
var vnode = options.render.call(null, renderContext._c, renderContext);
if (vnode instanceof VNode) {
- return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options)
+ return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
} else if (Array.isArray(vnode)) {
var vnodes = normalizeChildren(vnode) || [];
var res = new Array(vnodes.length);
for (var i = 0; i < vnodes.length; i++) {
- res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options);
+ res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
}
return res
}
}
-function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) {
+function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
// #7817 clone node before setting fnContext, otherwise if the node is reused
// (e.g. it was from a cached normal slot) the fnContext causes named slots
// that should not be matched to match.
var clone = cloneVNode(vnode);
clone.fnContext = contextVm;
clone.fnOptions = options;
+ if (process.env.NODE_ENV !== 'production') {
+ (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
+ }
if (data.slot) {
(clone.data || (clone.data = {})).slot = data.slot;
}
@@ -4114,21 +4202,8 @@ function mergeProps (to, from) {
/* */
-
-
-
-// Register the component hook to weex native render engine.
-// The hook will be triggered by native, not javascript.
-
-
-// Updates the state of the component to weex native render engine.
-
/* */
-// https://github.com/Hanks10100/weex-native-directive/tree/master/component
-
-// listening on native callback
-
/* */
/* */
@@ -4296,10 +4371,6 @@ function createComponent (
asyncFactory
);
- // Weex specific: invoke recycle-list optimized @render function for
- // extracting cell-slot template.
- // https://github.com/Hanks10100/weex-native-directive/tree/master/component
- /* istanbul ignore if */
return vnode
}
@@ -4347,12 +4418,21 @@ function mergeHook$1 (f1, f2) {
// prop and event handler respectively.
function transformModel (options, data) {
var prop = (options.model && options.model.prop) || 'value';
- var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
+ var event = (options.model && options.model.event) || 'input'
+ ;(data.props || (data.props = {}))[prop] = data.model.value;
var on = data.on || (data.on = {});
- if (isDef(on[event])) {
- on[event] = [data.model.callback].concat(on[event]);
+ var existing = on[event];
+ var callback = data.model.callback;
+ if (isDef(existing)) {
+ if (
+ Array.isArray(existing)
+ ? existing.indexOf(callback) === -1
+ : existing !== callback
+ ) {
+ on[event] = [callback].concat(existing);
+ }
} else {
- on[event] = data.model.callback;
+ on[event] = callback;
}
}
@@ -4440,7 +4520,7 @@ function _createElement (
config.parsePlatformTagName(tag), data, children,
undefined, undefined, context
);
- } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
+ } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
// component
vnode = createComponent(Ctor, data, context, children, tag);
} else {
@@ -4522,15 +4602,15 @@ function initRender (vm) {
/* istanbul ignore else */
if (process.env.NODE_ENV !== 'production') {
- defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
!isUpdatingChildComponent && warn("$attrs is readonly.", vm);
}, true);
- defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () {
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
!isUpdatingChildComponent && warn("$listeners is readonly.", vm);
}, true);
} else {
- defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
- defineReactive(vm, '$listeners', options._parentListeners || emptyObject, null, true);
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true);
}
}
@@ -4548,14 +4628,6 @@ function renderMixin (Vue) {
var render = ref.render;
var _parentVnode = ref._parentVnode;
- // reset _rendered flag on slots for duplicate slot check
- if (process.env.NODE_ENV !== 'production') {
- for (var key in vm.$slots) {
- // $flow-disable-line
- vm.$slots[key]._rendered = false;
- }
- }
-
if (_parentVnode) {
vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject;
}
@@ -4572,15 +4644,11 @@ function renderMixin (Vue) {
// return error render result,
// or previous vnode to prevent render error causing blank component
/* istanbul ignore else */
- if (process.env.NODE_ENV !== 'production') {
- if (vm.$options.renderError) {
- try {
- vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
- } catch (e) {
- handleError(e, vm, "renderError");
- vnode = vm._vnode;
- }
- } else {
+ if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
+ try {
+ vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
+ } catch (e) {
+ handleError(e, vm, "renderError");
vnode = vm._vnode;
}
} else {
@@ -4915,6 +4983,8 @@ function initAssetRegisters (Vue) {
/* */
+
+
function getComponentName (opts) {
return opts && (opts.Ctor.options.name || opts.tag)
}
@@ -4978,10 +5048,8 @@ var KeepAlive = {
},
destroyed: function destroyed () {
- var this$1 = this;
-
- for (var key in this$1.cache) {
- pruneCacheEntry(this$1.cache, key, this$1.keys);
+ for (var key in this.cache) {
+ pruneCacheEntry(this.cache, key, this.keys);
}
},
@@ -5041,11 +5109,11 @@ var KeepAlive = {
}
return vnode || (slot && slot[0])
}
-}
+};
var builtInComponents = {
KeepAlive: KeepAlive
-}
+};
/* */
@@ -5069,7 +5137,7 @@ function initGlobalAPI (Vue) {
warn: warn,
extend: extend,
mergeOptions: mergeOptions,
- defineReactive: defineReactive
+ defineReactive: defineReactive$$1
};
Vue.set = set;
@@ -5111,7 +5179,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
value: FunctionalRenderContext
});
-Vue.version = '2.5.17-beta.0';
+Vue.version = '2.5.18-beta.0';
/* */
@@ -5389,20 +5457,19 @@ function setStyleScope (node, scopeId) {
node.setAttribute(scopeId, '');
}
-
-var nodeOps = Object.freeze({
- createElement: createElement$1,
- createElementNS: createElementNS,
- createTextNode: createTextNode,
- createComment: createComment,
- insertBefore: insertBefore,
- removeChild: removeChild,
- appendChild: appendChild,
- parentNode: parentNode,
- nextSibling: nextSibling,
- tagName: tagName,
- setTextContent: setTextContent,
- setStyleScope: setStyleScope
+var nodeOps = /*#__PURE__*/Object.freeze({
+ createElement: createElement$1,
+ createElementNS: createElementNS,
+ createTextNode: createTextNode,
+ createComment: createComment,
+ insertBefore: insertBefore,
+ removeChild: removeChild,
+ appendChild: appendChild,
+ parentNode: parentNode,
+ nextSibling: nextSibling,
+ tagName: tagName,
+ setTextContent: setTextContent,
+ setStyleScope: setStyleScope
});
/* */
@@ -5420,7 +5487,7 @@ var ref = {
destroy: function destroy (vnode) {
registerRef(vnode, true);
}
-}
+};
function registerRef (vnode, isRemoval) {
var key = vnode.data.ref;
@@ -5465,6 +5532,12 @@ var emptyNode = new VNode('', {}, []);
var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
+function childrenIgnored (vnode) {
+ return vnode && vnode.data && vnode.data.domProps && (
+ vnode.data.domProps.innerHTML || vnode.data.domProps.textContent
+ )
+}
+
function sameVnode (a, b) {
return (
a.key === b.key && (
@@ -5472,6 +5545,7 @@ function sameVnode (a, b) {
a.tag === b.tag &&
a.isComment === b.isComment &&
isDef(a.data) === isDef(b.data) &&
+ !childrenIgnored(a) && !childrenIgnored(b) &&
sameInputType(a, b)
) || (
isTrue(a.isAsyncPlaceholder) &&
@@ -5521,13 +5595,13 @@ function createPatchFunction (backend) {
}
function createRmCb (childElm, listeners) {
- function remove () {
- if (--remove.listeners === 0) {
+ function remove$$1 () {
+ if (--remove$$1.listeners === 0) {
removeNode(childElm);
}
}
- remove.listeners = listeners;
- return remove
+ remove$$1.listeners = listeners;
+ return remove$$1
}
function removeNode (el) {
@@ -5688,7 +5762,7 @@ function createPatchFunction (backend) {
function insert (parent, elm, ref$$1) {
if (isDef(parent)) {
if (isDef(ref$$1)) {
- if (ref$$1.parentNode === parent) {
+ if (nodeOps.parentNode(ref$$1) === parent) {
nodeOps.insertBefore(parent, elm, ref$$1);
}
} else {
@@ -5843,20 +5917,20 @@ function createPatchFunction (backend) {
} else if (isUndef(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode)) {
- patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode)) {
- patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
- patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
- patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
@@ -5870,7 +5944,7 @@ function createPatchFunction (backend) {
} else {
vnodeToMove = oldCh[idxInOld];
if (sameVnode(vnodeToMove, newStartVnode)) {
- patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue);
+ patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldCh[idxInOld] = undefined;
canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
} else {
@@ -5914,11 +5988,23 @@ function createPatchFunction (backend) {
}
}
- function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
+ function patchVnode (
+ oldVnode,
+ vnode,
+ insertedVnodeQueue,
+ ownerArray,
+ index,
+ removeOnly
+ ) {
if (oldVnode === vnode) {
return
}
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
+ // clone reused vnode
+ vnode = ownerArray[index] = cloneVNode(vnode);
+ }
+
var elm = vnode.elm = oldVnode.elm;
if (isTrue(oldVnode.isAsyncPlaceholder)) {
@@ -5959,6 +6045,9 @@ function createPatchFunction (backend) {
if (isDef(oldCh) && isDef(ch)) {
if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
} else if (isDef(ch)) {
+ if (process.env.NODE_ENV !== 'production') {
+ checkDuplicateKeys(ch);
+ }
if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
} else if (isDef(oldCh)) {
@@ -6117,7 +6206,7 @@ function createPatchFunction (backend) {
var isRealElement = isDef(oldVnode.nodeType);
if (!isRealElement && sameVnode(oldVnode, vnode)) {
// patch existing root node
- patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
} else {
if (isRealElement) {
// mounting to a real element
@@ -6213,7 +6302,7 @@ var directives = {
destroy: function unbindDirectives (vnode) {
updateDirectives(vnode, emptyNode);
}
-}
+};
function updateDirectives (oldVnode, vnode) {
if (oldVnode.data.directives || vnode.data.directives) {
@@ -6324,7 +6413,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
var baseModules = [
ref,
directives
-]
+];
/* */
@@ -6408,7 +6497,7 @@ function baseSetAttr (el, key, value) {
/* istanbul ignore if */
if (
isIE && !isIE9 &&
- el.tagName === 'TEXTAREA' &&
+ (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') &&
key === 'placeholder' && !el.__ieph
) {
var blocker = function (e) {
@@ -6426,7 +6515,7 @@ function baseSetAttr (el, key, value) {
var attrs = {
create: updateAttrs,
update: updateAttrs
-}
+};
/* */
@@ -6464,7 +6553,7 @@ function updateClass (oldVnode, vnode) {
var klass = {
create: updateClass,
update: updateClass
-}
+};
/* */
@@ -6628,6 +6717,18 @@ function addHandler (
);
}
+ // normalize click.right and click.middle since they don't actually fire
+ // this is technically browser-specific, but at least for now browsers are
+ // the only target envs that have right/middle clicks.
+ if (name === 'click') {
+ if (modifiers.right) {
+ name = 'contextmenu';
+ delete modifiers.right;
+ } else if (modifiers.middle) {
+ name = 'mouseup';
+ }
+ }
+
// check capture modifier
if (modifiers.capture) {
delete modifiers.capture;
@@ -6643,18 +6744,6 @@ function addHandler (
name = '&' + name; // mark the event as passive
}
- // normalize click.right and click.middle since they don't actually fire
- // this is technically browser-specific, but at least for now browsers are
- // the only target envs that have right/middle clicks.
- if (name === 'click') {
- if (modifiers.right) {
- name = 'contextmenu';
- delete modifiers.right;
- } else if (modifiers.middle) {
- name = 'mouseup';
- }
- }
-
var events;
if (modifiers.native) {
delete modifiers.native;
@@ -6790,12 +6879,7 @@ function genAssignmentCode (
*
*/
-var len;
-var str;
-var chr;
-var index$1;
-var expressionPos;
-var expressionEndPos;
+var len, str, chr, index$1, expressionPos, expressionEndPos;
@@ -7076,7 +7160,7 @@ function normalizeEvents (on) {
var target$1;
-function createOnceHandler (handler, event, capture) {
+function createOnceHandler$1 (event, handler, capture) {
var _target = target$1; // save current target element in closure
return function onceHandler () {
var res = handler.apply(null, arguments);
@@ -7089,12 +7173,10 @@ function createOnceHandler (handler, event, capture) {
function add$1 (
event,
handler,
- once$$1,
capture,
passive
) {
handler = withMacroTask(handler);
- if (once$$1) { handler = createOnceHandler(handler, event, capture); }
target$1.addEventListener(
event,
handler,
@@ -7125,14 +7207,14 @@ function updateDOMListeners (oldVnode, vnode) {
var oldOn = oldVnode.data.on || {};
target$1 = vnode.elm;
normalizeEvents(on);
- updateListeners(on, oldOn, add$1, remove$2, vnode.context);
+ updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
target$1 = undefined;
}
var events = {
create: updateDOMListeners,
update: updateDOMListeners
-}
+};
/* */
@@ -7226,7 +7308,7 @@ function isDirtyWithModifiers (elm, newVal) {
var domProps = {
create: updateDOMProps,
update: updateDOMProps
-}
+};
/* */
@@ -7387,10 +7469,12 @@ function updateStyle (oldVnode, vnode) {
var style = {
create: updateStyle,
update: updateStyle
-}
+};
/* */
+var whitespaceRE = /\s+/;
+
/**
* Add class with compatibility for SVG since classList is not supported on
* SVG elements in IE
@@ -7404,7 +7488,7 @@ function addClass (el, cls) {
/* istanbul ignore else */
if (el.classList) {
if (cls.indexOf(' ') > -1) {
- cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
+ cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
} else {
el.classList.add(cls);
}
@@ -7429,7 +7513,7 @@ function removeClass (el, cls) {
/* istanbul ignore else */
if (el.classList) {
if (cls.indexOf(' ') > -1) {
- cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
+ cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
} else {
el.classList.remove(cls);
}
@@ -7453,20 +7537,20 @@ function removeClass (el, cls) {
/* */
-function resolveTransition (def) {
- if (!def) {
+function resolveTransition (def$$1) {
+ if (!def$$1) {
return
}
/* istanbul ignore else */
- if (typeof def === 'object') {
+ if (typeof def$$1 === 'object') {
var res = {};
- if (def.css !== false) {
- extend(res, autoCssTransition(def.name || 'v'));
+ if (def$$1.css !== false) {
+ extend(res, autoCssTransition(def$$1.name || 'v'));
}
- extend(res, def);
+ extend(res, def$$1);
return res
- } else if (typeof def === 'string') {
- return autoCssTransition(def)
+ } else if (typeof def$$1 === 'string') {
+ return autoCssTransition(def$$1)
}
}
@@ -7569,11 +7653,12 @@ var transformRE = /\b(transform|all)(,|$)/;
function getTransitionInfo (el, expectedType) {
var styles = window.getComputedStyle(el);
- var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
- var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
+ // JSDOM may return undefined for transition properties
+ var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
+ var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
- var animationDelays = styles[animationProp + 'Delay'].split(', ');
- var animationDurations = styles[animationProp + 'Duration'].split(', ');
+ var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
+ var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
var animationTimeout = getTimeout(animationDelays, animationDurations);
var type;
@@ -7627,8 +7712,12 @@ function getTimeout (delays, durations) {
}))
}
+// Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
+// in a locale-dependent way, using a comma instead of a dot.
+// If comma is not replaced with a dot, the input will be rounded down (i.e. acting
+// as a floor function) causing unexpected behaviors
function toMs (s) {
- return Number(s.slice(0, -1)) * 1000
+ return Number(s.slice(0, -1).replace(',', '.')) * 1000
}
/* */
@@ -7860,7 +7949,7 @@ function leave (vnode, rm) {
return
}
// record leaving element
- if (!vnode.data.show) {
+ if (!vnode.data.show && el.parentNode) {
(el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
}
beforeLeave && beforeLeave(el);
@@ -7949,7 +8038,7 @@ var transition = inBrowser ? {
rm();
}
}
-} : {}
+} : {};
var platformModules = [
attrs,
@@ -7958,7 +8047,7 @@ var platformModules = [
domProps,
style,
transition
-]
+];
/* */
@@ -8169,18 +8258,15 @@ var show = {
el.style.display = el.__vOriginalDisplay;
}
}
-}
+};
var platformDirectives = {
model: directive,
show: show
-}
+};
/* */
-// Provides transition support for a single element/component.
-// supports transition mode (out-in / in-out)
-
var transitionProps = {
name: String,
appear: Boolean,
@@ -8246,6 +8332,10 @@ function isSameChild (child, oldChild) {
return oldChild.key === child.key && oldChild.tag === child.tag
}
+var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
+
+var isVShowDirective = function (d) { return d.name === 'show'; };
+
var Transition = {
name: 'transition',
props: transitionProps,
@@ -8260,7 +8350,7 @@ var Transition = {
}
// filter out text nodes (possible whitespaces)
- children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); });
+ children = children.filter(isNotTextNode);
/* istanbul ignore if */
if (!children.length) {
return
@@ -8325,7 +8415,7 @@ var Transition = {
// mark v-show
// so that the transition module can hand over the control to the directive
- if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
+ if (child.data.directives && child.data.directives.some(isVShowDirective)) {
child.data.show = true;
}
@@ -8363,21 +8453,10 @@ var Transition = {
return rawChild
}
-}
+};
/* */
-// Provides transition support for list items.
-// supports move transitions using the FLIP technique.
-
-// Because the vdom's children update algorithm is "unstable" - i.e.
-// it doesn't guarantee the relative positioning of removed elements,
-// we force transition-group to update its children into two passes:
-// in the first pass, we remove all nodes that need to be removed,
-// triggering their leaving transition; in the second pass, we insert/move
-// into the final desired state. This way in the second pass removed
-// nodes will remain where they should be.
-
var props = extend({
tag: String,
moveClass: String
@@ -8473,6 +8552,9 @@ var TransitionGroup = {
addTransitionClass(el, moveClass);
s.transform = s.WebkitTransform = s.transitionDuration = '';
el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
+ if (e && e.target !== el) {
+ return
+ }
if (!e || /transform$/.test(e.propertyName)) {
el.removeEventListener(transitionEndEvent, cb);
el._moveCb = null;
@@ -8510,7 +8592,7 @@ var TransitionGroup = {
return (this._hasMove = info.hasTransform)
}
}
-}
+};
function callPendingCbs (c) {
/* istanbul ignore if */
@@ -8543,7 +8625,7 @@ function applyTranslation (c) {
var platformComponents = {
Transition: Transition,
TransitionGroup: TransitionGroup
-}
+};
/* */
@@ -8604,7 +8686,7 @@ if (inBrowser) {
/* */
-var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
+var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
var buildRegex = cached(function (delimiters) {
@@ -8690,7 +8772,7 @@ var klass$1 = {
staticKeys: ['staticClass'],
transformNode: transformNode,
genData: genData
-}
+};
/* */
@@ -8734,7 +8816,7 @@ var style$1 = {
staticKeys: ['staticStyle'],
transformNode: transformNode$1,
genData: genData$1
-}
+};
/* */
@@ -8746,7 +8828,7 @@ var he = {
decoder.innerHTML = html;
return decoder.textContent
}
-}
+};
/* */
@@ -8775,13 +8857,6 @@ var isNonPhrasingTag = makeMap(
* Not type-checking this file because it's mostly vendor code.
*/
-/*!
- * HTML Parser By John Resig (ejohn.org)
- * Modified by Juriy "kangax" Zaytsev
- * Original code by Erik Arvidsson, Mozilla Public License
- * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
- */
-
// Regular Expressions for parsing tags and attributes
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
@@ -8796,11 +8871,6 @@ var doctype = /^]+>/i;
var comment = /^= 0; pos--) {
if (stack[pos].lowerCasedTag === lowerCasedTagName) {
break
@@ -9083,7 +9144,7 @@ function parseHTML (html, options) {
var onRE = /^@|^v-on:/;
var dirRE = /^v-|^@|^:/;
-var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/;
+var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
var stripParensRE = /^\(|\)$/g;
@@ -9268,7 +9329,8 @@ function parse (
processIfConditions(element, currentParent);
} else if (element.slotScope) { // scoped slot
currentParent.plain = false;
- var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
+ var name = element.slotTarget || '"default"'
+ ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
} else {
currentParent.children.push(element);
element.parent = currentParent;
@@ -9392,8 +9454,20 @@ function processElement (element, options) {
function processKey (el) {
var exp = getBindingAttr(el, 'key');
if (exp) {
- if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
- warn$2(" cannot be keyed. Place the key on real elements instead.");
+ if (process.env.NODE_ENV !== 'production') {
+ if (el.tag === 'template') {
+ warn$2(" cannot be keyed. Place the key on real elements instead.");
+ }
+ if (el.for) {
+ var iterator = el.iterator2 || el.iterator1;
+ var parent = el.parent;
+ if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
+ warn$2(
+ "Do not use v-for index as key on children, " +
+ "this is the same as not using keys."
+ );
+ }
+ }
}
el.key = exp;
}
@@ -9431,7 +9505,7 @@ function parseFor (exp) {
var alias = inMatch[1].trim().replace(stripParensRE, '');
var iteratorMatch = alias.match(forIteratorRE);
if (iteratorMatch) {
- res.alias = alias.replace(forIteratorRE, '');
+ res.alias = alias.replace(forIteratorRE, '').trim();
res.iterator1 = iteratorMatch[1].trim();
if (iteratorMatch[2]) {
res.iterator2 = iteratorMatch[2].trim();
@@ -9584,6 +9658,14 @@ function processAttrs (el) {
name = name.replace(bindRE, '');
value = parseFilters(value);
isProp = false;
+ if (
+ process.env.NODE_ENV !== 'production' &&
+ value.trim().length === 0
+ ) {
+ warn$2(
+ ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
+ );
+ }
if (modifiers) {
if (modifiers.prop) {
isProp = true;
@@ -9732,16 +9814,6 @@ function checkForAliasModel (el, value) {
/* */
-/**
- * Expand input[v-model] with dyanmic type bindings into v-if-else chains
- * Turn this:
- *
- * into this:
- *
- *
- *
- */
-
function preTransformNode (el, options) {
if (el.tag === 'input') {
var map = el.attrsMap;
@@ -9808,15 +9880,15 @@ function cloneASTElement (el) {
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
}
-var model$2 = {
+var model$1 = {
preTransformNode: preTransformNode
-}
+};
var modules$1 = [
klass$1,
style$1,
- model$2
-]
+ model$1
+];
/* */
@@ -9838,7 +9910,7 @@ var directives$1 = {
model: model,
text: text,
html: html
-}
+};
/* */
@@ -10035,8 +10107,7 @@ var modifierCode = {
function genHandlers (
events,
- isNative,
- warn
+ isNative
) {
var res = isNative ? 'nativeOn:{' : 'on:{';
for (var name in events) {
@@ -10064,7 +10135,6 @@ function genHandler (
if (isMethodPath || isFunctionExpression) {
return handler.value
}
- /* istanbul ignore if */
return ("function($event){" + (handler.value) + "}") // inline statement
} else {
var code = '';
@@ -10101,7 +10171,6 @@ function genHandler (
: isFunctionExpression
? ("return (" + (handler.value) + ")($event)")
: handler.value;
- /* istanbul ignore if */
return ("function($event){" + code + handlerCode + "}")
}
}
@@ -10150,10 +10219,14 @@ var baseDirectives = {
on: on,
bind: bind$1,
cloak: noop
-}
+};
/* */
+
+
+
+
var CodegenState = function CodegenState (options) {
this.options = options;
this.warn = options.warn || baseWarn;
@@ -10161,9 +10234,10 @@ var CodegenState = function CodegenState (options) {
this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
this.directives = extend(extend({}, baseDirectives), options.directives);
var isReservedTag = options.isReservedTag || no;
- this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
+ this.maybeComponent = function (el) { return !(isReservedTag(el.tag) && !el.component); };
this.onceId = 0;
this.staticRenderFns = [];
+ this.pre = false;
};
@@ -10181,6 +10255,10 @@ function generate (
}
function genElement (el, state) {
+ if (el.parent) {
+ el.pre = el.pre || el.parent.pre;
+ }
+
if (el.staticRoot && !el.staticProcessed) {
return genStatic(el, state)
} else if (el.once && !el.onceProcessed) {
@@ -10189,7 +10267,7 @@ function genElement (el, state) {
return genFor(el, state)
} else if (el.if && !el.ifProcessed) {
return genIf(el, state)
- } else if (el.tag === 'template' && !el.slotTarget) {
+ } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
return genChildren(el, state) || 'void 0'
} else if (el.tag === 'slot') {
return genSlot(el, state)
@@ -10199,7 +10277,10 @@ function genElement (el, state) {
if (el.component) {
code = genComponent(el.component, el, state);
} else {
- var data = el.plain ? undefined : genData$2(el, state);
+ var data;
+ if (!el.plain || (el.pre && state.maybeComponent(el))) {
+ data = genData$2(el, state);
+ }
var children = el.inlineTemplate ? null : genChildren(el, state, true);
code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
@@ -10215,7 +10296,15 @@ function genElement (el, state) {
// hoist static sub-trees out
function genStatic (el, state) {
el.staticProcessed = true;
+ // Some elements (templates) need to behave differently inside of a v-pre
+ // node. All pre nodes are static roots, so we can use this as a location to
+ // wrap a state change and reset it upon exiting the pre node.
+ var originalPreState = state.pre;
+ if (el.pre) {
+ state.pre = el.pre;
+ }
state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
+ state.pre = originalPreState;
return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
}
@@ -10356,10 +10445,10 @@ function genData$2 (el, state) {
}
// event handlers
if (el.events) {
- data += (genHandlers(el.events, false, state.warn)) + ",";
+ data += (genHandlers(el.events, false)) + ",";
}
if (el.nativeEvents) {
- data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
+ data += (genHandlers(el.nativeEvents, true)) + ",";
}
// slot target
// only for non-scoped slots
@@ -10451,7 +10540,7 @@ function genScopedSlot (
var fn = "function(" + (String(el.slotScope)) + "){" +
"return " + (el.tag === 'template'
? el.if
- ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
+ ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
: genChildren(el, state) || 'undefined'
: genElement(el, state)) + "}";
return ("{key:" + key + ",fn:" + fn + "}")
@@ -10489,13 +10578,16 @@ function genChildren (
el$1.tag !== 'template' &&
el$1.tag !== 'slot'
) {
- return (altGenElement || genElement)(el$1, state)
+ // because el may be a functional component and return an Array instead of a single root.
+ // In this case, just a simple normalization is needed
+ var normalizationType = state.maybeComponent(el$1) ? ",1" : "";
+ return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
}
- var normalizationType = checkSkip
+ var normalizationType$1 = checkSkip
? getNormalizationType(children, state.maybeComponent)
: 0;
var gen = altGenNode || genNode;
- return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
+ return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
}
}
@@ -10533,7 +10625,7 @@ function needsNormalization (el) {
function genNode (node, state) {
if (node.type === 1) {
return genElement(node, state)
- } if (node.type === 3 && node.isComment) {
+ } else if (node.type === 3 && node.isComment) {
return genComment(node)
} else {
return genText(node)
@@ -10706,6 +10798,8 @@ function checkExpression (exp, text, errors) {
/* */
+
+
function createFunction (code, errors) {
try {
return new Function(code)
@@ -10877,6 +10971,7 @@ var createCompiler = createCompilerCreator(function baseCompile (
/* */
var ref$1 = createCompiler(baseOptions);
+var compile = ref$1.compile;
var compileToFunctions = ref$1.compileToFunctions;
/* */
diff --git a/dist/vue.js b/dist/vue.js
index 74a71bb673a..3047cc4396e 100644
--- a/dist/vue.js
+++ b/dist/vue.js
@@ -1,10978 +1,11057 @@
/*!
- * Vue.js v2.5.17-beta.0
+ * Vue.js v2.5.18-beta.0
* (c) 2014-2018 Evan You
* Released under the MIT License.
*/
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global.Vue = factory());
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global.Vue = factory());
}(this, (function () { 'use strict';
-/* */
+ /* */
-var emptyObject = Object.freeze({});
+ var emptyObject = Object.freeze({});
-// these helpers produces better vm code in JS engines due to their
-// explicitness and function inlining
-function isUndef (v) {
- return v === undefined || v === null
-}
-
-function isDef (v) {
- return v !== undefined && v !== null
-}
-
-function isTrue (v) {
- return v === true
-}
-
-function isFalse (v) {
- return v === false
-}
-
-/**
- * Check if value is primitive
- */
-function isPrimitive (value) {
- return (
- typeof value === 'string' ||
- typeof value === 'number' ||
- // $flow-disable-line
- typeof value === 'symbol' ||
- typeof value === 'boolean'
- )
-}
-
-/**
- * Quick object check - this is primarily used to tell
- * Objects from primitive values when we know the value
- * is a JSON-compliant type.
- */
-function isObject (obj) {
- return obj !== null && typeof obj === 'object'
-}
-
-/**
- * Get the raw type string of a value e.g. [object Object]
- */
-var _toString = Object.prototype.toString;
-
-function toRawType (value) {
- return _toString.call(value).slice(8, -1)
-}
-
-/**
- * Strict object type check. Only returns true
- * for plain JavaScript objects.
- */
-function isPlainObject (obj) {
- return _toString.call(obj) === '[object Object]'
-}
-
-function isRegExp (v) {
- return _toString.call(v) === '[object RegExp]'
-}
-
-/**
- * Check if val is a valid array index.
- */
-function isValidArrayIndex (val) {
- var n = parseFloat(String(val));
- return n >= 0 && Math.floor(n) === n && isFinite(val)
-}
+ // These helpers produce better VM code in JS engines due to their
+ // explicitness and function inlining.
+ function isUndef (v) {
+ return v === undefined || v === null
+ }
-/**
- * Convert a value to a string that is actually rendered.
- */
-function toString (val) {
- return val == null
- ? ''
- : typeof val === 'object'
- ? JSON.stringify(val, null, 2)
- : String(val)
-}
-
-/**
- * Convert a input value to a number for persistence.
- * If the conversion fails, return original string.
- */
-function toNumber (val) {
- var n = parseFloat(val);
- return isNaN(n) ? val : n
-}
-
-/**
- * Make a map and return a function for checking if a key
- * is in that map.
- */
-function makeMap (
- str,
- expectsLowerCase
-) {
- var map = Object.create(null);
- var list = str.split(',');
- for (var i = 0; i < list.length; i++) {
- map[list[i]] = true;
- }
- return expectsLowerCase
- ? function (val) { return map[val.toLowerCase()]; }
- : function (val) { return map[val]; }
-}
-
-/**
- * Check if a tag is a built-in tag.
- */
-var isBuiltInTag = makeMap('slot,component', true);
+ function isDef (v) {
+ return v !== undefined && v !== null
+ }
-/**
- * Check if a attribute is a reserved attribute.
- */
-var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
+ function isTrue (v) {
+ return v === true
+ }
-/**
- * Remove an item from an array
- */
-function remove (arr, item) {
- if (arr.length) {
- var index = arr.indexOf(item);
- if (index > -1) {
- return arr.splice(index, 1)
- }
+ function isFalse (v) {
+ return v === false
}
-}
-/**
- * Check whether the object has the property.
- */
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-function hasOwn (obj, key) {
- return hasOwnProperty.call(obj, key)
-}
+ /**
+ * Check if value is primitive.
+ */
+ function isPrimitive (value) {
+ return (
+ typeof value === 'string' ||
+ typeof value === 'number' ||
+ // $flow-disable-line
+ typeof value === 'symbol' ||
+ typeof value === 'boolean'
+ )
+ }
-/**
- * Create a cached version of a pure function.
- */
-function cached (fn) {
- var cache = Object.create(null);
- return (function cachedFn (str) {
- var hit = cache[str];
- return hit || (cache[str] = fn(str))
- })
-}
-
-/**
- * Camelize a hyphen-delimited string.
- */
-var camelizeRE = /-(\w)/g;
-var camelize = cached(function (str) {
- return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
-});
+ /**
+ * Quick object check - this is primarily used to tell
+ * Objects from primitive values when we know the value
+ * is a JSON-compliant type.
+ */
+ function isObject (obj) {
+ return obj !== null && typeof obj === 'object'
+ }
-/**
- * Capitalize a string.
- */
-var capitalize = cached(function (str) {
- return str.charAt(0).toUpperCase() + str.slice(1)
-});
+ /**
+ * Get the raw type string of a value, e.g., [object Object].
+ */
+ var _toString = Object.prototype.toString;
-/**
- * Hyphenate a camelCase string.
- */
-var hyphenateRE = /\B([A-Z])/g;
-var hyphenate = cached(function (str) {
- return str.replace(hyphenateRE, '-$1').toLowerCase()
-});
-
-/**
- * Simple bind polyfill for environments that do not support it... e.g.
- * PhantomJS 1.x. Technically we don't need this anymore since native bind is
- * now more performant in most browsers, but removing it would be breaking for
- * code that was able to run in PhantomJS 1.x, so this must be kept for
- * backwards compatibility.
- */
+ function toRawType (value) {
+ return _toString.call(value).slice(8, -1)
+ }
-/* istanbul ignore next */
-function polyfillBind (fn, ctx) {
- function boundFn (a) {
- var l = arguments.length;
- return l
- ? l > 1
- ? fn.apply(ctx, arguments)
- : fn.call(ctx, a)
- : fn.call(ctx)
+ /**
+ * Strict object type check. Only returns true
+ * for plain JavaScript objects.
+ */
+ function isPlainObject (obj) {
+ return _toString.call(obj) === '[object Object]'
}
- boundFn._length = fn.length;
- return boundFn
-}
+ function isRegExp (v) {
+ return _toString.call(v) === '[object RegExp]'
+ }
-function nativeBind (fn, ctx) {
- return fn.bind(ctx)
-}
+ /**
+ * Check if val is a valid array index.
+ */
+ function isValidArrayIndex (val) {
+ var n = parseFloat(String(val));
+ return n >= 0 && Math.floor(n) === n && isFinite(val)
+ }
-var bind = Function.prototype.bind
- ? nativeBind
- : polyfillBind;
+ /**
+ * Convert a value to a string that is actually rendered.
+ */
+ function toString (val) {
+ return val == null
+ ? ''
+ : typeof val === 'object'
+ ? JSON.stringify(val, null, 2)
+ : String(val)
+ }
-/**
- * Convert an Array-like object to a real Array.
- */
-function toArray (list, start) {
- start = start || 0;
- var i = list.length - start;
- var ret = new Array(i);
- while (i--) {
- ret[i] = list[i + start];
- }
- return ret
-}
-
-/**
- * Mix properties into target object.
- */
-function extend (to, _from) {
- for (var key in _from) {
- to[key] = _from[key];
+ /**
+ * Convert an input value to a number for persistence.
+ * If the conversion fails, return original string.
+ */
+ function toNumber (val) {
+ var n = parseFloat(val);
+ return isNaN(n) ? val : n
}
- return to
-}
-/**
- * Merge an Array of Objects into a single Object.
- */
-function toObject (arr) {
- var res = {};
- for (var i = 0; i < arr.length; i++) {
- if (arr[i]) {
- extend(res, arr[i]);
+ /**
+ * Make a map and return a function for checking if a key
+ * is in that map.
+ */
+ function makeMap (
+ str,
+ expectsLowerCase
+ ) {
+ var map = Object.create(null);
+ var list = str.split(',');
+ for (var i = 0; i < list.length; i++) {
+ map[list[i]] = true;
}
+ return expectsLowerCase
+ ? function (val) { return map[val.toLowerCase()]; }
+ : function (val) { return map[val]; }
}
- return res
-}
-
-/**
- * Perform no operation.
- * Stubbing args to make Flow happy without leaving useless transpiled code
- * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
- */
-function noop (a, b, c) {}
-/**
- * Always return false.
- */
-var no = function (a, b, c) { return false; };
+ /**
+ * Check if a tag is a built-in tag.
+ */
+ var isBuiltInTag = makeMap('slot,component', true);
-/**
- * Return same value
- */
-var identity = function (_) { return _; };
+ /**
+ * Check if an attribute is a reserved attribute.
+ */
+ var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
-/**
- * Generate a static keys string from compiler modules.
- */
-function genStaticKeys (modules) {
- return modules.reduce(function (keys, m) {
- return keys.concat(m.staticKeys || [])
- }, []).join(',')
-}
-
-/**
- * Check if two values are loosely equal - that is,
- * if they are plain objects, do they have the same shape?
- */
-function looseEqual (a, b) {
- if (a === b) { return true }
- var isObjectA = isObject(a);
- var isObjectB = isObject(b);
- if (isObjectA && isObjectB) {
- try {
- var isArrayA = Array.isArray(a);
- var isArrayB = Array.isArray(b);
- if (isArrayA && isArrayB) {
- return a.length === b.length && a.every(function (e, i) {
- return looseEqual(e, b[i])
- })
- } else if (!isArrayA && !isArrayB) {
- var keysA = Object.keys(a);
- var keysB = Object.keys(b);
- return keysA.length === keysB.length && keysA.every(function (key) {
- return looseEqual(a[key], b[key])
- })
- } else {
- /* istanbul ignore next */
- return false
+ /**
+ * Remove an item from an array.
+ */
+ function remove (arr, item) {
+ if (arr.length) {
+ var index = arr.indexOf(item);
+ if (index > -1) {
+ return arr.splice(index, 1)
}
- } catch (e) {
- /* istanbul ignore next */
- return false
}
- } else if (!isObjectA && !isObjectB) {
- return String(a) === String(b)
- } else {
- return false
}
-}
-function looseIndexOf (arr, val) {
- for (var i = 0; i < arr.length; i++) {
- if (looseEqual(arr[i], val)) { return i }
- }
- return -1
-}
-
-/**
- * Ensure a function is called only once.
- */
-function once (fn) {
- var called = false;
- return function () {
- if (!called) {
- called = true;
- fn.apply(this, arguments);
- }
- }
-}
-
-var SSR_ATTR = 'data-server-rendered';
-
-var ASSET_TYPES = [
- 'component',
- 'directive',
- 'filter'
-];
-
-var LIFECYCLE_HOOKS = [
- 'beforeCreate',
- 'created',
- 'beforeMount',
- 'mounted',
- 'beforeUpdate',
- 'updated',
- 'beforeDestroy',
- 'destroyed',
- 'activated',
- 'deactivated',
- 'errorCaptured'
-];
-
-/* */
-
-var config = ({
/**
- * Option merge strategies (used in core/util/options)
+ * Check whether an object has the property.
*/
- // $flow-disable-line
- optionMergeStrategies: Object.create(null),
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ function hasOwn (obj, key) {
+ return hasOwnProperty.call(obj, key)
+ }
/**
- * Whether to suppress warnings.
+ * Create a cached version of a pure function.
*/
- silent: false,
+ function cached (fn) {
+ var cache = Object.create(null);
+ return (function cachedFn (str) {
+ var hit = cache[str];
+ return hit || (cache[str] = fn(str))
+ })
+ }
/**
- * Show production mode tip message on boot?
+ * Camelize a hyphen-delimited string.
*/
- productionTip: "development" !== 'production',
+ var camelizeRE = /-(\w)/g;
+ var camelize = cached(function (str) {
+ return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
+ });
/**
- * Whether to enable devtools
+ * Capitalize a string.
*/
- devtools: "development" !== 'production',
+ var capitalize = cached(function (str) {
+ return str.charAt(0).toUpperCase() + str.slice(1)
+ });
/**
- * Whether to record perf
+ * Hyphenate a camelCase string.
*/
- performance: false,
+ var hyphenateRE = /\B([A-Z])/g;
+ var hyphenate = cached(function (str) {
+ return str.replace(hyphenateRE, '-$1').toLowerCase()
+ });
/**
- * Error handler for watcher errors
+ * Simple bind polyfill for environments that do not support it,
+ * e.g., PhantomJS 1.x. Technically, we don't need this anymore
+ * since native bind is now performant enough in most browsers.
+ * But removing it would mean breaking code that was able to run in
+ * PhantomJS 1.x, so this must be kept for backward compatibility.
*/
- errorHandler: null,
+
+ /* istanbul ignore next */
+ function polyfillBind (fn, ctx) {
+ function boundFn (a) {
+ var l = arguments.length;
+ return l
+ ? l > 1
+ ? fn.apply(ctx, arguments)
+ : fn.call(ctx, a)
+ : fn.call(ctx)
+ }
+
+ boundFn._length = fn.length;
+ return boundFn
+ }
+
+ function nativeBind (fn, ctx) {
+ return fn.bind(ctx)
+ }
+
+ var bind = Function.prototype.bind
+ ? nativeBind
+ : polyfillBind;
/**
- * Warn handler for watcher warns
+ * Convert an Array-like object to a real Array.
*/
- warnHandler: null,
+ function toArray (list, start) {
+ start = start || 0;
+ var i = list.length - start;
+ var ret = new Array(i);
+ while (i--) {
+ ret[i] = list[i + start];
+ }
+ return ret
+ }
/**
- * Ignore certain custom elements
+ * Mix properties into target object.
*/
- ignoredElements: [],
+ function extend (to, _from) {
+ for (var key in _from) {
+ to[key] = _from[key];
+ }
+ return to
+ }
/**
- * Custom user key aliases for v-on
+ * Merge an Array of Objects into a single Object.
*/
- // $flow-disable-line
- keyCodes: Object.create(null),
+ function toObject (arr) {
+ var res = {};
+ for (var i = 0; i < arr.length; i++) {
+ if (arr[i]) {
+ extend(res, arr[i]);
+ }
+ }
+ return res
+ }
+
+ /* eslint-disable no-unused-vars */
/**
- * Check if a tag is reserved so that it cannot be registered as a
- * component. This is platform-dependent and may be overwritten.
+ * Perform no operation.
+ * Stubbing args to make Flow happy without leaving useless transpiled code
+ * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
- isReservedTag: no,
+ function noop (a, b, c) {}
/**
- * Check if an attribute is reserved so that it cannot be used as a component
- * prop. This is platform-dependent and may be overwritten.
+ * Always return false.
*/
- isReservedAttr: no,
+ var no = function (a, b, c) { return false; };
+
+ /* eslint-enable no-unused-vars */
/**
- * Check if a tag is an unknown element.
- * Platform-dependent.
+ * Return the same value.
*/
- isUnknownElement: no,
+ var identity = function (_) { return _; };
/**
- * Get the namespace of an element
+ * Generate a string containing static keys from compiler modules.
*/
- getTagNamespace: noop,
+ function genStaticKeys (modules) {
+ return modules.reduce(function (keys, m) {
+ return keys.concat(m.staticKeys || [])
+ }, []).join(',')
+ }
/**
- * Parse the real tag name for the specific platform.
+ * Check if two values are loosely equal - that is,
+ * if they are plain objects, do they have the same shape?
*/
- parsePlatformTagName: identity,
+ function looseEqual (a, b) {
+ if (a === b) { return true }
+ var isObjectA = isObject(a);
+ var isObjectB = isObject(b);
+ if (isObjectA && isObjectB) {
+ try {
+ var isArrayA = Array.isArray(a);
+ var isArrayB = Array.isArray(b);
+ if (isArrayA && isArrayB) {
+ return a.length === b.length && a.every(function (e, i) {
+ return looseEqual(e, b[i])
+ })
+ } else if (a instanceof Date && b instanceof Date) {
+ return a.getTime() === b.getTime()
+ } else if (!isArrayA && !isArrayB) {
+ var keysA = Object.keys(a);
+ var keysB = Object.keys(b);
+ return keysA.length === keysB.length && keysA.every(function (key) {
+ return looseEqual(a[key], b[key])
+ })
+ } else {
+ /* istanbul ignore next */
+ return false
+ }
+ } catch (e) {
+ /* istanbul ignore next */
+ return false
+ }
+ } else if (!isObjectA && !isObjectB) {
+ return String(a) === String(b)
+ } else {
+ return false
+ }
+ }
/**
- * Check if an attribute must be bound using property, e.g. value
- * Platform-dependent.
+ * Return the first index at which a loosely equal value can be
+ * found in the array (if value is a plain object, the array must
+ * contain an object of the same shape), or -1 if it is not present.
*/
- mustUseProp: no,
+ function looseIndexOf (arr, val) {
+ for (var i = 0; i < arr.length; i++) {
+ if (looseEqual(arr[i], val)) { return i }
+ }
+ return -1
+ }
/**
- * Exposed for legacy reasons
+ * Ensure a function is called only once.
*/
- _lifecycleHooks: LIFECYCLE_HOOKS
-})
+ function once (fn) {
+ var called = false;
+ return function () {
+ if (!called) {
+ called = true;
+ fn.apply(this, arguments);
+ }
+ }
+ }
-/* */
+ var SSR_ATTR = 'data-server-rendered';
-/**
- * Check if a string starts with $ or _
- */
-function isReserved (str) {
- var c = (str + '').charCodeAt(0);
- return c === 0x24 || c === 0x5F
-}
+ var ASSET_TYPES = [
+ 'component',
+ 'directive',
+ 'filter'
+ ];
-/**
- * Define a property.
- */
-function def (obj, key, val, enumerable) {
- Object.defineProperty(obj, key, {
- value: val,
- enumerable: !!enumerable,
- writable: true,
- configurable: true
+ var LIFECYCLE_HOOKS = [
+ 'beforeCreate',
+ 'created',
+ 'beforeMount',
+ 'mounted',
+ 'beforeUpdate',
+ 'updated',
+ 'beforeDestroy',
+ 'destroyed',
+ 'activated',
+ 'deactivated',
+ 'errorCaptured'
+ ];
+
+ /* */
+
+
+
+ var config = ({
+ /**
+ * Option merge strategies (used in core/util/options)
+ */
+ // $flow-disable-line
+ optionMergeStrategies: Object.create(null),
+
+ /**
+ * Whether to suppress warnings.
+ */
+ silent: false,
+
+ /**
+ * Show production mode tip message on boot?
+ */
+ productionTip: "development" !== 'production',
+
+ /**
+ * Whether to enable devtools
+ */
+ devtools: "development" !== 'production',
+
+ /**
+ * Whether to record perf
+ */
+ performance: false,
+
+ /**
+ * Error handler for watcher errors
+ */
+ errorHandler: null,
+
+ /**
+ * Warn handler for watcher warns
+ */
+ warnHandler: null,
+
+ /**
+ * Ignore certain custom elements
+ */
+ ignoredElements: [],
+
+ /**
+ * Custom user key aliases for v-on
+ */
+ // $flow-disable-line
+ keyCodes: Object.create(null),
+
+ /**
+ * Check if a tag is reserved so that it cannot be registered as a
+ * component. This is platform-dependent and may be overwritten.
+ */
+ isReservedTag: no,
+
+ /**
+ * Check if an attribute is reserved so that it cannot be used as a component
+ * prop. This is platform-dependent and may be overwritten.
+ */
+ isReservedAttr: no,
+
+ /**
+ * Check if a tag is an unknown element.
+ * Platform-dependent.
+ */
+ isUnknownElement: no,
+
+ /**
+ * Get the namespace of an element
+ */
+ getTagNamespace: noop,
+
+ /**
+ * Parse the real tag name for the specific platform.
+ */
+ parsePlatformTagName: identity,
+
+ /**
+ * Check if an attribute must be bound using property, e.g. value
+ * Platform-dependent.
+ */
+ mustUseProp: no,
+
+ /**
+ * Perform updates asynchronously. Intended to be used by Vue Test Utils
+ * This will significantly reduce performance if set to false.
+ */
+ async: true,
+
+ /**
+ * Exposed for legacy reasons
+ */
+ _lifecycleHooks: LIFECYCLE_HOOKS
});
-}
-/**
- * Parse simple path.
- */
-var bailRE = /[^\w.$]/;
-function parsePath (path) {
- if (bailRE.test(path)) {
- return
- }
- var segments = path.split('.');
- return function (obj) {
- for (var i = 0; i < segments.length; i++) {
- if (!obj) { return }
- obj = obj[segments[i]];
- }
- return obj
- }
-}
-
-/* */
-
-// can we use __proto__?
-var hasProto = '__proto__' in {};
-
-// Browser environment sniffing
-var inBrowser = typeof window !== 'undefined';
-var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
-var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
-var UA = inBrowser && window.navigator.userAgent.toLowerCase();
-var isIE = UA && /msie|trident/.test(UA);
-var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
-var isEdge = UA && UA.indexOf('edge/') > 0;
-var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
-var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
-var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
-
-// Firefox has a "watch" function on Object.prototype...
-var nativeWatch = ({}).watch;
-
-var supportsPassive = false;
-if (inBrowser) {
- try {
- var opts = {};
- Object.defineProperty(opts, 'passive', ({
- get: function get () {
- /* istanbul ignore next */
- supportsPassive = true;
- }
- })); // https://github.com/facebook/flow/issues/285
- window.addEventListener('test-passive', null, opts);
- } catch (e) {}
-}
-
-// this needs to be lazy-evaled because vue may be required before
-// vue-server-renderer can set VUE_ENV
-var _isServer;
-var isServerRendering = function () {
- if (_isServer === undefined) {
- /* istanbul ignore if */
- if (!inBrowser && !inWeex && typeof global !== 'undefined') {
- // detect presence of vue-server-renderer and avoid
- // Webpack shimming the process
- _isServer = global['process'].env.VUE_ENV === 'server';
- } else {
- _isServer = false;
+ /* */
+
+ /**
+ * Check if a string starts with $ or _
+ */
+ function isReserved (str) {
+ var c = (str + '').charCodeAt(0);
+ return c === 0x24 || c === 0x5F
+ }
+
+ /**
+ * Define a property.
+ */
+ function def (obj, key, val, enumerable) {
+ Object.defineProperty(obj, key, {
+ value: val,
+ enumerable: !!enumerable,
+ writable: true,
+ configurable: true
+ });
+ }
+
+ /**
+ * Parse simple path.
+ */
+ var bailRE = /[^\w.$]/;
+ function parsePath (path) {
+ if (bailRE.test(path)) {
+ return
+ }
+ var segments = path.split('.');
+ return function (obj) {
+ for (var i = 0; i < segments.length; i++) {
+ if (!obj) { return }
+ obj = obj[segments[i]];
+ }
+ return obj
}
}
- return _isServer
-};
-// detect devtools
-var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
+ /* */
+
+ // can we use __proto__?
+ var hasProto = '__proto__' in {};
-/* istanbul ignore next */
-function isNative (Ctor) {
- return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
-}
+ // Browser environment sniffing
+ var inBrowser = typeof window !== 'undefined';
+ var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
+ var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
+ var UA = inBrowser && window.navigator.userAgent.toLowerCase();
+ var isIE = UA && /msie|trident/.test(UA);
+ var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
+ var isEdge = UA && UA.indexOf('edge/') > 0;
+ var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
+ var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
+ var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
-var hasSymbol =
- typeof Symbol !== 'undefined' && isNative(Symbol) &&
- typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
+ // Firefox has a "watch" function on Object.prototype...
+ var nativeWatch = ({}).watch;
-var _Set;
-/* istanbul ignore if */ // $flow-disable-line
-if (typeof Set !== 'undefined' && isNative(Set)) {
- // use native Set when available.
- _Set = Set;
-} else {
- // a non-standard Set polyfill that only works with primitive keys.
- _Set = (function () {
- function Set () {
- this.set = Object.create(null);
+ var supportsPassive = false;
+ if (inBrowser) {
+ try {
+ var opts = {};
+ Object.defineProperty(opts, 'passive', ({
+ get: function get () {
+ /* istanbul ignore next */
+ supportsPassive = true;
+ }
+ })); // https://github.com/facebook/flow/issues/285
+ window.addEventListener('test-passive', null, opts);
+ } catch (e) {}
+ }
+
+ // this needs to be lazy-evaled because vue may be required before
+ // vue-server-renderer can set VUE_ENV
+ var _isServer;
+ var isServerRendering = function () {
+ if (_isServer === undefined) {
+ /* istanbul ignore if */
+ if (!inBrowser && !inWeex && typeof global !== 'undefined') {
+ // detect presence of vue-server-renderer and avoid
+ // Webpack shimming the process
+ _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
+ } else {
+ _isServer = false;
+ }
}
- Set.prototype.has = function has (key) {
- return this.set[key] === true
- };
- Set.prototype.add = function add (key) {
- this.set[key] = true;
- };
- Set.prototype.clear = function clear () {
- this.set = Object.create(null);
- };
+ return _isServer
+ };
- return Set;
- }());
-}
+ // detect devtools
+ var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
-/* */
+ /* istanbul ignore next */
+ function isNative (Ctor) {
+ return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
+ }
-var warn = noop;
-var tip = noop;
-var generateComponentTrace = (noop); // work around flow check
-var formatComponentName = (noop);
+ var hasSymbol =
+ typeof Symbol !== 'undefined' && isNative(Symbol) &&
+ typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
-{
- var hasConsole = typeof console !== 'undefined';
- var classifyRE = /(?:^|[-_])(\w)/g;
- var classify = function (str) { return str
- .replace(classifyRE, function (c) { return c.toUpperCase(); })
- .replace(/[-_]/g, ''); };
+ var _Set;
+ /* istanbul ignore if */ // $flow-disable-line
+ if (typeof Set !== 'undefined' && isNative(Set)) {
+ // use native Set when available.
+ _Set = Set;
+ } else {
+ // a non-standard Set polyfill that only works with primitive keys.
+ _Set = /*@__PURE__*/(function () {
+ function Set () {
+ this.set = Object.create(null);
+ }
+ Set.prototype.has = function has (key) {
+ return this.set[key] === true
+ };
+ Set.prototype.add = function add (key) {
+ this.set[key] = true;
+ };
+ Set.prototype.clear = function clear () {
+ this.set = Object.create(null);
+ };
- warn = function (msg, vm) {
- var trace = vm ? generateComponentTrace(vm) : '';
+ return Set;
+ }());
+ }
- if (config.warnHandler) {
- config.warnHandler.call(null, msg, vm, trace);
- } else if (hasConsole && (!config.silent)) {
- console.error(("[Vue warn]: " + msg + trace));
- }
- };
+ /* */
- tip = function (msg, vm) {
- if (hasConsole && (!config.silent)) {
- console.warn("[Vue tip]: " + msg + (
- vm ? generateComponentTrace(vm) : ''
- ));
- }
- };
+ var warn = noop;
+ var tip = noop;
+ var generateComponentTrace = (noop); // work around flow check
+ var formatComponentName = (noop);
- formatComponentName = function (vm, includeFile) {
- if (vm.$root === vm) {
- return ''
- }
- var options = typeof vm === 'function' && vm.cid != null
- ? vm.options
- : vm._isVue
- ? vm.$options || vm.constructor.options
- : vm || {};
- var name = options.name || options._componentTag;
- var file = options.__file;
- if (!name && file) {
- var match = file.match(/([^/\\]+)\.vue$/);
- name = match && match[1];
- }
+ {
+ var hasConsole = typeof console !== 'undefined';
+ var classifyRE = /(?:^|[-_])(\w)/g;
+ var classify = function (str) { return str
+ .replace(classifyRE, function (c) { return c.toUpperCase(); })
+ .replace(/[-_]/g, ''); };
- return (
- (name ? ("<" + (classify(name)) + ">") : "") +
- (file && includeFile !== false ? (" at " + file) : '')
- )
- };
+ warn = function (msg, vm) {
+ var trace = vm ? generateComponentTrace(vm) : '';
- var repeat = function (str, n) {
- var res = '';
- while (n) {
- if (n % 2 === 1) { res += str; }
- if (n > 1) { str += str; }
- n >>= 1;
- }
- return res
- };
+ if (config.warnHandler) {
+ config.warnHandler.call(null, msg, vm, trace);
+ } else if (hasConsole && (!config.silent)) {
+ console.error(("[Vue warn]: " + msg + trace));
+ }
+ };
- generateComponentTrace = function (vm) {
- if (vm._isVue && vm.$parent) {
- var tree = [];
- var currentRecursiveSequence = 0;
- while (vm) {
- if (tree.length > 0) {
- var last = tree[tree.length - 1];
- if (last.constructor === vm.constructor) {
- currentRecursiveSequence++;
- vm = vm.$parent;
- continue
- } else if (currentRecursiveSequence > 0) {
- tree[tree.length - 1] = [last, currentRecursiveSequence];
- currentRecursiveSequence = 0;
- }
- }
- tree.push(vm);
- vm = vm.$parent;
+ tip = function (msg, vm) {
+ if (hasConsole && (!config.silent)) {
+ console.warn("[Vue tip]: " + msg + (
+ vm ? generateComponentTrace(vm) : ''
+ ));
}
- return '\n\nfound in\n\n' + tree
- .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
- ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
- : formatComponentName(vm))); })
- .join('\n')
- } else {
- return ("\n\n(found in " + (formatComponentName(vm)) + ")")
- }
- };
-}
+ };
-/* */
+ formatComponentName = function (vm, includeFile) {
+ if (vm.$root === vm) {
+ return ''
+ }
+ var options = typeof vm === 'function' && vm.cid != null
+ ? vm.options
+ : vm._isVue
+ ? vm.$options || vm.constructor.options
+ : vm || {};
+ var name = options.name || options._componentTag;
+ var file = options.__file;
+ if (!name && file) {
+ var match = file.match(/([^/\\]+)\.vue$/);
+ name = match && match[1];
+ }
+
+ return (
+ (name ? ("<" + (classify(name)) + ">") : "") +
+ (file && includeFile !== false ? (" at " + file) : '')
+ )
+ };
+ var repeat = function (str, n) {
+ var res = '';
+ while (n) {
+ if (n % 2 === 1) { res += str; }
+ if (n > 1) { str += str; }
+ n >>= 1;
+ }
+ return res
+ };
-var uid = 0;
+ generateComponentTrace = function (vm) {
+ if (vm._isVue && vm.$parent) {
+ var tree = [];
+ var currentRecursiveSequence = 0;
+ while (vm) {
+ if (tree.length > 0) {
+ var last = tree[tree.length - 1];
+ if (last.constructor === vm.constructor) {
+ currentRecursiveSequence++;
+ vm = vm.$parent;
+ continue
+ } else if (currentRecursiveSequence > 0) {
+ tree[tree.length - 1] = [last, currentRecursiveSequence];
+ currentRecursiveSequence = 0;
+ }
+ }
+ tree.push(vm);
+ vm = vm.$parent;
+ }
+ return '\n\nfound in\n\n' + tree
+ .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
+ ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
+ : formatComponentName(vm))); })
+ .join('\n')
+ } else {
+ return ("\n\n(found in " + (formatComponentName(vm)) + ")")
+ }
+ };
+ }
-/**
- * A dep is an observable that can have multiple
- * directives subscribing to it.
- */
-var Dep = function Dep () {
- this.id = uid++;
- this.subs = [];
-};
-
-Dep.prototype.addSub = function addSub (sub) {
- this.subs.push(sub);
-};
-
-Dep.prototype.removeSub = function removeSub (sub) {
- remove(this.subs, sub);
-};
-
-Dep.prototype.depend = function depend () {
- if (Dep.target) {
- Dep.target.addDep(this);
- }
-};
-
-Dep.prototype.notify = function notify () {
- // stabilize the subscriber list first
- var subs = this.subs.slice();
- for (var i = 0, l = subs.length; i < l; i++) {
- subs[i].update();
- }
-};
-
-// the current target watcher being evaluated.
-// this is globally unique because there could be only one
-// watcher being evaluated at any time.
-Dep.target = null;
-var targetStack = [];
-
-function pushTarget (_target) {
- if (Dep.target) { targetStack.push(Dep.target); }
- Dep.target = _target;
-}
-
-function popTarget () {
- Dep.target = targetStack.pop();
-}
-
-/* */
-
-var VNode = function VNode (
- tag,
- data,
- children,
- text,
- elm,
- context,
- componentOptions,
- asyncFactory
-) {
- this.tag = tag;
- this.data = data;
- this.children = children;
- this.text = text;
- this.elm = elm;
- this.ns = undefined;
- this.context = context;
- this.fnContext = undefined;
- this.fnOptions = undefined;
- this.fnScopeId = undefined;
- this.key = data && data.key;
- this.componentOptions = componentOptions;
- this.componentInstance = undefined;
- this.parent = undefined;
- this.raw = false;
- this.isStatic = false;
- this.isRootInsert = true;
- this.isComment = false;
- this.isCloned = false;
- this.isOnce = false;
- this.asyncFactory = asyncFactory;
- this.asyncMeta = undefined;
- this.isAsyncPlaceholder = false;
-};
-
-var prototypeAccessors = { child: { configurable: true } };
-
-// DEPRECATED: alias for componentInstance for backwards compat.
-/* istanbul ignore next */
-prototypeAccessors.child.get = function () {
- return this.componentInstance
-};
-
-Object.defineProperties( VNode.prototype, prototypeAccessors );
-
-var createEmptyVNode = function (text) {
- if ( text === void 0 ) text = '';
-
- var node = new VNode();
- node.text = text;
- node.isComment = true;
- return node
-};
-
-function createTextVNode (val) {
- return new VNode(undefined, undefined, undefined, String(val))
-}
-
-// optimized shallow clone
-// used for static nodes and slot nodes because they may be reused across
-// multiple renders, cloning them avoids errors when DOM manipulations rely
-// on their elm reference.
-function cloneVNode (vnode) {
- var cloned = new VNode(
- vnode.tag,
- vnode.data,
- vnode.children,
- vnode.text,
- vnode.elm,
- vnode.context,
- vnode.componentOptions,
- vnode.asyncFactory
- );
- cloned.ns = vnode.ns;
- cloned.isStatic = vnode.isStatic;
- cloned.key = vnode.key;
- cloned.isComment = vnode.isComment;
- cloned.fnContext = vnode.fnContext;
- cloned.fnOptions = vnode.fnOptions;
- cloned.fnScopeId = vnode.fnScopeId;
- cloned.asyncMeta = vnode.asyncMeta;
- cloned.isCloned = true;
- return cloned
-}
-
-/*
- * not type checking this file because flow doesn't play well with
- * dynamically accessing methods on Array prototype
- */
+ /* */
-var arrayProto = Array.prototype;
-var arrayMethods = Object.create(arrayProto);
-
-var methodsToPatch = [
- 'push',
- 'pop',
- 'shift',
- 'unshift',
- 'splice',
- 'sort',
- 'reverse'
-];
-
-/**
- * Intercept mutating methods and emit events
- */
-methodsToPatch.forEach(function (method) {
- // cache original method
- var original = arrayProto[method];
- def(arrayMethods, method, function mutator () {
- var args = [], len = arguments.length;
- while ( len-- ) args[ len ] = arguments[ len ];
+ var uid = 0;
- var result = original.apply(this, args);
- var ob = this.__ob__;
- var inserted;
- switch (method) {
- case 'push':
- case 'unshift':
- inserted = args;
- break
- case 'splice':
- inserted = args.slice(2);
- break
- }
- if (inserted) { ob.observeArray(inserted); }
- // notify change
- ob.dep.notify();
- return result
- });
-});
+ /**
+ * A dep is an observable that can have multiple
+ * directives subscribing to it.
+ */
+ var Dep = function Dep () {
+ this.id = uid++;
+ this.subs = [];
+ };
-/* */
+ Dep.prototype.addSub = function addSub (sub) {
+ this.subs.push(sub);
+ };
-var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
+ Dep.prototype.removeSub = function removeSub (sub) {
+ remove(this.subs, sub);
+ };
-/**
- * In some cases we may want to disable observation inside a component's
- * update computation.
- */
-var shouldObserve = true;
+ Dep.prototype.depend = function depend () {
+ if (Dep.target) {
+ Dep.target.addDep(this);
+ }
+ };
-function toggleObserving (value) {
- shouldObserve = value;
-}
+ Dep.prototype.notify = function notify () {
+ // stabilize the subscriber list first
+ var subs = this.subs.slice();
+ if (!config.async) {
+ // subs aren't sorted in scheduler if not running async
+ // we need to sort them now to make sure they fire in correct
+ // order
+ subs.sort(function (a, b) { return a.id - b.id; });
+ }
+ for (var i = 0, l = subs.length; i < l; i++) {
+ subs[i].update();
+ }
+ };
-/**
- * Observer class that is attached to each observed
- * object. Once attached, the observer converts the target
- * object's property keys into getter/setters that
- * collect dependencies and dispatch updates.
- */
-var Observer = function Observer (value) {
- this.value = value;
- this.dep = new Dep();
- this.vmCount = 0;
- def(value, '__ob__', this);
- if (Array.isArray(value)) {
- var augment = hasProto
- ? protoAugment
- : copyAugment;
- augment(value, arrayMethods, arrayKeys);
- this.observeArray(value);
- } else {
- this.walk(value);
- }
-};
+ // the current target watcher being evaluated.
+ // this is globally unique because there could be only one
+ // watcher being evaluated at any time.
+ Dep.target = null;
+ var targetStack = [];
-/**
- * Walk through each property and convert them into
- * getter/setters. This method should only be called when
- * value type is Object.
- */
-Observer.prototype.walk = function walk (obj) {
- var keys = Object.keys(obj);
- for (var i = 0; i < keys.length; i++) {
- defineReactive(obj, keys[i]);
+ function pushTarget (target) {
+ targetStack.push(target);
+ Dep.target = target;
}
-};
-/**
- * Observe a list of Array items.
- */
-Observer.prototype.observeArray = function observeArray (items) {
- for (var i = 0, l = items.length; i < l; i++) {
- observe(items[i]);
+ function popTarget () {
+ targetStack.pop();
+ Dep.target = targetStack[targetStack.length - 1];
}
-};
-// helpers
+ /* */
-/**
- * Augment an target Object or Array by intercepting
- * the prototype chain using __proto__
- */
-function protoAugment (target, src, keys) {
- /* eslint-disable no-proto */
- target.__proto__ = src;
- /* eslint-enable no-proto */
-}
-
-/**
- * Augment an target Object or Array by defining
- * hidden properties.
- */
-/* istanbul ignore next */
-function copyAugment (target, src, keys) {
- for (var i = 0, l = keys.length; i < l; i++) {
- var key = keys[i];
- def(target, key, src[key]);
- }
-}
-
-/**
- * Attempt to create an observer instance for a value,
- * returns the new observer if successfully observed,
- * or the existing observer if the value already has one.
- */
-function observe (value, asRootData) {
- if (!isObject(value) || value instanceof VNode) {
- return
- }
- var ob;
- if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
- ob = value.__ob__;
- } else if (
- shouldObserve &&
- !isServerRendering() &&
- (Array.isArray(value) || isPlainObject(value)) &&
- Object.isExtensible(value) &&
- !value._isVue
+ var VNode = function VNode (
+ tag,
+ data,
+ children,
+ text,
+ elm,
+ context,
+ componentOptions,
+ asyncFactory
) {
- ob = new Observer(value);
- }
- if (asRootData && ob) {
- ob.vmCount++;
- }
- return ob
-}
+ this.tag = tag;
+ this.data = data;
+ this.children = children;
+ this.text = text;
+ this.elm = elm;
+ this.ns = undefined;
+ this.context = context;
+ this.fnContext = undefined;
+ this.fnOptions = undefined;
+ this.fnScopeId = undefined;
+ this.key = data && data.key;
+ this.componentOptions = componentOptions;
+ this.componentInstance = undefined;
+ this.parent = undefined;
+ this.raw = false;
+ this.isStatic = false;
+ this.isRootInsert = true;
+ this.isComment = false;
+ this.isCloned = false;
+ this.isOnce = false;
+ this.asyncFactory = asyncFactory;
+ this.asyncMeta = undefined;
+ this.isAsyncPlaceholder = false;
+ };
-/**
- * Define a reactive property on an Object.
- */
-function defineReactive (
- obj,
- key,
- val,
- customSetter,
- shallow
-) {
- var dep = new Dep();
+ var prototypeAccessors = { child: { configurable: true } };
- var property = Object.getOwnPropertyDescriptor(obj, key);
- if (property && property.configurable === false) {
- return
- }
+ // DEPRECATED: alias for componentInstance for backwards compat.
+ /* istanbul ignore next */
+ prototypeAccessors.child.get = function () {
+ return this.componentInstance
+ };
- // cater for pre-defined getter/setters
- var getter = property && property.get;
- var setter = property && property.set;
- if ((!getter || setter) && arguments.length === 2) {
- val = obj[key];
- }
+ Object.defineProperties( VNode.prototype, prototypeAccessors );
- var childOb = !shallow && observe(val);
- Object.defineProperty(obj, key, {
- enumerable: true,
- configurable: true,
- get: function reactiveGetter () {
- var value = getter ? getter.call(obj) : val;
- if (Dep.target) {
- dep.depend();
- if (childOb) {
- childOb.dep.depend();
- if (Array.isArray(value)) {
- dependArray(value);
+ var createEmptyVNode = function (text) {
+ if ( text === void 0 ) text = '';
+
+ var node = new VNode();
+ node.text = text;
+ node.isComment = true;
+ return node
+ };
+
+ function createTextVNode (val) {
+ return new VNode(undefined, undefined, undefined, String(val))
+ }
+
+ // optimized shallow clone
+ // used for static nodes and slot nodes because they may be reused across
+ // multiple renders, cloning them avoids errors when DOM manipulations rely
+ // on their elm reference.
+ function cloneVNode (vnode) {
+ var cloned = new VNode(
+ vnode.tag,
+ vnode.data,
+ // #7975
+ // clone children array to avoid mutating original in case of cloning
+ // a child.
+ vnode.children && vnode.children.slice(),
+ vnode.text,
+ vnode.elm,
+ vnode.context,
+ vnode.componentOptions,
+ vnode.asyncFactory
+ );
+ cloned.ns = vnode.ns;
+ cloned.isStatic = vnode.isStatic;
+ cloned.key = vnode.key;
+ cloned.isComment = vnode.isComment;
+ cloned.fnContext = vnode.fnContext;
+ cloned.fnOptions = vnode.fnOptions;
+ cloned.fnScopeId = vnode.fnScopeId;
+ cloned.asyncMeta = vnode.asyncMeta;
+ cloned.isCloned = true;
+ return cloned
+ }
+
+ /*
+ * not type checking this file because flow doesn't play well with
+ * dynamically accessing methods on Array prototype
+ */
+
+ var arrayProto = Array.prototype;
+ var arrayMethods = Object.create(arrayProto);
+
+ var methodsToPatch = [
+ 'push',
+ 'pop',
+ 'shift',
+ 'unshift',
+ 'splice',
+ 'sort',
+ 'reverse'
+ ];
+
+ /**
+ * Intercept mutating methods and emit events
+ */
+ methodsToPatch.forEach(function (method) {
+ // cache original method
+ var original = arrayProto[method];
+ def(arrayMethods, method, function mutator () {
+ var args = [], len = arguments.length;
+ while ( len-- ) args[ len ] = arguments[ len ];
+
+ var result = original.apply(this, args);
+ var ob = this.__ob__;
+ var inserted;
+ switch (method) {
+ case 'push':
+ case 'unshift':
+ inserted = args;
+ break
+ case 'splice':
+ inserted = args.slice(2);
+ break
+ }
+ if (inserted) { ob.observeArray(inserted); }
+ // notify change
+ ob.dep.notify();
+ return result
+ });
+ });
+
+ /* */
+
+ var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
+
+ /**
+ * In some cases we may want to disable observation inside a component's
+ * update computation.
+ */
+ var shouldObserve = true;
+
+ function toggleObserving (value) {
+ shouldObserve = value;
+ }
+
+ /**
+ * Observer class that is attached to each observed
+ * object. Once attached, the observer converts the target
+ * object's property keys into getter/setters that
+ * collect dependencies and dispatch updates.
+ */
+ var Observer = function Observer (value) {
+ this.value = value;
+ this.dep = new Dep();
+ this.vmCount = 0;
+ def(value, '__ob__', this);
+ if (Array.isArray(value)) {
+ if (hasProto) {
+ protoAugment(value, arrayMethods);
+ } else {
+ copyAugment(value, arrayMethods, arrayKeys);
+ }
+ this.observeArray(value);
+ } else {
+ this.walk(value);
+ }
+ };
+
+ /**
+ * Walk through all properties and convert them into
+ * getter/setters. This method should only be called when
+ * value type is Object.
+ */
+ Observer.prototype.walk = function walk (obj) {
+ var keys = Object.keys(obj);
+ for (var i = 0; i < keys.length; i++) {
+ defineReactive$$1(obj, keys[i]);
+ }
+ };
+
+ /**
+ * Observe a list of Array items.
+ */
+ Observer.prototype.observeArray = function observeArray (items) {
+ for (var i = 0, l = items.length; i < l; i++) {
+ observe(items[i]);
+ }
+ };
+
+ // helpers
+
+ /**
+ * Augment a target Object or Array by intercepting
+ * the prototype chain using __proto__
+ */
+ function protoAugment (target, src) {
+ /* eslint-disable no-proto */
+ target.__proto__ = src;
+ /* eslint-enable no-proto */
+ }
+
+ /**
+ * Augment a target Object or Array by defining
+ * hidden properties.
+ */
+ /* istanbul ignore next */
+ function copyAugment (target, src, keys) {
+ for (var i = 0, l = keys.length; i < l; i++) {
+ var key = keys[i];
+ def(target, key, src[key]);
+ }
+ }
+
+ /**
+ * Attempt to create an observer instance for a value,
+ * returns the new observer if successfully observed,
+ * or the existing observer if the value already has one.
+ */
+ function observe (value, asRootData) {
+ if (!isObject(value) || value instanceof VNode) {
+ return
+ }
+ var ob;
+ if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
+ ob = value.__ob__;
+ } else if (
+ shouldObserve &&
+ !isServerRendering() &&
+ (Array.isArray(value) || isPlainObject(value)) &&
+ Object.isExtensible(value) &&
+ !value._isVue
+ ) {
+ ob = new Observer(value);
+ }
+ if (asRootData && ob) {
+ ob.vmCount++;
+ }
+ return ob
+ }
+
+ /**
+ * Define a reactive property on an Object.
+ */
+ function defineReactive$$1 (
+ obj,
+ key,
+ val,
+ customSetter,
+ shallow
+ ) {
+ var dep = new Dep();
+
+ var property = Object.getOwnPropertyDescriptor(obj, key);
+ if (property && property.configurable === false) {
+ return
+ }
+
+ // cater for pre-defined getter/setters
+ var getter = property && property.get;
+ var setter = property && property.set;
+ if ((!getter || setter) && arguments.length === 2) {
+ val = obj[key];
+ }
+
+ var childOb = !shallow && observe(val);
+ Object.defineProperty(obj, key, {
+ enumerable: true,
+ configurable: true,
+ get: function reactiveGetter () {
+ var value = getter ? getter.call(obj) : val;
+ if (Dep.target) {
+ dep.depend();
+ if (childOb) {
+ childOb.dep.depend();
+ if (Array.isArray(value)) {
+ dependArray(value);
+ }
+ }
+ }
+ return value
+ },
+ set: function reactiveSetter (newVal) {
+ var value = getter ? getter.call(obj) : val;
+ /* eslint-disable no-self-compare */
+ if (newVal === value || (newVal !== newVal && value !== value)) {
+ return
+ }
+ /* eslint-enable no-self-compare */
+ if (customSetter) {
+ customSetter();
+ }
+ // #7981: for accessor properties without setter
+ if (getter && !setter) { return }
+ if (setter) {
+ setter.call(obj, newVal);
+ } else {
+ val = newVal;
+ }
+ childOb = !shallow && observe(newVal);
+ dep.notify();
+ }
+ });
+ }
+
+ /**
+ * Set a property on an object. Adds the new property and
+ * triggers change notification if the property doesn't
+ * already exist.
+ */
+ function set (target, key, val) {
+ if (isUndef(target) || isPrimitive(target)
+ ) {
+ warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
+ }
+ if (Array.isArray(target) && isValidArrayIndex(key)) {
+ target.length = Math.max(target.length, key);
+ target.splice(key, 1, val);
+ return val
+ }
+ if (key in target && !(key in Object.prototype)) {
+ target[key] = val;
+ return val
+ }
+ var ob = (target).__ob__;
+ if (target._isVue || (ob && ob.vmCount)) {
+ warn(
+ 'Avoid adding reactive properties to a Vue instance or its root $data ' +
+ 'at runtime - declare it upfront in the data option.'
+ );
+ return val
+ }
+ if (!ob) {
+ target[key] = val;
+ return val
+ }
+ defineReactive$$1(ob.value, key, val);
+ ob.dep.notify();
+ return val
+ }
+
+ /**
+ * Delete a property and trigger change if necessary.
+ */
+ function del (target, key) {
+ if (isUndef(target) || isPrimitive(target)
+ ) {
+ warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
+ }
+ if (Array.isArray(target) && isValidArrayIndex(key)) {
+ target.splice(key, 1);
+ return
+ }
+ var ob = (target).__ob__;
+ if (target._isVue || (ob && ob.vmCount)) {
+ warn(
+ 'Avoid deleting properties on a Vue instance or its root $data ' +
+ '- just set it to null.'
+ );
+ return
+ }
+ if (!hasOwn(target, key)) {
+ return
+ }
+ delete target[key];
+ if (!ob) {
+ return
+ }
+ ob.dep.notify();
+ }
+
+ /**
+ * Collect dependencies on array elements when the array is touched, since
+ * we cannot intercept array element access like property getters.
+ */
+ function dependArray (value) {
+ for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
+ e = value[i];
+ e && e.__ob__ && e.__ob__.dep.depend();
+ if (Array.isArray(e)) {
+ dependArray(e);
+ }
+ }
+ }
+
+ /* */
+
+ /**
+ * Option overwriting strategies are functions that handle
+ * how to merge a parent option value and a child option
+ * value into the final value.
+ */
+ var strats = config.optionMergeStrategies;
+
+ /**
+ * Options with restrictions
+ */
+ {
+ strats.el = strats.propsData = function (parent, child, vm, key) {
+ if (!vm) {
+ warn(
+ "option \"" + key + "\" can only be used during instance " +
+ 'creation with the `new` keyword.'
+ );
+ }
+ return defaultStrat(parent, child)
+ };
+ }
+
+ /**
+ * Helper that recursively merges two data objects together.
+ */
+ function mergeData (to, from) {
+ if (!from) { return to }
+ var key, toVal, fromVal;
+ var keys = Object.keys(from);
+ for (var i = 0; i < keys.length; i++) {
+ key = keys[i];
+ toVal = to[key];
+ fromVal = from[key];
+ if (!hasOwn(to, key)) {
+ set(to, key, fromVal);
+ } else if (
+ toVal !== fromVal &&
+ isPlainObject(toVal) &&
+ isPlainObject(fromVal)
+ ) {
+ mergeData(toVal, fromVal);
+ }
+ }
+ return to
+ }
+
+ /**
+ * Data
+ */
+ function mergeDataOrFn (
+ parentVal,
+ childVal,
+ vm
+ ) {
+ if (!vm) {
+ // in a Vue.extend merge, both should be functions
+ if (!childVal) {
+ return parentVal
+ }
+ if (!parentVal) {
+ return childVal
+ }
+ // when parentVal & childVal are both present,
+ // we need to return a function that returns the
+ // merged result of both functions... no need to
+ // check if parentVal is a function here because
+ // it has to be a function to pass previous merges.
+ return function mergedDataFn () {
+ return mergeData(
+ typeof childVal === 'function' ? childVal.call(this, this) : childVal,
+ typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
+ )
+ }
+ } else {
+ return function mergedInstanceDataFn () {
+ // instance merge
+ var instanceData = typeof childVal === 'function'
+ ? childVal.call(vm, vm)
+ : childVal;
+ var defaultData = typeof parentVal === 'function'
+ ? parentVal.call(vm, vm)
+ : parentVal;
+ if (instanceData) {
+ return mergeData(instanceData, defaultData)
+ } else {
+ return defaultData
+ }
+ }
+ }
+ }
+
+ strats.data = function (
+ parentVal,
+ childVal,
+ vm
+ ) {
+ if (!vm) {
+ if (childVal && typeof childVal !== 'function') {
+ warn(
+ 'The "data" option should be a function ' +
+ 'that returns a per-instance value in component ' +
+ 'definitions.',
+ vm
+ );
+
+ return parentVal
+ }
+ return mergeDataOrFn(parentVal, childVal)
+ }
+
+ return mergeDataOrFn(parentVal, childVal, vm)
+ };
+
+ /**
+ * Hooks and props are merged as arrays.
+ */
+ function mergeHook (
+ parentVal,
+ childVal
+ ) {
+ return childVal
+ ? parentVal
+ ? parentVal.concat(childVal)
+ : Array.isArray(childVal)
+ ? childVal
+ : [childVal]
+ : parentVal
+ }
+
+ LIFECYCLE_HOOKS.forEach(function (hook) {
+ strats[hook] = mergeHook;
+ });
+
+ /**
+ * Assets
+ *
+ * When a vm is present (instance creation), we need to do
+ * a three-way merge between constructor options, instance
+ * options and parent options.
+ */
+ function mergeAssets (
+ parentVal,
+ childVal,
+ vm,
+ key
+ ) {
+ var res = Object.create(parentVal || null);
+ if (childVal) {
+ assertObjectType(key, childVal, vm);
+ return extend(res, childVal)
+ } else {
+ return res
+ }
+ }
+
+ ASSET_TYPES.forEach(function (type) {
+ strats[type + 's'] = mergeAssets;
+ });
+
+ /**
+ * Watchers.
+ *
+ * Watchers hashes should not overwrite one
+ * another, so we merge them as arrays.
+ */
+ strats.watch = function (
+ parentVal,
+ childVal,
+ vm,
+ key
+ ) {
+ // work around Firefox's Object.prototype.watch...
+ if (parentVal === nativeWatch) { parentVal = undefined; }
+ if (childVal === nativeWatch) { childVal = undefined; }
+ /* istanbul ignore if */
+ if (!childVal) { return Object.create(parentVal || null) }
+ {
+ assertObjectType(key, childVal, vm);
+ }
+ if (!parentVal) { return childVal }
+ var ret = {};
+ extend(ret, parentVal);
+ for (var key$1 in childVal) {
+ var parent = ret[key$1];
+ var child = childVal[key$1];
+ if (parent && !Array.isArray(parent)) {
+ parent = [parent];
+ }
+ ret[key$1] = parent
+ ? parent.concat(child)
+ : Array.isArray(child) ? child : [child];
+ }
+ return ret
+ };
+
+ /**
+ * Other object hashes.
+ */
+ strats.props =
+ strats.methods =
+ strats.inject =
+ strats.computed = function (
+ parentVal,
+ childVal,
+ vm,
+ key
+ ) {
+ if (childVal && "development" !== 'production') {
+ assertObjectType(key, childVal, vm);
+ }
+ if (!parentVal) { return childVal }
+ var ret = Object.create(null);
+ extend(ret, parentVal);
+ if (childVal) { extend(ret, childVal); }
+ return ret
+ };
+ strats.provide = mergeDataOrFn;
+
+ /**
+ * Default strategy.
+ */
+ var defaultStrat = function (parentVal, childVal) {
+ return childVal === undefined
+ ? parentVal
+ : childVal
+ };
+
+ /**
+ * Validate component names
+ */
+ function checkComponents (options) {
+ for (var key in options.components) {
+ validateComponentName(key);
+ }
+ }
+
+ function validateComponentName (name) {
+ if (!/^[a-zA-Z][\w-]*$/.test(name)) {
+ warn(
+ 'Invalid component name: "' + name + '". Component names ' +
+ 'can only contain alphanumeric characters and the hyphen, ' +
+ 'and must start with a letter.'
+ );
+ }
+ if (isBuiltInTag(name) || config.isReservedTag(name)) {
+ warn(
+ 'Do not use built-in or reserved HTML elements as component ' +
+ 'id: ' + name
+ );
+ }
+ }
+
+ /**
+ * Ensure all props option syntax are normalized into the
+ * Object-based format.
+ */
+ function normalizeProps (options, vm) {
+ var props = options.props;
+ if (!props) { return }
+ var res = {};
+ var i, val, name;
+ if (Array.isArray(props)) {
+ i = props.length;
+ while (i--) {
+ val = props[i];
+ if (typeof val === 'string') {
+ name = camelize(val);
+ res[name] = { type: null };
+ } else {
+ warn('props must be strings when using array syntax.');
+ }
+ }
+ } else if (isPlainObject(props)) {
+ for (var key in props) {
+ val = props[key];
+ name = camelize(key);
+ res[name] = isPlainObject(val)
+ ? val
+ : { type: val };
+ }
+ } else {
+ warn(
+ "Invalid value for option \"props\": expected an Array or an Object, " +
+ "but got " + (toRawType(props)) + ".",
+ vm
+ );
+ }
+ options.props = res;
+ }
+
+ /**
+ * Normalize all injections into Object-based format
+ */
+ function normalizeInject (options, vm) {
+ var inject = options.inject;
+ if (!inject) { return }
+ var normalized = options.inject = {};
+ if (Array.isArray(inject)) {
+ for (var i = 0; i < inject.length; i++) {
+ normalized[inject[i]] = { from: inject[i] };
+ }
+ } else if (isPlainObject(inject)) {
+ for (var key in inject) {
+ var val = inject[key];
+ normalized[key] = isPlainObject(val)
+ ? extend({ from: key }, val)
+ : { from: val };
+ }
+ } else {
+ warn(
+ "Invalid value for option \"inject\": expected an Array or an Object, " +
+ "but got " + (toRawType(inject)) + ".",
+ vm
+ );
+ }
+ }
+
+ /**
+ * Normalize raw function directives into object format.
+ */
+ function normalizeDirectives (options) {
+ var dirs = options.directives;
+ if (dirs) {
+ for (var key in dirs) {
+ var def = dirs[key];
+ if (typeof def === 'function') {
+ dirs[key] = { bind: def, update: def };
+ }
+ }
+ }
+ }
+
+ function assertObjectType (name, value, vm) {
+ if (!isPlainObject(value)) {
+ warn(
+ "Invalid value for option \"" + name + "\": expected an Object, " +
+ "but got " + (toRawType(value)) + ".",
+ vm
+ );
+ }
+ }
+
+ /**
+ * Merge two option objects into a new one.
+ * Core utility used in both instantiation and inheritance.
+ */
+ function mergeOptions (
+ parent,
+ child,
+ vm
+ ) {
+ {
+ checkComponents(child);
+ }
+
+ if (typeof child === 'function') {
+ child = child.options;
+ }
+
+ normalizeProps(child, vm);
+ normalizeInject(child, vm);
+ normalizeDirectives(child);
+
+ // Apply extends and mixins on the child options,
+ // but only if it is a raw options object that isn't
+ // the result of another mergeOptions call.
+ // Only merged options has the _base property.
+ if (!child._base) {
+ if (child.extends) {
+ parent = mergeOptions(parent, child.extends, vm);
+ }
+ if (child.mixins) {
+ for (var i = 0, l = child.mixins.length; i < l; i++) {
+ parent = mergeOptions(parent, child.mixins[i], vm);
+ }
+ }
+ }
+
+ var options = {};
+ var key;
+ for (key in parent) {
+ mergeField(key);
+ }
+ for (key in child) {
+ if (!hasOwn(parent, key)) {
+ mergeField(key);
+ }
+ }
+ function mergeField (key) {
+ var strat = strats[key] || defaultStrat;
+ options[key] = strat(parent[key], child[key], vm, key);
+ }
+ return options
+ }
+
+ /**
+ * Resolve an asset.
+ * This function is used because child instances need access
+ * to assets defined in its ancestor chain.
+ */
+ function resolveAsset (
+ options,
+ type,
+ id,
+ warnMissing
+ ) {
+ /* istanbul ignore if */
+ if (typeof id !== 'string') {
+ return
+ }
+ var assets = options[type];
+ // check local registration variations first
+ if (hasOwn(assets, id)) { return assets[id] }
+ var camelizedId = camelize(id);
+ if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
+ var PascalCaseId = capitalize(camelizedId);
+ if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
+ // fallback to prototype chain
+ var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
+ if (warnMissing && !res) {
+ warn(
+ 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
+ options
+ );
+ }
+ return res
+ }
+
+ /* */
+
+
+
+ function validateProp (
+ key,
+ propOptions,
+ propsData,
+ vm
+ ) {
+ var prop = propOptions[key];
+ var absent = !hasOwn(propsData, key);
+ var value = propsData[key];
+ // boolean casting
+ var booleanIndex = getTypeIndex(Boolean, prop.type);
+ if (booleanIndex > -1) {
+ if (absent && !hasOwn(prop, 'default')) {
+ value = false;
+ } else if (value === '' || value === hyphenate(key)) {
+ // only cast empty string / same name to boolean if
+ // boolean has higher priority
+ var stringIndex = getTypeIndex(String, prop.type);
+ if (stringIndex < 0 || booleanIndex < stringIndex) {
+ value = true;
+ }
+ }
+ }
+ // check default value
+ if (value === undefined) {
+ value = getPropDefaultValue(vm, prop, key);
+ // since the default value is a fresh copy,
+ // make sure to observe it.
+ var prevShouldObserve = shouldObserve;
+ toggleObserving(true);
+ observe(value);
+ toggleObserving(prevShouldObserve);
+ }
+ {
+ assertProp(prop, key, value, vm, absent);
+ }
+ return value
+ }
+
+ /**
+ * Get the default value of a prop.
+ */
+ function getPropDefaultValue (vm, prop, key) {
+ // no default, return undefined
+ if (!hasOwn(prop, 'default')) {
+ return undefined
+ }
+ var def = prop.default;
+ // warn against non-factory defaults for Object & Array
+ if (isObject(def)) {
+ warn(
+ 'Invalid default value for prop "' + key + '": ' +
+ 'Props with type Object/Array must use a factory function ' +
+ 'to return the default value.',
+ vm
+ );
+ }
+ // the raw prop value was also undefined from previous render,
+ // return previous default value to avoid unnecessary watcher trigger
+ if (vm && vm.$options.propsData &&
+ vm.$options.propsData[key] === undefined &&
+ vm._props[key] !== undefined
+ ) {
+ return vm._props[key]
+ }
+ // call factory function for non-Function types
+ // a value is Function if its prototype is function even across different execution context
+ return typeof def === 'function' && getType(prop.type) !== 'Function'
+ ? def.call(vm)
+ : def
+ }
+
+ /**
+ * Assert whether a prop is valid.
+ */
+ function assertProp (
+ prop,
+ name,
+ value,
+ vm,
+ absent
+ ) {
+ if (prop.required && absent) {
+ warn(
+ 'Missing required prop: "' + name + '"',
+ vm
+ );
+ return
+ }
+ if (value == null && !prop.required) {
+ return
+ }
+ var type = prop.type;
+ var valid = !type || type === true;
+ var expectedTypes = [];
+ if (type) {
+ if (!Array.isArray(type)) {
+ type = [type];
+ }
+ for (var i = 0; i < type.length && !valid; i++) {
+ var assertedType = assertType(value, type[i]);
+ expectedTypes.push(assertedType.expectedType || '');
+ valid = assertedType.valid;
+ }
+ }
+
+ if (!valid) {
+ warn(
+ getInvalidTypeMessage(name, value, expectedTypes),
+ vm
+ );
+ return
+ }
+ var validator = prop.validator;
+ if (validator) {
+ if (!validator(value)) {
+ warn(
+ 'Invalid prop: custom validator check failed for prop "' + name + '".',
+ vm
+ );
+ }
+ }
+ }
+
+ var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
+
+ function assertType (value, type) {
+ var valid;
+ var expectedType = getType(type);
+ if (simpleCheckRE.test(expectedType)) {
+ var t = typeof value;
+ valid = t === expectedType.toLowerCase();
+ // for primitive wrapper objects
+ if (!valid && t === 'object') {
+ valid = value instanceof type;
+ }
+ } else if (expectedType === 'Object') {
+ valid = isPlainObject(value);
+ } else if (expectedType === 'Array') {
+ valid = Array.isArray(value);
+ } else {
+ valid = value instanceof type;
+ }
+ return {
+ valid: valid,
+ expectedType: expectedType
+ }
+ }
+
+ /**
+ * Use function string name to check built-in types,
+ * because a simple equality check will fail when running
+ * across different vms / iframes.
+ */
+ function getType (fn) {
+ var match = fn && fn.toString().match(/^\s*function (\w+)/);
+ return match ? match[1] : ''
+ }
+
+ function isSameType (a, b) {
+ return getType(a) === getType(b)
+ }
+
+ function getTypeIndex (type, expectedTypes) {
+ if (!Array.isArray(expectedTypes)) {
+ return isSameType(expectedTypes, type) ? 0 : -1
+ }
+ for (var i = 0, len = expectedTypes.length; i < len; i++) {
+ if (isSameType(expectedTypes[i], type)) {
+ return i
+ }
+ }
+ return -1
+ }
+
+ function getInvalidTypeMessage (name, value, expectedTypes) {
+ var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
+ " Expected " + (expectedTypes.map(capitalize).join(', '));
+ var expectedType = expectedTypes[0];
+ var receivedType = toRawType(value);
+ var expectedValue = styleValue(value, expectedType);
+ var receivedValue = styleValue(value, receivedType);
+ // check if we need to specify expected value
+ if (expectedTypes.length === 1 &&
+ isExplicable(expectedType) &&
+ !isBoolean(expectedType, receivedType)) {
+ message += " with value " + expectedValue;
+ }
+ message += ", got " + receivedType + " ";
+ // check if we need to specify received value
+ if (isExplicable(receivedType)) {
+ message += "with value " + receivedValue + ".";
+ }
+ return message
+ }
+
+ function styleValue (value, type) {
+ if (type === 'String') {
+ return ("\"" + value + "\"")
+ } else if (type === 'Number') {
+ return ("" + (Number(value)))
+ } else {
+ return ("" + value)
+ }
+ }
+
+ function isExplicable (value) {
+ var explicitTypes = ['string', 'number', 'boolean'];
+ return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
+ }
+
+ function isBoolean () {
+ var args = [], len = arguments.length;
+ while ( len-- ) args[ len ] = arguments[ len ];
+
+ return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
+ }
+
+ /* */
+
+ function handleError (err, vm, info) {
+ if (vm) {
+ var cur = vm;
+ while ((cur = cur.$parent)) {
+ var hooks = cur.$options.errorCaptured;
+ if (hooks) {
+ for (var i = 0; i < hooks.length; i++) {
+ try {
+ var capture = hooks[i].call(cur, err, vm, info) === false;
+ if (capture) { return }
+ } catch (e) {
+ globalHandleError(e, cur, 'errorCaptured hook');
+ }
+ }
+ }
+ }
+ }
+ globalHandleError(err, vm, info);
+ }
+
+ function globalHandleError (err, vm, info) {
+ if (config.errorHandler) {
+ try {
+ return config.errorHandler.call(null, err, vm, info)
+ } catch (e) {
+ logError(e, null, 'config.errorHandler');
+ }
+ }
+ logError(err, vm, info);
+ }
+
+ function logError (err, vm, info) {
+ {
+ warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
+ }
+ /* istanbul ignore else */
+ if ((inBrowser || inWeex) && typeof console !== 'undefined') {
+ console.error(err);
+ } else {
+ throw err
+ }
+ }
+
+ /* */
+
+ var callbacks = [];
+ var pending = false;
+
+ function flushCallbacks () {
+ pending = false;
+ var copies = callbacks.slice(0);
+ callbacks.length = 0;
+ for (var i = 0; i < copies.length; i++) {
+ copies[i]();
+ }
+ }
+
+ // Here we have async deferring wrappers using both microtasks and (macro) tasks.
+ // In < 2.4 we used microtasks everywhere, but there are some scenarios where
+ // microtasks have too high a priority and fire in between supposedly
+ // sequential events (e.g. #4521, #6690) or even between bubbling of the same
+ // event (#6566). However, using (macro) tasks everywhere also has subtle problems
+ // when state is changed right before repaint (e.g. #6813, out-in transitions).
+ // Here we use microtask by default, but expose a way to force (macro) task when
+ // needed (e.g. in event handlers attached by v-on).
+ var microTimerFunc;
+ var macroTimerFunc;
+ var useMacroTask = false;
+
+ // Determine (macro) task defer implementation.
+ // Technically setImmediate should be the ideal choice, but it's only available
+ // in IE. The only polyfill that consistently queues the callback after all DOM
+ // events triggered in the same loop is by using MessageChannel.
+ /* istanbul ignore if */
+ if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
+ macroTimerFunc = function () {
+ setImmediate(flushCallbacks);
+ };
+ } else if (typeof MessageChannel !== 'undefined' && (
+ isNative(MessageChannel) ||
+ // PhantomJS
+ MessageChannel.toString() === '[object MessageChannelConstructor]'
+ )) {
+ var channel = new MessageChannel();
+ var port = channel.port2;
+ channel.port1.onmessage = flushCallbacks;
+ macroTimerFunc = function () {
+ port.postMessage(1);
+ };
+ } else {
+ /* istanbul ignore next */
+ macroTimerFunc = function () {
+ setTimeout(flushCallbacks, 0);
+ };
+ }
+
+ // Determine microtask defer implementation.
+ /* istanbul ignore next, $flow-disable-line */
+ if (typeof Promise !== 'undefined' && isNative(Promise)) {
+ var p = Promise.resolve();
+ microTimerFunc = function () {
+ p.then(flushCallbacks);
+ // in problematic UIWebViews, Promise.then doesn't completely break, but
+ // it can get stuck in a weird state where callbacks are pushed into the
+ // microtask queue but the queue isn't being flushed, until the browser
+ // needs to do some other work, e.g. handle a timer. Therefore we can
+ // "force" the microtask queue to be flushed by adding an empty timer.
+ if (isIOS) { setTimeout(noop); }
+ };
+ } else {
+ // fallback to macro
+ microTimerFunc = macroTimerFunc;
+ }
+
+ /**
+ * Wrap a function so that if any code inside triggers state change,
+ * the changes are queued using a (macro) task instead of a microtask.
+ */
+ function withMacroTask (fn) {
+ return fn._withTask || (fn._withTask = function () {
+ useMacroTask = true;
+ try {
+ return fn.apply(null, arguments)
+ } finally {
+ useMacroTask = false;
+ }
+ })
+ }
+
+ function nextTick (cb, ctx) {
+ var _resolve;
+ callbacks.push(function () {
+ if (cb) {
+ try {
+ cb.call(ctx);
+ } catch (e) {
+ handleError(e, ctx, 'nextTick');
+ }
+ } else if (_resolve) {
+ _resolve(ctx);
+ }
+ });
+ if (!pending) {
+ pending = true;
+ if (useMacroTask) {
+ macroTimerFunc();
+ } else {
+ microTimerFunc();
+ }
+ }
+ // $flow-disable-line
+ if (!cb && typeof Promise !== 'undefined') {
+ return new Promise(function (resolve) {
+ _resolve = resolve;
+ })
+ }
+ }
+
+ /* */
+
+ var mark;
+ var measure;
+
+ {
+ var perf = inBrowser && window.performance;
+ /* istanbul ignore if */
+ if (
+ perf &&
+ perf.mark &&
+ perf.measure &&
+ perf.clearMarks &&
+ perf.clearMeasures
+ ) {
+ mark = function (tag) { return perf.mark(tag); };
+ measure = function (name, startTag, endTag) {
+ perf.measure(name, startTag, endTag);
+ perf.clearMarks(startTag);
+ perf.clearMarks(endTag);
+ perf.clearMeasures(name);
+ };
+ }
+ }
+
+ /* not type checking this file because flow doesn't play well with Proxy */
+
+ var initProxy;
+
+ {
+ var allowedGlobals = makeMap(
+ 'Infinity,undefined,NaN,isFinite,isNaN,' +
+ 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
+ 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
+ 'require' // for Webpack/Browserify
+ );
+
+ var warnNonPresent = function (target, key) {
+ warn(
+ "Property or method \"" + key + "\" is not defined on the instance but " +
+ 'referenced during render. Make sure that this property is reactive, ' +
+ 'either in the data option, or for class-based components, by ' +
+ 'initializing the property. ' +
+ 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
+ target
+ );
+ };
+
+ var warnReservedPrefix = function (target, key) {
+ warn(
+ "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
+ 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
+ 'prevent conflicts with Vue internals' +
+ 'See: https://vuejs.org/v2/api/#data',
+ target
+ );
+ };
+
+ var hasProxy =
+ typeof Proxy !== 'undefined' && isNative(Proxy);
+
+ if (hasProxy) {
+ var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
+ config.keyCodes = new Proxy(config.keyCodes, {
+ set: function set (target, key, value) {
+ if (isBuiltInModifier(key)) {
+ warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
+ return false
+ } else {
+ target[key] = value;
+ return true
+ }
+ }
+ });
+ }
+
+ var hasHandler = {
+ has: function has (target, key) {
+ var has = key in target;
+ var isAllowed = allowedGlobals(key) ||
+ (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
+ if (!has && !isAllowed) {
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
+ }
+ return has || !isAllowed
+ }
+ };
+
+ var getHandler = {
+ get: function get (target, key) {
+ if (typeof key === 'string' && !(key in target)) {
+ if (key in target.$data) { warnReservedPrefix(target, key); }
+ else { warnNonPresent(target, key); }
+ }
+ return target[key]
+ }
+ };
+
+ initProxy = function initProxy (vm) {
+ if (hasProxy) {
+ // determine which proxy handler to use
+ var options = vm.$options;
+ var handlers = options.render && options.render._withStripped
+ ? getHandler
+ : hasHandler;
+ vm._renderProxy = new Proxy(vm, handlers);
+ } else {
+ vm._renderProxy = vm;
+ }
+ };
+ }
+
+ /* */
+
+ var seenObjects = new _Set();
+
+ /**
+ * Recursively traverse an object to evoke all converted
+ * getters, so that every nested property inside the object
+ * is collected as a "deep" dependency.
+ */
+ function traverse (val) {
+ _traverse(val, seenObjects);
+ seenObjects.clear();
+ }
+
+ function _traverse (val, seen) {
+ var i, keys;
+ var isA = Array.isArray(val);
+ if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
+ return
+ }
+ if (val.__ob__) {
+ var depId = val.__ob__.dep.id;
+ if (seen.has(depId)) {
+ return
+ }
+ seen.add(depId);
+ }
+ if (isA) {
+ i = val.length;
+ while (i--) { _traverse(val[i], seen); }
+ } else {
+ keys = Object.keys(val);
+ i = keys.length;
+ while (i--) { _traverse(val[keys[i]], seen); }
+ }
+ }
+
+ /* */
+
+ var normalizeEvent = cached(function (name) {
+ var passive = name.charAt(0) === '&';
+ name = passive ? name.slice(1) : name;
+ var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
+ name = once$$1 ? name.slice(1) : name;
+ var capture = name.charAt(0) === '!';
+ name = capture ? name.slice(1) : name;
+ return {
+ name: name,
+ once: once$$1,
+ capture: capture,
+ passive: passive
+ }
+ });
+
+ function createFnInvoker (fns) {
+ function invoker () {
+ var arguments$1 = arguments;
+
+ var fns = invoker.fns;
+ if (Array.isArray(fns)) {
+ var cloned = fns.slice();
+ for (var i = 0; i < cloned.length; i++) {
+ cloned[i].apply(null, arguments$1);
+ }
+ } else {
+ // return handler return value for single handlers
+ return fns.apply(null, arguments)
+ }
+ }
+ invoker.fns = fns;
+ return invoker
+ }
+
+ function updateListeners (
+ on,
+ oldOn,
+ add,
+ remove$$1,
+ createOnceHandler,
+ vm
+ ) {
+ var name, def$$1, cur, old, event;
+ for (name in on) {
+ def$$1 = cur = on[name];
+ old = oldOn[name];
+ event = normalizeEvent(name);
+ if (isUndef(cur)) {
+ warn(
+ "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
+ vm
+ );
+ } else if (isUndef(old)) {
+ if (isUndef(cur.fns)) {
+ cur = on[name] = createFnInvoker(cur);
+ }
+ if (isTrue(event.once)) {
+ cur = on[name] = createOnceHandler(event.name, cur, event.capture);
+ }
+ add(event.name, cur, event.capture, event.passive, event.params);
+ } else if (cur !== old) {
+ old.fns = cur;
+ on[name] = old;
+ }
+ }
+ for (name in oldOn) {
+ if (isUndef(on[name])) {
+ event = normalizeEvent(name);
+ remove$$1(event.name, oldOn[name], event.capture);
+ }
+ }
+ }
+
+ /* */
+
+ function mergeVNodeHook (def, hookKey, hook) {
+ if (def instanceof VNode) {
+ def = def.data.hook || (def.data.hook = {});
+ }
+ var invoker;
+ var oldHook = def[hookKey];
+
+ function wrappedHook () {
+ hook.apply(this, arguments);
+ // important: remove merged hook to ensure it's called only once
+ // and prevent memory leak
+ remove(invoker.fns, wrappedHook);
+ }
+
+ if (isUndef(oldHook)) {
+ // no existing hook
+ invoker = createFnInvoker([wrappedHook]);
+ } else {
+ /* istanbul ignore if */
+ if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
+ // already a merged invoker
+ invoker = oldHook;
+ invoker.fns.push(wrappedHook);
+ } else {
+ // existing plain hook
+ invoker = createFnInvoker([oldHook, wrappedHook]);
+ }
+ }
+
+ invoker.merged = true;
+ def[hookKey] = invoker;
+ }
+
+ /* */
+
+ function extractPropsFromVNodeData (
+ data,
+ Ctor,
+ tag
+ ) {
+ // we are only extracting raw values here.
+ // validation and default values are handled in the child
+ // component itself.
+ var propOptions = Ctor.options.props;
+ if (isUndef(propOptions)) {
+ return
+ }
+ var res = {};
+ var attrs = data.attrs;
+ var props = data.props;
+ if (isDef(attrs) || isDef(props)) {
+ for (var key in propOptions) {
+ var altKey = hyphenate(key);
+ {
+ var keyInLowerCase = key.toLowerCase();
+ if (
+ key !== keyInLowerCase &&
+ attrs && hasOwn(attrs, keyInLowerCase)
+ ) {
+ tip(
+ "Prop \"" + keyInLowerCase + "\" is passed to component " +
+ (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
+ " \"" + key + "\". " +
+ "Note that HTML attributes are case-insensitive and camelCased " +
+ "props need to use their kebab-case equivalents when using in-DOM " +
+ "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
+ );
+ }
+ }
+ checkProp(res, props, key, altKey, true) ||
+ checkProp(res, attrs, key, altKey, false);
+ }
+ }
+ return res
+ }
+
+ function checkProp (
+ res,
+ hash,
+ key,
+ altKey,
+ preserve
+ ) {
+ if (isDef(hash)) {
+ if (hasOwn(hash, key)) {
+ res[key] = hash[key];
+ if (!preserve) {
+ delete hash[key];
+ }
+ return true
+ } else if (hasOwn(hash, altKey)) {
+ res[key] = hash[altKey];
+ if (!preserve) {
+ delete hash[altKey];
+ }
+ return true
+ }
+ }
+ return false
+ }
+
+ /* */
+
+ // The template compiler attempts to minimize the need for normalization by
+ // statically analyzing the template at compile time.
+ //
+ // For plain HTML markup, normalization can be completely skipped because the
+ // generated render function is guaranteed to return Array. There are
+ // two cases where extra normalization is needed:
+
+ // 1. When the children contains components - because a functional component
+ // may return an Array instead of a single root. In this case, just a simple
+ // normalization is needed - if any child is an Array, we flatten the whole
+ // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
+ // because functional components already normalize their own children.
+ function simpleNormalizeChildren (children) {
+ for (var i = 0; i < children.length; i++) {
+ if (Array.isArray(children[i])) {
+ return Array.prototype.concat.apply([], children)
+ }
+ }
+ return children
+ }
+
+ // 2. When the children contains constructs that always generated nested Arrays,
+ // e.g. , , v-for, or when the children is provided by user
+ // with hand-written render functions / JSX. In such cases a full normalization
+ // is needed to cater to all possible types of children values.
+ function normalizeChildren (children) {
+ return isPrimitive(children)
+ ? [createTextVNode(children)]
+ : Array.isArray(children)
+ ? normalizeArrayChildren(children)
+ : undefined
+ }
+
+ function isTextNode (node) {
+ return isDef(node) && isDef(node.text) && isFalse(node.isComment)
+ }
+
+ function normalizeArrayChildren (children, nestedIndex) {
+ var res = [];
+ var i, c, lastIndex, last;
+ for (i = 0; i < children.length; i++) {
+ c = children[i];
+ if (isUndef(c) || typeof c === 'boolean') { continue }
+ lastIndex = res.length - 1;
+ last = res[lastIndex];
+ // nested
+ if (Array.isArray(c)) {
+ if (c.length > 0) {
+ c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
+ // merge adjacent text nodes
+ if (isTextNode(c[0]) && isTextNode(last)) {
+ res[lastIndex] = createTextVNode(last.text + (c[0]).text);
+ c.shift();
+ }
+ res.push.apply(res, c);
+ }
+ } else if (isPrimitive(c)) {
+ if (isTextNode(last)) {
+ // merge adjacent text nodes
+ // this is necessary for SSR hydration because text nodes are
+ // essentially merged when rendered to HTML strings
+ res[lastIndex] = createTextVNode(last.text + c);
+ } else if (c !== '') {
+ // convert primitive to vnode
+ res.push(createTextVNode(c));
+ }
+ } else {
+ if (isTextNode(c) && isTextNode(last)) {
+ // merge adjacent text nodes
+ res[lastIndex] = createTextVNode(last.text + c.text);
+ } else {
+ // default key for nested array children (likely generated by v-for)
+ if (isTrue(children._isVList) &&
+ isDef(c.tag) &&
+ isUndef(c.key) &&
+ isDef(nestedIndex)) {
+ c.key = "__vlist" + nestedIndex + "_" + i + "__";
+ }
+ res.push(c);
+ }
+ }
+ }
+ return res
+ }
+
+ /* */
+
+ function ensureCtor (comp, base) {
+ if (
+ comp.__esModule ||
+ (hasSymbol && comp[Symbol.toStringTag] === 'Module')
+ ) {
+ comp = comp.default;
+ }
+ return isObject(comp)
+ ? base.extend(comp)
+ : comp
+ }
+
+ function createAsyncPlaceholder (
+ factory,
+ data,
+ context,
+ children,
+ tag
+ ) {
+ var node = createEmptyVNode();
+ node.asyncFactory = factory;
+ node.asyncMeta = { data: data, context: context, children: children, tag: tag };
+ return node
+ }
+
+ function resolveAsyncComponent (
+ factory,
+ baseCtor,
+ context
+ ) {
+ if (isTrue(factory.error) && isDef(factory.errorComp)) {
+ return factory.errorComp
+ }
+
+ if (isDef(factory.resolved)) {
+ return factory.resolved
+ }
+
+ if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
+ return factory.loadingComp
+ }
+
+ if (isDef(factory.contexts)) {
+ // already pending
+ factory.contexts.push(context);
+ } else {
+ var contexts = factory.contexts = [context];
+ var sync = true;
+
+ var forceRender = function (renderCompleted) {
+ for (var i = 0, l = contexts.length; i < l; i++) {
+ contexts[i].$forceUpdate();
+ }
+
+ if (renderCompleted) {
+ contexts.length = 0;
+ }
+ };
+
+ var resolve = once(function (res) {
+ // cache resolved
+ factory.resolved = ensureCtor(res, baseCtor);
+ // invoke callbacks only if this is not a synchronous resolve
+ // (async resolves are shimmed as synchronous during SSR)
+ if (!sync) {
+ forceRender(true);
+ }
+ });
+
+ var reject = once(function (reason) {
+ warn(
+ "Failed to resolve async component: " + (String(factory)) +
+ (reason ? ("\nReason: " + reason) : '')
+ );
+ if (isDef(factory.errorComp)) {
+ factory.error = true;
+ forceRender(true);
+ }
+ });
+
+ var res = factory(resolve, reject);
+
+ if (isObject(res)) {
+ if (typeof res.then === 'function') {
+ // () => Promise
+ if (isUndef(factory.resolved)) {
+ res.then(resolve, reject);
+ }
+ } else if (isDef(res.component) && typeof res.component.then === 'function') {
+ res.component.then(resolve, reject);
+
+ if (isDef(res.error)) {
+ factory.errorComp = ensureCtor(res.error, baseCtor);
+ }
+
+ if (isDef(res.loading)) {
+ factory.loadingComp = ensureCtor(res.loading, baseCtor);
+ if (res.delay === 0) {
+ factory.loading = true;
+ } else {
+ setTimeout(function () {
+ if (isUndef(factory.resolved) && isUndef(factory.error)) {
+ factory.loading = true;
+ forceRender(false);
+ }
+ }, res.delay || 200);
+ }
+ }
+
+ if (isDef(res.timeout)) {
+ setTimeout(function () {
+ if (isUndef(factory.resolved)) {
+ reject(
+ "timeout (" + (res.timeout) + "ms)"
+ );
+ }
+ }, res.timeout);
+ }
+ }
+ }
+
+ sync = false;
+ // return in case resolved synchronously
+ return factory.loading
+ ? factory.loadingComp
+ : factory.resolved
+ }
+ }
+
+ /* */
+
+ function isAsyncPlaceholder (node) {
+ return node.isComment && node.asyncFactory
+ }
+
+ /* */
+
+ function getFirstComponentChild (children) {
+ if (Array.isArray(children)) {
+ for (var i = 0; i < children.length; i++) {
+ var c = children[i];
+ if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
+ return c
+ }
+ }
+ }
+ }
+
+ /* */
+
+ /* */
+
+ function initEvents (vm) {
+ vm._events = Object.create(null);
+ vm._hasHookEvent = false;
+ // init parent attached events
+ var listeners = vm.$options._parentListeners;
+ if (listeners) {
+ updateComponentListeners(vm, listeners);
+ }
+ }
+
+ var target;
+
+ function add (event, fn) {
+ target.$on(event, fn);
+ }
+
+ function remove$1 (event, fn) {
+ target.$off(event, fn);
+ }
+
+ function createOnceHandler (event, fn) {
+ var _target = target;
+ return function onceHandler () {
+ var res = fn.apply(null, arguments);
+ if (res !== null) {
+ _target.$off(event, onceHandler);
+ }
+ }
+ }
+
+ function updateComponentListeners (
+ vm,
+ listeners,
+ oldListeners
+ ) {
+ target = vm;
+ updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
+ target = undefined;
+ }
+
+ function eventsMixin (Vue) {
+ var hookRE = /^hook:/;
+ Vue.prototype.$on = function (event, fn) {
+ var vm = this;
+ if (Array.isArray(event)) {
+ for (var i = 0, l = event.length; i < l; i++) {
+ vm.$on(event[i], fn);
+ }
+ } else {
+ (vm._events[event] || (vm._events[event] = [])).push(fn);
+ // optimize hook:event cost by using a boolean flag marked at registration
+ // instead of a hash lookup
+ if (hookRE.test(event)) {
+ vm._hasHookEvent = true;
+ }
+ }
+ return vm
+ };
+
+ Vue.prototype.$once = function (event, fn) {
+ var vm = this;
+ function on () {
+ vm.$off(event, on);
+ fn.apply(vm, arguments);
+ }
+ on.fn = fn;
+ vm.$on(event, on);
+ return vm
+ };
+
+ Vue.prototype.$off = function (event, fn) {
+ var vm = this;
+ // all
+ if (!arguments.length) {
+ vm._events = Object.create(null);
+ return vm
+ }
+ // array of events
+ if (Array.isArray(event)) {
+ for (var i = 0, l = event.length; i < l; i++) {
+ vm.$off(event[i], fn);
+ }
+ return vm
+ }
+ // specific event
+ var cbs = vm._events[event];
+ if (!cbs) {
+ return vm
+ }
+ if (!fn) {
+ vm._events[event] = null;
+ return vm
+ }
+ if (fn) {
+ // specific handler
+ var cb;
+ var i$1 = cbs.length;
+ while (i$1--) {
+ cb = cbs[i$1];
+ if (cb === fn || cb.fn === fn) {
+ cbs.splice(i$1, 1);
+ break
+ }
+ }
+ }
+ return vm
+ };
+
+ Vue.prototype.$emit = function (event) {
+ var vm = this;
+ {
+ var lowerCaseEvent = event.toLowerCase();
+ if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
+ tip(
+ "Event \"" + lowerCaseEvent + "\" is emitted in component " +
+ (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
+ "Note that HTML attributes are case-insensitive and you cannot use " +
+ "v-on to listen to camelCase events when using in-DOM templates. " +
+ "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
+ );
+ }
+ }
+ var cbs = vm._events[event];
+ if (cbs) {
+ cbs = cbs.length > 1 ? toArray(cbs) : cbs;
+ var args = toArray(arguments, 1);
+ for (var i = 0, l = cbs.length; i < l; i++) {
+ try {
+ cbs[i].apply(vm, args);
+ } catch (e) {
+ handleError(e, vm, ("event handler for \"" + event + "\""));
+ }
+ }
+ }
+ return vm
+ };
+ }
+
+ /* */
+
+
+
+ /**
+ * Runtime helper for resolving raw children VNodes into a slot object.
+ */
+ function resolveSlots (
+ children,
+ context
+ ) {
+ var slots = {};
+ if (!children) {
+ return slots
+ }
+ for (var i = 0, l = children.length; i < l; i++) {
+ var child = children[i];
+ var data = child.data;
+ // remove slot attribute if the node is resolved as a Vue slot node
+ if (data && data.attrs && data.attrs.slot) {
+ delete data.attrs.slot;
+ }
+ // named slots should only be respected if the vnode was rendered in the
+ // same context.
+ if ((child.context === context || child.fnContext === context) &&
+ data && data.slot != null
+ ) {
+ var name = data.slot;
+ var slot = (slots[name] || (slots[name] = []));
+ if (child.tag === 'template') {
+ slot.push.apply(slot, child.children || []);
+ } else {
+ slot.push(child);
+ }
+ } else {
+ (slots.default || (slots.default = [])).push(child);
+ }
+ }
+ // ignore slots that contains only whitespace
+ for (var name$1 in slots) {
+ if (slots[name$1].every(isWhitespace)) {
+ delete slots[name$1];
+ }
+ }
+ return slots
+ }
+
+ function isWhitespace (node) {
+ return (node.isComment && !node.asyncFactory) || node.text === ' '
+ }
+
+ function resolveScopedSlots (
+ fns, // see flow/vnode
+ res
+ ) {
+ res = res || {};
+ for (var i = 0; i < fns.length; i++) {
+ if (Array.isArray(fns[i])) {
+ resolveScopedSlots(fns[i], res);
+ } else {
+ res[fns[i].key] = fns[i].fn;
+ }
+ }
+ return res
+ }
+
+ /* */
+
+ var activeInstance = null;
+ var isUpdatingChildComponent = false;
+
+ function initLifecycle (vm) {
+ var options = vm.$options;
+
+ // locate first non-abstract parent
+ var parent = options.parent;
+ if (parent && !options.abstract) {
+ while (parent.$options.abstract && parent.$parent) {
+ parent = parent.$parent;
+ }
+ parent.$children.push(vm);
+ }
+
+ vm.$parent = parent;
+ vm.$root = parent ? parent.$root : vm;
+
+ vm.$children = [];
+ vm.$refs = {};
+
+ vm._watcher = null;
+ vm._inactive = null;
+ vm._directInactive = false;
+ vm._isMounted = false;
+ vm._isDestroyed = false;
+ vm._isBeingDestroyed = false;
+ }
+
+ function lifecycleMixin (Vue) {
+ Vue.prototype._update = function (vnode, hydrating) {
+ var vm = this;
+ var prevEl = vm.$el;
+ var prevVnode = vm._vnode;
+ var prevActiveInstance = activeInstance;
+ activeInstance = vm;
+ vm._vnode = vnode;
+ // Vue.prototype.__patch__ is injected in entry points
+ // based on the rendering backend used.
+ if (!prevVnode) {
+ // initial render
+ vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
+ } else {
+ // updates
+ vm.$el = vm.__patch__(prevVnode, vnode);
+ }
+ activeInstance = prevActiveInstance;
+ // update __vue__ reference
+ if (prevEl) {
+ prevEl.__vue__ = null;
+ }
+ if (vm.$el) {
+ vm.$el.__vue__ = vm;
+ }
+ // if parent is an HOC, update its $el as well
+ if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
+ vm.$parent.$el = vm.$el;
+ }
+ // updated hook is called by the scheduler to ensure that children are
+ // updated in a parent's updated hook.
+ };
+
+ Vue.prototype.$forceUpdate = function () {
+ var vm = this;
+ if (vm._watcher) {
+ vm._watcher.update();
+ }
+ };
+
+ Vue.prototype.$destroy = function () {
+ var vm = this;
+ if (vm._isBeingDestroyed) {
+ return
+ }
+ callHook(vm, 'beforeDestroy');
+ vm._isBeingDestroyed = true;
+ // remove self from parent
+ var parent = vm.$parent;
+ if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
+ remove(parent.$children, vm);
+ }
+ // teardown watchers
+ if (vm._watcher) {
+ vm._watcher.teardown();
+ }
+ var i = vm._watchers.length;
+ while (i--) {
+ vm._watchers[i].teardown();
+ }
+ // remove reference from data ob
+ // frozen object may not have observer.
+ if (vm._data.__ob__) {
+ vm._data.__ob__.vmCount--;
+ }
+ // call the last hook...
+ vm._isDestroyed = true;
+ // invoke destroy hooks on current rendered tree
+ vm.__patch__(vm._vnode, null);
+ // fire destroyed hook
+ callHook(vm, 'destroyed');
+ // turn off all instance listeners.
+ vm.$off();
+ // remove __vue__ reference
+ if (vm.$el) {
+ vm.$el.__vue__ = null;
+ }
+ // release circular reference (#6759)
+ if (vm.$vnode) {
+ vm.$vnode.parent = null;
+ }
+ };
+ }
+
+ function mountComponent (
+ vm,
+ el,
+ hydrating
+ ) {
+ vm.$el = el;
+ if (!vm.$options.render) {
+ vm.$options.render = createEmptyVNode;
+ {
+ /* istanbul ignore if */
+ if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
+ vm.$options.el || el) {
+ warn(
+ 'You are using the runtime-only build of Vue where the template ' +
+ 'compiler is not available. Either pre-compile the templates into ' +
+ 'render functions, or use the compiler-included build.',
+ vm
+ );
+ } else {
+ warn(
+ 'Failed to mount component: template or render function not defined.',
+ vm
+ );
+ }
+ }
+ }
+ callHook(vm, 'beforeMount');
+
+ var updateComponent;
+ /* istanbul ignore if */
+ if (config.performance && mark) {
+ updateComponent = function () {
+ var name = vm._name;
+ var id = vm._uid;
+ var startTag = "vue-perf-start:" + id;
+ var endTag = "vue-perf-end:" + id;
+
+ mark(startTag);
+ var vnode = vm._render();
+ mark(endTag);
+ measure(("vue " + name + " render"), startTag, endTag);
+
+ mark(startTag);
+ vm._update(vnode, hydrating);
+ mark(endTag);
+ measure(("vue " + name + " patch"), startTag, endTag);
+ };
+ } else {
+ updateComponent = function () {
+ vm._update(vm._render(), hydrating);
+ };
+ }
+
+ // we set this to vm._watcher inside the watcher's constructor
+ // since the watcher's initial patch may call $forceUpdate (e.g. inside child
+ // component's mounted hook), which relies on vm._watcher being already defined
+ new Watcher(vm, updateComponent, noop, {
+ before: function before () {
+ if (vm._isMounted) {
+ callHook(vm, 'beforeUpdate');
+ }
+ }
+ }, true /* isRenderWatcher */);
+ hydrating = false;
+
+ // manually mounted instance, call mounted on self
+ // mounted is called for render-created child components in its inserted hook
+ if (vm.$vnode == null) {
+ vm._isMounted = true;
+ callHook(vm, 'mounted');
+ }
+ return vm
+ }
+
+ function updateChildComponent (
+ vm,
+ propsData,
+ listeners,
+ parentVnode,
+ renderChildren
+ ) {
+ {
+ isUpdatingChildComponent = true;
+ }
+
+ // determine whether component has slot children
+ // we need to do this before overwriting $options._renderChildren
+ var hasChildren = !!(
+ renderChildren || // has new static slots
+ vm.$options._renderChildren || // has old static slots
+ parentVnode.data.scopedSlots || // has new scoped slots
+ vm.$scopedSlots !== emptyObject // has old scoped slots
+ );
+
+ vm.$options._parentVnode = parentVnode;
+ vm.$vnode = parentVnode; // update vm's placeholder node without re-render
+
+ if (vm._vnode) { // update child tree's parent
+ vm._vnode.parent = parentVnode;
+ }
+ vm.$options._renderChildren = renderChildren;
+
+ // update $attrs and $listeners hash
+ // these are also reactive so they may trigger child update if the child
+ // used them during render
+ vm.$attrs = parentVnode.data.attrs || emptyObject;
+ vm.$listeners = listeners || emptyObject;
+
+ // update props
+ if (propsData && vm.$options.props) {
+ toggleObserving(false);
+ var props = vm._props;
+ var propKeys = vm.$options._propKeys || [];
+ for (var i = 0; i < propKeys.length; i++) {
+ var key = propKeys[i];
+ var propOptions = vm.$options.props; // wtf flow?
+ props[key] = validateProp(key, propOptions, propsData, vm);
+ }
+ toggleObserving(true);
+ // keep a copy of raw propsData
+ vm.$options.propsData = propsData;
+ }
+
+ // update listeners
+ listeners = listeners || emptyObject;
+ var oldListeners = vm.$options._parentListeners;
+ vm.$options._parentListeners = listeners;
+ updateComponentListeners(vm, listeners, oldListeners);
+
+ // resolve slots + force update if has children
+ if (hasChildren) {
+ vm.$slots = resolveSlots(renderChildren, parentVnode.context);
+ vm.$forceUpdate();
+ }
+
+ {
+ isUpdatingChildComponent = false;
+ }
+ }
+
+ function isInInactiveTree (vm) {
+ while (vm && (vm = vm.$parent)) {
+ if (vm._inactive) { return true }
+ }
+ return false
+ }
+
+ function activateChildComponent (vm, direct) {
+ if (direct) {
+ vm._directInactive = false;
+ if (isInInactiveTree(vm)) {
+ return
+ }
+ } else if (vm._directInactive) {
+ return
+ }
+ if (vm._inactive || vm._inactive === null) {
+ vm._inactive = false;
+ for (var i = 0; i < vm.$children.length; i++) {
+ activateChildComponent(vm.$children[i]);
+ }
+ callHook(vm, 'activated');
+ }
+ }
+
+ function deactivateChildComponent (vm, direct) {
+ if (direct) {
+ vm._directInactive = true;
+ if (isInInactiveTree(vm)) {
+ return
+ }
+ }
+ if (!vm._inactive) {
+ vm._inactive = true;
+ for (var i = 0; i < vm.$children.length; i++) {
+ deactivateChildComponent(vm.$children[i]);
+ }
+ callHook(vm, 'deactivated');
+ }
+ }
+
+ function callHook (vm, hook) {
+ // #7573 disable dep collection when invoking lifecycle hooks
+ pushTarget();
+ var handlers = vm.$options[hook];
+ if (handlers) {
+ for (var i = 0, j = handlers.length; i < j; i++) {
+ try {
+ handlers[i].call(vm);
+ } catch (e) {
+ handleError(e, vm, (hook + " hook"));
+ }
+ }
+ }
+ if (vm._hasHookEvent) {
+ vm.$emit('hook:' + hook);
+ }
+ popTarget();
+ }
+
+ /* */
+
+ var MAX_UPDATE_COUNT = 100;
+
+ var queue = [];
+ var activatedChildren = [];
+ var has = {};
+ var circular = {};
+ var waiting = false;
+ var flushing = false;
+ var index = 0;
+
+ /**
+ * Reset the scheduler's state.
+ */
+ function resetSchedulerState () {
+ index = queue.length = activatedChildren.length = 0;
+ has = {};
+ {
+ circular = {};
+ }
+ waiting = flushing = false;
+ }
+
+ /**
+ * Flush both queues and run the watchers.
+ */
+ function flushSchedulerQueue () {
+ flushing = true;
+ var watcher, id;
+
+ // Sort queue before flush.
+ // This ensures that:
+ // 1. Components are updated from parent to child. (because parent is always
+ // created before the child)
+ // 2. A component's user watchers are run before its render watcher (because
+ // user watchers are created before the render watcher)
+ // 3. If a component is destroyed during a parent component's watcher run,
+ // its watchers can be skipped.
+ queue.sort(function (a, b) { return a.id - b.id; });
+
+ // do not cache length because more watchers might be pushed
+ // as we run existing watchers
+ for (index = 0; index < queue.length; index++) {
+ watcher = queue[index];
+ if (watcher.before) {
+ watcher.before();
+ }
+ id = watcher.id;
+ has[id] = null;
+ watcher.run();
+ // in dev build, check and stop circular updates.
+ if (has[id] != null) {
+ circular[id] = (circular[id] || 0) + 1;
+ if (circular[id] > MAX_UPDATE_COUNT) {
+ warn(
+ 'You may have an infinite update loop ' + (
+ watcher.user
+ ? ("in watcher with expression \"" + (watcher.expression) + "\"")
+ : "in a component render function."
+ ),
+ watcher.vm
+ );
+ break
+ }
+ }
+ }
+
+ // keep copies of post queues before resetting state
+ var activatedQueue = activatedChildren.slice();
+ var updatedQueue = queue.slice();
+
+ resetSchedulerState();
+
+ // call component updated and activated hooks
+ callActivatedHooks(activatedQueue);
+ callUpdatedHooks(updatedQueue);
+
+ // devtool hook
+ /* istanbul ignore if */
+ if (devtools && config.devtools) {
+ devtools.emit('flush');
+ }
+ }
+
+ function callUpdatedHooks (queue) {
+ var i = queue.length;
+ while (i--) {
+ var watcher = queue[i];
+ var vm = watcher.vm;
+ if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
+ callHook(vm, 'updated');
+ }
+ }
+ }
+
+ /**
+ * Queue a kept-alive component that was activated during patch.
+ * The queue will be processed after the entire tree has been patched.
+ */
+ function queueActivatedComponent (vm) {
+ // setting _inactive to false here so that a render function can
+ // rely on checking whether it's in an inactive tree (e.g. router-view)
+ vm._inactive = false;
+ activatedChildren.push(vm);
+ }
+
+ function callActivatedHooks (queue) {
+ for (var i = 0; i < queue.length; i++) {
+ queue[i]._inactive = true;
+ activateChildComponent(queue[i], true /* true */);
+ }
+ }
+
+ /**
+ * Push a watcher into the watcher queue.
+ * Jobs with duplicate IDs will be skipped unless it's
+ * pushed when the queue is being flushed.
+ */
+ function queueWatcher (watcher) {
+ var id = watcher.id;
+ if (has[id] == null) {
+ has[id] = true;
+ if (!flushing) {
+ queue.push(watcher);
+ } else {
+ // if already flushing, splice the watcher based on its id
+ // if already past its id, it will be run next immediately.
+ var i = queue.length - 1;
+ while (i > index && queue[i].id > watcher.id) {
+ i--;
+ }
+ queue.splice(i + 1, 0, watcher);
+ }
+ // queue the flush
+ if (!waiting) {
+ waiting = true;
+
+ if (!config.async) {
+ flushSchedulerQueue();
+ return
+ }
+ nextTick(flushSchedulerQueue);
+ }
+ }
+ }
+
+ /* */
+
+
+
+ var uid$1 = 0;
+
+ /**
+ * A watcher parses an expression, collects dependencies,
+ * and fires callback when the expression value changes.
+ * This is used for both the $watch() api and directives.
+ */
+ var Watcher = function Watcher (
+ vm,
+ expOrFn,
+ cb,
+ options,
+ isRenderWatcher
+ ) {
+ this.vm = vm;
+ if (isRenderWatcher) {
+ vm._watcher = this;
+ }
+ vm._watchers.push(this);
+ // options
+ if (options) {
+ this.deep = !!options.deep;
+ this.user = !!options.user;
+ this.lazy = !!options.lazy;
+ this.sync = !!options.sync;
+ this.before = options.before;
+ } else {
+ this.deep = this.user = this.lazy = this.sync = false;
+ }
+ this.cb = cb;
+ this.id = ++uid$1; // uid for batching
+ this.active = true;
+ this.dirty = this.lazy; // for lazy watchers
+ this.deps = [];
+ this.newDeps = [];
+ this.depIds = new _Set();
+ this.newDepIds = new _Set();
+ this.expression = expOrFn.toString();
+ // parse expression for getter
+ if (typeof expOrFn === 'function') {
+ this.getter = expOrFn;
+ } else {
+ this.getter = parsePath(expOrFn);
+ if (!this.getter) {
+ this.getter = noop;
+ warn(
+ "Failed watching path: \"" + expOrFn + "\" " +
+ 'Watcher only accepts simple dot-delimited paths. ' +
+ 'For full control, use a function instead.',
+ vm
+ );
+ }
+ }
+ this.value = this.lazy
+ ? undefined
+ : this.get();
+ };
+
+ /**
+ * Evaluate the getter, and re-collect dependencies.
+ */
+ Watcher.prototype.get = function get () {
+ pushTarget(this);
+ var value;
+ var vm = this.vm;
+ try {
+ value = this.getter.call(vm, vm);
+ } catch (e) {
+ if (this.user) {
+ handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
+ } else {
+ throw e
+ }
+ } finally {
+ // "touch" every property so they are all tracked as
+ // dependencies for deep watching
+ if (this.deep) {
+ traverse(value);
+ }
+ popTarget();
+ this.cleanupDeps();
+ }
+ return value
+ };
+
+ /**
+ * Add a dependency to this directive.
+ */
+ Watcher.prototype.addDep = function addDep (dep) {
+ var id = dep.id;
+ if (!this.newDepIds.has(id)) {
+ this.newDepIds.add(id);
+ this.newDeps.push(dep);
+ if (!this.depIds.has(id)) {
+ dep.addSub(this);
+ }
+ }
+ };
+
+ /**
+ * Clean up for dependency collection.
+ */
+ Watcher.prototype.cleanupDeps = function cleanupDeps () {
+ var i = this.deps.length;
+ while (i--) {
+ var dep = this.deps[i];
+ if (!this.newDepIds.has(dep.id)) {
+ dep.removeSub(this);
+ }
+ }
+ var tmp = this.depIds;
+ this.depIds = this.newDepIds;
+ this.newDepIds = tmp;
+ this.newDepIds.clear();
+ tmp = this.deps;
+ this.deps = this.newDeps;
+ this.newDeps = tmp;
+ this.newDeps.length = 0;
+ };
+
+ /**
+ * Subscriber interface.
+ * Will be called when a dependency changes.
+ */
+ Watcher.prototype.update = function update () {
+ /* istanbul ignore else */
+ if (this.lazy) {
+ this.dirty = true;
+ } else if (this.sync) {
+ this.run();
+ } else {
+ queueWatcher(this);
+ }
+ };
+
+ /**
+ * Scheduler job interface.
+ * Will be called by the scheduler.
+ */
+ Watcher.prototype.run = function run () {
+ if (this.active) {
+ var value = this.get();
+ if (
+ value !== this.value ||
+ // Deep watchers and watchers on Object/Arrays should fire even
+ // when the value is the same, because the value may
+ // have mutated.
+ isObject(value) ||
+ this.deep
+ ) {
+ // set new value
+ var oldValue = this.value;
+ this.value = value;
+ if (this.user) {
+ try {
+ this.cb.call(this.vm, value, oldValue);
+ } catch (e) {
+ handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ }
+ } else {
+ this.cb.call(this.vm, value, oldValue);
+ }
+ }
+ }
+ };
+
+ /**
+ * Evaluate the value of the watcher.
+ * This only gets called for lazy watchers.
+ */
+ Watcher.prototype.evaluate = function evaluate () {
+ this.value = this.get();
+ this.dirty = false;
+ };
+
+ /**
+ * Depend on all deps collected by this watcher.
+ */
+ Watcher.prototype.depend = function depend () {
+ var i = this.deps.length;
+ while (i--) {
+ this.deps[i].depend();
+ }
+ };
+
+ /**
+ * Remove self from all dependencies' subscriber list.
+ */
+ Watcher.prototype.teardown = function teardown () {
+ if (this.active) {
+ // remove self from vm's watcher list
+ // this is a somewhat expensive operation so we skip it
+ // if the vm is being destroyed.
+ if (!this.vm._isBeingDestroyed) {
+ remove(this.vm._watchers, this);
+ }
+ var i = this.deps.length;
+ while (i--) {
+ this.deps[i].removeSub(this);
+ }
+ this.active = false;
+ }
+ };
+
+ /* */
+
+ var sharedPropertyDefinition = {
+ enumerable: true,
+ configurable: true,
+ get: noop,
+ set: noop
+ };
+
+ function proxy (target, sourceKey, key) {
+ sharedPropertyDefinition.get = function proxyGetter () {
+ return this[sourceKey][key]
+ };
+ sharedPropertyDefinition.set = function proxySetter (val) {
+ this[sourceKey][key] = val;
+ };
+ Object.defineProperty(target, key, sharedPropertyDefinition);
+ }
+
+ function initState (vm) {
+ vm._watchers = [];
+ var opts = vm.$options;
+ if (opts.props) { initProps(vm, opts.props); }
+ if (opts.methods) { initMethods(vm, opts.methods); }
+ if (opts.data) {
+ initData(vm);
+ } else {
+ observe(vm._data = {}, true /* asRootData */);
+ }
+ if (opts.computed) { initComputed(vm, opts.computed); }
+ if (opts.watch && opts.watch !== nativeWatch) {
+ initWatch(vm, opts.watch);
+ }
+ }
+
+ function initProps (vm, propsOptions) {
+ var propsData = vm.$options.propsData || {};
+ var props = vm._props = {};
+ // cache prop keys so that future props updates can iterate using Array
+ // instead of dynamic object key enumeration.
+ var keys = vm.$options._propKeys = [];
+ var isRoot = !vm.$parent;
+ // root instance props should be converted
+ if (!isRoot) {
+ toggleObserving(false);
+ }
+ var loop = function ( key ) {
+ keys.push(key);
+ var value = validateProp(key, propsOptions, propsData, vm);
+ /* istanbul ignore else */
+ {
+ var hyphenatedKey = hyphenate(key);
+ if (isReservedAttribute(hyphenatedKey) ||
+ config.isReservedAttr(hyphenatedKey)) {
+ warn(
+ ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
+ vm
+ );
+ }
+ defineReactive$$1(props, key, value, function () {
+ if (!isRoot && !isUpdatingChildComponent) {
+ warn(
+ "Avoid mutating a prop directly since the value will be " +
+ "overwritten whenever the parent component re-renders. " +
+ "Instead, use a data or computed property based on the prop's " +
+ "value. Prop being mutated: \"" + key + "\"",
+ vm
+ );
}
+ });
+ }
+ // static props are already proxied on the component's prototype
+ // during Vue.extend(). We only need to proxy props defined at
+ // instantiation here.
+ if (!(key in vm)) {
+ proxy(vm, "_props", key);
+ }
+ };
+
+ for (var key in propsOptions) loop( key );
+ toggleObserving(true);
+ }
+
+ function initData (vm) {
+ var data = vm.$options.data;
+ data = vm._data = typeof data === 'function'
+ ? getData(data, vm)
+ : data || {};
+ if (!isPlainObject(data)) {
+ data = {};
+ warn(
+ 'data functions should return an object:\n' +
+ 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
+ vm
+ );
+ }
+ // proxy data on instance
+ var keys = Object.keys(data);
+ var props = vm.$options.props;
+ var methods = vm.$options.methods;
+ var i = keys.length;
+ while (i--) {
+ var key = keys[i];
+ {
+ if (methods && hasOwn(methods, key)) {
+ warn(
+ ("Method \"" + key + "\" has already been defined as a data property."),
+ vm
+ );
}
}
- return value
- },
- set: function reactiveSetter (newVal) {
- var value = getter ? getter.call(obj) : val;
- /* eslint-disable no-self-compare */
- if (newVal === value || (newVal !== newVal && value !== value)) {
- return
+ if (props && hasOwn(props, key)) {
+ warn(
+ "The data property \"" + key + "\" is already declared as a prop. " +
+ "Use prop default value instead.",
+ vm
+ );
+ } else if (!isReserved(key)) {
+ proxy(vm, "_data", key);
+ }
+ }
+ // observe data
+ observe(data, true /* asRootData */);
+ }
+
+ function getData (data, vm) {
+ // #7573 disable dep collection when invoking data getters
+ pushTarget();
+ try {
+ return data.call(vm, vm)
+ } catch (e) {
+ handleError(e, vm, "data()");
+ return {}
+ } finally {
+ popTarget();
+ }
+ }
+
+ var computedWatcherOptions = { lazy: true };
+
+ function initComputed (vm, computed) {
+ // $flow-disable-line
+ var watchers = vm._computedWatchers = Object.create(null);
+ // computed properties are just getters during SSR
+ var isSSR = isServerRendering();
+
+ for (var key in computed) {
+ var userDef = computed[key];
+ var getter = typeof userDef === 'function' ? userDef : userDef.get;
+ if (getter == null) {
+ warn(
+ ("Getter is missing for computed property \"" + key + "\"."),
+ vm
+ );
}
- /* eslint-enable no-self-compare */
- if ("development" !== 'production' && customSetter) {
- customSetter();
+
+ if (!isSSR) {
+ // create internal watcher for the computed property.
+ watchers[key] = new Watcher(
+ vm,
+ getter || noop,
+ noop,
+ computedWatcherOptions
+ );
}
- if (setter) {
- setter.call(obj, newVal);
+
+ // component-defined computed properties are already defined on the
+ // component prototype. We only need to define computed properties defined
+ // at instantiation here.
+ if (!(key in vm)) {
+ defineComputed(vm, key, userDef);
} else {
- val = newVal;
+ if (key in vm.$data) {
+ warn(("The computed property \"" + key + "\" is already defined in data."), vm);
+ } else if (vm.$options.props && key in vm.$options.props) {
+ warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
+ }
}
- childOb = !shallow && observe(newVal);
- dep.notify();
}
- });
-}
+ }
-/**
- * Set a property on an object. Adds the new property and
- * triggers change notification if the property doesn't
- * already exist.
- */
-function set (target, key, val) {
- if ("development" !== 'production' &&
- (isUndef(target) || isPrimitive(target))
+ function defineComputed (
+ target,
+ key,
+ userDef
) {
- warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
+ var shouldCache = !isServerRendering();
+ if (typeof userDef === 'function') {
+ sharedPropertyDefinition.get = shouldCache
+ ? createComputedGetter(key)
+ : createGetterInvoker(userDef);
+ sharedPropertyDefinition.set = noop;
+ } else {
+ sharedPropertyDefinition.get = userDef.get
+ ? shouldCache && userDef.cache !== false
+ ? createComputedGetter(key)
+ : createGetterInvoker(userDef.get)
+ : noop;
+ sharedPropertyDefinition.set = userDef.set || noop;
+ }
+ if (sharedPropertyDefinition.set === noop) {
+ sharedPropertyDefinition.set = function () {
+ warn(
+ ("Computed property \"" + key + "\" was assigned to but it has no setter."),
+ this
+ );
+ };
+ }
+ Object.defineProperty(target, key, sharedPropertyDefinition);
}
- if (Array.isArray(target) && isValidArrayIndex(key)) {
- target.length = Math.max(target.length, key);
- target.splice(key, 1, val);
- return val
+
+ function createComputedGetter (key) {
+ return function computedGetter () {
+ var watcher = this._computedWatchers && this._computedWatchers[key];
+ if (watcher) {
+ if (watcher.dirty) {
+ watcher.evaluate();
+ }
+ if (Dep.target) {
+ watcher.depend();
+ }
+ return watcher.value
+ }
+ }
}
- if (key in target && !(key in Object.prototype)) {
- target[key] = val;
- return val
+
+ function createGetterInvoker(fn) {
+ return function computedGetter () {
+ return fn.call(this, this)
+ }
}
- var ob = (target).__ob__;
- if (target._isVue || (ob && ob.vmCount)) {
- "development" !== 'production' && warn(
- 'Avoid adding reactive properties to a Vue instance or its root $data ' +
- 'at runtime - declare it upfront in the data option.'
- );
- return val
+
+ function initMethods (vm, methods) {
+ var props = vm.$options.props;
+ for (var key in methods) {
+ {
+ if (typeof methods[key] !== 'function') {
+ warn(
+ "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
+ "Did you reference the function correctly?",
+ vm
+ );
+ }
+ if (props && hasOwn(props, key)) {
+ warn(
+ ("Method \"" + key + "\" has already been defined as a prop."),
+ vm
+ );
+ }
+ if ((key in vm) && isReserved(key)) {
+ warn(
+ "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
+ "Avoid defining component methods that start with _ or $."
+ );
+ }
+ }
+ vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
+ }
}
- if (!ob) {
- target[key] = val;
- return val
+
+ function initWatch (vm, watch) {
+ for (var key in watch) {
+ var handler = watch[key];
+ if (Array.isArray(handler)) {
+ for (var i = 0; i < handler.length; i++) {
+ createWatcher(vm, key, handler[i]);
+ }
+ } else {
+ createWatcher(vm, key, handler);
+ }
+ }
}
- defineReactive(ob.value, key, val);
- ob.dep.notify();
- return val
-}
-/**
- * Delete a property and trigger change if necessary.
- */
-function del (target, key) {
- if ("development" !== 'production' &&
- (isUndef(target) || isPrimitive(target))
+ function createWatcher (
+ vm,
+ expOrFn,
+ handler,
+ options
) {
- warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
- }
- if (Array.isArray(target) && isValidArrayIndex(key)) {
- target.splice(key, 1);
- return
- }
- var ob = (target).__ob__;
- if (target._isVue || (ob && ob.vmCount)) {
- "development" !== 'production' && warn(
- 'Avoid deleting properties on a Vue instance or its root $data ' +
- '- just set it to null.'
- );
- return
- }
- if (!hasOwn(target, key)) {
- return
- }
- delete target[key];
- if (!ob) {
- return
+ if (isPlainObject(handler)) {
+ options = handler;
+ handler = handler.handler;
+ }
+ if (typeof handler === 'string') {
+ handler = vm[handler];
+ }
+ return vm.$watch(expOrFn, handler, options)
}
- ob.dep.notify();
-}
-/**
- * Collect dependencies on array elements when the array is touched, since
- * we cannot intercept array element access like property getters.
- */
-function dependArray (value) {
- for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
- e = value[i];
- e && e.__ob__ && e.__ob__.dep.depend();
- if (Array.isArray(e)) {
- dependArray(e);
+ function stateMixin (Vue) {
+ // flow somehow has problems with directly declared definition object
+ // when using Object.defineProperty, so we have to procedurally build up
+ // the object here.
+ var dataDef = {};
+ dataDef.get = function () { return this._data };
+ var propsDef = {};
+ propsDef.get = function () { return this._props };
+ {
+ dataDef.set = function () {
+ warn(
+ 'Avoid replacing instance root $data. ' +
+ 'Use nested data properties instead.',
+ this
+ );
+ };
+ propsDef.set = function () {
+ warn("$props is readonly.", this);
+ };
}
+ Object.defineProperty(Vue.prototype, '$data', dataDef);
+ Object.defineProperty(Vue.prototype, '$props', propsDef);
+
+ Vue.prototype.$set = set;
+ Vue.prototype.$delete = del;
+
+ Vue.prototype.$watch = function (
+ expOrFn,
+ cb,
+ options
+ ) {
+ var vm = this;
+ if (isPlainObject(cb)) {
+ return createWatcher(vm, expOrFn, cb, options)
+ }
+ options = options || {};
+ options.user = true;
+ var watcher = new Watcher(vm, expOrFn, cb, options);
+ if (options.immediate) {
+ try {
+ cb.call(vm, watcher.value);
+ } catch (error) {
+ handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
+ }
+ }
+ return function unwatchFn () {
+ watcher.teardown();
+ }
+ };
}
-}
-/* */
+ /* */
-/**
- * Option overwriting strategies are functions that handle
- * how to merge a parent option value and a child option
- * value into the final value.
- */
-var strats = config.optionMergeStrategies;
+ function initProvide (vm) {
+ var provide = vm.$options.provide;
+ if (provide) {
+ vm._provided = typeof provide === 'function'
+ ? provide.call(vm)
+ : provide;
+ }
+ }
-/**
- * Options with restrictions
- */
-{
- strats.el = strats.propsData = function (parent, child, vm, key) {
- if (!vm) {
- warn(
- "option \"" + key + "\" can only be used during instance " +
- 'creation with the `new` keyword.'
- );
+ function initInjections (vm) {
+ var result = resolveInject(vm.$options.inject, vm);
+ if (result) {
+ toggleObserving(false);
+ Object.keys(result).forEach(function (key) {
+ /* istanbul ignore else */
+ {
+ defineReactive$$1(vm, key, result[key], function () {
+ warn(
+ "Avoid mutating an injected value directly since the changes will be " +
+ "overwritten whenever the provided component re-renders. " +
+ "injection being mutated: \"" + key + "\"",
+ vm
+ );
+ });
+ }
+ });
+ toggleObserving(true);
}
- return defaultStrat(parent, child)
- };
-}
+ }
-/**
- * Helper that recursively merges two data objects together.
- */
-function mergeData (to, from) {
- if (!from) { return to }
- var key, toVal, fromVal;
- var keys = Object.keys(from);
- for (var i = 0; i < keys.length; i++) {
- key = keys[i];
- toVal = to[key];
- fromVal = from[key];
- if (!hasOwn(to, key)) {
- set(to, key, fromVal);
- } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
- mergeData(toVal, fromVal);
- }
- }
- return to
-}
-
-/**
- * Data
- */
-function mergeDataOrFn (
- parentVal,
- childVal,
- vm
-) {
- if (!vm) {
- // in a Vue.extend merge, both should be functions
- if (!childVal) {
- return parentVal
- }
- if (!parentVal) {
- return childVal
- }
- // when parentVal & childVal are both present,
- // we need to return a function that returns the
- // merged result of both functions... no need to
- // check if parentVal is a function here because
- // it has to be a function to pass previous merges.
- return function mergedDataFn () {
- return mergeData(
- typeof childVal === 'function' ? childVal.call(this, this) : childVal,
- typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
- )
+ function resolveInject (inject, vm) {
+ if (inject) {
+ // inject is :any because flow is not smart enough to figure out cached
+ var result = Object.create(null);
+ var keys = hasSymbol
+ ? Reflect.ownKeys(inject).filter(function (key) {
+ /* istanbul ignore next */
+ return Object.getOwnPropertyDescriptor(inject, key).enumerable
+ })
+ : Object.keys(inject);
+
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ var provideKey = inject[key].from;
+ var source = vm;
+ while (source) {
+ if (source._provided && hasOwn(source._provided, provideKey)) {
+ result[key] = source._provided[provideKey];
+ break
+ }
+ source = source.$parent;
+ }
+ if (!source) {
+ if ('default' in inject[key]) {
+ var provideDefault = inject[key].default;
+ result[key] = typeof provideDefault === 'function'
+ ? provideDefault.call(vm)
+ : provideDefault;
+ } else {
+ warn(("Injection \"" + key + "\" not found"), vm);
+ }
+ }
+ }
+ return result
}
- } else {
- return function mergedInstanceDataFn () {
- // instance merge
- var instanceData = typeof childVal === 'function'
- ? childVal.call(vm, vm)
- : childVal;
- var defaultData = typeof parentVal === 'function'
- ? parentVal.call(vm, vm)
- : parentVal;
- if (instanceData) {
- return mergeData(instanceData, defaultData)
- } else {
- return defaultData
+ }
+
+ /* */
+
+ /**
+ * Runtime helper for rendering v-for lists.
+ */
+ function renderList (
+ val,
+ render
+ ) {
+ var ret, i, l, keys, key;
+ if (Array.isArray(val) || typeof val === 'string') {
+ ret = new Array(val.length);
+ for (i = 0, l = val.length; i < l; i++) {
+ ret[i] = render(val[i], i);
+ }
+ } else if (typeof val === 'number') {
+ ret = new Array(val);
+ for (i = 0; i < val; i++) {
+ ret[i] = render(i + 1, i);
+ }
+ } else if (isObject(val)) {
+ keys = Object.keys(val);
+ ret = new Array(keys.length);
+ for (i = 0, l = keys.length; i < l; i++) {
+ key = keys[i];
+ ret[i] = render(val[key], key, i);
}
}
+ if (isDef(ret)) {
+ (ret)._isVList = true;
+ }
+ return ret
}
-}
-strats.data = function (
- parentVal,
- childVal,
- vm
-) {
- if (!vm) {
- if (childVal && typeof childVal !== 'function') {
- "development" !== 'production' && warn(
- 'The "data" option should be a function ' +
- 'that returns a per-instance value in component ' +
- 'definitions.',
- vm
- );
+ /* */
+
+ /**
+ * Runtime helper for rendering
+ */
+ function renderSlot (
+ name,
+ fallback,
+ props,
+ bindObject
+ ) {
+ var scopedSlotFn = this.$scopedSlots[name];
+ var nodes;
+ if (scopedSlotFn) { // scoped slot
+ props = props || {};
+ if (bindObject) {
+ if (!isObject(bindObject)) {
+ warn(
+ 'slot v-bind without argument expects an Object',
+ this
+ );
+ }
+ props = extend(extend({}, bindObject), props);
+ }
+ nodes = scopedSlotFn(props) || fallback;
+ } else {
+ nodes = this.$slots[name] || fallback;
+ }
- return parentVal
+ var target = props && props.slot;
+ if (target) {
+ return this.$createElement('template', { slot: target }, nodes)
+ } else {
+ return nodes
}
- return mergeDataOrFn(parentVal, childVal)
}
- return mergeDataOrFn(parentVal, childVal, vm)
-};
+ /* */
-/**
- * Hooks and props are merged as arrays.
- */
-function mergeHook (
- parentVal,
- childVal
-) {
- return childVal
- ? parentVal
- ? parentVal.concat(childVal)
- : Array.isArray(childVal)
- ? childVal
- : [childVal]
- : parentVal
-}
-
-LIFECYCLE_HOOKS.forEach(function (hook) {
- strats[hook] = mergeHook;
-});
-
-/**
- * Assets
- *
- * When a vm is present (instance creation), we need to do
- * a three-way merge between constructor options, instance
- * options and parent options.
- */
-function mergeAssets (
- parentVal,
- childVal,
- vm,
- key
-) {
- var res = Object.create(parentVal || null);
- if (childVal) {
- "development" !== 'production' && assertObjectType(key, childVal, vm);
- return extend(res, childVal)
- } else {
- return res
+ /**
+ * Runtime helper for resolving filters
+ */
+ function resolveFilter (id) {
+ return resolveAsset(this.$options, 'filters', id, true) || identity
}
-}
-ASSET_TYPES.forEach(function (type) {
- strats[type + 's'] = mergeAssets;
-});
+ /* */
-/**
- * Watchers.
- *
- * Watchers hashes should not overwrite one
- * another, so we merge them as arrays.
- */
-strats.watch = function (
- parentVal,
- childVal,
- vm,
- key
-) {
- // work around Firefox's Object.prototype.watch...
- if (parentVal === nativeWatch) { parentVal = undefined; }
- if (childVal === nativeWatch) { childVal = undefined; }
- /* istanbul ignore if */
- if (!childVal) { return Object.create(parentVal || null) }
- {
- assertObjectType(key, childVal, vm);
- }
- if (!parentVal) { return childVal }
- var ret = {};
- extend(ret, parentVal);
- for (var key$1 in childVal) {
- var parent = ret[key$1];
- var child = childVal[key$1];
- if (parent && !Array.isArray(parent)) {
- parent = [parent];
- }
- ret[key$1] = parent
- ? parent.concat(child)
- : Array.isArray(child) ? child : [child];
- }
- return ret
-};
-
-/**
- * Other object hashes.
- */
-strats.props =
-strats.methods =
-strats.inject =
-strats.computed = function (
- parentVal,
- childVal,
- vm,
- key
-) {
- if (childVal && "development" !== 'production') {
- assertObjectType(key, childVal, vm);
- }
- if (!parentVal) { return childVal }
- var ret = Object.create(null);
- extend(ret, parentVal);
- if (childVal) { extend(ret, childVal); }
- return ret
-};
-strats.provide = mergeDataOrFn;
-
-/**
- * Default strategy.
- */
-var defaultStrat = function (parentVal, childVal) {
- return childVal === undefined
- ? parentVal
- : childVal
-};
-
-/**
- * Validate component names
- */
-function checkComponents (options) {
- for (var key in options.components) {
- validateComponentName(key);
- }
-}
-
-function validateComponentName (name) {
- if (!/^[a-zA-Z][\w-]*$/.test(name)) {
- warn(
- 'Invalid component name: "' + name + '". Component names ' +
- 'can only contain alphanumeric characters and the hyphen, ' +
- 'and must start with a letter.'
- );
+ function isKeyNotMatch (expect, actual) {
+ if (Array.isArray(expect)) {
+ return expect.indexOf(actual) === -1
+ } else {
+ return expect !== actual
+ }
}
- if (isBuiltInTag(name) || config.isReservedTag(name)) {
- warn(
- 'Do not use built-in or reserved HTML elements as component ' +
- 'id: ' + name
- );
+
+ /**
+ * Runtime helper for checking keyCodes from config.
+ * exposed as Vue.prototype._k
+ * passing in eventKeyName as last argument separately for backwards compat
+ */
+ function checkKeyCodes (
+ eventKeyCode,
+ key,
+ builtInKeyCode,
+ eventKeyName,
+ builtInKeyName
+ ) {
+ var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
+ if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
+ return isKeyNotMatch(builtInKeyName, eventKeyName)
+ } else if (mappedKeyCode) {
+ return isKeyNotMatch(mappedKeyCode, eventKeyCode)
+ } else if (eventKeyName) {
+ return hyphenate(eventKeyName) !== key
+ }
}
-}
-/**
- * Ensure all props option syntax are normalized into the
- * Object-based format.
- */
-function normalizeProps (options, vm) {
- var props = options.props;
- if (!props) { return }
- var res = {};
- var i, val, name;
- if (Array.isArray(props)) {
- i = props.length;
- while (i--) {
- val = props[i];
- if (typeof val === 'string') {
- name = camelize(val);
- res[name] = { type: null };
+ /* */
+
+ /**
+ * Runtime helper for merging v-bind="object" into a VNode's data.
+ */
+ function bindObjectProps (
+ data,
+ tag,
+ value,
+ asProp,
+ isSync
+ ) {
+ if (value) {
+ if (!isObject(value)) {
+ warn(
+ 'v-bind without argument expects an Object or Array value',
+ this
+ );
} else {
- warn('props must be strings when using array syntax.');
+ if (Array.isArray(value)) {
+ value = toObject(value);
+ }
+ var hash;
+ var loop = function ( key ) {
+ if (
+ key === 'class' ||
+ key === 'style' ||
+ isReservedAttribute(key)
+ ) {
+ hash = data;
+ } else {
+ var type = data.attrs && data.attrs.type;
+ hash = asProp || config.mustUseProp(tag, type, key)
+ ? data.domProps || (data.domProps = {})
+ : data.attrs || (data.attrs = {});
+ }
+ var camelizedKey = camelize(key);
+ if (!(key in hash) && !(camelizedKey in hash)) {
+ hash[key] = value[key];
+
+ if (isSync) {
+ var on = data.on || (data.on = {});
+ on[("update:" + camelizedKey)] = function ($event) {
+ value[key] = $event;
+ };
+ }
+ }
+ };
+
+ for (var key in value) loop( key );
}
}
- } else if (isPlainObject(props)) {
- for (var key in props) {
- val = props[key];
- name = camelize(key);
- res[name] = isPlainObject(val)
- ? val
- : { type: val };
- }
- } else {
- warn(
- "Invalid value for option \"props\": expected an Array or an Object, " +
- "but got " + (toRawType(props)) + ".",
- vm
- );
+ return data
}
- options.props = res;
-}
-/**
- * Normalize all injections into Object-based format
- */
-function normalizeInject (options, vm) {
- var inject = options.inject;
- if (!inject) { return }
- var normalized = options.inject = {};
- if (Array.isArray(inject)) {
- for (var i = 0; i < inject.length; i++) {
- normalized[inject[i]] = { from: inject[i] };
- }
- } else if (isPlainObject(inject)) {
- for (var key in inject) {
- var val = inject[key];
- normalized[key] = isPlainObject(val)
- ? extend({ from: key }, val)
- : { from: val };
- }
- } else {
- warn(
- "Invalid value for option \"inject\": expected an Array or an Object, " +
- "but got " + (toRawType(inject)) + ".",
- vm
+ /* */
+
+ /**
+ * Runtime helper for rendering static trees.
+ */
+ function renderStatic (
+ index,
+ isInFor
+ ) {
+ var cached = this._staticTrees || (this._staticTrees = []);
+ var tree = cached[index];
+ // if has already-rendered static tree and not inside v-for,
+ // we can reuse the same tree.
+ if (tree && !isInFor) {
+ return tree
+ }
+ // otherwise, render a fresh tree.
+ tree = cached[index] = this.$options.staticRenderFns[index].call(
+ this._renderProxy,
+ null,
+ this // for render fns generated for functional component templates
);
+ markStatic(tree, ("__static__" + index), false);
+ return tree
}
-}
-/**
- * Normalize raw function directives into object format.
- */
-function normalizeDirectives (options) {
- var dirs = options.directives;
- if (dirs) {
- for (var key in dirs) {
- var def = dirs[key];
- if (typeof def === 'function') {
- dirs[key] = { bind: def, update: def };
+ /**
+ * Runtime helper for v-once.
+ * Effectively it means marking the node as static with a unique key.
+ */
+ function markOnce (
+ tree,
+ index,
+ key
+ ) {
+ markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
+ return tree
+ }
+
+ function markStatic (
+ tree,
+ key,
+ isOnce
+ ) {
+ if (Array.isArray(tree)) {
+ for (var i = 0; i < tree.length; i++) {
+ if (tree[i] && typeof tree[i] !== 'string') {
+ markStaticNode(tree[i], (key + "_" + i), isOnce);
+ }
}
+ } else {
+ markStaticNode(tree, key, isOnce);
}
}
-}
-
-function assertObjectType (name, value, vm) {
- if (!isPlainObject(value)) {
- warn(
- "Invalid value for option \"" + name + "\": expected an Object, " +
- "but got " + (toRawType(value)) + ".",
- vm
- );
- }
-}
-/**
- * Merge two option objects into a new one.
- * Core utility used in both instantiation and inheritance.
- */
-function mergeOptions (
- parent,
- child,
- vm
-) {
- {
- checkComponents(child);
+ function markStaticNode (node, key, isOnce) {
+ node.isStatic = true;
+ node.key = key;
+ node.isOnce = isOnce;
}
- if (typeof child === 'function') {
- child = child.options;
- }
+ /* */
- normalizeProps(child, vm);
- normalizeInject(child, vm);
- normalizeDirectives(child);
- var extendsFrom = child.extends;
- if (extendsFrom) {
- parent = mergeOptions(parent, extendsFrom, vm);
- }
- if (child.mixins) {
- for (var i = 0, l = child.mixins.length; i < l; i++) {
- parent = mergeOptions(parent, child.mixins[i], vm);
+ function bindObjectListeners (data, value) {
+ if (value) {
+ if (!isPlainObject(value)) {
+ warn(
+ 'v-on without argument expects an Object value',
+ this
+ );
+ } else {
+ var on = data.on = data.on ? extend({}, data.on) : {};
+ for (var key in value) {
+ var existing = on[key];
+ var ours = value[key];
+ on[key] = existing ? [].concat(existing, ours) : ours;
+ }
+ }
}
+ return data
}
- var options = {};
- var key;
- for (key in parent) {
- mergeField(key);
+
+ /* */
+
+ function installRenderHelpers (target) {
+ target._o = markOnce;
+ target._n = toNumber;
+ target._s = toString;
+ target._l = renderList;
+ target._t = renderSlot;
+ target._q = looseEqual;
+ target._i = looseIndexOf;
+ target._m = renderStatic;
+ target._f = resolveFilter;
+ target._k = checkKeyCodes;
+ target._b = bindObjectProps;
+ target._v = createTextVNode;
+ target._e = createEmptyVNode;
+ target._u = resolveScopedSlots;
+ target._g = bindObjectListeners;
}
- for (key in child) {
- if (!hasOwn(parent, key)) {
- mergeField(key);
+
+ /* */
+
+ function FunctionalRenderContext (
+ data,
+ props,
+ children,
+ parent,
+ Ctor
+ ) {
+ var options = Ctor.options;
+ // ensure the createElement function in functional components
+ // gets a unique context - this is necessary for correct named slot check
+ var contextVm;
+ if (hasOwn(parent, '_uid')) {
+ contextVm = Object.create(parent);
+ // $flow-disable-line
+ contextVm._original = parent;
+ } else {
+ // the context vm passed in is a functional context as well.
+ // in this case we want to make sure we are able to get a hold to the
+ // real context instance.
+ contextVm = parent;
+ // $flow-disable-line
+ parent = parent._original;
+ }
+ var isCompiled = isTrue(options._compiled);
+ var needNormalization = !isCompiled;
+
+ this.data = data;
+ this.props = props;
+ this.children = children;
+ this.parent = parent;
+ this.listeners = data.on || emptyObject;
+ this.injections = resolveInject(options.inject, parent);
+ this.slots = function () { return resolveSlots(children, parent); };
+
+ // support for compiled functional template
+ if (isCompiled) {
+ // exposing $options for renderStatic()
+ this.$options = options;
+ // pre-resolve slots for renderSlot()
+ this.$slots = this.slots();
+ this.$scopedSlots = data.scopedSlots || emptyObject;
+ }
+
+ if (options._scopeId) {
+ this._c = function (a, b, c, d) {
+ var vnode = createElement(contextVm, a, b, c, d, needNormalization);
+ if (vnode && !Array.isArray(vnode)) {
+ vnode.fnScopeId = options._scopeId;
+ vnode.fnContext = parent;
+ }
+ return vnode
+ };
+ } else {
+ this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
}
}
- function mergeField (key) {
- var strat = strats[key] || defaultStrat;
- options[key] = strat(parent[key], child[key], vm, key);
- }
- return options
-}
-/**
- * Resolve an asset.
- * This function is used because child instances need access
- * to assets defined in its ancestor chain.
- */
-function resolveAsset (
- options,
- type,
- id,
- warnMissing
-) {
- /* istanbul ignore if */
- if (typeof id !== 'string') {
- return
- }
- var assets = options[type];
- // check local registration variations first
- if (hasOwn(assets, id)) { return assets[id] }
- var camelizedId = camelize(id);
- if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
- var PascalCaseId = capitalize(camelizedId);
- if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
- // fallback to prototype chain
- var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
- if ("development" !== 'production' && warnMissing && !res) {
- warn(
- 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
- options
- );
- }
- return res
-}
-
-/* */
-
-function validateProp (
- key,
- propOptions,
- propsData,
- vm
-) {
- var prop = propOptions[key];
- var absent = !hasOwn(propsData, key);
- var value = propsData[key];
- // boolean casting
- var booleanIndex = getTypeIndex(Boolean, prop.type);
- if (booleanIndex > -1) {
- if (absent && !hasOwn(prop, 'default')) {
- value = false;
- } else if (value === '' || value === hyphenate(key)) {
- // only cast empty string / same name to boolean if
- // boolean has higher priority
- var stringIndex = getTypeIndex(String, prop.type);
- if (stringIndex < 0 || booleanIndex < stringIndex) {
- value = true;
- }
- }
- }
- // check default value
- if (value === undefined) {
- value = getPropDefaultValue(vm, prop, key);
- // since the default value is a fresh copy,
- // make sure to observe it.
- var prevShouldObserve = shouldObserve;
- toggleObserving(true);
- observe(value);
- toggleObserving(prevShouldObserve);
- }
- {
- assertProp(prop, key, value, vm, absent);
- }
- return value
-}
+ installRenderHelpers(FunctionalRenderContext.prototype);
-/**
- * Get the default value of a prop.
- */
-function getPropDefaultValue (vm, prop, key) {
- // no default, return undefined
- if (!hasOwn(prop, 'default')) {
- return undefined
- }
- var def = prop.default;
- // warn against non-factory defaults for Object & Array
- if ("development" !== 'production' && isObject(def)) {
- warn(
- 'Invalid default value for prop "' + key + '": ' +
- 'Props with type Object/Array must use a factory function ' +
- 'to return the default value.',
- vm
- );
- }
- // the raw prop value was also undefined from previous render,
- // return previous default value to avoid unnecessary watcher trigger
- if (vm && vm.$options.propsData &&
- vm.$options.propsData[key] === undefined &&
- vm._props[key] !== undefined
+ function createFunctionalComponent (
+ Ctor,
+ propsData,
+ data,
+ contextVm,
+ children
) {
- return vm._props[key]
- }
- // call factory function for non-Function types
- // a value is Function if its prototype is function even across different execution context
- return typeof def === 'function' && getType(prop.type) !== 'Function'
- ? def.call(vm)
- : def
-}
+ var options = Ctor.options;
+ var props = {};
+ var propOptions = options.props;
+ if (isDef(propOptions)) {
+ for (var key in propOptions) {
+ props[key] = validateProp(key, propOptions, propsData || emptyObject);
+ }
+ } else {
+ if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
+ if (isDef(data.props)) { mergeProps(props, data.props); }
+ }
-/**
- * Assert whether a prop is valid.
- */
-function assertProp (
- prop,
- name,
- value,
- vm,
- absent
-) {
- if (prop.required && absent) {
- warn(
- 'Missing required prop: "' + name + '"',
- vm
+ var renderContext = new FunctionalRenderContext(
+ data,
+ props,
+ children,
+ contextVm,
+ Ctor
);
- return
- }
- if (value == null && !prop.required) {
- return
+
+ var vnode = options.render.call(null, renderContext._c, renderContext);
+
+ if (vnode instanceof VNode) {
+ return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
+ } else if (Array.isArray(vnode)) {
+ var vnodes = normalizeChildren(vnode) || [];
+ var res = new Array(vnodes.length);
+ for (var i = 0; i < vnodes.length; i++) {
+ res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
+ }
+ return res
+ }
}
- var type = prop.type;
- var valid = !type || type === true;
- var expectedTypes = [];
- if (type) {
- if (!Array.isArray(type)) {
- type = [type];
+
+ function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
+ // #7817 clone node before setting fnContext, otherwise if the node is reused
+ // (e.g. it was from a cached normal slot) the fnContext causes named slots
+ // that should not be matched to match.
+ var clone = cloneVNode(vnode);
+ clone.fnContext = contextVm;
+ clone.fnOptions = options;
+ {
+ (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
}
- for (var i = 0; i < type.length && !valid; i++) {
- var assertedType = assertType(value, type[i]);
- expectedTypes.push(assertedType.expectedType || '');
- valid = assertedType.valid;
+ if (data.slot) {
+ (clone.data || (clone.data = {})).slot = data.slot;
}
+ return clone
}
- if (!valid) {
- warn(
- "Invalid prop: type check failed for prop \"" + name + "\"." +
- " Expected " + (expectedTypes.map(capitalize).join(', ')) +
- ", got " + (toRawType(value)) + ".",
- vm
- );
- return
- }
- var validator = prop.validator;
- if (validator) {
- if (!validator(value)) {
- warn(
- 'Invalid prop: custom validator check failed for prop "' + name + '".',
- vm
- );
+
+ function mergeProps (to, from) {
+ for (var key in from) {
+ to[camelize(key)] = from[key];
}
}
-}
-var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
+ /* */
-function assertType (value, type) {
- var valid;
- var expectedType = getType(type);
- if (simpleCheckRE.test(expectedType)) {
- var t = typeof value;
- valid = t === expectedType.toLowerCase();
- // for primitive wrapper objects
- if (!valid && t === 'object') {
- valid = value instanceof type;
- }
- } else if (expectedType === 'Object') {
- valid = isPlainObject(value);
- } else if (expectedType === 'Array') {
- valid = Array.isArray(value);
- } else {
- valid = value instanceof type;
- }
- return {
- valid: valid,
- expectedType: expectedType
- }
-}
+ /* */
-/**
- * Use function string name to check built-in types,
- * because a simple equality check will fail when running
- * across different vms / iframes.
- */
-function getType (fn) {
- var match = fn && fn.toString().match(/^\s*function (\w+)/);
- return match ? match[1] : ''
-}
+ /* */
-function isSameType (a, b) {
- return getType(a) === getType(b)
-}
+ /* */
-function getTypeIndex (type, expectedTypes) {
- if (!Array.isArray(expectedTypes)) {
- return isSameType(expectedTypes, type) ? 0 : -1
- }
- for (var i = 0, len = expectedTypes.length; i < len; i++) {
- if (isSameType(expectedTypes[i], type)) {
- return i
- }
- }
- return -1
-}
+ // inline hooks to be invoked on component VNodes during patch
+ var componentVNodeHooks = {
+ init: function init (vnode, hydrating) {
+ if (
+ vnode.componentInstance &&
+ !vnode.componentInstance._isDestroyed &&
+ vnode.data.keepAlive
+ ) {
+ // kept-alive components, treat as a patch
+ var mountedNode = vnode; // work around flow
+ componentVNodeHooks.prepatch(mountedNode, mountedNode);
+ } else {
+ var child = vnode.componentInstance = createComponentInstanceForVnode(
+ vnode,
+ activeInstance
+ );
+ child.$mount(hydrating ? vnode.elm : undefined, hydrating);
+ }
+ },
-/* */
+ prepatch: function prepatch (oldVnode, vnode) {
+ var options = vnode.componentOptions;
+ var child = vnode.componentInstance = oldVnode.componentInstance;
+ updateChildComponent(
+ child,
+ options.propsData, // updated props
+ options.listeners, // updated listeners
+ vnode, // new parent vnode
+ options.children // new children
+ );
+ },
-function handleError (err, vm, info) {
- if (vm) {
- var cur = vm;
- while ((cur = cur.$parent)) {
- var hooks = cur.$options.errorCaptured;
- if (hooks) {
- for (var i = 0; i < hooks.length; i++) {
- try {
- var capture = hooks[i].call(cur, err, vm, info) === false;
- if (capture) { return }
- } catch (e) {
- globalHandleError(e, cur, 'errorCaptured hook');
- }
+ insert: function insert (vnode) {
+ var context = vnode.context;
+ var componentInstance = vnode.componentInstance;
+ if (!componentInstance._isMounted) {
+ componentInstance._isMounted = true;
+ callHook(componentInstance, 'mounted');
+ }
+ if (vnode.data.keepAlive) {
+ if (context._isMounted) {
+ // vue-router#1212
+ // During updates, a kept-alive component's child components may
+ // change, so directly walking the tree here may call activated hooks
+ // on incorrect children. Instead we push them into a queue which will
+ // be processed after the whole patch process ended.
+ queueActivatedComponent(componentInstance);
+ } else {
+ activateChildComponent(componentInstance, true /* direct */);
+ }
+ }
+ },
+
+ destroy: function destroy (vnode) {
+ var componentInstance = vnode.componentInstance;
+ if (!componentInstance._isDestroyed) {
+ if (!vnode.data.keepAlive) {
+ componentInstance.$destroy();
+ } else {
+ deactivateChildComponent(componentInstance, true /* direct */);
}
}
}
- }
- globalHandleError(err, vm, info);
-}
+ };
-function globalHandleError (err, vm, info) {
- if (config.errorHandler) {
- try {
- return config.errorHandler.call(null, err, vm, info)
- } catch (e) {
- logError(e, null, 'config.errorHandler');
+ var hooksToMerge = Object.keys(componentVNodeHooks);
+
+ function createComponent (
+ Ctor,
+ data,
+ context,
+ children,
+ tag
+ ) {
+ if (isUndef(Ctor)) {
+ return
}
- }
- logError(err, vm, info);
-}
-function logError (err, vm, info) {
- {
- warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
- }
- /* istanbul ignore else */
- if ((inBrowser || inWeex) && typeof console !== 'undefined') {
- console.error(err);
- } else {
- throw err
- }
-}
-
-/* */
-/* globals MessageChannel */
-
-var callbacks = [];
-var pending = false;
-
-function flushCallbacks () {
- pending = false;
- var copies = callbacks.slice(0);
- callbacks.length = 0;
- for (var i = 0; i < copies.length; i++) {
- copies[i]();
- }
-}
-
-// Here we have async deferring wrappers using both microtasks and (macro) tasks.
-// In < 2.4 we used microtasks everywhere, but there are some scenarios where
-// microtasks have too high a priority and fire in between supposedly
-// sequential events (e.g. #4521, #6690) or even between bubbling of the same
-// event (#6566). However, using (macro) tasks everywhere also has subtle problems
-// when state is changed right before repaint (e.g. #6813, out-in transitions).
-// Here we use microtask by default, but expose a way to force (macro) task when
-// needed (e.g. in event handlers attached by v-on).
-var microTimerFunc;
-var macroTimerFunc;
-var useMacroTask = false;
-
-// Determine (macro) task defer implementation.
-// Technically setImmediate should be the ideal choice, but it's only available
-// in IE. The only polyfill that consistently queues the callback after all DOM
-// events triggered in the same loop is by using MessageChannel.
-/* istanbul ignore if */
-if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
- macroTimerFunc = function () {
- setImmediate(flushCallbacks);
- };
-} else if (typeof MessageChannel !== 'undefined' && (
- isNative(MessageChannel) ||
- // PhantomJS
- MessageChannel.toString() === '[object MessageChannelConstructor]'
-)) {
- var channel = new MessageChannel();
- var port = channel.port2;
- channel.port1.onmessage = flushCallbacks;
- macroTimerFunc = function () {
- port.postMessage(1);
- };
-} else {
- /* istanbul ignore next */
- macroTimerFunc = function () {
- setTimeout(flushCallbacks, 0);
- };
-}
-
-// Determine microtask defer implementation.
-/* istanbul ignore next, $flow-disable-line */
-if (typeof Promise !== 'undefined' && isNative(Promise)) {
- var p = Promise.resolve();
- microTimerFunc = function () {
- p.then(flushCallbacks);
- // in problematic UIWebViews, Promise.then doesn't completely break, but
- // it can get stuck in a weird state where callbacks are pushed into the
- // microtask queue but the queue isn't being flushed, until the browser
- // needs to do some other work, e.g. handle a timer. Therefore we can
- // "force" the microtask queue to be flushed by adding an empty timer.
- if (isIOS) { setTimeout(noop); }
- };
-} else {
- // fallback to macro
- microTimerFunc = macroTimerFunc;
-}
-
-/**
- * Wrap a function so that if any code inside triggers state change,
- * the changes are queued using a (macro) task instead of a microtask.
- */
-function withMacroTask (fn) {
- return fn._withTask || (fn._withTask = function () {
- useMacroTask = true;
- var res = fn.apply(null, arguments);
- useMacroTask = false;
- return res
- })
-}
+ var baseCtor = context.$options._base;
-function nextTick (cb, ctx) {
- var _resolve;
- callbacks.push(function () {
- if (cb) {
- try {
- cb.call(ctx);
- } catch (e) {
- handleError(e, ctx, 'nextTick');
- }
- } else if (_resolve) {
- _resolve(ctx);
+ // plain options object: turn it into a constructor
+ if (isObject(Ctor)) {
+ Ctor = baseCtor.extend(Ctor);
}
- });
- if (!pending) {
- pending = true;
- if (useMacroTask) {
- macroTimerFunc();
- } else {
- microTimerFunc();
+
+ // if at this stage it's not a constructor or an async component factory,
+ // reject.
+ if (typeof Ctor !== 'function') {
+ {
+ warn(("Invalid Component definition: " + (String(Ctor))), context);
+ }
+ return
}
- }
- // $flow-disable-line
- if (!cb && typeof Promise !== 'undefined') {
- return new Promise(function (resolve) {
- _resolve = resolve;
- })
- }
-}
-/* */
+ // async component
+ var asyncFactory;
+ if (isUndef(Ctor.cid)) {
+ asyncFactory = Ctor;
+ Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
+ if (Ctor === undefined) {
+ // return a placeholder node for async component, which is rendered
+ // as a comment node but preserves all the raw information for the node.
+ // the information will be used for async server-rendering and hydration.
+ return createAsyncPlaceholder(
+ asyncFactory,
+ data,
+ context,
+ children,
+ tag
+ )
+ }
+ }
-var mark;
-var measure;
+ data = data || {};
-{
- var perf = inBrowser && window.performance;
- /* istanbul ignore if */
- if (
- perf &&
- perf.mark &&
- perf.measure &&
- perf.clearMarks &&
- perf.clearMeasures
- ) {
- mark = function (tag) { return perf.mark(tag); };
- measure = function (name, startTag, endTag) {
- perf.measure(name, startTag, endTag);
- perf.clearMarks(startTag);
- perf.clearMarks(endTag);
- perf.clearMeasures(name);
- };
- }
-}
+ // resolve constructor options in case global mixins are applied after
+ // component constructor creation
+ resolveConstructorOptions(Ctor);
-/* not type checking this file because flow doesn't play well with Proxy */
+ // transform component v-model data into props & events
+ if (isDef(data.model)) {
+ transformModel(Ctor.options, data);
+ }
-var initProxy;
+ // extract props
+ var propsData = extractPropsFromVNodeData(data, Ctor, tag);
-{
- var allowedGlobals = makeMap(
- 'Infinity,undefined,NaN,isFinite,isNaN,' +
- 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
- 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
- 'require' // for Webpack/Browserify
- );
+ // functional component
+ if (isTrue(Ctor.options.functional)) {
+ return createFunctionalComponent(Ctor, propsData, data, context, children)
+ }
- var warnNonPresent = function (target, key) {
- warn(
- "Property or method \"" + key + "\" is not defined on the instance but " +
- 'referenced during render. Make sure that this property is reactive, ' +
- 'either in the data option, or for class-based components, by ' +
- 'initializing the property. ' +
- 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
- target
- );
- };
+ // extract listeners, since these needs to be treated as
+ // child component listeners instead of DOM listeners
+ var listeners = data.on;
+ // replace with listeners with .native modifier
+ // so it gets processed during parent component patch.
+ data.on = data.nativeOn;
- var hasProxy =
- typeof Proxy !== 'undefined' && isNative(Proxy);
+ if (isTrue(Ctor.options.abstract)) {
+ // abstract components do not keep anything
+ // other than props & listeners & slot
- if (hasProxy) {
- var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
- config.keyCodes = new Proxy(config.keyCodes, {
- set: function set (target, key, value) {
- if (isBuiltInModifier(key)) {
- warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
- return false
- } else {
- target[key] = value;
- return true
- }
+ // work around flow
+ var slot = data.slot;
+ data = {};
+ if (slot) {
+ data.slot = slot;
}
- });
+ }
+
+ // install component management hooks onto the placeholder node
+ installComponentHooks(data);
+
+ // return a placeholder vnode
+ var name = Ctor.options.name || tag;
+ var vnode = new VNode(
+ ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
+ data, undefined, undefined, undefined, context,
+ { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
+ asyncFactory
+ );
+
+ return vnode
}
- var hasHandler = {
- has: function has (target, key) {
- var has = key in target;
- var isAllowed = allowedGlobals(key) || (typeof key === 'string' && key.charAt(0) === '_');
- if (!has && !isAllowed) {
- warnNonPresent(target, key);
- }
- return has || !isAllowed
+ function createComponentInstanceForVnode (
+ vnode, // we know it's MountedComponentVNode but flow doesn't
+ parent // activeInstance in lifecycle state
+ ) {
+ var options = {
+ _isComponent: true,
+ _parentVnode: vnode,
+ parent: parent
+ };
+ // check inline-template render functions
+ var inlineTemplate = vnode.data.inlineTemplate;
+ if (isDef(inlineTemplate)) {
+ options.render = inlineTemplate.render;
+ options.staticRenderFns = inlineTemplate.staticRenderFns;
}
- };
+ return new vnode.componentOptions.Ctor(options)
+ }
- var getHandler = {
- get: function get (target, key) {
- if (typeof key === 'string' && !(key in target)) {
- warnNonPresent(target, key);
+ function installComponentHooks (data) {
+ var hooks = data.hook || (data.hook = {});
+ for (var i = 0; i < hooksToMerge.length; i++) {
+ var key = hooksToMerge[i];
+ var existing = hooks[key];
+ var toMerge = componentVNodeHooks[key];
+ if (existing !== toMerge && !(existing && existing._merged)) {
+ hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
}
- return target[key]
}
- };
+ }
- initProxy = function initProxy (vm) {
- if (hasProxy) {
- // determine which proxy handler to use
- var options = vm.$options;
- var handlers = options.render && options.render._withStripped
- ? getHandler
- : hasHandler;
- vm._renderProxy = new Proxy(vm, handlers);
+ function mergeHook$1 (f1, f2) {
+ var merged = function (a, b) {
+ // flow complains about extra args which is why we use any
+ f1(a, b);
+ f2(a, b);
+ };
+ merged._merged = true;
+ return merged
+ }
+
+ // transform component v-model info (value and callback) into
+ // prop and event handler respectively.
+ function transformModel (options, data) {
+ var prop = (options.model && options.model.prop) || 'value';
+ var event = (options.model && options.model.event) || 'input'
+ ;(data.props || (data.props = {}))[prop] = data.model.value;
+ var on = data.on || (data.on = {});
+ var existing = on[event];
+ var callback = data.model.callback;
+ if (isDef(existing)) {
+ if (
+ Array.isArray(existing)
+ ? existing.indexOf(callback) === -1
+ : existing !== callback
+ ) {
+ on[event] = [callback].concat(existing);
+ }
} else {
- vm._renderProxy = vm;
+ on[event] = callback;
}
- };
-}
+ }
-/* */
+ /* */
-var seenObjects = new _Set();
+ var SIMPLE_NORMALIZE = 1;
+ var ALWAYS_NORMALIZE = 2;
-/**
- * Recursively traverse an object to evoke all converted
- * getters, so that every nested property inside the object
- * is collected as a "deep" dependency.
- */
-function traverse (val) {
- _traverse(val, seenObjects);
- seenObjects.clear();
-}
-
-function _traverse (val, seen) {
- var i, keys;
- var isA = Array.isArray(val);
- if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
- return
- }
- if (val.__ob__) {
- var depId = val.__ob__.dep.id;
- if (seen.has(depId)) {
- return
+ // wrapper function for providing a more flexible interface
+ // without getting yelled at by flow
+ function createElement (
+ context,
+ tag,
+ data,
+ children,
+ normalizationType,
+ alwaysNormalize
+ ) {
+ if (Array.isArray(data) || isPrimitive(data)) {
+ normalizationType = children;
+ children = data;
+ data = undefined;
+ }
+ if (isTrue(alwaysNormalize)) {
+ normalizationType = ALWAYS_NORMALIZE;
}
- seen.add(depId);
+ return _createElement(context, tag, data, children, normalizationType)
}
- if (isA) {
- i = val.length;
- while (i--) { _traverse(val[i], seen); }
- } else {
- keys = Object.keys(val);
- i = keys.length;
- while (i--) { _traverse(val[keys[i]], seen); }
- }
-}
-
-/* */
-
-var normalizeEvent = cached(function (name) {
- var passive = name.charAt(0) === '&';
- name = passive ? name.slice(1) : name;
- var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
- name = once$$1 ? name.slice(1) : name;
- var capture = name.charAt(0) === '!';
- name = capture ? name.slice(1) : name;
- return {
- name: name,
- once: once$$1,
- capture: capture,
- passive: passive
- }
-});
-
-function createFnInvoker (fns) {
- function invoker () {
- var arguments$1 = arguments;
-
- var fns = invoker.fns;
- if (Array.isArray(fns)) {
- var cloned = fns.slice();
- for (var i = 0; i < cloned.length; i++) {
- cloned[i].apply(null, arguments$1);
+
+ function _createElement (
+ context,
+ tag,
+ data,
+ children,
+ normalizationType
+ ) {
+ if (isDef(data) && isDef((data).__ob__)) {
+ warn(
+ "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
+ 'Always create fresh vnode data objects in each render!',
+ context
+ );
+ return createEmptyVNode()
+ }
+ // object syntax in v-bind
+ if (isDef(data) && isDef(data.is)) {
+ tag = data.is;
+ }
+ if (!tag) {
+ // in case of component :is set to falsy value
+ return createEmptyVNode()
+ }
+ // warn against non-primitive key
+ if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
+ ) {
+ {
+ warn(
+ 'Avoid using non-primitive value as key, ' +
+ 'use string/number value instead.',
+ context
+ );
+ }
+ }
+ // support single function children as default scoped slot
+ if (Array.isArray(children) &&
+ typeof children[0] === 'function'
+ ) {
+ data = data || {};
+ data.scopedSlots = { default: children[0] };
+ children.length = 0;
+ }
+ if (normalizationType === ALWAYS_NORMALIZE) {
+ children = normalizeChildren(children);
+ } else if (normalizationType === SIMPLE_NORMALIZE) {
+ children = simpleNormalizeChildren(children);
+ }
+ var vnode, ns;
+ if (typeof tag === 'string') {
+ var Ctor;
+ ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
+ if (config.isReservedTag(tag)) {
+ // platform built-in elements
+ vnode = new VNode(
+ config.parsePlatformTagName(tag), data, children,
+ undefined, undefined, context
+ );
+ } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
+ // component
+ vnode = createComponent(Ctor, data, context, children, tag);
+ } else {
+ // unknown or unlisted namespaced elements
+ // check at runtime because it may get assigned a namespace when its
+ // parent normalizes children
+ vnode = new VNode(
+ tag, data, children,
+ undefined, undefined, context
+ );
}
} else {
- // return handler return value for single handlers
- return fns.apply(null, arguments)
- }
- }
- invoker.fns = fns;
- return invoker
-}
-
-function updateListeners (
- on,
- oldOn,
- add,
- remove$$1,
- vm
-) {
- var name, def, cur, old, event;
- for (name in on) {
- def = cur = on[name];
- old = oldOn[name];
- event = normalizeEvent(name);
- /* istanbul ignore if */
- if (isUndef(cur)) {
- "development" !== 'production' && warn(
- "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
- vm
- );
- } else if (isUndef(old)) {
- if (isUndef(cur.fns)) {
- cur = on[name] = createFnInvoker(cur);
+ // direct component options / constructor
+ vnode = createComponent(tag, data, context, children);
+ }
+ if (Array.isArray(vnode)) {
+ return vnode
+ } else if (isDef(vnode)) {
+ if (isDef(ns)) { applyNS(vnode, ns); }
+ if (isDef(data)) { registerDeepBindings(data); }
+ return vnode
+ } else {
+ return createEmptyVNode()
+ }
+ }
+
+ function applyNS (vnode, ns, force) {
+ vnode.ns = ns;
+ if (vnode.tag === 'foreignObject') {
+ // use default namespace inside foreignObject
+ ns = undefined;
+ force = true;
+ }
+ if (isDef(vnode.children)) {
+ for (var i = 0, l = vnode.children.length; i < l; i++) {
+ var child = vnode.children[i];
+ if (isDef(child.tag) && (
+ isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
+ applyNS(child, ns, force);
+ }
}
- add(event.name, cur, event.once, event.capture, event.passive, event.params);
- } else if (cur !== old) {
- old.fns = cur;
- on[name] = old;
}
}
- for (name in oldOn) {
- if (isUndef(on[name])) {
- event = normalizeEvent(name);
- remove$$1(event.name, oldOn[name], event.capture);
+
+ // ref #5318
+ // necessary to ensure parent re-render when deep bindings like :style and
+ // :class are used on slot nodes
+ function registerDeepBindings (data) {
+ if (isObject(data.style)) {
+ traverse(data.style);
+ }
+ if (isObject(data.class)) {
+ traverse(data.class);
}
}
-}
-/* */
+ /* */
-function mergeVNodeHook (def, hookKey, hook) {
- if (def instanceof VNode) {
- def = def.data.hook || (def.data.hook = {});
- }
- var invoker;
- var oldHook = def[hookKey];
+ function initRender (vm) {
+ vm._vnode = null; // the root of the child tree
+ vm._staticTrees = null; // v-once cached trees
+ var options = vm.$options;
+ var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
+ var renderContext = parentVnode && parentVnode.context;
+ vm.$slots = resolveSlots(options._renderChildren, renderContext);
+ vm.$scopedSlots = emptyObject;
+ // bind the createElement fn to this instance
+ // so that we get proper render context inside it.
+ // args order: tag, data, children, normalizationType, alwaysNormalize
+ // internal version is used by render functions compiled from templates
+ vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
+ // normalization is always applied for the public version, used in
+ // user-written render functions.
+ vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
- function wrappedHook () {
- hook.apply(this, arguments);
- // important: remove merged hook to ensure it's called only once
- // and prevent memory leak
- remove(invoker.fns, wrappedHook);
- }
+ // $attrs & $listeners are exposed for easier HOC creation.
+ // they need to be reactive so that HOCs using them are always updated
+ var parentData = parentVnode && parentVnode.data;
- if (isUndef(oldHook)) {
- // no existing hook
- invoker = createFnInvoker([wrappedHook]);
- } else {
- /* istanbul ignore if */
- if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
- // already a merged invoker
- invoker = oldHook;
- invoker.fns.push(wrappedHook);
- } else {
- // existing plain hook
- invoker = createFnInvoker([oldHook, wrappedHook]);
- }
- }
-
- invoker.merged = true;
- def[hookKey] = invoker;
-}
-
-/* */
-
-function extractPropsFromVNodeData (
- data,
- Ctor,
- tag
-) {
- // we are only extracting raw values here.
- // validation and default values are handled in the child
- // component itself.
- var propOptions = Ctor.options.props;
- if (isUndef(propOptions)) {
- return
- }
- var res = {};
- var attrs = data.attrs;
- var props = data.props;
- if (isDef(attrs) || isDef(props)) {
- for (var key in propOptions) {
- var altKey = hyphenate(key);
- {
- var keyInLowerCase = key.toLowerCase();
- if (
- key !== keyInLowerCase &&
- attrs && hasOwn(attrs, keyInLowerCase)
- ) {
- tip(
- "Prop \"" + keyInLowerCase + "\" is passed to component " +
- (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
- " \"" + key + "\". " +
- "Note that HTML attributes are case-insensitive and camelCased " +
- "props need to use their kebab-case equivalents when using in-DOM " +
- "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
- );
- }
- }
- checkProp(res, props, key, altKey, true) ||
- checkProp(res, attrs, key, altKey, false);
+ /* istanbul ignore else */
+ {
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
+ !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
+ }, true);
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
+ !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
+ }, true);
}
}
- return res
-}
-function checkProp (
- res,
- hash,
- key,
- altKey,
- preserve
-) {
- if (isDef(hash)) {
- if (hasOwn(hash, key)) {
- res[key] = hash[key];
- if (!preserve) {
- delete hash[key];
- }
- return true
- } else if (hasOwn(hash, altKey)) {
- res[key] = hash[altKey];
- if (!preserve) {
- delete hash[altKey];
+ function renderMixin (Vue) {
+ // install runtime convenience helpers
+ installRenderHelpers(Vue.prototype);
+
+ Vue.prototype.$nextTick = function (fn) {
+ return nextTick(fn, this)
+ };
+
+ Vue.prototype._render = function () {
+ var vm = this;
+ var ref = vm.$options;
+ var render = ref.render;
+ var _parentVnode = ref._parentVnode;
+
+ if (_parentVnode) {
+ vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject;
}
- return true
- }
- }
- return false
-}
-
-/* */
-
-// The template compiler attempts to minimize the need for normalization by
-// statically analyzing the template at compile time.
-//
-// For plain HTML markup, normalization can be completely skipped because the
-// generated render function is guaranteed to return Array. There are
-// two cases where extra normalization is needed:
-
-// 1. When the children contains components - because a functional component
-// may return an Array instead of a single root. In this case, just a simple
-// normalization is needed - if any child is an Array, we flatten the whole
-// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
-// because functional components already normalize their own children.
-function simpleNormalizeChildren (children) {
- for (var i = 0; i < children.length; i++) {
- if (Array.isArray(children[i])) {
- return Array.prototype.concat.apply([], children)
- }
- }
- return children
-}
-
-// 2. When the children contains constructs that always generated nested Arrays,
-// e.g. , , v-for, or when the children is provided by user
-// with hand-written render functions / JSX. In such cases a full normalization
-// is needed to cater to all possible types of children values.
-function normalizeChildren (children) {
- return isPrimitive(children)
- ? [createTextVNode(children)]
- : Array.isArray(children)
- ? normalizeArrayChildren(children)
- : undefined
-}
-
-function isTextNode (node) {
- return isDef(node) && isDef(node.text) && isFalse(node.isComment)
-}
-
-function normalizeArrayChildren (children, nestedIndex) {
- var res = [];
- var i, c, lastIndex, last;
- for (i = 0; i < children.length; i++) {
- c = children[i];
- if (isUndef(c) || typeof c === 'boolean') { continue }
- lastIndex = res.length - 1;
- last = res[lastIndex];
- // nested
- if (Array.isArray(c)) {
- if (c.length > 0) {
- c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
- // merge adjacent text nodes
- if (isTextNode(c[0]) && isTextNode(last)) {
- res[lastIndex] = createTextVNode(last.text + (c[0]).text);
- c.shift();
- }
- res.push.apply(res, c);
- }
- } else if (isPrimitive(c)) {
- if (isTextNode(last)) {
- // merge adjacent text nodes
- // this is necessary for SSR hydration because text nodes are
- // essentially merged when rendered to HTML strings
- res[lastIndex] = createTextVNode(last.text + c);
- } else if (c !== '') {
- // convert primitive to vnode
- res.push(createTextVNode(c));
+
+ // set parent vnode. this allows render functions to have access
+ // to the data on the placeholder node.
+ vm.$vnode = _parentVnode;
+ // render self
+ var vnode;
+ try {
+ vnode = render.call(vm._renderProxy, vm.$createElement);
+ } catch (e) {
+ handleError(e, vm, "render");
+ // return error render result,
+ // or previous vnode to prevent render error causing blank component
+ /* istanbul ignore else */
+ if (vm.$options.renderError) {
+ try {
+ vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
+ } catch (e) {
+ handleError(e, vm, "renderError");
+ vnode = vm._vnode;
+ }
+ } else {
+ vnode = vm._vnode;
+ }
}
- } else {
- if (isTextNode(c) && isTextNode(last)) {
- // merge adjacent text nodes
- res[lastIndex] = createTextVNode(last.text + c.text);
- } else {
- // default key for nested array children (likely generated by v-for)
- if (isTrue(children._isVList) &&
- isDef(c.tag) &&
- isUndef(c.key) &&
- isDef(nestedIndex)) {
- c.key = "__vlist" + nestedIndex + "_" + i + "__";
+ // return empty vnode in case the render function errored out
+ if (!(vnode instanceof VNode)) {
+ if (Array.isArray(vnode)) {
+ warn(
+ 'Multiple root nodes returned from render function. Render function ' +
+ 'should return a single root node.',
+ vm
+ );
}
- res.push(c);
+ vnode = createEmptyVNode();
}
- }
+ // set parent
+ vnode.parent = _parentVnode;
+ return vnode
+ };
}
- return res
-}
-/* */
+ /* */
-function ensureCtor (comp, base) {
- if (
- comp.__esModule ||
- (hasSymbol && comp[Symbol.toStringTag] === 'Module')
- ) {
- comp = comp.default;
- }
- return isObject(comp)
- ? base.extend(comp)
- : comp
-}
-
-function createAsyncPlaceholder (
- factory,
- data,
- context,
- children,
- tag
-) {
- var node = createEmptyVNode();
- node.asyncFactory = factory;
- node.asyncMeta = { data: data, context: context, children: children, tag: tag };
- return node
-}
-
-function resolveAsyncComponent (
- factory,
- baseCtor,
- context
-) {
- if (isTrue(factory.error) && isDef(factory.errorComp)) {
- return factory.errorComp
- }
-
- if (isDef(factory.resolved)) {
- return factory.resolved
- }
-
- if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
- return factory.loadingComp
- }
-
- if (isDef(factory.contexts)) {
- // already pending
- factory.contexts.push(context);
- } else {
- var contexts = factory.contexts = [context];
- var sync = true;
+ var uid$3 = 0;
+
+ function initMixin (Vue) {
+ Vue.prototype._init = function (options) {
+ var vm = this;
+ // a uid
+ vm._uid = uid$3++;
- var forceRender = function () {
- for (var i = 0, l = contexts.length; i < l; i++) {
- contexts[i].$forceUpdate();
+ var startTag, endTag;
+ /* istanbul ignore if */
+ if (config.performance && mark) {
+ startTag = "vue-perf-start:" + (vm._uid);
+ endTag = "vue-perf-end:" + (vm._uid);
+ mark(startTag);
+ }
+
+ // a flag to avoid this being observed
+ vm._isVue = true;
+ // merge options
+ if (options && options._isComponent) {
+ // optimize internal component instantiation
+ // since dynamic options merging is pretty slow, and none of the
+ // internal component options needs special treatment.
+ initInternalComponent(vm, options);
+ } else {
+ vm.$options = mergeOptions(
+ resolveConstructorOptions(vm.constructor),
+ options || {},
+ vm
+ );
}
- };
+ /* istanbul ignore else */
+ {
+ initProxy(vm);
+ }
+ // expose real self
+ vm._self = vm;
+ initLifecycle(vm);
+ initEvents(vm);
+ initRender(vm);
+ callHook(vm, 'beforeCreate');
+ initInjections(vm); // resolve injections before data/props
+ initState(vm);
+ initProvide(vm); // resolve provide after data/props
+ callHook(vm, 'created');
- var resolve = once(function (res) {
- // cache resolved
- factory.resolved = ensureCtor(res, baseCtor);
- // invoke callbacks only if this is not a synchronous resolve
- // (async resolves are shimmed as synchronous during SSR)
- if (!sync) {
- forceRender();
+ /* istanbul ignore if */
+ if (config.performance && mark) {
+ vm._name = formatComponentName(vm, false);
+ mark(endTag);
+ measure(("vue " + (vm._name) + " init"), startTag, endTag);
}
- });
- var reject = once(function (reason) {
- "development" !== 'production' && warn(
- "Failed to resolve async component: " + (String(factory)) +
- (reason ? ("\nReason: " + reason) : '')
- );
- if (isDef(factory.errorComp)) {
- factory.error = true;
- forceRender();
+ if (vm.$options.el) {
+ vm.$mount(vm.$options.el);
}
- });
-
- var res = factory(resolve, reject);
+ };
+ }
- if (isObject(res)) {
- if (typeof res.then === 'function') {
- // () => Promise
- if (isUndef(factory.resolved)) {
- res.then(resolve, reject);
+ function initInternalComponent (vm, options) {
+ var opts = vm.$options = Object.create(vm.constructor.options);
+ // doing this because it's faster than dynamic enumeration.
+ var parentVnode = options._parentVnode;
+ opts.parent = options.parent;
+ opts._parentVnode = parentVnode;
+
+ var vnodeComponentOptions = parentVnode.componentOptions;
+ opts.propsData = vnodeComponentOptions.propsData;
+ opts._parentListeners = vnodeComponentOptions.listeners;
+ opts._renderChildren = vnodeComponentOptions.children;
+ opts._componentTag = vnodeComponentOptions.tag;
+
+ if (options.render) {
+ opts.render = options.render;
+ opts.staticRenderFns = options.staticRenderFns;
+ }
+ }
+
+ function resolveConstructorOptions (Ctor) {
+ var options = Ctor.options;
+ if (Ctor.super) {
+ var superOptions = resolveConstructorOptions(Ctor.super);
+ var cachedSuperOptions = Ctor.superOptions;
+ if (superOptions !== cachedSuperOptions) {
+ // super option changed,
+ // need to resolve new options.
+ Ctor.superOptions = superOptions;
+ // check if there are any late-modified/attached options (#4976)
+ var modifiedOptions = resolveModifiedOptions(Ctor);
+ // update base extend options
+ if (modifiedOptions) {
+ extend(Ctor.extendOptions, modifiedOptions);
}
- } else if (isDef(res.component) && typeof res.component.then === 'function') {
- res.component.then(resolve, reject);
-
- if (isDef(res.error)) {
- factory.errorComp = ensureCtor(res.error, baseCtor);
+ options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
+ if (options.name) {
+ options.components[options.name] = Ctor;
}
+ }
+ }
+ return options
+ }
- if (isDef(res.loading)) {
- factory.loadingComp = ensureCtor(res.loading, baseCtor);
- if (res.delay === 0) {
- factory.loading = true;
- } else {
- setTimeout(function () {
- if (isUndef(factory.resolved) && isUndef(factory.error)) {
- factory.loading = true;
- forceRender();
- }
- }, res.delay || 200);
- }
- }
+ function resolveModifiedOptions (Ctor) {
+ var modified;
+ var latest = Ctor.options;
+ var extended = Ctor.extendOptions;
+ var sealed = Ctor.sealedOptions;
+ for (var key in latest) {
+ if (latest[key] !== sealed[key]) {
+ if (!modified) { modified = {}; }
+ modified[key] = dedupe(latest[key], extended[key], sealed[key]);
+ }
+ }
+ return modified
+ }
- if (isDef(res.timeout)) {
- setTimeout(function () {
- if (isUndef(factory.resolved)) {
- reject(
- "timeout (" + (res.timeout) + "ms)"
- );
- }
- }, res.timeout);
+ function dedupe (latest, extended, sealed) {
+ // compare latest and sealed to ensure lifecycle hooks won't be duplicated
+ // between merges
+ if (Array.isArray(latest)) {
+ var res = [];
+ sealed = Array.isArray(sealed) ? sealed : [sealed];
+ extended = Array.isArray(extended) ? extended : [extended];
+ for (var i = 0; i < latest.length; i++) {
+ // push original options and not sealed options to exclude duplicated options
+ if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
+ res.push(latest[i]);
}
}
+ return res
+ } else {
+ return latest
}
+ }
- sync = false;
- // return in case resolved synchronously
- return factory.loading
- ? factory.loadingComp
- : factory.resolved
+ function Vue (options) {
+ if (!(this instanceof Vue)
+ ) {
+ warn('Vue is a constructor and should be called with the `new` keyword');
+ }
+ this._init(options);
}
-}
-/* */
+ initMixin(Vue);
+ stateMixin(Vue);
+ eventsMixin(Vue);
+ lifecycleMixin(Vue);
+ renderMixin(Vue);
-function isAsyncPlaceholder (node) {
- return node.isComment && node.asyncFactory
-}
+ /* */
-/* */
+ function initUse (Vue) {
+ Vue.use = function (plugin) {
+ var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
+ if (installedPlugins.indexOf(plugin) > -1) {
+ return this
+ }
-function getFirstComponentChild (children) {
- if (Array.isArray(children)) {
- for (var i = 0; i < children.length; i++) {
- var c = children[i];
- if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
- return c
+ // additional parameters
+ var args = toArray(arguments, 1);
+ args.unshift(this);
+ if (typeof plugin.install === 'function') {
+ plugin.install.apply(plugin, args);
+ } else if (typeof plugin === 'function') {
+ plugin.apply(null, args);
}
- }
+ installedPlugins.push(plugin);
+ return this
+ };
}
-}
-
-/* */
-/* */
+ /* */
-function initEvents (vm) {
- vm._events = Object.create(null);
- vm._hasHookEvent = false;
- // init parent attached events
- var listeners = vm.$options._parentListeners;
- if (listeners) {
- updateComponentListeners(vm, listeners);
+ function initMixin$1 (Vue) {
+ Vue.mixin = function (mixin) {
+ this.options = mergeOptions(this.options, mixin);
+ return this
+ };
}
-}
-var target;
+ /* */
-function add (event, fn, once) {
- if (once) {
- target.$once(event, fn);
- } else {
- target.$on(event, fn);
- }
-}
+ function initExtend (Vue) {
+ /**
+ * Each instance constructor, including Vue, has a unique
+ * cid. This enables us to create wrapped "child
+ * constructors" for prototypal inheritance and cache them.
+ */
+ Vue.cid = 0;
+ var cid = 1;
-function remove$1 (event, fn) {
- target.$off(event, fn);
-}
+ /**
+ * Class inheritance
+ */
+ Vue.extend = function (extendOptions) {
+ extendOptions = extendOptions || {};
+ var Super = this;
+ var SuperId = Super.cid;
+ var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
+ if (cachedCtors[SuperId]) {
+ return cachedCtors[SuperId]
+ }
-function updateComponentListeners (
- vm,
- listeners,
- oldListeners
-) {
- target = vm;
- updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
- target = undefined;
-}
+ var name = extendOptions.name || Super.options.name;
+ if (name) {
+ validateComponentName(name);
+ }
-function eventsMixin (Vue) {
- var hookRE = /^hook:/;
- Vue.prototype.$on = function (event, fn) {
- var this$1 = this;
+ var Sub = function VueComponent (options) {
+ this._init(options);
+ };
+ Sub.prototype = Object.create(Super.prototype);
+ Sub.prototype.constructor = Sub;
+ Sub.cid = cid++;
+ Sub.options = mergeOptions(
+ Super.options,
+ extendOptions
+ );
+ Sub['super'] = Super;
- var vm = this;
- if (Array.isArray(event)) {
- for (var i = 0, l = event.length; i < l; i++) {
- this$1.$on(event[i], fn);
+ // For props and computed properties, we define the proxy getters on
+ // the Vue instances at extension time, on the extended prototype. This
+ // avoids Object.defineProperty calls for each instance created.
+ if (Sub.options.props) {
+ initProps$1(Sub);
}
- } else {
- (vm._events[event] || (vm._events[event] = [])).push(fn);
- // optimize hook:event cost by using a boolean flag marked at registration
- // instead of a hash lookup
- if (hookRE.test(event)) {
- vm._hasHookEvent = true;
+ if (Sub.options.computed) {
+ initComputed$1(Sub);
}
- }
- return vm
- };
-
- Vue.prototype.$once = function (event, fn) {
- var vm = this;
- function on () {
- vm.$off(event, on);
- fn.apply(vm, arguments);
- }
- on.fn = fn;
- vm.$on(event, on);
- return vm
- };
- Vue.prototype.$off = function (event, fn) {
- var this$1 = this;
+ // allow further extension/mixin/plugin usage
+ Sub.extend = Super.extend;
+ Sub.mixin = Super.mixin;
+ Sub.use = Super.use;
- var vm = this;
- // all
- if (!arguments.length) {
- vm._events = Object.create(null);
- return vm
- }
- // array of events
- if (Array.isArray(event)) {
- for (var i = 0, l = event.length; i < l; i++) {
- this$1.$off(event[i], fn);
- }
- return vm
- }
- // specific event
- var cbs = vm._events[event];
- if (!cbs) {
- return vm
- }
- if (!fn) {
- vm._events[event] = null;
- return vm
- }
- if (fn) {
- // specific handler
- var cb;
- var i$1 = cbs.length;
- while (i$1--) {
- cb = cbs[i$1];
- if (cb === fn || cb.fn === fn) {
- cbs.splice(i$1, 1);
- break
- }
+ // create asset registers, so extended classes
+ // can have their private assets too.
+ ASSET_TYPES.forEach(function (type) {
+ Sub[type] = Super[type];
+ });
+ // enable recursive self-lookup
+ if (name) {
+ Sub.options.components[name] = Sub;
}
+
+ // keep a reference to the super options at extension time.
+ // later at instantiation we can check if Super's options have
+ // been updated.
+ Sub.superOptions = Super.options;
+ Sub.extendOptions = extendOptions;
+ Sub.sealedOptions = extend({}, Sub.options);
+
+ // cache constructor
+ cachedCtors[SuperId] = Sub;
+ return Sub
+ };
+ }
+
+ function initProps$1 (Comp) {
+ var props = Comp.options.props;
+ for (var key in props) {
+ proxy(Comp.prototype, "_props", key);
}
- return vm
- };
+ }
- Vue.prototype.$emit = function (event) {
- var vm = this;
- {
- var lowerCaseEvent = event.toLowerCase();
- if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
- tip(
- "Event \"" + lowerCaseEvent + "\" is emitted in component " +
- (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
- "Note that HTML attributes are case-insensitive and you cannot use " +
- "v-on to listen to camelCase events when using in-DOM templates. " +
- "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
- );
- }
+ function initComputed$1 (Comp) {
+ var computed = Comp.options.computed;
+ for (var key in computed) {
+ defineComputed(Comp.prototype, key, computed[key]);
}
- var cbs = vm._events[event];
- if (cbs) {
- cbs = cbs.length > 1 ? toArray(cbs) : cbs;
- var args = toArray(arguments, 1);
- for (var i = 0, l = cbs.length; i < l; i++) {
- try {
- cbs[i].apply(vm, args);
- } catch (e) {
- handleError(e, vm, ("event handler for \"" + event + "\""));
+ }
+
+ /* */
+
+ function initAssetRegisters (Vue) {
+ /**
+ * Create asset registration methods.
+ */
+ ASSET_TYPES.forEach(function (type) {
+ Vue[type] = function (
+ id,
+ definition
+ ) {
+ if (!definition) {
+ return this.options[type + 's'][id]
+ } else {
+ /* istanbul ignore if */
+ if (type === 'component') {
+ validateComponentName(id);
+ }
+ if (type === 'component' && isPlainObject(definition)) {
+ definition.name = definition.name || id;
+ definition = this.options._base.extend(definition);
+ }
+ if (type === 'directive' && typeof definition === 'function') {
+ definition = { bind: definition, update: definition };
+ }
+ this.options[type + 's'][id] = definition;
+ return definition
}
- }
- }
- return vm
- };
-}
+ };
+ });
+ }
-/* */
+ /* */
-/**
- * Runtime helper for resolving raw children VNodes into a slot object.
- */
-function resolveSlots (
- children,
- context
-) {
- var slots = {};
- if (!children) {
- return slots
+ function getComponentName (opts) {
+ return opts && (opts.Ctor.options.name || opts.tag)
}
- for (var i = 0, l = children.length; i < l; i++) {
- var child = children[i];
- var data = child.data;
- // remove slot attribute if the node is resolved as a Vue slot node
- if (data && data.attrs && data.attrs.slot) {
- delete data.attrs.slot;
- }
- // named slots should only be respected if the vnode was rendered in the
- // same context.
- if ((child.context === context || child.fnContext === context) &&
- data && data.slot != null
- ) {
- var name = data.slot;
- var slot = (slots[name] || (slots[name] = []));
- if (child.tag === 'template') {
- slot.push.apply(slot, child.children || []);
- } else {
- slot.push(child);
- }
- } else {
- (slots.default || (slots.default = [])).push(child);
+
+ function matches (pattern, name) {
+ if (Array.isArray(pattern)) {
+ return pattern.indexOf(name) > -1
+ } else if (typeof pattern === 'string') {
+ return pattern.split(',').indexOf(name) > -1
+ } else if (isRegExp(pattern)) {
+ return pattern.test(name)
}
+ /* istanbul ignore next */
+ return false
}
- // ignore slots that contains only whitespace
- for (var name$1 in slots) {
- if (slots[name$1].every(isWhitespace)) {
- delete slots[name$1];
+
+ function pruneCache (keepAliveInstance, filter) {
+ var cache = keepAliveInstance.cache;
+ var keys = keepAliveInstance.keys;
+ var _vnode = keepAliveInstance._vnode;
+ for (var key in cache) {
+ var cachedNode = cache[key];
+ if (cachedNode) {
+ var name = getComponentName(cachedNode.componentOptions);
+ if (name && !filter(name)) {
+ pruneCacheEntry(cache, key, keys, _vnode);
+ }
+ }
}
}
- return slots
-}
-function isWhitespace (node) {
- return (node.isComment && !node.asyncFactory) || node.text === ' '
-}
-
-function resolveScopedSlots (
- fns, // see flow/vnode
- res
-) {
- res = res || {};
- for (var i = 0; i < fns.length; i++) {
- if (Array.isArray(fns[i])) {
- resolveScopedSlots(fns[i], res);
- } else {
- res[fns[i].key] = fns[i].fn;
+ function pruneCacheEntry (
+ cache,
+ key,
+ keys,
+ current
+ ) {
+ var cached$$1 = cache[key];
+ if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
+ cached$$1.componentInstance.$destroy();
}
+ cache[key] = null;
+ remove(keys, key);
}
- return res
-}
-/* */
+ var patternTypes = [String, RegExp, Array];
-var activeInstance = null;
-var isUpdatingChildComponent = false;
+ var KeepAlive = {
+ name: 'keep-alive',
+ abstract: true,
-function initLifecycle (vm) {
- var options = vm.$options;
+ props: {
+ include: patternTypes,
+ exclude: patternTypes,
+ max: [String, Number]
+ },
- // locate first non-abstract parent
- var parent = options.parent;
- if (parent && !options.abstract) {
- while (parent.$options.abstract && parent.$parent) {
- parent = parent.$parent;
- }
- parent.$children.push(vm);
- }
+ created: function created () {
+ this.cache = Object.create(null);
+ this.keys = [];
+ },
- vm.$parent = parent;
- vm.$root = parent ? parent.$root : vm;
+ destroyed: function destroyed () {
+ for (var key in this.cache) {
+ pruneCacheEntry(this.cache, key, this.keys);
+ }
+ },
- vm.$children = [];
- vm.$refs = {};
+ mounted: function mounted () {
+ var this$1 = this;
- vm._watcher = null;
- vm._inactive = null;
- vm._directInactive = false;
- vm._isMounted = false;
- vm._isDestroyed = false;
- vm._isBeingDestroyed = false;
-}
+ this.$watch('include', function (val) {
+ pruneCache(this$1, function (name) { return matches(val, name); });
+ });
+ this.$watch('exclude', function (val) {
+ pruneCache(this$1, function (name) { return !matches(val, name); });
+ });
+ },
-function lifecycleMixin (Vue) {
- Vue.prototype._update = function (vnode, hydrating) {
- var vm = this;
- var prevEl = vm.$el;
- var prevVnode = vm._vnode;
- var prevActiveInstance = activeInstance;
- activeInstance = vm;
- vm._vnode = vnode;
- // Vue.prototype.__patch__ is injected in entry points
- // based on the rendering backend used.
- if (!prevVnode) {
- // initial render
- vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
- } else {
- // updates
- vm.$el = vm.__patch__(prevVnode, vnode);
- }
- activeInstance = prevActiveInstance;
- // update __vue__ reference
- if (prevEl) {
- prevEl.__vue__ = null;
- }
- if (vm.$el) {
- vm.$el.__vue__ = vm;
- }
- // if parent is an HOC, update its $el as well
- if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
- vm.$parent.$el = vm.$el;
- }
- // updated hook is called by the scheduler to ensure that children are
- // updated in a parent's updated hook.
- };
+ render: function render () {
+ var slot = this.$slots.default;
+ var vnode = getFirstComponentChild(slot);
+ var componentOptions = vnode && vnode.componentOptions;
+ if (componentOptions) {
+ // check pattern
+ var name = getComponentName(componentOptions);
+ var ref = this;
+ var include = ref.include;
+ var exclude = ref.exclude;
+ if (
+ // not included
+ (include && (!name || !matches(include, name))) ||
+ // excluded
+ (exclude && name && matches(exclude, name))
+ ) {
+ return vnode
+ }
+
+ var ref$1 = this;
+ var cache = ref$1.cache;
+ var keys = ref$1.keys;
+ var key = vnode.key == null
+ // same constructor may get registered as different local components
+ // so cid alone is not enough (#3269)
+ ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
+ : vnode.key;
+ if (cache[key]) {
+ vnode.componentInstance = cache[key].componentInstance;
+ // make current key freshest
+ remove(keys, key);
+ keys.push(key);
+ } else {
+ cache[key] = vnode;
+ keys.push(key);
+ // prune oldest entry
+ if (this.max && keys.length > parseInt(this.max)) {
+ pruneCacheEntry(cache, keys[0], keys, this._vnode);
+ }
+ }
- Vue.prototype.$forceUpdate = function () {
- var vm = this;
- if (vm._watcher) {
- vm._watcher.update();
+ vnode.data.keepAlive = true;
+ }
+ return vnode || (slot && slot[0])
}
};
- Vue.prototype.$destroy = function () {
- var vm = this;
- if (vm._isBeingDestroyed) {
- return
- }
- callHook(vm, 'beforeDestroy');
- vm._isBeingDestroyed = true;
- // remove self from parent
- var parent = vm.$parent;
- if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
- remove(parent.$children, vm);
- }
- // teardown watchers
- if (vm._watcher) {
- vm._watcher.teardown();
- }
- var i = vm._watchers.length;
- while (i--) {
- vm._watchers[i].teardown();
- }
- // remove reference from data ob
- // frozen object may not have observer.
- if (vm._data.__ob__) {
- vm._data.__ob__.vmCount--;
- }
- // call the last hook...
- vm._isDestroyed = true;
- // invoke destroy hooks on current rendered tree
- vm.__patch__(vm._vnode, null);
- // fire destroyed hook
- callHook(vm, 'destroyed');
- // turn off all instance listeners.
- vm.$off();
- // remove __vue__ reference
- if (vm.$el) {
- vm.$el.__vue__ = null;
- }
- // release circular reference (#6759)
- if (vm.$vnode) {
- vm.$vnode.parent = null;
- }
+ var builtInComponents = {
+ KeepAlive: KeepAlive
};
-}
-
-function mountComponent (
- vm,
- el,
- hydrating
-) {
- vm.$el = el;
- if (!vm.$options.render) {
- vm.$options.render = createEmptyVNode;
+
+ /* */
+
+ function initGlobalAPI (Vue) {
+ // config
+ var configDef = {};
+ configDef.get = function () { return config; };
{
- /* istanbul ignore if */
- if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
- vm.$options.el || el) {
- warn(
- 'You are using the runtime-only build of Vue where the template ' +
- 'compiler is not available. Either pre-compile the templates into ' +
- 'render functions, or use the compiler-included build.',
- vm
- );
- } else {
+ configDef.set = function () {
warn(
- 'Failed to mount component: template or render function not defined.',
- vm
+ 'Do not replace the Vue.config object, set individual fields instead.'
);
- }
+ };
}
- }
- callHook(vm, 'beforeMount');
+ Object.defineProperty(Vue, 'config', configDef);
- var updateComponent;
- /* istanbul ignore if */
- if ("development" !== 'production' && config.performance && mark) {
- updateComponent = function () {
- var name = vm._name;
- var id = vm._uid;
- var startTag = "vue-perf-start:" + id;
- var endTag = "vue-perf-end:" + id;
-
- mark(startTag);
- var vnode = vm._render();
- mark(endTag);
- measure(("vue " + name + " render"), startTag, endTag);
-
- mark(startTag);
- vm._update(vnode, hydrating);
- mark(endTag);
- measure(("vue " + name + " patch"), startTag, endTag);
- };
- } else {
- updateComponent = function () {
- vm._update(vm._render(), hydrating);
+ // exposed util methods.
+ // NOTE: these are not considered part of the public API - avoid relying on
+ // them unless you are aware of the risk.
+ Vue.util = {
+ warn: warn,
+ extend: extend,
+ mergeOptions: mergeOptions,
+ defineReactive: defineReactive$$1
};
+
+ Vue.set = set;
+ Vue.delete = del;
+ Vue.nextTick = nextTick;
+
+ Vue.options = Object.create(null);
+ ASSET_TYPES.forEach(function (type) {
+ Vue.options[type + 's'] = Object.create(null);
+ });
+
+ // this is used to identify the "base" constructor to extend all plain-object
+ // components with in Weex's multi-instance scenarios.
+ Vue.options._base = Vue;
+
+ extend(Vue.options.components, builtInComponents);
+
+ initUse(Vue);
+ initMixin$1(Vue);
+ initExtend(Vue);
+ initAssetRegisters(Vue);
}
- // we set this to vm._watcher inside the watcher's constructor
- // since the watcher's initial patch may call $forceUpdate (e.g. inside child
- // component's mounted hook), which relies on vm._watcher being already defined
- new Watcher(vm, updateComponent, noop, {
- before: function before () {
- if (vm._isMounted) {
- callHook(vm, 'beforeUpdate');
- }
+ initGlobalAPI(Vue);
+
+ Object.defineProperty(Vue.prototype, '$isServer', {
+ get: isServerRendering
+ });
+
+ Object.defineProperty(Vue.prototype, '$ssrContext', {
+ get: function get () {
+ /* istanbul ignore next */
+ return this.$vnode && this.$vnode.ssrContext
}
- }, true /* isRenderWatcher */);
- hydrating = false;
+ });
- // manually mounted instance, call mounted on self
- // mounted is called for render-created child components in its inserted hook
- if (vm.$vnode == null) {
- vm._isMounted = true;
- callHook(vm, 'mounted');
- }
- return vm
-}
+ // expose FunctionalRenderContext for ssr runtime helper installation
+ Object.defineProperty(Vue, 'FunctionalRenderContext', {
+ value: FunctionalRenderContext
+ });
-function updateChildComponent (
- vm,
- propsData,
- listeners,
- parentVnode,
- renderChildren
-) {
- {
- isUpdatingChildComponent = true;
- }
+ Vue.version = '2.5.18-beta.0';
+
+ /* */
+
+ // these are reserved for web because they are directly compiled away
+ // during template compilation
+ var isReservedAttr = makeMap('style,class');
+
+ // attributes that should be using props for binding
+ var acceptValue = makeMap('input,textarea,option,select,progress');
+ var mustUseProp = function (tag, type, attr) {
+ return (
+ (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
+ (attr === 'selected' && tag === 'option') ||
+ (attr === 'checked' && tag === 'input') ||
+ (attr === 'muted' && tag === 'video')
+ )
+ };
+
+ var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
- // determine whether component has slot children
- // we need to do this before overwriting $options._renderChildren
- var hasChildren = !!(
- renderChildren || // has new static slots
- vm.$options._renderChildren || // has old static slots
- parentVnode.data.scopedSlots || // has new scoped slots
- vm.$scopedSlots !== emptyObject // has old scoped slots
+ var isBooleanAttr = makeMap(
+ 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
+ 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
+ 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
+ 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
+ 'required,reversed,scoped,seamless,selected,sortable,translate,' +
+ 'truespeed,typemustmatch,visible'
);
- vm.$options._parentVnode = parentVnode;
- vm.$vnode = parentVnode; // update vm's placeholder node without re-render
+ var xlinkNS = 'http://www.w3.org/1999/xlink';
- if (vm._vnode) { // update child tree's parent
- vm._vnode.parent = parentVnode;
- }
- vm.$options._renderChildren = renderChildren;
+ var isXlink = function (name) {
+ return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
+ };
+
+ var getXlinkProp = function (name) {
+ return isXlink(name) ? name.slice(6, name.length) : ''
+ };
- // update $attrs and $listeners hash
- // these are also reactive so they may trigger child update if the child
- // used them during render
- vm.$attrs = parentVnode.data.attrs || emptyObject;
- vm.$listeners = listeners || emptyObject;
+ var isFalsyAttrValue = function (val) {
+ return val == null || val === false
+ };
+
+ /* */
- // update props
- if (propsData && vm.$options.props) {
- toggleObserving(false);
- var props = vm._props;
- var propKeys = vm.$options._propKeys || [];
- for (var i = 0; i < propKeys.length; i++) {
- var key = propKeys[i];
- var propOptions = vm.$options.props; // wtf flow?
- props[key] = validateProp(key, propOptions, propsData, vm);
+ function genClassForVnode (vnode) {
+ var data = vnode.data;
+ var parentNode = vnode;
+ var childNode = vnode;
+ while (isDef(childNode.componentInstance)) {
+ childNode = childNode.componentInstance._vnode;
+ if (childNode && childNode.data) {
+ data = mergeClassData(childNode.data, data);
+ }
}
- toggleObserving(true);
- // keep a copy of raw propsData
- vm.$options.propsData = propsData;
+ while (isDef(parentNode = parentNode.parent)) {
+ if (parentNode && parentNode.data) {
+ data = mergeClassData(data, parentNode.data);
+ }
+ }
+ return renderClass(data.staticClass, data.class)
}
- // update listeners
- listeners = listeners || emptyObject;
- var oldListeners = vm.$options._parentListeners;
- vm.$options._parentListeners = listeners;
- updateComponentListeners(vm, listeners, oldListeners);
-
- // resolve slots + force update if has children
- if (hasChildren) {
- vm.$slots = resolveSlots(renderChildren, parentVnode.context);
- vm.$forceUpdate();
+ function mergeClassData (child, parent) {
+ return {
+ staticClass: concat(child.staticClass, parent.staticClass),
+ class: isDef(child.class)
+ ? [child.class, parent.class]
+ : parent.class
+ }
}
- {
- isUpdatingChildComponent = false;
+ function renderClass (
+ staticClass,
+ dynamicClass
+ ) {
+ if (isDef(staticClass) || isDef(dynamicClass)) {
+ return concat(staticClass, stringifyClass(dynamicClass))
+ }
+ /* istanbul ignore next */
+ return ''
}
-}
-function isInInactiveTree (vm) {
- while (vm && (vm = vm.$parent)) {
- if (vm._inactive) { return true }
+ function concat (a, b) {
+ return a ? b ? (a + ' ' + b) : a : (b || '')
}
- return false
-}
-function activateChildComponent (vm, direct) {
- if (direct) {
- vm._directInactive = false;
- if (isInInactiveTree(vm)) {
- return
+ function stringifyClass (value) {
+ if (Array.isArray(value)) {
+ return stringifyArray(value)
}
- } else if (vm._directInactive) {
- return
- }
- if (vm._inactive || vm._inactive === null) {
- vm._inactive = false;
- for (var i = 0; i < vm.$children.length; i++) {
- activateChildComponent(vm.$children[i]);
+ if (isObject(value)) {
+ return stringifyObject(value)
}
- callHook(vm, 'activated');
- }
-}
-
-function deactivateChildComponent (vm, direct) {
- if (direct) {
- vm._directInactive = true;
- if (isInInactiveTree(vm)) {
- return
+ if (typeof value === 'string') {
+ return value
}
+ /* istanbul ignore next */
+ return ''
}
- if (!vm._inactive) {
- vm._inactive = true;
- for (var i = 0; i < vm.$children.length; i++) {
- deactivateChildComponent(vm.$children[i]);
+
+ function stringifyArray (value) {
+ var res = '';
+ var stringified;
+ for (var i = 0, l = value.length; i < l; i++) {
+ if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
+ if (res) { res += ' '; }
+ res += stringified;
+ }
}
- callHook(vm, 'deactivated');
+ return res
}
-}
-function callHook (vm, hook) {
- // #7573 disable dep collection when invoking lifecycle hooks
- pushTarget();
- var handlers = vm.$options[hook];
- if (handlers) {
- for (var i = 0, j = handlers.length; i < j; i++) {
- try {
- handlers[i].call(vm);
- } catch (e) {
- handleError(e, vm, (hook + " hook"));
+ function stringifyObject (value) {
+ var res = '';
+ for (var key in value) {
+ if (value[key]) {
+ if (res) { res += ' '; }
+ res += key;
}
}
+ return res
}
- if (vm._hasHookEvent) {
- vm.$emit('hook:' + hook);
- }
- popTarget();
-}
-/* */
+ /* */
+
+ var namespaceMap = {
+ svg: 'http://www.w3.org/2000/svg',
+ math: 'http://www.w3.org/1998/Math/MathML'
+ };
+
+ var isHTMLTag = makeMap(
+ 'html,body,base,head,link,meta,style,title,' +
+ 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
+ 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
+ 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
+ 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
+ 'embed,object,param,source,canvas,script,noscript,del,ins,' +
+ 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
+ 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
+ 'output,progress,select,textarea,' +
+ 'details,dialog,menu,menuitem,summary,' +
+ 'content,element,shadow,template,blockquote,iframe,tfoot'
+ );
+ // this map is intentionally selective, only covering SVG elements that may
+ // contain child elements.
+ var isSVG = makeMap(
+ 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
+ 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
+ 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
+ true
+ );
-var MAX_UPDATE_COUNT = 100;
+ var isPreTag = function (tag) { return tag === 'pre'; };
-var queue = [];
-var activatedChildren = [];
-var has = {};
-var circular = {};
-var waiting = false;
-var flushing = false;
-var index = 0;
+ var isReservedTag = function (tag) {
+ return isHTMLTag(tag) || isSVG(tag)
+ };
-/**
- * Reset the scheduler's state.
- */
-function resetSchedulerState () {
- index = queue.length = activatedChildren.length = 0;
- has = {};
- {
- circular = {};
+ function getTagNamespace (tag) {
+ if (isSVG(tag)) {
+ return 'svg'
+ }
+ // basic support for MathML
+ // note it doesn't support other MathML elements being component roots
+ if (tag === 'math') {
+ return 'math'
+ }
}
- waiting = flushing = false;
-}
-/**
- * Flush both queues and run the watchers.
- */
-function flushSchedulerQueue () {
- flushing = true;
- var watcher, id;
-
- // Sort queue before flush.
- // This ensures that:
- // 1. Components are updated from parent to child. (because parent is always
- // created before the child)
- // 2. A component's user watchers are run before its render watcher (because
- // user watchers are created before the render watcher)
- // 3. If a component is destroyed during a parent component's watcher run,
- // its watchers can be skipped.
- queue.sort(function (a, b) { return a.id - b.id; });
-
- // do not cache length because more watchers might be pushed
- // as we run existing watchers
- for (index = 0; index < queue.length; index++) {
- watcher = queue[index];
- if (watcher.before) {
- watcher.before();
- }
- id = watcher.id;
- has[id] = null;
- watcher.run();
- // in dev build, check and stop circular updates.
- if ("development" !== 'production' && has[id] != null) {
- circular[id] = (circular[id] || 0) + 1;
- if (circular[id] > MAX_UPDATE_COUNT) {
+ var unknownElementCache = Object.create(null);
+ function isUnknownElement (tag) {
+ /* istanbul ignore if */
+ if (!inBrowser) {
+ return true
+ }
+ if (isReservedTag(tag)) {
+ return false
+ }
+ tag = tag.toLowerCase();
+ /* istanbul ignore if */
+ if (unknownElementCache[tag] != null) {
+ return unknownElementCache[tag]
+ }
+ var el = document.createElement(tag);
+ if (tag.indexOf('-') > -1) {
+ // http://stackoverflow.com/a/28210364/1070244
+ return (unknownElementCache[tag] = (
+ el.constructor === window.HTMLUnknownElement ||
+ el.constructor === window.HTMLElement
+ ))
+ } else {
+ return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
+ }
+ }
+
+ var isTextInputType = makeMap('text,number,password,search,email,tel,url');
+
+ /* */
+
+ /**
+ * Query an element selector if it's not an element already.
+ */
+ function query (el) {
+ if (typeof el === 'string') {
+ var selected = document.querySelector(el);
+ if (!selected) {
warn(
- 'You may have an infinite update loop ' + (
- watcher.user
- ? ("in watcher with expression \"" + (watcher.expression) + "\"")
- : "in a component render function."
- ),
- watcher.vm
+ 'Cannot find element: ' + el
);
- break
+ return document.createElement('div')
}
+ return selected
+ } else {
+ return el
}
}
- // keep copies of post queues before resetting state
- var activatedQueue = activatedChildren.slice();
- var updatedQueue = queue.slice();
+ /* */
+
+ function createElement$1 (tagName, vnode) {
+ var elm = document.createElement(tagName);
+ if (tagName !== 'select') {
+ return elm
+ }
+ // false or null will remove the attribute but undefined will not
+ if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
+ elm.setAttribute('multiple', 'multiple');
+ }
+ return elm
+ }
- resetSchedulerState();
+ function createElementNS (namespace, tagName) {
+ return document.createElementNS(namespaceMap[namespace], tagName)
+ }
- // call component updated and activated hooks
- callActivatedHooks(activatedQueue);
- callUpdatedHooks(updatedQueue);
+ function createTextNode (text) {
+ return document.createTextNode(text)
+ }
- // devtool hook
- /* istanbul ignore if */
- if (devtools && config.devtools) {
- devtools.emit('flush');
+ function createComment (text) {
+ return document.createComment(text)
}
-}
-function callUpdatedHooks (queue) {
- var i = queue.length;
- while (i--) {
- var watcher = queue[i];
- var vm = watcher.vm;
- if (vm._watcher === watcher && vm._isMounted) {
- callHook(vm, 'updated');
- }
+ function insertBefore (parentNode, newNode, referenceNode) {
+ parentNode.insertBefore(newNode, referenceNode);
}
-}
-/**
- * Queue a kept-alive component that was activated during patch.
- * The queue will be processed after the entire tree has been patched.
- */
-function queueActivatedComponent (vm) {
- // setting _inactive to false here so that a render function can
- // rely on checking whether it's in an inactive tree (e.g. router-view)
- vm._inactive = false;
- activatedChildren.push(vm);
-}
-
-function callActivatedHooks (queue) {
- for (var i = 0; i < queue.length; i++) {
- queue[i]._inactive = true;
- activateChildComponent(queue[i], true /* true */);
- }
-}
-
-/**
- * Push a watcher into the watcher queue.
- * Jobs with duplicate IDs will be skipped unless it's
- * pushed when the queue is being flushed.
- */
-function queueWatcher (watcher) {
- var id = watcher.id;
- if (has[id] == null) {
- has[id] = true;
- if (!flushing) {
- queue.push(watcher);
- } else {
- // if already flushing, splice the watcher based on its id
- // if already past its id, it will be run next immediately.
- var i = queue.length - 1;
- while (i > index && queue[i].id > watcher.id) {
- i--;
- }
- queue.splice(i + 1, 0, watcher);
- }
- // queue the flush
- if (!waiting) {
- waiting = true;
- nextTick(flushSchedulerQueue);
- }
+ function removeChild (node, child) {
+ node.removeChild(child);
}
-}
-/* */
+ function appendChild (node, child) {
+ node.appendChild(child);
+ }
-var uid$1 = 0;
+ function parentNode (node) {
+ return node.parentNode
+ }
-/**
- * A watcher parses an expression, collects dependencies,
- * and fires callback when the expression value changes.
- * This is used for both the $watch() api and directives.
- */
-var Watcher = function Watcher (
- vm,
- expOrFn,
- cb,
- options,
- isRenderWatcher
-) {
- this.vm = vm;
- if (isRenderWatcher) {
- vm._watcher = this;
- }
- vm._watchers.push(this);
- // options
- if (options) {
- this.deep = !!options.deep;
- this.user = !!options.user;
- this.computed = !!options.computed;
- this.sync = !!options.sync;
- this.before = options.before;
- } else {
- this.deep = this.user = this.computed = this.sync = false;
- }
- this.cb = cb;
- this.id = ++uid$1; // uid for batching
- this.active = true;
- this.dirty = this.computed; // for computed watchers
- this.deps = [];
- this.newDeps = [];
- this.depIds = new _Set();
- this.newDepIds = new _Set();
- this.expression = expOrFn.toString();
- // parse expression for getter
- if (typeof expOrFn === 'function') {
- this.getter = expOrFn;
- } else {
- this.getter = parsePath(expOrFn);
- if (!this.getter) {
- this.getter = function () {};
- "development" !== 'production' && warn(
- "Failed watching path: \"" + expOrFn + "\" " +
- 'Watcher only accepts simple dot-delimited paths. ' +
- 'For full control, use a function instead.',
- vm
- );
- }
+ function nextSibling (node) {
+ return node.nextSibling
}
- if (this.computed) {
- this.value = undefined;
- this.dep = new Dep();
- } else {
- this.value = this.get();
+
+ function tagName (node) {
+ return node.tagName
}
-};
-/**
- * Evaluate the getter, and re-collect dependencies.
- */
-Watcher.prototype.get = function get () {
- pushTarget(this);
- var value;
- var vm = this.vm;
- try {
- value = this.getter.call(vm, vm);
- } catch (e) {
- if (this.user) {
- handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
- } else {
- throw e
- }
- } finally {
- // "touch" every property so they are all tracked as
- // dependencies for deep watching
- if (this.deep) {
- traverse(value);
- }
- popTarget();
- this.cleanupDeps();
+ function setTextContent (node, text) {
+ node.textContent = text;
}
- return value
-};
-/**
- * Add a dependency to this directive.
- */
-Watcher.prototype.addDep = function addDep (dep) {
- var id = dep.id;
- if (!this.newDepIds.has(id)) {
- this.newDepIds.add(id);
- this.newDeps.push(dep);
- if (!this.depIds.has(id)) {
- dep.addSub(this);
- }
+ function setStyleScope (node, scopeId) {
+ node.setAttribute(scopeId, '');
}
-};
-/**
- * Clean up for dependency collection.
- */
-Watcher.prototype.cleanupDeps = function cleanupDeps () {
- var this$1 = this;
-
- var i = this.deps.length;
- while (i--) {
- var dep = this$1.deps[i];
- if (!this$1.newDepIds.has(dep.id)) {
- dep.removeSub(this$1);
- }
- }
- var tmp = this.depIds;
- this.depIds = this.newDepIds;
- this.newDepIds = tmp;
- this.newDepIds.clear();
- tmp = this.deps;
- this.deps = this.newDeps;
- this.newDeps = tmp;
- this.newDeps.length = 0;
-};
-
-/**
- * Subscriber interface.
- * Will be called when a dependency changes.
- */
-Watcher.prototype.update = function update () {
- var this$1 = this;
-
- /* istanbul ignore else */
- if (this.computed) {
- // A computed property watcher has two modes: lazy and activated.
- // It initializes as lazy by default, and only becomes activated when
- // it is depended on by at least one subscriber, which is typically
- // another computed property or a component's render function.
- if (this.dep.subs.length === 0) {
- // In lazy mode, we don't want to perform computations until necessary,
- // so we simply mark the watcher as dirty. The actual computation is
- // performed just-in-time in this.evaluate() when the computed property
- // is accessed.
- this.dirty = true;
- } else {
- // In activated mode, we want to proactively perform the computation
- // but only notify our subscribers when the value has indeed changed.
- this.getAndInvoke(function () {
- this$1.dep.notify();
- });
+ var nodeOps = /*#__PURE__*/Object.freeze({
+ createElement: createElement$1,
+ createElementNS: createElementNS,
+ createTextNode: createTextNode,
+ createComment: createComment,
+ insertBefore: insertBefore,
+ removeChild: removeChild,
+ appendChild: appendChild,
+ parentNode: parentNode,
+ nextSibling: nextSibling,
+ tagName: tagName,
+ setTextContent: setTextContent,
+ setStyleScope: setStyleScope
+ });
+
+ /* */
+
+ var ref = {
+ create: function create (_, vnode) {
+ registerRef(vnode);
+ },
+ update: function update (oldVnode, vnode) {
+ if (oldVnode.data.ref !== vnode.data.ref) {
+ registerRef(oldVnode, true);
+ registerRef(vnode);
+ }
+ },
+ destroy: function destroy (vnode) {
+ registerRef(vnode, true);
}
- } else if (this.sync) {
- this.run();
- } else {
- queueWatcher(this);
- }
-};
+ };
-/**
- * Scheduler job interface.
- * Will be called by the scheduler.
- */
-Watcher.prototype.run = function run () {
- if (this.active) {
- this.getAndInvoke(this.cb);
- }
-};
-
-Watcher.prototype.getAndInvoke = function getAndInvoke (cb) {
- var value = this.get();
- if (
- value !== this.value ||
- // Deep watchers and watchers on Object/Arrays should fire even
- // when the value is the same, because the value may
- // have mutated.
- isObject(value) ||
- this.deep
- ) {
- // set new value
- var oldValue = this.value;
- this.value = value;
- this.dirty = false;
- if (this.user) {
- try {
- cb.call(this.vm, value, oldValue);
- } catch (e) {
- handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
+ function registerRef (vnode, isRemoval) {
+ var key = vnode.data.ref;
+ if (!isDef(key)) { return }
+
+ var vm = vnode.context;
+ var ref = vnode.componentInstance || vnode.elm;
+ var refs = vm.$refs;
+ if (isRemoval) {
+ if (Array.isArray(refs[key])) {
+ remove(refs[key], ref);
+ } else if (refs[key] === ref) {
+ refs[key] = undefined;
}
} else {
- cb.call(this.vm, value, oldValue);
+ if (vnode.data.refInFor) {
+ if (!Array.isArray(refs[key])) {
+ refs[key] = [ref];
+ } else if (refs[key].indexOf(ref) < 0) {
+ // $flow-disable-line
+ refs[key].push(ref);
+ }
+ } else {
+ refs[key] = ref;
+ }
}
}
-};
-/**
- * Evaluate and return the value of the watcher.
- * This only gets called for computed property watchers.
- */
-Watcher.prototype.evaluate = function evaluate () {
- if (this.dirty) {
- this.value = this.get();
- this.dirty = false;
+ /**
+ * Virtual DOM patching algorithm based on Snabbdom by
+ * Simon Friis Vindum (@paldepind)
+ * Licensed under the MIT License
+ * https://github.com/paldepind/snabbdom/blob/master/LICENSE
+ *
+ * modified by Evan You (@yyx990803)
+ *
+ * Not type-checking this because this file is perf-critical and the cost
+ * of making flow understand it is not worth it.
+ */
+
+ var emptyNode = new VNode('', {}, []);
+
+ var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
+
+ function childrenIgnored (vnode) {
+ return vnode && vnode.data && vnode.data.domProps && (
+ vnode.data.domProps.innerHTML || vnode.data.domProps.textContent
+ )
}
- return this.value
-};
-/**
- * Depend on this watcher. Only for computed property watchers.
- */
-Watcher.prototype.depend = function depend () {
- if (this.dep && Dep.target) {
- this.dep.depend();
+ function sameVnode (a, b) {
+ return (
+ a.key === b.key && (
+ (
+ a.tag === b.tag &&
+ a.isComment === b.isComment &&
+ isDef(a.data) === isDef(b.data) &&
+ !childrenIgnored(a) && !childrenIgnored(b) &&
+ sameInputType(a, b)
+ ) || (
+ isTrue(a.isAsyncPlaceholder) &&
+ a.asyncFactory === b.asyncFactory &&
+ isUndef(b.asyncFactory.error)
+ )
+ )
+ )
}
-};
-/**
- * Remove self from all dependencies' subscriber list.
- */
-Watcher.prototype.teardown = function teardown () {
- var this$1 = this;
+ function sameInputType (a, b) {
+ if (a.tag !== 'input') { return true }
+ var i;
+ var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
+ var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
+ return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
+ }
- if (this.active) {
- // remove self from vm's watcher list
- // this is a somewhat expensive operation so we skip it
- // if the vm is being destroyed.
- if (!this.vm._isBeingDestroyed) {
- remove(this.vm._watchers, this);
+ function createKeyToOldIdx (children, beginIdx, endIdx) {
+ var i, key;
+ var map = {};
+ for (i = beginIdx; i <= endIdx; ++i) {
+ key = children[i].key;
+ if (isDef(key)) { map[key] = i; }
}
- var i = this.deps.length;
- while (i--) {
- this$1.deps[i].removeSub(this$1);
- }
- this.active = false;
+ return map
}
-};
-/* */
+ function createPatchFunction (backend) {
+ var i, j;
+ var cbs = {};
-var sharedPropertyDefinition = {
- enumerable: true,
- configurable: true,
- get: noop,
- set: noop
-};
+ var modules = backend.modules;
+ var nodeOps = backend.nodeOps;
-function proxy (target, sourceKey, key) {
- sharedPropertyDefinition.get = function proxyGetter () {
- return this[sourceKey][key]
- };
- sharedPropertyDefinition.set = function proxySetter (val) {
- this[sourceKey][key] = val;
- };
- Object.defineProperty(target, key, sharedPropertyDefinition);
-}
-
-function initState (vm) {
- vm._watchers = [];
- var opts = vm.$options;
- if (opts.props) { initProps(vm, opts.props); }
- if (opts.methods) { initMethods(vm, opts.methods); }
- if (opts.data) {
- initData(vm);
- } else {
- observe(vm._data = {}, true /* asRootData */);
- }
- if (opts.computed) { initComputed(vm, opts.computed); }
- if (opts.watch && opts.watch !== nativeWatch) {
- initWatch(vm, opts.watch);
- }
-}
-
-function initProps (vm, propsOptions) {
- var propsData = vm.$options.propsData || {};
- var props = vm._props = {};
- // cache prop keys so that future props updates can iterate using Array
- // instead of dynamic object key enumeration.
- var keys = vm.$options._propKeys = [];
- var isRoot = !vm.$parent;
- // root instance props should be converted
- if (!isRoot) {
- toggleObserving(false);
- }
- var loop = function ( key ) {
- keys.push(key);
- var value = validateProp(key, propsOptions, propsData, vm);
- /* istanbul ignore else */
- {
- var hyphenatedKey = hyphenate(key);
- if (isReservedAttribute(hyphenatedKey) ||
- config.isReservedAttr(hyphenatedKey)) {
- warn(
- ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
- vm
- );
- }
- defineReactive(props, key, value, function () {
- if (vm.$parent && !isUpdatingChildComponent) {
- warn(
- "Avoid mutating a prop directly since the value will be " +
- "overwritten whenever the parent component re-renders. " +
- "Instead, use a data or computed property based on the prop's " +
- "value. Prop being mutated: \"" + key + "\"",
- vm
- );
+ for (i = 0; i < hooks.length; ++i) {
+ cbs[hooks[i]] = [];
+ for (j = 0; j < modules.length; ++j) {
+ if (isDef(modules[j][hooks[i]])) {
+ cbs[hooks[i]].push(modules[j][hooks[i]]);
}
- });
+ }
}
- // static props are already proxied on the component's prototype
- // during Vue.extend(). We only need to proxy props defined at
- // instantiation here.
- if (!(key in vm)) {
- proxy(vm, "_props", key);
+
+ function emptyNodeAt (elm) {
+ return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
}
- };
- for (var key in propsOptions) loop( key );
- toggleObserving(true);
-}
-
-function initData (vm) {
- var data = vm.$options.data;
- data = vm._data = typeof data === 'function'
- ? getData(data, vm)
- : data || {};
- if (!isPlainObject(data)) {
- data = {};
- "development" !== 'production' && warn(
- 'data functions should return an object:\n' +
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
- vm
- );
- }
- // proxy data on instance
- var keys = Object.keys(data);
- var props = vm.$options.props;
- var methods = vm.$options.methods;
- var i = keys.length;
- while (i--) {
- var key = keys[i];
- {
- if (methods && hasOwn(methods, key)) {
- warn(
- ("Method \"" + key + "\" has already been defined as a data property."),
- vm
- );
+ function createRmCb (childElm, listeners) {
+ function remove$$1 () {
+ if (--remove$$1.listeners === 0) {
+ removeNode(childElm);
+ }
}
+ remove$$1.listeners = listeners;
+ return remove$$1
}
- if (props && hasOwn(props, key)) {
- "development" !== 'production' && warn(
- "The data property \"" + key + "\" is already declared as a prop. " +
- "Use prop default value instead.",
- vm
- );
- } else if (!isReserved(key)) {
- proxy(vm, "_data", key);
- }
- }
- // observe data
- observe(data, true /* asRootData */);
-}
-
-function getData (data, vm) {
- // #7573 disable dep collection when invoking data getters
- pushTarget();
- try {
- return data.call(vm, vm)
- } catch (e) {
- handleError(e, vm, "data()");
- return {}
- } finally {
- popTarget();
- }
-}
-var computedWatcherOptions = { computed: true };
-
-function initComputed (vm, computed) {
- // $flow-disable-line
- var watchers = vm._computedWatchers = Object.create(null);
- // computed properties are just getters during SSR
- var isSSR = isServerRendering();
-
- for (var key in computed) {
- var userDef = computed[key];
- var getter = typeof userDef === 'function' ? userDef : userDef.get;
- if ("development" !== 'production' && getter == null) {
- warn(
- ("Getter is missing for computed property \"" + key + "\"."),
- vm
- );
+ function removeNode (el) {
+ var parent = nodeOps.parentNode(el);
+ // element may have already been removed due to v-html / v-text
+ if (isDef(parent)) {
+ nodeOps.removeChild(parent, el);
+ }
}
- if (!isSSR) {
- // create internal watcher for the computed property.
- watchers[key] = new Watcher(
- vm,
- getter || noop,
- noop,
- computedWatcherOptions
- );
+ function isUnknownElement$$1 (vnode, inVPre) {
+ return (
+ !inVPre &&
+ !vnode.ns &&
+ !(
+ config.ignoredElements.length &&
+ config.ignoredElements.some(function (ignore) {
+ return isRegExp(ignore)
+ ? ignore.test(vnode.tag)
+ : ignore === vnode.tag
+ })
+ ) &&
+ config.isUnknownElement(vnode.tag)
+ )
}
- // component-defined computed properties are already defined on the
- // component prototype. We only need to define computed properties defined
- // at instantiation here.
- if (!(key in vm)) {
- defineComputed(vm, key, userDef);
- } else {
- if (key in vm.$data) {
- warn(("The computed property \"" + key + "\" is already defined in data."), vm);
- } else if (vm.$options.props && key in vm.$options.props) {
- warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
- }
- }
- }
-}
-
-function defineComputed (
- target,
- key,
- userDef
-) {
- var shouldCache = !isServerRendering();
- if (typeof userDef === 'function') {
- sharedPropertyDefinition.get = shouldCache
- ? createComputedGetter(key)
- : userDef;
- sharedPropertyDefinition.set = noop;
- } else {
- sharedPropertyDefinition.get = userDef.get
- ? shouldCache && userDef.cache !== false
- ? createComputedGetter(key)
- : userDef.get
- : noop;
- sharedPropertyDefinition.set = userDef.set
- ? userDef.set
- : noop;
- }
- if ("development" !== 'production' &&
- sharedPropertyDefinition.set === noop) {
- sharedPropertyDefinition.set = function () {
- warn(
- ("Computed property \"" + key + "\" was assigned to but it has no setter."),
- this
- );
- };
- }
- Object.defineProperty(target, key, sharedPropertyDefinition);
-}
+ var creatingElmInVPre = 0;
-function createComputedGetter (key) {
- return function computedGetter () {
- var watcher = this._computedWatchers && this._computedWatchers[key];
- if (watcher) {
- watcher.depend();
- return watcher.evaluate()
- }
- }
-}
+ function createElm (
+ vnode,
+ insertedVnodeQueue,
+ parentElm,
+ refElm,
+ nested,
+ ownerArray,
+ index
+ ) {
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
+ // This vnode was used in a previous render!
+ // now it's used as a new node, overwriting its elm would cause
+ // potential patch errors down the road when it's used as an insertion
+ // reference node. Instead, we clone the node on-demand before creating
+ // associated DOM element for it.
+ vnode = ownerArray[index] = cloneVNode(vnode);
+ }
-function initMethods (vm, methods) {
- var props = vm.$options.props;
- for (var key in methods) {
- {
- if (methods[key] == null) {
- warn(
- "Method \"" + key + "\" has an undefined value in the component definition. " +
- "Did you reference the function correctly?",
- vm
- );
+ vnode.isRootInsert = !nested; // for transition enter check
+ if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
+ return
}
- if (props && hasOwn(props, key)) {
- warn(
- ("Method \"" + key + "\" has already been defined as a prop."),
- vm
- );
+
+ var data = vnode.data;
+ var children = vnode.children;
+ var tag = vnode.tag;
+ if (isDef(tag)) {
+ {
+ if (data && data.pre) {
+ creatingElmInVPre++;
+ }
+ if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
+ warn(
+ 'Unknown custom element: <' + tag + '> - did you ' +
+ 'register the component correctly? For recursive components, ' +
+ 'make sure to provide the "name" option.',
+ vnode.context
+ );
+ }
+ }
+
+ vnode.elm = vnode.ns
+ ? nodeOps.createElementNS(vnode.ns, tag)
+ : nodeOps.createElement(tag, vnode);
+ setScope(vnode);
+
+ /* istanbul ignore if */
+ {
+ createChildren(vnode, children, insertedVnodeQueue);
+ if (isDef(data)) {
+ invokeCreateHooks(vnode, insertedVnodeQueue);
+ }
+ insert(parentElm, vnode.elm, refElm);
+ }
+
+ if (data && data.pre) {
+ creatingElmInVPre--;
+ }
+ } else if (isTrue(vnode.isComment)) {
+ vnode.elm = nodeOps.createComment(vnode.text);
+ insert(parentElm, vnode.elm, refElm);
+ } else {
+ vnode.elm = nodeOps.createTextNode(vnode.text);
+ insert(parentElm, vnode.elm, refElm);
}
- if ((key in vm) && isReserved(key)) {
- warn(
- "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
- "Avoid defining component methods that start with _ or $."
- );
+ }
+
+ function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
+ var i = vnode.data;
+ if (isDef(i)) {
+ var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
+ if (isDef(i = i.hook) && isDef(i = i.init)) {
+ i(vnode, false /* hydrating */);
+ }
+ // after calling the init hook, if the vnode is a child component
+ // it should've created a child instance and mounted it. the child
+ // component also has set the placeholder vnode's elm.
+ // in that case we can just return the element and be done.
+ if (isDef(vnode.componentInstance)) {
+ initComponent(vnode, insertedVnodeQueue);
+ insert(parentElm, vnode.elm, refElm);
+ if (isTrue(isReactivated)) {
+ reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
+ }
+ return true
+ }
}
}
- vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
- }
-}
-function initWatch (vm, watch) {
- for (var key in watch) {
- var handler = watch[key];
- if (Array.isArray(handler)) {
- for (var i = 0; i < handler.length; i++) {
- createWatcher(vm, key, handler[i]);
+ function initComponent (vnode, insertedVnodeQueue) {
+ if (isDef(vnode.data.pendingInsert)) {
+ insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
+ vnode.data.pendingInsert = null;
}
- } else {
- createWatcher(vm, key, handler);
- }
- }
-}
-
-function createWatcher (
- vm,
- expOrFn,
- handler,
- options
-) {
- if (isPlainObject(handler)) {
- options = handler;
- handler = handler.handler;
- }
- if (typeof handler === 'string') {
- handler = vm[handler];
- }
- return vm.$watch(expOrFn, handler, options)
-}
-
-function stateMixin (Vue) {
- // flow somehow has problems with directly declared definition object
- // when using Object.defineProperty, so we have to procedurally build up
- // the object here.
- var dataDef = {};
- dataDef.get = function () { return this._data };
- var propsDef = {};
- propsDef.get = function () { return this._props };
- {
- dataDef.set = function (newData) {
- warn(
- 'Avoid replacing instance root $data. ' +
- 'Use nested data properties instead.',
- this
- );
- };
- propsDef.set = function () {
- warn("$props is readonly.", this);
- };
- }
- Object.defineProperty(Vue.prototype, '$data', dataDef);
- Object.defineProperty(Vue.prototype, '$props', propsDef);
+ vnode.elm = vnode.componentInstance.$el;
+ if (isPatchable(vnode)) {
+ invokeCreateHooks(vnode, insertedVnodeQueue);
+ setScope(vnode);
+ } else {
+ // empty component root.
+ // skip all element-related modules except for ref (#3455)
+ registerRef(vnode);
+ // make sure to invoke the insert hook
+ insertedVnodeQueue.push(vnode);
+ }
+ }
- Vue.prototype.$set = set;
- Vue.prototype.$delete = del;
+ function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
+ var i;
+ // hack for #4339: a reactivated component with inner transition
+ // does not trigger because the inner node's created hooks are not called
+ // again. It's not ideal to involve module-specific logic in here but
+ // there doesn't seem to be a better way to do it.
+ var innerNode = vnode;
+ while (innerNode.componentInstance) {
+ innerNode = innerNode.componentInstance._vnode;
+ if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
+ for (i = 0; i < cbs.activate.length; ++i) {
+ cbs.activate[i](emptyNode, innerNode);
+ }
+ insertedVnodeQueue.push(innerNode);
+ break
+ }
+ }
+ // unlike a newly created component,
+ // a reactivated keep-alive component doesn't insert itself
+ insert(parentElm, vnode.elm, refElm);
+ }
- Vue.prototype.$watch = function (
- expOrFn,
- cb,
- options
- ) {
- var vm = this;
- if (isPlainObject(cb)) {
- return createWatcher(vm, expOrFn, cb, options)
+ function insert (parent, elm, ref$$1) {
+ if (isDef(parent)) {
+ if (isDef(ref$$1)) {
+ if (nodeOps.parentNode(ref$$1) === parent) {
+ nodeOps.insertBefore(parent, elm, ref$$1);
+ }
+ } else {
+ nodeOps.appendChild(parent, elm);
+ }
+ }
}
- options = options || {};
- options.user = true;
- var watcher = new Watcher(vm, expOrFn, cb, options);
- if (options.immediate) {
- cb.call(vm, watcher.value);
+
+ function createChildren (vnode, children, insertedVnodeQueue) {
+ if (Array.isArray(children)) {
+ {
+ checkDuplicateKeys(children);
+ }
+ for (var i = 0; i < children.length; ++i) {
+ createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
+ }
+ } else if (isPrimitive(vnode.text)) {
+ nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
+ }
}
- return function unwatchFn () {
- watcher.teardown();
+
+ function isPatchable (vnode) {
+ while (vnode.componentInstance) {
+ vnode = vnode.componentInstance._vnode;
+ }
+ return isDef(vnode.tag)
}
- };
-}
-/* */
+ function invokeCreateHooks (vnode, insertedVnodeQueue) {
+ for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
+ cbs.create[i$1](emptyNode, vnode);
+ }
+ i = vnode.data.hook; // Reuse variable
+ if (isDef(i)) {
+ if (isDef(i.create)) { i.create(emptyNode, vnode); }
+ if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
+ }
+ }
-function initProvide (vm) {
- var provide = vm.$options.provide;
- if (provide) {
- vm._provided = typeof provide === 'function'
- ? provide.call(vm)
- : provide;
- }
-}
+ // set scope id attribute for scoped CSS.
+ // this is implemented as a special case to avoid the overhead
+ // of going through the normal attribute patching process.
+ function setScope (vnode) {
+ var i;
+ if (isDef(i = vnode.fnScopeId)) {
+ nodeOps.setStyleScope(vnode.elm, i);
+ } else {
+ var ancestor = vnode;
+ while (ancestor) {
+ if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
+ nodeOps.setStyleScope(vnode.elm, i);
+ }
+ ancestor = ancestor.parent;
+ }
+ }
+ // for slot content they should also get the scopeId from the host instance.
+ if (isDef(i = activeInstance) &&
+ i !== vnode.context &&
+ i !== vnode.fnContext &&
+ isDef(i = i.$options._scopeId)
+ ) {
+ nodeOps.setStyleScope(vnode.elm, i);
+ }
+ }
-function initInjections (vm) {
- var result = resolveInject(vm.$options.inject, vm);
- if (result) {
- toggleObserving(false);
- Object.keys(result).forEach(function (key) {
- /* istanbul ignore else */
- {
- defineReactive(vm, key, result[key], function () {
- warn(
- "Avoid mutating an injected value directly since the changes will be " +
- "overwritten whenever the provided component re-renders. " +
- "injection being mutated: \"" + key + "\"",
- vm
- );
- });
+ function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
+ for (; startIdx <= endIdx; ++startIdx) {
+ createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
}
- });
- toggleObserving(true);
- }
-}
+ }
-function resolveInject (inject, vm) {
- if (inject) {
- // inject is :any because flow is not smart enough to figure out cached
- var result = Object.create(null);
- var keys = hasSymbol
- ? Reflect.ownKeys(inject).filter(function (key) {
- /* istanbul ignore next */
- return Object.getOwnPropertyDescriptor(inject, key).enumerable
- })
- : Object.keys(inject);
+ function invokeDestroyHook (vnode) {
+ var i, j;
+ var data = vnode.data;
+ if (isDef(data)) {
+ if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
+ for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
+ }
+ if (isDef(i = vnode.children)) {
+ for (j = 0; j < vnode.children.length; ++j) {
+ invokeDestroyHook(vnode.children[j]);
+ }
+ }
+ }
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- var provideKey = inject[key].from;
- var source = vm;
- while (source) {
- if (source._provided && hasOwn(source._provided, provideKey)) {
- result[key] = source._provided[provideKey];
- break
+ function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
+ for (; startIdx <= endIdx; ++startIdx) {
+ var ch = vnodes[startIdx];
+ if (isDef(ch)) {
+ if (isDef(ch.tag)) {
+ removeAndInvokeRemoveHook(ch);
+ invokeDestroyHook(ch);
+ } else { // Text node
+ removeNode(ch.elm);
+ }
}
- source = source.$parent;
}
- if (!source) {
- if ('default' in inject[key]) {
- var provideDefault = inject[key].default;
- result[key] = typeof provideDefault === 'function'
- ? provideDefault.call(vm)
- : provideDefault;
+ }
+
+ function removeAndInvokeRemoveHook (vnode, rm) {
+ if (isDef(rm) || isDef(vnode.data)) {
+ var i;
+ var listeners = cbs.remove.length + 1;
+ if (isDef(rm)) {
+ // we have a recursively passed down rm callback
+ // increase the listeners count
+ rm.listeners += listeners;
+ } else {
+ // directly removing
+ rm = createRmCb(vnode.elm, listeners);
+ }
+ // recursively invoke hooks on child component root node
+ if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
+ removeAndInvokeRemoveHook(i, rm);
+ }
+ for (i = 0; i < cbs.remove.length; ++i) {
+ cbs.remove[i](vnode, rm);
+ }
+ if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
+ i(vnode, rm);
} else {
- warn(("Injection \"" + key + "\" not found"), vm);
+ rm();
}
+ } else {
+ removeNode(vnode.elm);
}
}
- return result
- }
-}
-/* */
+ function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
+ var oldStartIdx = 0;
+ var newStartIdx = 0;
+ var oldEndIdx = oldCh.length - 1;
+ var oldStartVnode = oldCh[0];
+ var oldEndVnode = oldCh[oldEndIdx];
+ var newEndIdx = newCh.length - 1;
+ var newStartVnode = newCh[0];
+ var newEndVnode = newCh[newEndIdx];
+ var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
-/**
- * Runtime helper for rendering v-for lists.
- */
-function renderList (
- val,
- render
-) {
- var ret, i, l, keys, key;
- if (Array.isArray(val) || typeof val === 'string') {
- ret = new Array(val.length);
- for (i = 0, l = val.length; i < l; i++) {
- ret[i] = render(val[i], i);
- }
- } else if (typeof val === 'number') {
- ret = new Array(val);
- for (i = 0; i < val; i++) {
- ret[i] = render(i + 1, i);
- }
- } else if (isObject(val)) {
- keys = Object.keys(val);
- ret = new Array(keys.length);
- for (i = 0, l = keys.length; i < l; i++) {
- key = keys[i];
- ret[i] = render(val[key], key, i);
- }
- }
- if (isDef(ret)) {
- (ret)._isVList = true;
- }
- return ret
-}
+ // removeOnly is a special flag used only by
+ // to ensure removed elements stay in correct relative positions
+ // during leaving transitions
+ var canMove = !removeOnly;
-/* */
+ {
+ checkDuplicateKeys(newCh);
+ }
+
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
+ if (isUndef(oldStartVnode)) {
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
+ } else if (isUndef(oldEndVnode)) {
+ oldEndVnode = oldCh[--oldEndIdx];
+ } else if (sameVnode(oldStartVnode, newStartVnode)) {
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
+ oldStartVnode = oldCh[++oldStartIdx];
+ newStartVnode = newCh[++newStartIdx];
+ } else if (sameVnode(oldEndVnode, newEndVnode)) {
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
+ oldEndVnode = oldCh[--oldEndIdx];
+ newEndVnode = newCh[--newEndIdx];
+ } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
+ canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
+ oldStartVnode = oldCh[++oldStartIdx];
+ newEndVnode = newCh[--newEndIdx];
+ } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
+ canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
+ oldEndVnode = oldCh[--oldEndIdx];
+ newStartVnode = newCh[++newStartIdx];
+ } else {
+ if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
+ idxInOld = isDef(newStartVnode.key)
+ ? oldKeyToIdx[newStartVnode.key]
+ : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
+ if (isUndef(idxInOld)) { // New element
+ createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
+ } else {
+ vnodeToMove = oldCh[idxInOld];
+ if (sameVnode(vnodeToMove, newStartVnode)) {
+ patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
+ oldCh[idxInOld] = undefined;
+ canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
+ } else {
+ // same key but different element. treat as new element
+ createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
+ }
+ }
+ newStartVnode = newCh[++newStartIdx];
+ }
+ }
+ if (oldStartIdx > oldEndIdx) {
+ refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
+ addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
+ } else if (newStartIdx > newEndIdx) {
+ removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
+ }
+ }
-/**
- * Runtime helper for rendering
- */
-function renderSlot (
- name,
- fallback,
- props,
- bindObject
-) {
- var scopedSlotFn = this.$scopedSlots[name];
- var nodes;
- if (scopedSlotFn) { // scoped slot
- props = props || {};
- if (bindObject) {
- if ("development" !== 'production' && !isObject(bindObject)) {
- warn(
- 'slot v-bind without argument expects an Object',
- this
- );
+ function checkDuplicateKeys (children) {
+ var seenKeys = {};
+ for (var i = 0; i < children.length; i++) {
+ var vnode = children[i];
+ var key = vnode.key;
+ if (isDef(key)) {
+ if (seenKeys[key]) {
+ warn(
+ ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
+ vnode.context
+ );
+ } else {
+ seenKeys[key] = true;
+ }
+ }
}
- props = extend(extend({}, bindObject), props);
}
- nodes = scopedSlotFn(props) || fallback;
- } else {
- var slotNodes = this.$slots[name];
- // warn duplicate slot usage
- if (slotNodes) {
- if ("development" !== 'production' && slotNodes._rendered) {
- warn(
- "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
- "- this will likely cause render errors.",
- this
- );
+
+ function findIdxInOld (node, oldCh, start, end) {
+ for (var i = start; i < end; i++) {
+ var c = oldCh[i];
+ if (isDef(c) && sameVnode(node, c)) { return i }
}
- slotNodes._rendered = true;
}
- nodes = slotNodes || fallback;
- }
- var target = props && props.slot;
- if (target) {
- return this.$createElement('template', { slot: target }, nodes)
- } else {
- return nodes
- }
-}
-
-/* */
+ function patchVnode (
+ oldVnode,
+ vnode,
+ insertedVnodeQueue,
+ ownerArray,
+ index,
+ removeOnly
+ ) {
+ if (oldVnode === vnode) {
+ return
+ }
-/**
- * Runtime helper for resolving filters
- */
-function resolveFilter (id) {
- return resolveAsset(this.$options, 'filters', id, true) || identity
-}
+ if (isDef(vnode.elm) && isDef(ownerArray)) {
+ // clone reused vnode
+ vnode = ownerArray[index] = cloneVNode(vnode);
+ }
-/* */
+ var elm = vnode.elm = oldVnode.elm;
-function isKeyNotMatch (expect, actual) {
- if (Array.isArray(expect)) {
- return expect.indexOf(actual) === -1
- } else {
- return expect !== actual
- }
-}
+ if (isTrue(oldVnode.isAsyncPlaceholder)) {
+ if (isDef(vnode.asyncFactory.resolved)) {
+ hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
+ } else {
+ vnode.isAsyncPlaceholder = true;
+ }
+ return
+ }
-/**
- * Runtime helper for checking keyCodes from config.
- * exposed as Vue.prototype._k
- * passing in eventKeyName as last argument separately for backwards compat
- */
-function checkKeyCodes (
- eventKeyCode,
- key,
- builtInKeyCode,
- eventKeyName,
- builtInKeyName
-) {
- var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
- if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
- return isKeyNotMatch(builtInKeyName, eventKeyName)
- } else if (mappedKeyCode) {
- return isKeyNotMatch(mappedKeyCode, eventKeyCode)
- } else if (eventKeyName) {
- return hyphenate(eventKeyName) !== key
- }
-}
-
-/* */
-
-/**
- * Runtime helper for merging v-bind="object" into a VNode's data.
- */
-function bindObjectProps (
- data,
- tag,
- value,
- asProp,
- isSync
-) {
- if (value) {
- if (!isObject(value)) {
- "development" !== 'production' && warn(
- 'v-bind without argument expects an Object or Array value',
- this
- );
- } else {
- if (Array.isArray(value)) {
- value = toObject(value);
+ // reuse element for static trees.
+ // note we only do this if the vnode is cloned -
+ // if the new node is not cloned it means the render functions have been
+ // reset by the hot-reload-api and we need to do a proper re-render.
+ if (isTrue(vnode.isStatic) &&
+ isTrue(oldVnode.isStatic) &&
+ vnode.key === oldVnode.key &&
+ (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
+ ) {
+ vnode.componentInstance = oldVnode.componentInstance;
+ return
}
- var hash;
- var loop = function ( key ) {
- if (
- key === 'class' ||
- key === 'style' ||
- isReservedAttribute(key)
- ) {
- hash = data;
- } else {
- var type = data.attrs && data.attrs.type;
- hash = asProp || config.mustUseProp(tag, type, key)
- ? data.domProps || (data.domProps = {})
- : data.attrs || (data.attrs = {});
- }
- if (!(key in hash)) {
- hash[key] = value[key];
-
- if (isSync) {
- var on = data.on || (data.on = {});
- on[("update:" + key)] = function ($event) {
- value[key] = $event;
- };
+
+ var i;
+ var data = vnode.data;
+ if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
+ i(oldVnode, vnode);
+ }
+
+ var oldCh = oldVnode.children;
+ var ch = vnode.children;
+ if (isDef(data) && isPatchable(vnode)) {
+ for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
+ if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
+ }
+ if (isUndef(vnode.text)) {
+ if (isDef(oldCh) && isDef(ch)) {
+ if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
+ } else if (isDef(ch)) {
+ {
+ checkDuplicateKeys(ch);
}
+ if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
+ addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
+ } else if (isDef(oldCh)) {
+ removeVnodes(elm, oldCh, 0, oldCh.length - 1);
+ } else if (isDef(oldVnode.text)) {
+ nodeOps.setTextContent(elm, '');
}
- };
-
- for (var key in value) loop( key );
+ } else if (oldVnode.text !== vnode.text) {
+ nodeOps.setTextContent(elm, vnode.text);
+ }
+ if (isDef(data)) {
+ if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
+ }
}
- }
- return data
-}
-
-/* */
-/**
- * Runtime helper for rendering static trees.
- */
-function renderStatic (
- index,
- isInFor
-) {
- var cached = this._staticTrees || (this._staticTrees = []);
- var tree = cached[index];
- // if has already-rendered static tree and not inside v-for,
- // we can reuse the same tree.
- if (tree && !isInFor) {
- return tree
- }
- // otherwise, render a fresh tree.
- tree = cached[index] = this.$options.staticRenderFns[index].call(
- this._renderProxy,
- null,
- this // for render fns generated for functional component templates
- );
- markStatic(tree, ("__static__" + index), false);
- return tree
-}
-
-/**
- * Runtime helper for v-once.
- * Effectively it means marking the node as static with a unique key.
- */
-function markOnce (
- tree,
- index,
- key
-) {
- markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
- return tree
-}
-
-function markStatic (
- tree,
- key,
- isOnce
-) {
- if (Array.isArray(tree)) {
- for (var i = 0; i < tree.length; i++) {
- if (tree[i] && typeof tree[i] !== 'string') {
- markStaticNode(tree[i], (key + "_" + i), isOnce);
+ function invokeInsertHook (vnode, queue, initial) {
+ // delay insert hooks for component root nodes, invoke them after the
+ // element is really inserted
+ if (isTrue(initial) && isDef(vnode.parent)) {
+ vnode.parent.data.pendingInsert = queue;
+ } else {
+ for (var i = 0; i < queue.length; ++i) {
+ queue[i].data.hook.insert(queue[i]);
+ }
}
}
- } else {
- markStaticNode(tree, key, isOnce);
- }
-}
-function markStaticNode (node, key, isOnce) {
- node.isStatic = true;
- node.key = key;
- node.isOnce = isOnce;
-}
+ var hydrationBailed = false;
+ // list of modules that can skip create hook during hydration because they
+ // are already rendered on the client or has no need for initialization
+ // Note: style is excluded because it relies on initial clone for future
+ // deep updates (#7063).
+ var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
-/* */
+ // Note: this is a browser-only function so we can assume elms are DOM nodes.
+ function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
+ var i;
+ var tag = vnode.tag;
+ var data = vnode.data;
+ var children = vnode.children;
+ inVPre = inVPre || (data && data.pre);
+ vnode.elm = elm;
-function bindObjectListeners (data, value) {
- if (value) {
- if (!isPlainObject(value)) {
- "development" !== 'production' && warn(
- 'v-on without argument expects an Object value',
- this
- );
- } else {
- var on = data.on = data.on ? extend({}, data.on) : {};
- for (var key in value) {
- var existing = on[key];
- var ours = value[key];
- on[key] = existing ? [].concat(existing, ours) : ours;
- }
- }
- }
- return data
-}
-
-/* */
-
-function installRenderHelpers (target) {
- target._o = markOnce;
- target._n = toNumber;
- target._s = toString;
- target._l = renderList;
- target._t = renderSlot;
- target._q = looseEqual;
- target._i = looseIndexOf;
- target._m = renderStatic;
- target._f = resolveFilter;
- target._k = checkKeyCodes;
- target._b = bindObjectProps;
- target._v = createTextVNode;
- target._e = createEmptyVNode;
- target._u = resolveScopedSlots;
- target._g = bindObjectListeners;
-}
-
-/* */
-
-function FunctionalRenderContext (
- data,
- props,
- children,
- parent,
- Ctor
-) {
- var options = Ctor.options;
- // ensure the createElement function in functional components
- // gets a unique context - this is necessary for correct named slot check
- var contextVm;
- if (hasOwn(parent, '_uid')) {
- contextVm = Object.create(parent);
- // $flow-disable-line
- contextVm._original = parent;
- } else {
- // the context vm passed in is a functional context as well.
- // in this case we want to make sure we are able to get a hold to the
- // real context instance.
- contextVm = parent;
- // $flow-disable-line
- parent = parent._original;
- }
- var isCompiled = isTrue(options._compiled);
- var needNormalization = !isCompiled;
-
- this.data = data;
- this.props = props;
- this.children = children;
- this.parent = parent;
- this.listeners = data.on || emptyObject;
- this.injections = resolveInject(options.inject, parent);
- this.slots = function () { return resolveSlots(children, parent); };
-
- // support for compiled functional template
- if (isCompiled) {
- // exposing $options for renderStatic()
- this.$options = options;
- // pre-resolve slots for renderSlot()
- this.$slots = this.slots();
- this.$scopedSlots = data.scopedSlots || emptyObject;
- }
-
- if (options._scopeId) {
- this._c = function (a, b, c, d) {
- var vnode = createElement(contextVm, a, b, c, d, needNormalization);
- if (vnode && !Array.isArray(vnode)) {
- vnode.fnScopeId = options._scopeId;
- vnode.fnContext = parent;
+ if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
+ vnode.isAsyncPlaceholder = true;
+ return true
}
- return vnode
- };
- } else {
- this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
- }
-}
-
-installRenderHelpers(FunctionalRenderContext.prototype);
-
-function createFunctionalComponent (
- Ctor,
- propsData,
- data,
- contextVm,
- children
-) {
- var options = Ctor.options;
- var props = {};
- var propOptions = options.props;
- if (isDef(propOptions)) {
- for (var key in propOptions) {
- props[key] = validateProp(key, propOptions, propsData || emptyObject);
+ // assert node match
+ {
+ if (!assertNodeMatch(elm, vnode, inVPre)) {
+ return false
+ }
+ }
+ if (isDef(data)) {
+ if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
+ if (isDef(i = vnode.componentInstance)) {
+ // child component. it should have hydrated its own tree.
+ initComponent(vnode, insertedVnodeQueue);
+ return true
+ }
+ }
+ if (isDef(tag)) {
+ if (isDef(children)) {
+ // empty element, allow client to pick up and populate children
+ if (!elm.hasChildNodes()) {
+ createChildren(vnode, children, insertedVnodeQueue);
+ } else {
+ // v-html and domProps: innerHTML
+ if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
+ if (i !== elm.innerHTML) {
+ /* istanbul ignore if */
+ if (typeof console !== 'undefined' &&
+ !hydrationBailed
+ ) {
+ hydrationBailed = true;
+ console.warn('Parent: ', elm);
+ console.warn('server innerHTML: ', i);
+ console.warn('client innerHTML: ', elm.innerHTML);
+ }
+ return false
+ }
+ } else {
+ // iterate and compare children lists
+ var childrenMatch = true;
+ var childNode = elm.firstChild;
+ for (var i$1 = 0; i$1 < children.length; i$1++) {
+ if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
+ childrenMatch = false;
+ break
+ }
+ childNode = childNode.nextSibling;
+ }
+ // if childNode is not null, it means the actual childNodes list is
+ // longer than the virtual children list.
+ if (!childrenMatch || childNode) {
+ /* istanbul ignore if */
+ if (typeof console !== 'undefined' &&
+ !hydrationBailed
+ ) {
+ hydrationBailed = true;
+ console.warn('Parent: ', elm);
+ console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
+ }
+ return false
+ }
+ }
+ }
+ }
+ if (isDef(data)) {
+ var fullInvoke = false;
+ for (var key in data) {
+ if (!isRenderedModule(key)) {
+ fullInvoke = true;
+ invokeCreateHooks(vnode, insertedVnodeQueue);
+ break
+ }
+ }
+ if (!fullInvoke && data['class']) {
+ // ensure collecting deps for deep class bindings for future updates
+ traverse(data['class']);
+ }
+ }
+ } else if (elm.data !== vnode.text) {
+ elm.data = vnode.text;
+ }
+ return true
}
- } else {
- if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
- if (isDef(data.props)) { mergeProps(props, data.props); }
- }
-
- var renderContext = new FunctionalRenderContext(
- data,
- props,
- children,
- contextVm,
- Ctor
- );
-
- var vnode = options.render.call(null, renderContext._c, renderContext);
- if (vnode instanceof VNode) {
- return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options)
- } else if (Array.isArray(vnode)) {
- var vnodes = normalizeChildren(vnode) || [];
- var res = new Array(vnodes.length);
- for (var i = 0; i < vnodes.length; i++) {
- res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options);
+ function assertNodeMatch (node, vnode, inVPre) {
+ if (isDef(vnode.tag)) {
+ return vnode.tag.indexOf('vue-component') === 0 || (
+ !isUnknownElement$$1(vnode, inVPre) &&
+ vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
+ )
+ } else {
+ return node.nodeType === (vnode.isComment ? 8 : 3)
+ }
}
- return res
- }
-}
-
-function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) {
- // #7817 clone node before setting fnContext, otherwise if the node is reused
- // (e.g. it was from a cached normal slot) the fnContext causes named slots
- // that should not be matched to match.
- var clone = cloneVNode(vnode);
- clone.fnContext = contextVm;
- clone.fnOptions = options;
- if (data.slot) {
- (clone.data || (clone.data = {})).slot = data.slot;
- }
- return clone
-}
-function mergeProps (to, from) {
- for (var key in from) {
- to[camelize(key)] = from[key];
- }
-}
-
-/* */
+ return function patch (oldVnode, vnode, hydrating, removeOnly) {
+ if (isUndef(vnode)) {
+ if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
+ return
+ }
+ var isInitialPatch = false;
+ var insertedVnodeQueue = [];
+ if (isUndef(oldVnode)) {
+ // empty mount (likely as component), create new root element
+ isInitialPatch = true;
+ createElm(vnode, insertedVnodeQueue);
+ } else {
+ var isRealElement = isDef(oldVnode.nodeType);
+ if (!isRealElement && sameVnode(oldVnode, vnode)) {
+ // patch existing root node
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
+ } else {
+ if (isRealElement) {
+ // mounting to a real element
+ // check if this is server-rendered content and if we can perform
+ // a successful hydration.
+ if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
+ oldVnode.removeAttribute(SSR_ATTR);
+ hydrating = true;
+ }
+ if (isTrue(hydrating)) {
+ if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
+ invokeInsertHook(vnode, insertedVnodeQueue, true);
+ return oldVnode
+ } else {
+ warn(
+ 'The client-side rendered virtual DOM tree is not matching ' +
+ 'server-rendered content. This is likely caused by incorrect ' +
+ 'HTML markup, for example nesting block-level elements inside ' +
+ ', or missing
. Bailing hydration and performing ' +
+ 'full client-side render.'
+ );
+ }
+ }
+ // either not server-rendered, or hydration failed.
+ // create an empty node and replace it
+ oldVnode = emptyNodeAt(oldVnode);
+ }
+ // replacing existing element
+ var oldElm = oldVnode.elm;
+ var parentElm = nodeOps.parentNode(oldElm);
+
+ // create new node
+ createElm(
+ vnode,
+ insertedVnodeQueue,
+ // extremely rare edge case: do not insert if old element is in a
+ // leaving transition. Only happens when combining transition +
+ // keep-alive + HOCs. (#4590)
+ oldElm._leaveCb ? null : parentElm,
+ nodeOps.nextSibling(oldElm)
+ );
-// Register the component hook to weex native render engine.
-// The hook will be triggered by native, not javascript.
+ // update parent placeholder node element, recursively
+ if (isDef(vnode.parent)) {
+ var ancestor = vnode.parent;
+ var patchable = isPatchable(vnode);
+ while (ancestor) {
+ for (var i = 0; i < cbs.destroy.length; ++i) {
+ cbs.destroy[i](ancestor);
+ }
+ ancestor.elm = vnode.elm;
+ if (patchable) {
+ for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
+ cbs.create[i$1](emptyNode, ancestor);
+ }
+ // #6513
+ // invoke insert hooks that may have been merged by create hooks.
+ // e.g. for directives that uses the "inserted" hook.
+ var insert = ancestor.data.hook.insert;
+ if (insert.merged) {
+ // start at index 1 to avoid re-invoking component mounted hook
+ for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
+ insert.fns[i$2]();
+ }
+ }
+ } else {
+ registerRef(ancestor);
+ }
+ ancestor = ancestor.parent;
+ }
+ }
+ // destroy old node
+ if (isDef(parentElm)) {
+ removeVnodes(parentElm, [oldVnode], 0, 0);
+ } else if (isDef(oldVnode.tag)) {
+ invokeDestroyHook(oldVnode);
+ }
+ }
+ }
-// Updates the state of the component to weex native render engine.
+ invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
+ return vnode.elm
+ }
+ }
-/* */
+ /* */
-// https://github.com/Hanks10100/weex-native-directive/tree/master/component
+ var directives = {
+ create: updateDirectives,
+ update: updateDirectives,
+ destroy: function unbindDirectives (vnode) {
+ updateDirectives(vnode, emptyNode);
+ }
+ };
-// listening on native callback
+ function updateDirectives (oldVnode, vnode) {
+ if (oldVnode.data.directives || vnode.data.directives) {
+ _update(oldVnode, vnode);
+ }
+ }
-/* */
+ function _update (oldVnode, vnode) {
+ var isCreate = oldVnode === emptyNode;
+ var isDestroy = vnode === emptyNode;
+ var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
+ var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
-/* */
+ var dirsWithInsert = [];
+ var dirsWithPostpatch = [];
-// inline hooks to be invoked on component VNodes during patch
-var componentVNodeHooks = {
- init: function init (vnode, hydrating) {
- if (
- vnode.componentInstance &&
- !vnode.componentInstance._isDestroyed &&
- vnode.data.keepAlive
- ) {
- // kept-alive components, treat as a patch
- var mountedNode = vnode; // work around flow
- componentVNodeHooks.prepatch(mountedNode, mountedNode);
- } else {
- var child = vnode.componentInstance = createComponentInstanceForVnode(
- vnode,
- activeInstance
- );
- child.$mount(hydrating ? vnode.elm : undefined, hydrating);
- }
- },
-
- prepatch: function prepatch (oldVnode, vnode) {
- var options = vnode.componentOptions;
- var child = vnode.componentInstance = oldVnode.componentInstance;
- updateChildComponent(
- child,
- options.propsData, // updated props
- options.listeners, // updated listeners
- vnode, // new parent vnode
- options.children // new children
- );
- },
-
- insert: function insert (vnode) {
- var context = vnode.context;
- var componentInstance = vnode.componentInstance;
- if (!componentInstance._isMounted) {
- componentInstance._isMounted = true;
- callHook(componentInstance, 'mounted');
- }
- if (vnode.data.keepAlive) {
- if (context._isMounted) {
- // vue-router#1212
- // During updates, a kept-alive component's child components may
- // change, so directly walking the tree here may call activated hooks
- // on incorrect children. Instead we push them into a queue which will
- // be processed after the whole patch process ended.
- queueActivatedComponent(componentInstance);
+ var key, oldDir, dir;
+ for (key in newDirs) {
+ oldDir = oldDirs[key];
+ dir = newDirs[key];
+ if (!oldDir) {
+ // new directive, bind
+ callHook$1(dir, 'bind', vnode, oldVnode);
+ if (dir.def && dir.def.inserted) {
+ dirsWithInsert.push(dir);
+ }
} else {
- activateChildComponent(componentInstance, true /* direct */);
+ // existing directive, update
+ dir.oldValue = oldDir.value;
+ callHook$1(dir, 'update', vnode, oldVnode);
+ if (dir.def && dir.def.componentUpdated) {
+ dirsWithPostpatch.push(dir);
+ }
}
}
- },
- destroy: function destroy (vnode) {
- var componentInstance = vnode.componentInstance;
- if (!componentInstance._isDestroyed) {
- if (!vnode.data.keepAlive) {
- componentInstance.$destroy();
+ if (dirsWithInsert.length) {
+ var callInsert = function () {
+ for (var i = 0; i < dirsWithInsert.length; i++) {
+ callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
+ }
+ };
+ if (isCreate) {
+ mergeVNodeHook(vnode, 'insert', callInsert);
} else {
- deactivateChildComponent(componentInstance, true /* direct */);
+ callInsert();
}
}
- }
-};
-var hooksToMerge = Object.keys(componentVNodeHooks);
+ if (dirsWithPostpatch.length) {
+ mergeVNodeHook(vnode, 'postpatch', function () {
+ for (var i = 0; i < dirsWithPostpatch.length; i++) {
+ callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
+ }
+ });
+ }
-function createComponent (
- Ctor,
- data,
- context,
- children,
- tag
-) {
- if (isUndef(Ctor)) {
- return
+ if (!isCreate) {
+ for (key in oldDirs) {
+ if (!newDirs[key]) {
+ // no longer present, unbind
+ callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
+ }
+ }
+ }
}
- var baseCtor = context.$options._base;
-
- // plain options object: turn it into a constructor
- if (isObject(Ctor)) {
- Ctor = baseCtor.extend(Ctor);
- }
+ var emptyModifiers = Object.create(null);
- // if at this stage it's not a constructor or an async component factory,
- // reject.
- if (typeof Ctor !== 'function') {
- {
- warn(("Invalid Component definition: " + (String(Ctor))), context);
- }
- return
- }
-
- // async component
- var asyncFactory;
- if (isUndef(Ctor.cid)) {
- asyncFactory = Ctor;
- Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
- if (Ctor === undefined) {
- // return a placeholder node for async component, which is rendered
- // as a comment node but preserves all the raw information for the node.
- // the information will be used for async server-rendering and hydration.
- return createAsyncPlaceholder(
- asyncFactory,
- data,
- context,
- children,
- tag
- )
+ function normalizeDirectives$1 (
+ dirs,
+ vm
+ ) {
+ var res = Object.create(null);
+ if (!dirs) {
+ // $flow-disable-line
+ return res
+ }
+ var i, dir;
+ for (i = 0; i < dirs.length; i++) {
+ dir = dirs[i];
+ if (!dir.modifiers) {
+ // $flow-disable-line
+ dir.modifiers = emptyModifiers;
+ }
+ res[getRawDirName(dir)] = dir;
+ dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
}
+ // $flow-disable-line
+ return res
}
- data = data || {};
-
- // resolve constructor options in case global mixins are applied after
- // component constructor creation
- resolveConstructorOptions(Ctor);
-
- // transform component v-model data into props & events
- if (isDef(data.model)) {
- transformModel(Ctor.options, data);
+ function getRawDirName (dir) {
+ return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
}
- // extract props
- var propsData = extractPropsFromVNodeData(data, Ctor, tag);
-
- // functional component
- if (isTrue(Ctor.options.functional)) {
- return createFunctionalComponent(Ctor, propsData, data, context, children)
+ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
+ var fn = dir.def && dir.def[hook];
+ if (fn) {
+ try {
+ fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
+ } catch (e) {
+ handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
+ }
+ }
}
- // extract listeners, since these needs to be treated as
- // child component listeners instead of DOM listeners
- var listeners = data.on;
- // replace with listeners with .native modifier
- // so it gets processed during parent component patch.
- data.on = data.nativeOn;
+ var baseModules = [
+ ref,
+ directives
+ ];
- if (isTrue(Ctor.options.abstract)) {
- // abstract components do not keep anything
- // other than props & listeners & slot
+ /* */
- // work around flow
- var slot = data.slot;
- data = {};
- if (slot) {
- data.slot = slot;
+ function updateAttrs (oldVnode, vnode) {
+ var opts = vnode.componentOptions;
+ if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
+ return
+ }
+ if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
+ return
+ }
+ var key, cur, old;
+ var elm = vnode.elm;
+ var oldAttrs = oldVnode.data.attrs || {};
+ var attrs = vnode.data.attrs || {};
+ // clone observed objects, as the user probably wants to mutate it
+ if (isDef(attrs.__ob__)) {
+ attrs = vnode.data.attrs = extend({}, attrs);
}
- }
-
- // install component management hooks onto the placeholder node
- installComponentHooks(data);
-
- // return a placeholder vnode
- var name = Ctor.options.name || tag;
- var vnode = new VNode(
- ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
- data, undefined, undefined, undefined, context,
- { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
- asyncFactory
- );
- // Weex specific: invoke recycle-list optimized @render function for
- // extracting cell-slot template.
- // https://github.com/Hanks10100/weex-native-directive/tree/master/component
- /* istanbul ignore if */
- return vnode
-}
-
-function createComponentInstanceForVnode (
- vnode, // we know it's MountedComponentVNode but flow doesn't
- parent // activeInstance in lifecycle state
-) {
- var options = {
- _isComponent: true,
- _parentVnode: vnode,
- parent: parent
- };
- // check inline-template render functions
- var inlineTemplate = vnode.data.inlineTemplate;
- if (isDef(inlineTemplate)) {
- options.render = inlineTemplate.render;
- options.staticRenderFns = inlineTemplate.staticRenderFns;
- }
- return new vnode.componentOptions.Ctor(options)
-}
-
-function installComponentHooks (data) {
- var hooks = data.hook || (data.hook = {});
- for (var i = 0; i < hooksToMerge.length; i++) {
- var key = hooksToMerge[i];
- var existing = hooks[key];
- var toMerge = componentVNodeHooks[key];
- if (existing !== toMerge && !(existing && existing._merged)) {
- hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
- }
- }
-}
-
-function mergeHook$1 (f1, f2) {
- var merged = function (a, b) {
- // flow complains about extra args which is why we use any
- f1(a, b);
- f2(a, b);
- };
- merged._merged = true;
- return merged
-}
-
-// transform component v-model info (value and callback) into
-// prop and event handler respectively.
-function transformModel (options, data) {
- var prop = (options.model && options.model.prop) || 'value';
- var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
- var on = data.on || (data.on = {});
- if (isDef(on[event])) {
- on[event] = [data.model.callback].concat(on[event]);
- } else {
- on[event] = data.model.callback;
- }
-}
-
-/* */
-
-var SIMPLE_NORMALIZE = 1;
-var ALWAYS_NORMALIZE = 2;
-
-// wrapper function for providing a more flexible interface
-// without getting yelled at by flow
-function createElement (
- context,
- tag,
- data,
- children,
- normalizationType,
- alwaysNormalize
-) {
- if (Array.isArray(data) || isPrimitive(data)) {
- normalizationType = children;
- children = data;
- data = undefined;
- }
- if (isTrue(alwaysNormalize)) {
- normalizationType = ALWAYS_NORMALIZE;
- }
- return _createElement(context, tag, data, children, normalizationType)
-}
-
-function _createElement (
- context,
- tag,
- data,
- children,
- normalizationType
-) {
- if (isDef(data) && isDef((data).__ob__)) {
- "development" !== 'production' && warn(
- "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
- 'Always create fresh vnode data objects in each render!',
- context
- );
- return createEmptyVNode()
- }
- // object syntax in v-bind
- if (isDef(data) && isDef(data.is)) {
- tag = data.is;
- }
- if (!tag) {
- // in case of component :is set to falsy value
- return createEmptyVNode()
- }
- // warn against non-primitive key
- if ("development" !== 'production' &&
- isDef(data) && isDef(data.key) && !isPrimitive(data.key)
- ) {
- {
- warn(
- 'Avoid using non-primitive value as key, ' +
- 'use string/number value instead.',
- context
- );
+ for (key in attrs) {
+ cur = attrs[key];
+ old = oldAttrs[key];
+ if (old !== cur) {
+ setAttr(elm, key, cur);
+ }
+ }
+ // #4391: in IE9, setting type can reset value for input[type=radio]
+ // #6666: IE/Edge forces progress value down to 1 before setting a max
+ /* istanbul ignore if */
+ if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
+ setAttr(elm, 'value', attrs.value);
+ }
+ for (key in oldAttrs) {
+ if (isUndef(attrs[key])) {
+ if (isXlink(key)) {
+ elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
+ } else if (!isEnumeratedAttr(key)) {
+ elm.removeAttribute(key);
+ }
+ }
}
}
- // support single function children as default scoped slot
- if (Array.isArray(children) &&
- typeof children[0] === 'function'
- ) {
- data = data || {};
- data.scopedSlots = { default: children[0] };
- children.length = 0;
- }
- if (normalizationType === ALWAYS_NORMALIZE) {
- children = normalizeChildren(children);
- } else if (normalizationType === SIMPLE_NORMALIZE) {
- children = simpleNormalizeChildren(children);
- }
- var vnode, ns;
- if (typeof tag === 'string') {
- var Ctor;
- ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
- if (config.isReservedTag(tag)) {
- // platform built-in elements
- vnode = new VNode(
- config.parsePlatformTagName(tag), data, children,
- undefined, undefined, context
- );
- } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
- // component
- vnode = createComponent(Ctor, data, context, children, tag);
+
+ function setAttr (el, key, value) {
+ if (el.tagName.indexOf('-') > -1) {
+ baseSetAttr(el, key, value);
+ } else if (isBooleanAttr(key)) {
+ // set attribute for blank value
+ // e.g.
+ if (isFalsyAttrValue(value)) {
+ el.removeAttribute(key);
+ } else {
+ // technically allowfullscreen is a boolean attribute for