Image optimization & Lazy Load by Optimole - Version 2.0.5

Version Description

Download this release

Release Info

Developer optimole
Plugin Icon 128x128 Image optimization & Lazy Load by Optimole
Version 2.0.5
Comparing to
See all releases

Code changes from version 2.0.4 to 2.0.5

CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
#### [Version 2.0.4](https://github.com/Codeinwp/optimole-wp/compare/v2.0.3...v2.0.4) (2019-03-11)
2
3
* **Bug Fixes**
1
+ #### [Version 2.0.5](https://github.com/Codeinwp/optimole-wp/compare/v2.0.4...v2.0.5) (2019-03-25)
2
+
3
+ * **Bug Fixes**
4
+ * adds compatibility with Jetelements Slider ([c9e518e](https://github.com/Codeinwp/optimole-wp/commit/c9e518e))
5
+ * compatibility with Metaslider, adds full support for all slider types available ([a09d1fd](https://github.com/Codeinwp/optimole-wp/commit/a09d1fd))
6
+ * compatibility with various themes logo markup based on the image url, removes the hook to theme_mods image replace ([34e0d85](https://github.com/Codeinwp/optimole-wp/commit/34e0d85))
7
+ * disable image replacement when we are in the Beaver Builder editing mode ([239442f](https://github.com/Codeinwp/optimole-wp/commit/239442f))
8
+ * image replacement on header tags which uses relative urls ([2caae7f](https://github.com/Codeinwp/optimole-wp/commit/2caae7f))
9
+ * image replacement on json strings with html entities encoded, conflicting with variation form Woocommerce fixes [#81](https://github.com/Codeinwp/optimole-wp/issues/81) ([2bae741](https://github.com/Codeinwp/optimole-wp/commit/2bae741))
10
+ * lazyload animation conflict with initial image animation ([3a84250](https://github.com/Codeinwp/optimole-wp/commit/3a84250))
11
+ * lazyload on image which uses relative urls ([4655994](https://github.com/Codeinwp/optimole-wp/commit/4655994))
12
+ * lazyload placeholder replacement affecting non-src urls, improving compatibility with Woocommerce ([7e13a32](https://github.com/Codeinwp/optimole-wp/commit/7e13a32))
13
+ * noscript image tag issue causing problems with too specific CSS selectors ([324effd](https://github.com/Codeinwp/optimole-wp/commit/324effd))
14
+ * relative url image replacement conflicting with plugins like WPML ([7a47827](https://github.com/Codeinwp/optimole-wp/commit/7a47827))
15
+ * thumbnails cropping mode not affecting the resulting optimole images ([0f6dacb](https://github.com/Codeinwp/optimole-wp/commit/0f6dacb))
16
+
17
+ * **Features**
18
+ * adds constant to disable latest images area ([a5891b6](https://github.com/Codeinwp/optimole-wp/commit/a5891b6))
19
+ * adds constant to switch on/off network based optimization ([1accde5](https://github.com/Codeinwp/optimole-wp/commit/1accde5))
20
+ * adds full compatibility with Beaver Builder, processing images from the generated css ([2a17f30](https://github.com/Codeinwp/optimole-wp/commit/2a17f30))
21
+
22
#### [Version 2.0.4](https://github.com/Codeinwp/optimole-wp/compare/v2.0.3...v2.0.4) (2019-03-11)
23
24
* **Bug Fixes**
README.md CHANGED
@@ -91,6 +91,29 @@ Premium users will be able to optimize 10GB images per month with a 50GB viewing
91
92
## Changelog ##
93
94
#### [Version 2.0.4](https://github.com/Codeinwp/optimole-wp/compare/v2.0.3...v2.0.4) (2019-03-11)
95
96
* **Bug Fixes**
91
92
## Changelog ##
93
94
+ #### [Version 2.0.5](https://github.com/Codeinwp/optimole-wp/compare/v2.0.4...v2.0.5) (2019-03-25)
95
+
96
+ * **Bug Fixes**
97
+ * adds compatibility with Jetelements Slider ([c9e518e](https://github.com/Codeinwp/optimole-wp/commit/c9e518e))
98
+ * compatibility with Metaslider, adds full support for all slider types available ([a09d1fd](https://github.com/Codeinwp/optimole-wp/commit/a09d1fd))
99
+ * compatibility with various themes logo markup based on the image url, removes the hook to theme_mods image replace ([34e0d85](https://github.com/Codeinwp/optimole-wp/commit/34e0d85))
100
+ * disable image replacement when we are in the Beaver Builder editing mode ([239442f](https://github.com/Codeinwp/optimole-wp/commit/239442f))
101
+ * image replacement on header tags which uses relative urls ([2caae7f](https://github.com/Codeinwp/optimole-wp/commit/2caae7f))
102
+ * image replacement on json strings with html entities encoded, conflicting with variation form Woocommerce fixes [#81](https://github.com/Codeinwp/optimole-wp/issues/81) ([2bae741](https://github.com/Codeinwp/optimole-wp/commit/2bae741))
103
+ * lazyload animation conflict with initial image animation ([3a84250](https://github.com/Codeinwp/optimole-wp/commit/3a84250))
104
+ * lazyload on image which uses relative urls ([4655994](https://github.com/Codeinwp/optimole-wp/commit/4655994))
105
+ * lazyload placeholder replacement affecting non-src urls, improving compatibility with Woocommerce ([7e13a32](https://github.com/Codeinwp/optimole-wp/commit/7e13a32))
106
+ * noscript image tag issue causing problems with too specific CSS selectors ([324effd](https://github.com/Codeinwp/optimole-wp/commit/324effd))
107
+ * relative url image replacement conflicting with plugins like WPML ([7a47827](https://github.com/Codeinwp/optimole-wp/commit/7a47827))
108
+ * thumbnails cropping mode not affecting the resulting optimole images ([0f6dacb](https://github.com/Codeinwp/optimole-wp/commit/0f6dacb))
109
+
110
+ * **Features**
111
+ * adds constant to disable latest images area ([a5891b6](https://github.com/Codeinwp/optimole-wp/commit/a5891b6))
112
+ * adds constant to switch on/off network based optimization ([1accde5](https://github.com/Codeinwp/optimole-wp/commit/1accde5))
113
+ * adds full compatibility with Beaver Builder, processing images from the generated css ([2a17f30](https://github.com/Codeinwp/optimole-wp/commit/2a17f30))
114
+
115
+
116
+
117
#### [Version 2.0.4](https://github.com/Codeinwp/optimole-wp/compare/v2.0.3...v2.0.4) (2019-03-11)
118
119
* **Bug Fixes**
assets/js/bundle.js CHANGED
@@ -405,8 +405,8 @@ module.exports = g;
405
"use strict";
406
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
407
/* WEBPACK VAR INJECTION */(function(process, global, setImmediate) {/*!
408
- * Vue.js v2.5.21
409
- * (c) 2014-2018 Evan You
410
* Released under the MIT License.
411
*/
412
/* */
@@ -482,13 +482,21 @@ function isValidArrayIndex (val) {
482
return n >= 0 && Math.floor(n) === n && isFinite(val)
483
}
484
485
/**
486
* Convert a value to a string that is actually rendered.
487
*/
488
function toString (val) {
489
return val == null
490
? ''
491
- : typeof val === 'object'
492
? JSON.stringify(val, null, 2)
493
: String(val)
494
}
@@ -764,7 +772,8 @@ var LIFECYCLE_HOOKS = [
764
'destroyed',
765
'activated',
766
'deactivated',
767
- 'errorCaptured'
768
];
769
770
/* */
@@ -867,6 +876,13 @@ var config = ({
867
868
/* */
869
870
/**
871
* Check if a string starts with $ or _
872
*/
@@ -890,7 +906,7 @@ function def (obj, key, val, enumerable) {
890
/**
891
* Parse simple path.
892
*/
893
- var bailRE = /[^\w.$]/;
894
function parsePath (path) {
895
if (bailRE.test(path)) {
896
return
@@ -921,6 +937,8 @@ var isEdge = UA && UA.indexOf('edge/') > 0;
921
var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
922
var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
923
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
924
925
// Firefox has a "watch" function on Object.prototype...
926
var nativeWatch = ({}).watch;
@@ -1033,7 +1051,7 @@ if (process.env.NODE_ENV !== 'production') {
1033
? vm.options
1034
: vm._isVue
1035
? vm.$options || vm.constructor.options
1036
- : vm || {};
1037
var name = options.name || options._componentTag;
1038
var file = options.__file;
1039
if (!name && file) {
@@ -1128,9 +1146,9 @@ Dep.prototype.notify = function notify () {
1128
}
1129
};
1130
1131
- // the current target watcher being evaluated.
1132
- // this is globally unique because there could be only one
1133
- // watcher being evaluated at any time.
1134
Dep.target = null;
1135
var targetStack = [];
1136
@@ -1566,9 +1584,15 @@ if (process.env.NODE_ENV !== 'production') {
1566
function mergeData (to, from) {
1567
if (!from) { return to }
1568
var key, toVal, fromVal;
1569
- var keys = Object.keys(from);
1570
for (var i = 0; i < keys.length; i++) {
1571
key = keys[i];
1572
toVal = to[key];
1573
fromVal = from[key];
1574
if (!hasOwn(to, key)) {
@@ -1658,13 +1682,26 @@ function mergeHook (
1658
parentVal,
1659
childVal
1660
) {
1661
- return childVal
1662
? parentVal
1663
? parentVal.concat(childVal)
1664
: Array.isArray(childVal)
1665
? childVal
1666
: [childVal]
1667
- : parentVal
1668
}
1669
1670
LIFECYCLE_HOOKS.forEach(function (hook) {
@@ -1775,11 +1812,10 @@ function checkComponents (options) {
1775
}
1776
1777
function validateComponentName (name) {
1778
- if (!/^[a-zA-Z][\w-]*#x2F;.test(name)) {
1779
warn(
1780
'Invalid component name: "' + name + '". Component names ' +
1781
- 'can only contain alphanumeric characters and the hyphen, ' +
1782
- 'and must start with a letter.'
1783
);
1784
}
1785
if (isBuiltInTag(name) || config.isReservedTag(name)) {
@@ -1862,9 +1898,9 @@ function normalizeDirectives (options) {
1862
var dirs = options.directives;
1863
if (dirs) {
1864
for (var key in dirs) {
1865
- var def = dirs[key];
1866
- if (typeof def === 'function') {
1867
- dirs[key] = { bind: def, update: def };
1868
}
1869
}
1870
}
@@ -1900,7 +1936,7 @@ function mergeOptions (
1900
normalizeProps(child, vm);
1901
normalizeInject(child, vm);
1902
normalizeDirectives(child);
1903
-
1904
// Apply extends and mixins on the child options,
1905
// but only if it is a raw options object that isn't
1906
// the result of another mergeOptions call.
@@ -2214,12 +2250,35 @@ function handleError (err, vm, info) {
2214
globalHandleError(err, vm, info);
2215
}
2216
2217
function globalHandleError (err, vm, info) {
2218
if (config.errorHandler) {
2219
try {
2220
return config.errorHandler.call(null, err, vm, info)
2221
} catch (e) {
2222
- logError(e, null, 'config.errorHandler');
2223
}
2224
}
2225
logError(err, vm, info);
@@ -2239,6 +2298,8 @@ function logError (err, vm, info) {
2239
2240
/* */
2241
2242
var callbacks = [];
2243
var pending = false;
2244
@@ -2251,76 +2312,69 @@ function flushCallbacks () {
2251
}
2252
}
2253
2254
- // Here we have async deferring wrappers using both microtasks and (macro) tasks.
2255
- // In < 2.4 we used microtasks everywhere, but there are some scenarios where
2256
- // microtasks have too high a priority and fire in between supposedly
2257
- // sequential events (e.g. #4521, #6690) or even between bubbling of the same
2258
- // event (#6566). However, using (macro) tasks everywhere also has subtle problems
2259
- // when state is changed right before repaint (e.g. #6813, out-in transitions).
2260
- // Here we use microtask by default, but expose a way to force (macro) task when
2261
- // needed (e.g. in event handlers attached by v-on).
2262
- var microTimerFunc;
2263
- var macroTimerFunc;
2264
- var useMacroTask = false;
2265
-
2266
- // Determine (macro) task defer implementation.
2267
- // Technically setImmediate should be the ideal choice, but it's only available
2268
- // in IE. The only polyfill that consistently queues the callback after all DOM
2269
- // events triggered in the same loop is by using MessageChannel.
2270
- /* istanbul ignore if */
2271
- if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
2272
- macroTimerFunc = function () {
2273
- setImmediate(flushCallbacks);
2274
- };
2275
- } else if (typeof MessageChannel !== 'undefined' && (
2276
- isNative(MessageChannel) ||
2277
- // PhantomJS
2278
- MessageChannel.toString() === '[object MessageChannelConstructor]'
2279
- )) {
2280
- var channel = new MessageChannel();
2281
- var port = channel.port2;
2282
- channel.port1.onmessage = flushCallbacks;
2283
- macroTimerFunc = function () {
2284
- port.postMessage(1);
2285
- };
2286
- } else {
2287
- /* istanbul ignore next */
2288
- macroTimerFunc = function () {
2289
- setTimeout(flushCallbacks, 0);
2290
- };
2291
- }
2292
-
2293
- // Determine microtask defer implementation.
2294
/* istanbul ignore next, $flow-disable-line */
2295
if (typeof Promise !== 'undefined' && isNative(Promise)) {
2296
var p = Promise.resolve();
2297
- microTimerFunc = function () {
2298
p.then(flushCallbacks);
2299
- // in problematic UIWebViews, Promise.then doesn't completely break, but
2300
// it can get stuck in a weird state where callbacks are pushed into the
2301
// microtask queue but the queue isn't being flushed, until the browser
2302
// needs to do some other work, e.g. handle a timer. Therefore we can
2303
// "force" the microtask queue to be flushed by adding an empty timer.
2304
if (isIOS) { setTimeout(noop); }
2305
};
2306
} else {
2307
- // fallback to macro
2308
- microTimerFunc = macroTimerFunc;
2309
- }
2310
-
2311
- /**
2312
- * Wrap a function so that if any code inside triggers state change,
2313
- * the changes are queued using a (macro) task instead of a microtask.
2314
- */
2315
- function withMacroTask (fn) {
2316
- return fn._withTask || (fn._withTask = function () {
2317
- useMacroTask = true;
2318
- try {
2319
- return fn.apply(null, arguments)
2320
- } finally {
2321
- useMacroTask = false;
2322
- }
2323
- })
2324
}
2325
2326
function nextTick (cb, ctx) {
@@ -2338,11 +2392,7 @@ function nextTick (cb, ctx) {
2338
});
2339
if (!pending) {
2340
pending = true;
2341
- if (useMacroTask) {
2342
- macroTimerFunc();
2343
- } else {
2344
- microTimerFunc();
2345
- }
2346
}
2347
// $flow-disable-line
2348
if (!cb && typeof Promise !== 'undefined') {
@@ -2372,7 +2422,7 @@ if (process.env.NODE_ENV !== 'production') {
2372
perf.measure(name, startTag, endTag);
2373
perf.clearMarks(startTag);
2374
perf.clearMarks(endTag);
2375
- perf.clearMeasures(name);
2376
};
2377
}
2378
}
@@ -2519,7 +2569,7 @@ var normalizeEvent = cached(function (name) {
2519
}
2520
});
2521
2522
- function createFnInvoker (fns) {
2523
function invoker () {
2524
var arguments$1 = arguments;
2525
@@ -2527,11 +2577,11 @@ function createFnInvoker (fns) {
2527
if (Array.isArray(fns)) {
2528
var cloned = fns.slice();
2529
for (var i = 0; i < cloned.length; i++) {
2530
- cloned[i].apply(null, arguments$1);
2531
}
2532
} else {
2533
// return handler return value for single handlers
2534
- return fns.apply(null, arguments)
2535
}
2536
}
2537
invoker.fns = fns;
@@ -2558,7 +2608,7 @@ function updateListeners (
2558
);
2559
} else if (isUndef(old)) {
2560
if (isUndef(cur.fns)) {
2561
- cur = on[name] = createFnInvoker(cur);
2562
}
2563
if (isTrue(event.once)) {
2564
cur = on[name] = createOnceHandler(event.name, cur, event.capture);
@@ -2769,313 +2819,89 @@ function normalizeArrayChildren (children, nestedIndex) {
2769
2770
/* */
2771
2772
- function ensureCtor (comp, base) {
2773
- if (
2774
- comp.__esModule ||
2775
- (hasSymbol && comp[Symbol.toStringTag] === 'Module')
2776
- ) {
2777
- comp = comp.default;
2778
}
2779
- return isObject(comp)
2780
- ? base.extend(comp)
2781
- : comp
2782
- }
2783
-
2784
- function createAsyncPlaceholder (
2785
- factory,
2786
- data,
2787
- context,
2788
- children,
2789
- tag
2790
- ) {
2791
- var node = createEmptyVNode();
2792
- node.asyncFactory = factory;
2793
- node.asyncMeta = { data: data, context: context, children: children, tag: tag };
2794
- return node
2795
}
2796
2797
- function resolveAsyncComponent (
2798
- factory,
2799
- baseCtor,
2800
- context
2801
- ) {
2802
- if (isTrue(factory.error) && isDef(factory.errorComp)) {
2803
- return factory.errorComp
2804
- }
2805
-
2806
- if (isDef(factory.resolved)) {
2807
- return factory.resolved
2808
- }
2809
-
2810
- if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
2811
- return factory.loadingComp
2812
- }
2813
-
2814
- if (isDef(factory.contexts)) {
2815
- // already pending
2816
- factory.contexts.push(context);
2817
- } else {
2818
- var contexts = factory.contexts = [context];
2819
- var sync = true;
2820
-
2821
- var forceRender = function (renderCompleted) {
2822
- for (var i = 0, l = contexts.length; i < l; i++) {
2823
- contexts[i].$forceUpdate();
2824
- }
2825
-
2826
- if (renderCompleted) {
2827
- contexts.length = 0;
2828
- }
2829
- };
2830
-
2831
- var resolve = once(function (res) {
2832
- // cache resolved
2833
- factory.resolved = ensureCtor(res, baseCtor);
2834
- // invoke callbacks only if this is not a synchronous resolve
2835
- // (async resolves are shimmed as synchronous during SSR)
2836
- if (!sync) {
2837
- forceRender(true);
2838
- }
2839
- });
2840
-
2841
- var reject = once(function (reason) {
2842
- process.env.NODE_ENV !== 'production' && warn(
2843
- "Failed to resolve async component: " + (String(factory)) +
2844
- (reason ? ("\nReason: " + reason) : '')
2845
- );
2846
- if (isDef(factory.errorComp)) {
2847
- factory.error = true;
2848
- forceRender(true);
2849
}
2850
});
2851
2852
- var res = factory(resolve, reject);
2853
-
2854
- if (isObject(res)) {
2855
- if (typeof res.then === 'function') {
2856
- // () => Promise
2857
- if (isUndef(factory.resolved)) {
2858
- res.then(resolve, reject);
2859
- }
2860
- } else if (isDef(res.component) && typeof res.component.then === 'function') {
2861
- res.component.then(resolve, reject);
2862
-
2863
- if (isDef(res.error)) {
2864
- factory.errorComp = ensureCtor(res.error, baseCtor);
2865
- }
2866
2867
- if (isDef(res.loading)) {
2868
- factory.loadingComp = ensureCtor(res.loading, baseCtor);
2869
- if (res.delay === 0) {
2870
- factory.loading = true;
2871
- } else {
2872
- setTimeout(function () {
2873
- if (isUndef(factory.resolved) && isUndef(factory.error)) {
2874
- factory.loading = true;
2875
- forceRender(false);
2876
- }
2877
- }, res.delay || 200);
2878
- }
2879
}
2880
-
2881
- if (isDef(res.timeout)) {
2882
- setTimeout(function () {
2883
- if (isUndef(factory.resolved)) {
2884
- reject(
2885
- process.env.NODE_ENV !== 'production'
2886
- ? ("timeout (" + (res.timeout) + "ms)")
2887
- : null
2888
- );
2889
- }
2890
- }, res.timeout);
2891
}
2892
}
2893
}
2894
-
2895
- sync = false;
2896
- // return in case resolved synchronously
2897
- return factory.loading
2898
- ? factory.loadingComp
2899
- : factory.resolved
2900
}
2901
}
2902
2903
/* */
2904
2905
- function isAsyncPlaceholder (node) {
2906
- return node.isComment && node.asyncFactory
2907
- }
2908
-
2909
- /* */
2910
-
2911
- function getFirstComponentChild (children) {
2912
- if (Array.isArray(children)) {
2913
- for (var i = 0; i < children.length; i++) {
2914
- var c = children[i];
2915
- if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
2916
- return c
2917
- }
2918
- }
2919
- }
2920
- }
2921
-
2922
- /* */
2923
2924
- /* */
2925
2926
- function initEvents (vm) {
2927
- vm._events = Object.create(null);
2928
- vm._hasHookEvent = false;
2929
- // init parent attached events
2930
- var listeners = vm.$options._parentListeners;
2931
- if (listeners) {
2932
- updateComponentListeners(vm, listeners);
2933
}
2934
- }
2935
-
2936
- var target;
2937
-
2938
- function add (event, fn) {
2939
- target.$on(event, fn);
2940
- }
2941
-
2942
- function remove$1 (event, fn) {
2943
- target.$off(event, fn);
2944
- }
2945
-
2946
- function createOnceHandler (event, fn) {
2947
- var _target = target;
2948
- return function onceHandler () {
2949
- var res = fn.apply(null, arguments);
2950
- if (res !== null) {
2951
- _target.$off(event, onceHandler);
2952
- }
2953
- }
2954
- }
2955
-
2956
- function updateComponentListeners (
2957
- vm,
2958
- listeners,
2959
- oldListeners
2960
- ) {
2961
- target = vm;
2962
- updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
2963
- target = undefined;
2964
- }
2965
-
2966
- function eventsMixin (Vue) {
2967
- var hookRE = /^hook:/;
2968
- Vue.prototype.$on = function (event, fn) {
2969
- var vm = this;
2970
- if (Array.isArray(event)) {
2971
- for (var i = 0, l = event.length; i < l; i++) {
2972
- vm.$on(event[i], fn);
2973
- }
2974
- } else {
2975
- (vm._events[event] || (vm._events[event] = [])).push(fn);
2976
- // optimize hook:event cost by using a boolean flag marked at registration
2977
- // instead of a hash lookup
2978
- if (hookRE.test(event)) {
2979
- vm._hasHookEvent = true;
2980
- }
2981
- }
2982
- return vm
2983
- };
2984
-
2985
- Vue.prototype.$once = function (event, fn) {
2986
- var vm = this;
2987
- function on () {
2988
- vm.$off(event, on);
2989
- fn.apply(vm, arguments);
2990
- }
2991
- on.fn = fn;
2992
- vm.$on(event, on);
2993
- return vm
2994
- };
2995
-
2996
- Vue.prototype.$off = function (event, fn) {
2997
- var vm = this;
2998
- // all
2999
- if (!arguments.length) {
3000
- vm._events = Object.create(null);
3001
- return vm
3002
- }
3003
- // array of events
3004
- if (Array.isArray(event)) {
3005
- for (var i = 0, l = event.length; i < l; i++) {
3006
- vm.$off(event[i], fn);
3007
- }
3008
- return vm
3009
- }
3010
- // specific event
3011
- var cbs = vm._events[event];
3012
- if (!cbs) {
3013
- return vm
3014
- }
3015
- if (!fn) {
3016
- vm._events[event] = null;
3017
- return vm
3018
- }
3019
- if (fn) {
3020
- // specific handler
3021
- var cb;
3022
- var i$1 = cbs.length;
3023
- while (i$1--) {
3024
- cb = cbs[i$1];
3025
- if (cb === fn || cb.fn === fn) {
3026
- cbs.splice(i$1, 1);
3027
- break
3028
- }
3029
- }
3030
- }
3031
- return vm
3032
- };
3033
-
3034
- Vue.prototype.$emit = function (event) {
3035
- var vm = this;
3036
- if (process.env.NODE_ENV !== 'production') {
3037
- var lowerCaseEvent = event.toLowerCase();
3038
- if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
3039
- tip(
3040
- "Event \"" + lowerCaseEvent + "\" is emitted in component " +
3041
- (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
3042
- "Note that HTML attributes are case-insensitive and you cannot use " +
3043
- "v-on to listen to camelCase events when using in-DOM templates. " +
3044
- "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
3045
- );
3046
- }
3047
- }
3048
- var cbs = vm._events[event];
3049
- if (cbs) {
3050
- cbs = cbs.length > 1 ? toArray(cbs) : cbs;
3051
- var args = toArray(arguments, 1);
3052
- for (var i = 0, l = cbs.length; i < l; i++) {
3053
- try {
3054
- cbs[i].apply(vm, args);
3055
- } catch (e) {
3056
- handleError(e, vm, ("event handler for \"" + event + "\""));
3057
- }
3058
- }
3059
- }
3060
- return vm
3061
- };
3062
- }
3063
-
3064
- /* */
3065
-
3066
-
3067
-
3068
- /**
3069
- * Runtime helper for resolving raw children VNodes into a slot object.
3070
- */
3071
- function resolveSlots (
3072
- children,
3073
- context
3074
- ) {
3075
var slots = {};
3076
- if (!children) {
3077
- return slots
3078
- }
3079
for (var i = 0, l = children.length; i < l; i++) {
3080
var child = children[i];
3081
var data = child.data;
@@ -3112,1977 +2938,2377 @@ function isWhitespace (node) {
3112
return (node.isComment && !node.asyncFactory) || node.text === ' '
3113
}
3114
3115
- function resolveScopedSlots (
3116
- fns, // see flow/vnode
3117
- res
3118
) {
3119
- res = res || {};
3120
- for (var i = 0; i < fns.length; i++) {
3121
- if (Array.isArray(fns[i])) {
3122
- resolveScopedSlots(fns[i], res);
3123
- } else {
3124
- res[fns[i].key] = fns[i].fn;
3125
}
3126
}
3127
return res
3128
}
3129
3130
- /* */
3131
3132
- var activeInstance = null;
3133
- var isUpdatingChildComponent = false;
3134
3135
- function setActiveInstance(vm) {
3136
- var prevActiveInstance = activeInstance;
3137
- activeInstance = vm;
3138
- return function () {
3139
- activeInstance = prevActiveInstance;
3140
}
3141
}
3142
3143
- function initLifecycle (vm) {
3144
- var options = vm.$options;
3145
3146
- // locate first non-abstract parent
3147
- var parent = options.parent;
3148
- if (parent && !options.abstract) {
3149
- while (parent.$options.abstract && parent.$parent) {
3150
- parent = parent.$parent;
3151
}
3152
- parent.$children.push(vm);
3153
}
3154
3155
- vm.$parent = parent;
3156
- vm.$root = parent ? parent.$root : vm;
3157
3158
- vm.$children = [];
3159
- vm.$refs = {};
3160
3161
- vm._watcher = null;
3162
- vm._inactive = null;
3163
- vm._directInactive = false;
3164
- vm._isMounted = false;
3165
- vm._isDestroyed = false;
3166
- vm._isBeingDestroyed = false;
3167
}
3168
3169
- function lifecycleMixin (Vue) {
3170
- Vue.prototype._update = function (vnode, hydrating) {
3171
- var vm = this;
3172
- var prevEl = vm.$el;
3173
- var prevVnode = vm._vnode;
3174
- var restoreActiveInstance = setActiveInstance(vm);
3175
- vm._vnode = vnode;
3176
- // Vue.prototype.__patch__ is injected in entry points
3177
- // based on the rendering backend used.
3178
- if (!prevVnode) {
3179
- // initial render
3180
- vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
3181
- } else {
3182
- // updates
3183
- vm.$el = vm.__patch__(prevVnode, vnode);
3184
- }
3185
- restoreActiveInstance();
3186
- // update __vue__ reference
3187
- if (prevEl) {
3188
- prevEl.__vue__ = null;
3189
- }
3190
- if (vm.$el) {
3191
- vm.$el.__vue__ = vm;
3192
- }
3193
- // if parent is an HOC, update its $el as well
3194
- if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
3195
- vm.$parent.$el = vm.$el;
3196
- }
3197
- // updated hook is called by the scheduler to ensure that children are
3198
- // updated in a parent's updated hook.
3199
- };
3200
3201
- Vue.prototype.$forceUpdate = function () {
3202
- var vm = this;
3203
- if (vm._watcher) {
3204
- vm._watcher.update();
3205
- }
3206
- };
3207
3208
- Vue.prototype.$destroy = function () {
3209
- var vm = this;
3210
- if (vm._isBeingDestroyed) {
3211
- return
3212
- }
3213
- callHook(vm, 'beforeDestroy');
3214
- vm._isBeingDestroyed = true;
3215
- // remove self from parent
3216
- var parent = vm.$parent;
3217
- if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
3218
- remove(parent.$children, vm);
3219
- }
3220
- // teardown watchers
3221
- if (vm._watcher) {
3222
- vm._watcher.teardown();
3223
- }
3224
- var i = vm._watchers.length;
3225
- while (i--) {
3226
- vm._watchers[i].teardown();
3227
- }
3228
- // remove reference from data ob
3229
- // frozen object may not have observer.
3230
- if (vm._data.__ob__) {
3231
- vm._data.__ob__.vmCount--;
3232
}
3233
- // call the last hook...
3234
- vm._isDestroyed = true;
3235
- // invoke destroy hooks on current rendered tree
3236
- vm.__patch__(vm._vnode, null);
3237
- // fire destroyed hook
3238
- callHook(vm, 'destroyed');
3239
- // turn off all instance listeners.
3240
- vm.$off();
3241
- // remove __vue__ reference
3242
- if (vm.$el) {
3243
- vm.$el.__vue__ = null;
3244
}
3245
- // release circular reference (#6759)
3246
- if (vm.$vnode) {
3247
- vm.$vnode.parent = null;
3248
}
3249
- };
3250
}
3251
3252
- function mountComponent (
3253
- vm,
3254
- el,
3255
- hydrating
3256
) {
3257
- vm.$el = el;
3258
- if (!vm.$options.render) {
3259
- vm.$options.render = createEmptyVNode;
3260
- if (process.env.NODE_ENV !== 'production') {
3261
- /* istanbul ignore if */
3262
- if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
3263
- vm.$options.el || el) {
3264
- warn(
3265
- 'You are using the runtime-only build of Vue where the template ' +
3266
- 'compiler is not available. Either pre-compile the templates into ' +
3267
- 'render functions, or use the compiler-included build.',
3268
- vm
3269
- );
3270
- } else {
3271
- warn(
3272
- 'Failed to mount component: template or render function not defined.',
3273
- vm
3274
- );
3275
}
3276
}
3277
}
3278
- callHook(vm, 'beforeMount');
3279
3280
- var updateComponent;
3281
- /* istanbul ignore if */
3282
- if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
3283
- updateComponent = function () {
3284
- var name = vm._name;
3285
- var id = vm._uid;
3286
- var startTag = "vue-perf-start:" + id;
3287
- var endTag = "vue-perf-end:" + id;
3288
3289
- mark(startTag);
3290
- var vnode = vm._render();
3291
- mark(endTag);
3292
- measure(("vue " + name + " render"), startTag, endTag);
3293
3294
- mark(startTag);
3295
- vm._update(vnode, hydrating);
3296
- mark(endTag);
3297
- measure(("vue " + name + " patch"), startTag, endTag);
3298
- };
3299
} else {
3300
- updateComponent = function () {
3301
- vm._update(vm._render(), hydrating);
3302
- };
3303
}
3304
3305
- // we set this to vm._watcher inside the watcher's constructor
3306
- // since the watcher's initial patch may call $forceUpdate (e.g. inside child
3307
- // component's mounted hook), which relies on vm._watcher being already defined
3308
- new Watcher(vm, updateComponent, noop, {
3309
- before: function before () {
3310
- if (vm._isMounted && !vm._isDestroyed) {
3311
- callHook(vm, 'beforeUpdate');
3312
- }
3313
}
3314
- }, true /* isRenderWatcher */);
3315
- hydrating = false;
3316
3317
- // manually mounted instance, call mounted on self
3318
- // mounted is called for render-created child components in its inserted hook
3319
- if (vm.$vnode == null) {
3320
- vm._isMounted = true;
3321
- callHook(vm, 'mounted');
3322
}
3323
- return vm
3324
}
3325
3326
- function updateChildComponent (
3327
- vm,
3328
propsData,
3329
- listeners,
3330
- parentVnode,
3331
- renderChildren
3332
) {
3333
- if (process.env.NODE_ENV !== 'production') {
3334
- isUpdatingChildComponent = true;
3335
}
3336
3337
- // determine whether component has slot children
3338
- // we need to do this before overwriting $options._renderChildren
3339
- var hasChildren = !!(
3340
- renderChildren || // has new static slots
3341
- vm.$options._renderChildren || // has old static slots
3342
- parentVnode.data.scopedSlots || // has new scoped slots
3343
- vm.$scopedSlots !== emptyObject // has old scoped slots
3344
);
3345
3346
- vm.$options._parentVnode = parentVnode;
3347
- vm.$vnode = parentVnode; // update vm's placeholder node without re-render
3348
-
3349
- if (vm._vnode) { // update child tree's parent
3350
- vm._vnode.parent = parentVnode;
3351
- }
3352
- vm.$options._renderChildren = renderChildren;
3353
-
3354
- // update $attrs and $listeners hash
3355
- // these are also reactive so they may trigger child update if the child
3356
- // used them during render
3357
- vm.$attrs = parentVnode.data.attrs || emptyObject;
3358
- vm.$listeners = listeners || emptyObject;
3359
3360
- // update props
3361
- if (propsData && vm.$options.props) {
3362
- toggleObserving(false);
3363
- var props = vm._props;
3364
- var propKeys = vm.$options._propKeys || [];
3365
- for (var i = 0; i < propKeys.length; i++) {
3366
- var key = propKeys[i];
3367
- var propOptions = vm.$options.props; // wtf flow?
3368
- props[key] = validateProp(key, propOptions, propsData, vm);
3369
}
3370
- toggleObserving(true);
3371
- // keep a copy of raw propsData
3372
- vm.$options.propsData = propsData;
3373
- }
3374
-
3375
- // update listeners
3376
- listeners = listeners || emptyObject;
3377
- var oldListeners = vm.$options._parentListeners;
3378
- vm.$options._parentListeners = listeners;
3379
- updateComponentListeners(vm, listeners, oldListeners);
3380
-
3381
- // resolve slots + force update if has children
3382
- if (hasChildren) {
3383
- vm.$slots = resolveSlots(renderChildren, parentVnode.context);
3384
- vm.$forceUpdate();
3385
}
3386
3387
if (process.env.NODE_ENV !== 'production') {
3388
- isUpdatingChildComponent = false;
3389
}
3390
}
3391
3392
- function isInInactiveTree (vm) {
3393
- while (vm && (vm = vm.$parent)) {
3394
- if (vm._inactive) { return true }
3395
}
3396
- return false
3397
}
3398
3399
- function activateChildComponent (vm, direct) {
3400
- if (direct) {
3401
- vm._directInactive = false;
3402
- if (isInInactiveTree(vm)) {
3403
- return
3404
}
3405
- } else if (vm._directInactive) {
3406
- return
3407
- }
3408
- if (vm._inactive || vm._inactive === null) {
3409
- vm._inactive = false;
3410
- for (var i = 0; i < vm.$children.length; i++) {
3411
- activateChildComponent(vm.$children[i]);
3412
}
3413
- callHook(vm, 'activated');
3414
- }
3415
- }
3416
3417
- function deactivateChildComponent (vm, direct) {
3418
- if (direct) {
3419
- vm._directInactive = true;
3420
- if (isInInactiveTree(vm)) {
3421
- return
3422
}
3423
}
3424
- if (!vm._inactive) {
3425
- vm._inactive = true;
3426
- for (var i = 0; i < vm.$children.length; i++) {
3427
- deactivateChildComponent(vm.$children[i]);
3428
}
3429
- callHook(vm, 'deactivated');
3430
}
3431
- }
3432
3433
- function callHook (vm, hook) {
3434
- // #7573 disable dep collection when invoking lifecycle hooks
3435
- pushTarget();
3436
- var handlers = vm.$options[hook];
3437
- if (handlers) {
3438
- for (var i = 0, j = handlers.length; i < j; i++) {
3439
- try {
3440
- handlers[i].call(vm);
3441
- } catch (e) {
3442
- handleError(e, vm, (hook + " hook"));
3443
- }
3444
}
3445
}
3446
- if (vm._hasHookEvent) {
3447
- vm.$emit('hook:' + hook);
3448
- }
3449
- popTarget();
3450
- }
3451
3452
- /* */
3453
3454
- var MAX_UPDATE_COUNT = 100;
3455
3456
- var queue = [];
3457
- var activatedChildren = [];
3458
- var has = {};
3459
- var circular = {};
3460
- var waiting = false;
3461
- var flushing = false;
3462
- var index = 0;
3463
3464
- /**
3465
- * Reset the scheduler's state.
3466
- */
3467
- function resetSchedulerState () {
3468
- index = queue.length = activatedChildren.length = 0;
3469
- has = {};
3470
- if (process.env.NODE_ENV !== 'production') {
3471
- circular = {};
3472
}
3473
- waiting = flushing = false;
3474
- }
3475
3476
- /**
3477
- * Flush both queues and run the watchers.
3478
- */
3479
- function flushSchedulerQueue () {
3480
- flushing = true;
3481
- var watcher, id;
3482
3483
- // Sort queue before flush.
3484
- // This ensures that:
3485
- // 1. Components are updated from parent to child. (because parent is always
3486
- // created before the child)
3487
- // 2. A component's user watchers are run before its render watcher (because
3488
- // user watchers are created before the render watcher)
3489
- // 3. If a component is destroyed during a parent component's watcher run,
3490
- // its watchers can be skipped.
3491
- queue.sort(function (a, b) { return a.id - b.id; });
3492
3493
- // do not cache length because more watchers might be pushed
3494
- // as we run existing watchers
3495
- for (index = 0; index < queue.length; index++) {
3496
- watcher = queue[index];
3497
- if (watcher.before) {
3498
- watcher.before();
3499
- }
3500
- id = watcher.id;
3501
- has[id] = null;
3502
- watcher.run();
3503
- // in dev build, check and stop circular updates.
3504
- if (process.env.NODE_ENV !== 'production' && has[id] != null) {
3505
- circular[id] = (circular[id] || 0) + 1;
3506
- if (circular[id] > MAX_UPDATE_COUNT) {
3507
- warn(
3508
- 'You may have an infinite update loop ' + (
3509
- watcher.user
3510
- ? ("in watcher with expression \"" + (watcher.expression) + "\"")
3511
- : "in a component render function."
3512
- ),
3513
- watcher.vm
3514
- );
3515
- break
3516
- }
3517
}
3518
}
3519
3520
- // keep copies of post queues before resetting state
3521
- var activatedQueue = activatedChildren.slice();
3522
- var updatedQueue = queue.slice();
3523
3524
- resetSchedulerState();
3525
3526
- // call component updated and activated hooks
3527
- callActivatedHooks(activatedQueue);
3528
- callUpdatedHooks(updatedQueue);
3529
3530
- // devtool hook
3531
- /* istanbul ignore if */
3532
- if (devtools && config.devtools) {
3533
- devtools.emit('flush');
3534
}
3535
}
3536
3537
- function callUpdatedHooks (queue) {
3538
- var i = queue.length;
3539
- while (i--) {
3540
- var watcher = queue[i];
3541
- var vm = watcher.vm;
3542
- if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
3543
- callHook(vm, 'updated');
3544
}
3545
}
3546
}
3547
3548
- /**
3549
- * Queue a kept-alive component that was activated during patch.
3550
- * The queue will be processed after the entire tree has been patched.
3551
- */
3552
- function queueActivatedComponent (vm) {
3553
- // setting _inactive to false here so that a render function can
3554
- // rely on checking whether it's in an inactive tree (e.g. router-view)
3555
- vm._inactive = false;
3556
- activatedChildren.push(vm);
3557
}
3558
3559
- function callActivatedHooks (queue) {
3560
- for (var i = 0; i < queue.length; i++) {
3561
- queue[i]._inactive = true;
3562
- activateChildComponent(queue[i], true /* true */);
3563
}
3564
}
3565
3566
- /**
3567
- * Push a watcher into the watcher queue.
3568
- * Jobs with duplicate IDs will be skipped unless it's
3569
- * pushed when the queue is being flushed.
3570
- */
3571
- function queueWatcher (watcher) {
3572
- var id = watcher.id;
3573
- if (has[id] == null) {
3574
- has[id] = true;
3575
- if (!flushing) {
3576
- queue.push(watcher);
3577
- } else {
3578
- // if already flushing, splice the watcher based on its id
3579
- // if already past its id, it will be run next immediately.
3580
- var i = queue.length - 1;
3581
- while (i > index && queue[i].id > watcher.id) {
3582
- i--;
3583
- }
3584
- queue.splice(i + 1, 0, watcher);
3585
- }
3586
- // queue the flush
3587
- if (!waiting) {
3588
- waiting = true;
3589
3590
- if (process.env.NODE_ENV !== 'production' && !config.async) {
3591
- flushSchedulerQueue();
3592
- return
3593
- }
3594
- nextTick(flushSchedulerQueue);
3595
- }
3596
}
3597
}
3598
3599
- /* */
3600
-
3601
-
3602
-
3603
- var uid$1 = 0;
3604
-
3605
- /**
3606
- * A watcher parses an expression, collects dependencies,
3607
- * and fires callback when the expression value changes.
3608
- * This is used for both the $watch() api and directives.
3609
- */
3610
- var Watcher = function Watcher (
3611
- vm,
3612
- expOrFn,
3613
- cb,
3614
- options,
3615
- isRenderWatcher
3616
) {
3617
- this.vm = vm;
3618
- if (isRenderWatcher) {
3619
- vm._watcher = this;
3620
}
3621
- vm._watchers.push(this);
3622
- // options
3623
- if (options) {
3624
- this.deep = !!options.deep;
3625
- this.user = !!options.user;
3626
- this.lazy = !!options.lazy;
3627
- this.sync = !!options.sync;
3628
- this.before = options.before;
3629
- } else {
3630
- this.deep = this.user = this.lazy = this.sync = false;
3631
}
3632
- this.cb = cb;
3633
- this.id = ++uid$1; // uid for batching
3634
- this.active = true;
3635
- this.dirty = this.lazy; // for lazy watchers
3636
- this.deps = [];
3637
- this.newDeps = [];
3638
- this.depIds = new _Set();
3639
- this.newDepIds = new _Set();
3640
- this.expression = process.env.NODE_ENV !== 'production'
3641
- ? expOrFn.toString()
3642
- : '';
3643
- // parse expression for getter
3644
- if (typeof expOrFn === 'function') {
3645
- this.getter = expOrFn;
3646
- } else {
3647
- this.getter = parsePath(expOrFn);
3648
- if (!this.getter) {
3649
- this.getter = noop;
3650
- process.env.NODE_ENV !== 'production' && warn(
3651
- "Failed watching path: \"" + expOrFn + "\" " +
3652
- 'Watcher only accepts simple dot-delimited paths. ' +
3653
- 'For full control, use a function instead.',
3654
- vm
3655
);
3656
}
3657
}
3658
- this.value = this.lazy
3659
- ? undefined
3660
- : this.get();
3661
- };
3662
-
3663
- /**
3664
- * Evaluate the getter, and re-collect dependencies.
3665
- */
3666
- Watcher.prototype.get = function get () {
3667
- pushTarget(this);
3668
- var value;
3669
- var vm = this.vm;
3670
- try {
3671
- value = this.getter.call(vm, vm);
3672
- } catch (e) {
3673
- if (this.user) {
3674
- handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
3675
} else {
3676
- throw e
3677
- }
3678
- } finally {
3679
- // "touch" every property so they are all tracked as
3680
- // dependencies for deep watching
3681
- if (this.deep) {
3682
- traverse(value);
3683
}
3684
- popTarget();
3685
- this.cleanupDeps();
3686
}
3687
- return value
3688
- };
3689
3690
- /**
3691
- * Add a dependency to this directive.
3692
- */
3693
- Watcher.prototype.addDep = function addDep (dep) {
3694
- var id = dep.id;
3695
- if (!this.newDepIds.has(id)) {
3696
- this.newDepIds.add(id);
3697
- this.newDeps.push(dep);
3698
- if (!this.depIds.has(id)) {
3699
- dep.addSub(this);
3700
}
3701
}
3702
- };
3703
3704
- /**
3705
- * Clean up for dependency collection.
3706
- */
3707
- Watcher.prototype.cleanupDeps = function cleanupDeps () {
3708
- var i = this.deps.length;
3709
- while (i--) {
3710
- var dep = this.deps[i];
3711
- if (!this.newDepIds.has(dep.id)) {
3712
- dep.removeSub(this);
3713
- }
3714
}
3715
- var tmp = this.depIds;
3716
- this.depIds = this.newDepIds;
3717
- this.newDepIds = tmp;
3718
- this.newDepIds.clear();
3719
- tmp = this.deps;
3720
- this.deps = this.newDeps;
3721
- this.newDeps = tmp;
3722
- this.newDeps.length = 0;
3723
- };
3724
3725
- /**
3726
- * Subscriber interface.
3727
- * Will be called when a dependency changes.
3728
- */
3729
- Watcher.prototype.update = function update () {
3730
/* istanbul ignore else */
3731
- if (this.lazy) {
3732
- this.dirty = true;
3733
- } else if (this.sync) {
3734
- this.run();
3735
} else {
3736
- queueWatcher(this);
3737
}
3738
- };
3739
3740
- /**
3741
- * Scheduler job interface.
3742
- * Will be called by the scheduler.
3743
- */
3744
- Watcher.prototype.run = function run () {
3745
- if (this.active) {
3746
- var value = this.get();
3747
- if (
3748
- value !== this.value ||
3749
- // Deep watchers and watchers on Object/Arrays should fire even
3750
- // when the value is the same, because the value may
3751
- // have mutated.
3752
- isObject(value) ||
3753
- this.deep
3754
- ) {
3755
- // set new value
3756
- var oldValue = this.value;
3757
- this.value = value;
3758
- if (this.user) {
3759
try {
3760
- this.cb.call(this.vm, value, oldValue);
3761
} catch (e) {
3762
- handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
3763
}
3764
} else {
3765
- this.cb.call(this.vm, value, oldValue);
3766
}
3767
}
3768
- }
3769
- };
3770
-
3771
- /**
3772
- * Evaluate the value of the watcher.
3773
- * This only gets called for lazy watchers.
3774
- */
3775
- Watcher.prototype.evaluate = function evaluate () {
3776
- this.value = this.get();
3777
- this.dirty = false;
3778
- };
3779
-
3780
- /**
3781
- * Depend on all deps collected by this watcher.
3782
- */
3783
- Watcher.prototype.depend = function depend () {
3784
- var i = this.deps.length;
3785
- while (i--) {
3786
- this.deps[i].depend();
3787
- }
3788
- };
3789
-
3790
- /**
3791
- * Remove self from all dependencies' subscriber list.
3792
- */
3793
- Watcher.prototype.teardown = function teardown () {
3794
- if (this.active) {
3795
- // remove self from vm's watcher list
3796
- // this is a somewhat expensive operation so we skip it
3797
- // if the vm is being destroyed.
3798
- if (!this.vm._isBeingDestroyed) {
3799
- remove(this.vm._watchers, this);
3800
}
3801
- var i = this.deps.length;
3802
- while (i--) {
3803
- this.deps[i].removeSub(this);
3804
}
3805
- this.active = false;
3806
- }
3807
- };
3808
3809
/* */
3810
3811
- var sharedPropertyDefinition = {
3812
- enumerable: true,
3813
- configurable: true,
3814
- get: noop,
3815
- set: noop
3816
- };
3817
3818
- function proxy (target, sourceKey, key) {
3819
- sharedPropertyDefinition.get = function proxyGetter () {
3820
- return this[sourceKey][key]
3821
- };
3822
- sharedPropertyDefinition.set = function proxySetter (val) {
3823
- this[sourceKey][key] = val;
3824
- };
3825
- Object.defineProperty(target, key, sharedPropertyDefinition);
3826
}
3827
3828
- function initState (vm) {
3829
- vm._watchers = [];
3830
- var opts = vm.$options;
3831
- if (opts.props) { initProps(vm, opts.props); }
3832
- if (opts.methods) { initMethods(vm, opts.methods); }
3833
- if (opts.data) {
3834
- initData(vm);
3835
- } else {
3836
- observe(vm._data = {}, true /* asRootData */);
3837
}
3838
- if (opts.computed) { initComputed(vm, opts.computed); }
3839
- if (opts.watch && opts.watch !== nativeWatch) {
3840
- initWatch(vm, opts.watch);
3841
}
3842
- }
3843
3844
- function initProps (vm, propsOptions) {
3845
- var propsData = vm.$options.propsData || {};
3846
- var props = vm._props = {};
3847
- // cache prop keys so that future props updates can iterate using Array
3848
- // instead of dynamic object key enumeration.
3849
- var keys = vm.$options._propKeys = [];
3850
- var isRoot = !vm.$parent;
3851
- // root instance props should be converted
3852
- if (!isRoot) {
3853
- toggleObserving(false);
3854
}
3855
- var loop = function ( key ) {
3856
- keys.push(key);
3857
- var value = validateProp(key, propsOptions, propsData, vm);
3858
- /* istanbul ignore else */
3859
- if (process.env.NODE_ENV !== 'production') {
3860
- var hyphenatedKey = hyphenate(key);
3861
- if (isReservedAttribute(hyphenatedKey) ||
3862
- config.isReservedAttr(hyphenatedKey)) {
3863
- warn(
3864
- ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
3865
- vm
3866
- );
3867
}
3868
- defineReactive$1(props, key, value, function () {
3869
- if (!isRoot && !isUpdatingChildComponent) {
3870
- warn(
3871
- "Avoid mutating a prop directly since the value will be " +
3872
- "overwritten whenever the parent component re-renders. " +
3873
- "Instead, use a data or computed property based on the prop's " +
3874
- "value. Prop being mutated: \"" + key + "\"",
3875
- vm
3876
- );
3877
}
3878
- });
3879
- } else {
3880
- defineReactive$1(props, key, value);
3881
- }
3882
- // static props are already proxied on the component's prototype
3883
- // during Vue.extend(). We only need to proxy props defined at
3884
- // instantiation here.
3885
- if (!(key in vm)) {
3886
- proxy(vm, "_props", key);
3887
}
3888
- };
3889
3890
- for (var key in propsOptions) loop( key );
3891
- toggleObserving(true);
3892
}
3893
3894
- function initData (vm) {
3895
- var data = vm.$options.data;
3896
- data = vm._data = typeof data === 'function'
3897
- ? getData(data, vm)
3898
- : data || {};
3899
- if (!isPlainObject(data)) {
3900
- data = {};
3901
- process.env.NODE_ENV !== 'production' && warn(
3902
- 'data functions should return an object:\n' +
3903
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
3904
- vm
3905
- );
3906
- }
3907
- // proxy data on instance
3908
- var keys = Object.keys(data);
3909
- var props = vm.$options.props;
3910
- var methods = vm.$options.methods;
3911
- var i = keys.length;
3912
- while (i--) {
3913
- var key = keys[i];
3914
- if (process.env.NODE_ENV !== 'production') {
3915
- if (methods && hasOwn(methods, key)) {
3916
- warn(
3917
- ("Method \"" + key + "\" has already been defined as a data property."),
3918
- vm
3919
- );
3920
}
3921
}
3922
- if (props && hasOwn(props, key)) {
3923
- process.env.NODE_ENV !== 'production' && warn(
3924
- "The data property \"" + key + "\" is already declared as a prop. " +
3925
- "Use prop default value instead.",
3926
- vm
3927
- );
3928
- } else if (!isReserved(key)) {
3929
- proxy(vm, "_data", key);
3930
- }
3931
}
3932
- // observe data
3933
- observe(data, true /* asRootData */);
3934
}
3935
3936
- function getData (data, vm) {
3937
- // #7573 disable dep collection when invoking data getters
3938
- pushTarget();
3939
- try {
3940
- return data.call(vm, vm)
3941
- } catch (e) {
3942
- handleError(e, vm, "data()");
3943
- return {}
3944
- } finally {
3945
- popTarget();
3946
}
3947
}
3948
3949
- var computedWatcherOptions = { lazy: true };
3950
-
3951
- function initComputed (vm, computed) {
3952
- // $flow-disable-line
3953
- var watchers = vm._computedWatchers = Object.create(null);
3954
- // computed properties are just getters during SSR
3955
- var isSSR = isServerRendering();
3956
3957
- for (var key in computed) {
3958
- var userDef = computed[key];
3959
- var getter = typeof userDef === 'function' ? userDef : userDef.get;
3960
- if (process.env.NODE_ENV !== 'production' && getter == null) {
3961
- warn(
3962
- ("Getter is missing for computed property \"" + key + "\"."),
3963
- vm
3964
- );
3965
- }
3966
3967
- if (!isSSR) {
3968
- // create internal watcher for the computed property.
3969
- watchers[key] = new Watcher(
3970
- vm,
3971
- getter || noop,
3972
- noop,
3973
- computedWatcherOptions
3974
- );
3975
- }
3976
3977
- // component-defined computed properties are already defined on the
3978
- // component prototype. We only need to define computed properties defined
3979
- // at instantiation here.
3980
- if (!(key in vm)) {
3981
- defineComputed(vm, key, userDef);
3982
- } else if (process.env.NODE_ENV !== 'production') {
3983
- if (key in vm.$data) {
3984
- warn(("The computed property \"" + key + "\" is already defined in data."), vm);
3985
- } else if (vm.$options.props && key in vm.$options.props) {
3986
- warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
3987
- }
3988
}
3989
}
3990
}
3991
3992
- function defineComputed (
3993
- target,
3994
- key,
3995
- userDef
3996
) {
3997
- var shouldCache = !isServerRendering();
3998
- if (typeof userDef === 'function') {
3999
- sharedPropertyDefinition.get = shouldCache
4000
- ? createComputedGetter(key)
4001
- : createGetterInvoker(userDef);
4002
- sharedPropertyDefinition.set = noop;
4003
- } else {
4004
- sharedPropertyDefinition.get = userDef.get
4005
- ? shouldCache && userDef.cache !== false
4006
- ? createComputedGetter(key)
4007
- : createGetterInvoker(userDef.get)
4008
- : noop;
4009
- sharedPropertyDefinition.set = userDef.set || noop;
4010
- }
4011
- if (process.env.NODE_ENV !== 'production' &&
4012
- sharedPropertyDefinition.set === noop) {
4013
- sharedPropertyDefinition.set = function () {
4014
- warn(
4015
- ("Computed property \"" + key + "\" was assigned to but it has no setter."),
4016
- this
4017
- );
4018
- };
4019
- }
4020
- Object.defineProperty(target, key, sharedPropertyDefinition);
4021
}
4022
4023
- function createComputedGetter (key) {
4024
- return function computedGetter () {
4025
- var watcher = this._computedWatchers && this._computedWatchers[key];
4026
- if (watcher) {
4027
- if (watcher.dirty) {
4028
- watcher.evaluate();
4029
}
4030
- if (Dep.target) {
4031
- watcher.depend();
4032
}
4033
- return watcher.value
4034
}
4035
- }
4036
- }
4037
4038
- function createGetterInvoker(fn) {
4039
- return function computedGetter () {
4040
- return fn.call(this, this)
4041
- }
4042
- }
4043
4044
- function initMethods (vm, methods) {
4045
- var props = vm.$options.props;
4046
- for (var key in methods) {
4047
if (process.env.NODE_ENV !== 'production') {
4048
- if (typeof methods[key] !== 'function') {
4049
- warn(
4050
- "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
4051
- "Did you reference the function correctly?",
4052
- vm
4053
- );
4054
- }
4055
- if (props && hasOwn(props, key)) {
4056
- warn(
4057
- ("Method \"" + key + "\" has already been defined as a prop."),
4058
- vm
4059
- );
4060
- }
4061
- if ((key in vm) && isReserved(key)) {
4062
- warn(
4063
- "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
4064
- "Avoid defining component methods that start with _ or $."
4065
);
4066
}
4067
}
4068
- vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
4069
- }
4070
- }
4071
-
4072
- function initWatch (vm, watch) {
4073
- for (var key in watch) {
4074
- var handler = watch[key];
4075
- if (Array.isArray(handler)) {
4076
- for (var i = 0; i < handler.length; i++) {
4077
- createWatcher(vm, key, handler[i]);
4078
}
4079
- } else {
4080
- createWatcher(vm, key, handler);
4081
}
4082
- }
4083
}
4084
4085
- function createWatcher (
4086
- vm,
4087
- expOrFn,
4088
- handler,
4089
- options
4090
- ) {
4091
- if (isPlainObject(handler)) {
4092
- options = handler;
4093
- handler = handler.handler;
4094
- }
4095
- if (typeof handler === 'string') {
4096
- handler = vm[handler];
4097
}
4098
- return vm.$watch(expOrFn, handler, options)
4099
}
4100
4101
- function stateMixin (Vue) {
4102
- // flow somehow has problems with directly declared definition object
4103
- // when using Object.defineProperty, so we have to procedurally build up
4104
- // the object here.
4105
- var dataDef = {};
4106
- dataDef.get = function () { return this._data };
4107
- var propsDef = {};
4108
- propsDef.get = function () { return this._props };
4109
- if (process.env.NODE_ENV !== 'production') {
4110
- dataDef.set = function () {
4111
- warn(
4112
- 'Avoid replacing instance root $data. ' +
4113
- 'Use nested data properties instead.',
4114
- this
4115
- );
4116
- };
4117
- propsDef.set = function () {
4118
- warn("$props is readonly.", this);
4119
- };
4120
}
4121
- Object.defineProperty(Vue.prototype, '$data', dataDef);
4122
- Object.defineProperty(Vue.prototype, '$props', propsDef);
4123
4124
- Vue.prototype.$set = set;
4125
- Vue.prototype.$delete = del;
4126
4127
- Vue.prototype.$watch = function (
4128
- expOrFn,
4129
- cb,
4130
- options
4131
- ) {
4132
var vm = this;
4133
- if (isPlainObject(cb)) {
4134
- return createWatcher(vm, expOrFn, cb, options)
4135
}
4136
- options = options || {};
4137
- options.user = true;
4138
- var watcher = new Watcher(vm, expOrFn, cb, options);
4139
- if (options.immediate) {
4140
- try {
4141
- cb.call(vm, watcher.value);
4142
- } catch (error) {
4143
- handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
4144
- }
4145
}
4146
- return function unwatchFn () {
4147
- watcher.teardown();
4148
}
4149
};
4150
- }
4151
-
4152
- /* */
4153
-
4154
- function initProvide (vm) {
4155
- var provide = vm.$options.provide;
4156
- if (provide) {
4157
- vm._provided = typeof provide === 'function'
4158
- ? provide.call(vm)
4159
- : provide;
4160
- }
4161
- }
4162
-
4163
- function initInjections (vm) {
4164
- var result = resolveInject(vm.$options.inject, vm);
4165
- if (result) {
4166
- toggleObserving(false);
4167
- Object.keys(result).forEach(function (key) {
4168
- /* istanbul ignore else */
4169
- if (process.env.NODE_ENV !== 'production') {
4170
- defineReactive$1(vm, key, result[key], function () {
4171
- warn(
4172
- "Avoid mutating an injected value directly since the changes will be " +
4173
- "overwritten whenever the provided component re-renders. " +
4174
- "injection being mutated: \"" + key + "\"",
4175
- vm
4176
- );
4177
- });
4178
- } else {
4179
- defineReactive$1(vm, key, result[key]);
4180
- }
4181
- });
4182
- toggleObserving(true);
4183
- }
4184
- }
4185
4186
- function resolveInject (inject, vm) {
4187
- if (inject) {
4188
- // inject is :any because flow is not smart enough to figure out cached
4189
- var result = Object.create(null);
4190
- var keys = hasSymbol
4191
- ? Reflect.ownKeys(inject).filter(function (key) {
4192
- /* istanbul ignore next */
4193
- return Object.getOwnPropertyDescriptor(inject, key).enumerable
4194
- })
4195
- : Object.keys(inject);
4196
4197
- for (var i = 0; i < keys.length; i++) {
4198
- var key = keys[i];
4199
- var provideKey = inject[key].from;
4200
- var source = vm;
4201
- while (source) {
4202
- if (source._provided && hasOwn(source._provided, provideKey)) {
4203
- result[key] = source._provided[provideKey];
4204
- break
4205
- }
4206
- source = source.$parent;
4207
- }
4208
- if (!source) {
4209
- if ('default' in inject[key]) {
4210
- var provideDefault = inject[key].default;
4211
- result[key] = typeof provideDefault === 'function'
4212
- ? provideDefault.call(vm)
4213
- : provideDefault;
4214
- } else if (process.env.NODE_ENV !== 'production') {
4215
- warn(("Injection \"" + key + "\" not found"), vm);
4216
- }
4217
- }
4218
}
4219
- return result
4220
- }
4221
- }
4222
-
4223
- /* */
4224
-
4225
- /**
4226
- * Runtime helper for rendering v-for lists.
4227
- */
4228
- function renderList (
4229
- val,
4230
- render
4231
- ) {
4232
- var ret, i, l, keys, key;
4233
- if (Array.isArray(val) || typeof val === 'string') {
4234
- ret = new Array(val.length);
4235
- for (i = 0, l = val.length; i < l; i++) {
4236
- ret[i] = render(val[i], i);
4237
}
4238
- } else if (typeof val === 'number') {
4239
- ret = new Array(val);
4240
- for (i = 0; i < val; i++) {
4241
- ret[i] = render(i + 1, i);
4242
}
4243
- } else if (isObject(val)) {
4244
- keys = Object.keys(val);
4245
- ret = new Array(keys.length);
4246
- for (i = 0, l = keys.length; i < l; i++) {
4247
- key = keys[i];
4248
- ret[i] = render(val[key], key, i);
4249
}
4250
- }
4251
- if (!isDef(ret)) {
4252
- ret = [];
4253
- }
4254
- (ret)._isVList = true;
4255
- return ret
4256
}
4257
4258
- /* */
4259
-
4260
- /**
4261
- * Runtime helper for rendering <slot>
4262
- */
4263
- function renderSlot (
4264
- name,
4265
- fallback,
4266
- props,
4267
- bindObject
4268
) {
4269
- var scopedSlotFn = this.$scopedSlots[name];
4270
- var nodes;
4271
- if (scopedSlotFn) { // scoped slot
4272
- props = props || {};
4273
- if (bindObject) {
4274
- if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
4275
warn(
4276
- 'slot v-bind without argument expects an Object',
4277
- this
4278
);
4279
}
4280
- props = extend(extend({}, bindObject), props);
4281
}
4282
- nodes = scopedSlotFn(props) || fallback;
4283
- } else {
4284
- nodes = this.$slots[name] || fallback;
4285
}
4286
4287
- var target = props && props.slot;
4288
- if (target) {
4289
- return this.$createElement('template', { slot: target }, nodes)
4290
- } else {
4291
- return nodes
4292
- }
4293
- }
4294
4295
- /* */
4296
4297
- /**
4298
- * Runtime helper for resolving filters
4299
- */
4300
- function resolveFilter (id) {
4301
- return resolveAsset(this.$options, 'filters', id, true) || identity
4302
- }
4303
4304
- /* */
4305
4306
- function isKeyNotMatch (expect, actual) {
4307
- if (Array.isArray(expect)) {
4308
- return expect.indexOf(actual) === -1
4309
- } else {
4310
- return expect !== actual
4311
}
4312
}
4313
4314
- /**
4315
- * Runtime helper for checking keyCodes from config.
4316
- * exposed as Vue.prototype._k
4317
- * passing in eventKeyName as last argument separately for backwards compat
4318
- */
4319
- function checkKeyCodes (
4320
- eventKeyCode,
4321
- key,
4322
- builtInKeyCode,
4323
- eventKeyName,
4324
- builtInKeyName
4325
) {
4326
- var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
4327
- if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
4328
- return isKeyNotMatch(builtInKeyName, eventKeyName)
4329
- } else if (mappedKeyCode) {
4330
- return isKeyNotMatch(mappedKeyCode, eventKeyCode)
4331
- } else if (eventKeyName) {
4332
- return hyphenate(eventKeyName) !== key
4333
}
4334
- }
4335
4336
- /* */
4337
4338
- /**
4339
- * Runtime helper for merging v-bind="object" into a VNode's data.
4340
- */
4341
- function bindObjectProps (
4342
- data,
4343
- tag,
4344
- value,
4345
- asProp,
4346
- isSync
4347
- ) {
4348
- if (value) {
4349
- if (!isObject(value)) {
4350
- process.env.NODE_ENV !== 'production' && warn(
4351
- 'v-bind without argument expects an Object or Array value',
4352
- this
4353
- );
4354
- } else {
4355
- if (Array.isArray(value)) {
4356
- value = toObject(value);
4357
- }
4358
- var hash;
4359
- var loop = function ( key ) {
4360
- if (
4361
- key === 'class' ||
4362
- key === 'style' ||
4363
- isReservedAttribute(key)
4364
- ) {
4365
- hash = data;
4366
- } else {
4367
- var type = data.attrs && data.attrs.type;
4368
- hash = asProp || config.mustUseProp(tag, type, key)
4369
- ? data.domProps || (data.domProps = {})
4370
- : data.attrs || (data.attrs = {});
4371
- }
4372
- var camelizedKey = camelize(key);
4373
- if (!(key in hash) && !(camelizedKey in hash)) {
4374
- hash[key] = value[key];
4375
4376
- if (isSync) {
4377
- var on = data.on || (data.on = {});
4378
- on[("update:" + camelizedKey)] = function ($event) {
4379
- value[key] = $event;
4380
- };
4381
- }
4382
- }
4383
- };
4384
4385
- for (var key in value) loop( key );
4386
}
4387
}
4388
- return data
4389
- }
4390
4391
- /* */
4392
4393
- /**
4394
- * Runtime helper for rendering static trees.
4395
- */
4396
- function renderStatic (
4397
- index,
4398
- isInFor
4399
- ) {
4400
- var cached = this._staticTrees || (this._staticTrees = []);
4401
- var tree = cached[index];
4402
- // if has already-rendered static tree and not inside v-for,
4403
- // we can reuse the same tree.
4404
- if (tree && !isInFor) {
4405
- return tree
4406
}
4407
- // otherwise, render a fresh tree.
4408
- tree = cached[index] = this.$options.staticRenderFns[index].call(
4409
- this._renderProxy,
4410
- null,
4411
- this // for render fns generated for functional component templates
4412
- );
4413
- markStatic(tree, ("__static__" + index), false);
4414
- return tree
4415
}
4416
4417
- /**
4418
- * Runtime helper for v-once.
4419
- * Effectively it means marking the node as static with a unique key.
4420
- */
4421
- function markOnce (
4422
- tree,
4423
- index,
4424
- key
4425
- ) {
4426
- markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
4427
- return tree
4428
}
4429
4430
- function markStatic (
4431
- tree,
4432
- key,
4433
- isOnce
4434
- ) {
4435
- if (Array.isArray(tree)) {
4436
- for (var i = 0; i < tree.length; i++) {
4437
- if (tree[i] && typeof tree[i] !== 'string') {
4438
- markStaticNode(tree[i], (key + "_" + i), isOnce);
4439
- }
4440
}
4441
- } else {
4442
- markStaticNode(tree, key, isOnce);
4443
}
4444
}
4445
4446
- function markStaticNode (node, key, isOnce) {
4447
- node.isStatic = true;
4448
- node.key = key;
4449
- node.isOnce = isOnce;
4450
}
4451
4452
- /* */
4453
-
4454
- function bindObjectListeners (data, value) {
4455
- if (value) {
4456
- if (!isPlainObject(value)) {
4457
- process.env.NODE_ENV !== 'production' && warn(
4458
- 'v-on without argument expects an Object value',
4459
- this
4460
- );
4461
- } else {
4462
- var on = data.on = data.on ? extend({}, data.on) : {};
4463
- for (var key in value) {
4464
- var existing = on[key];
4465
- var ours = value[key];
4466
- on[key] = existing ? [].concat(existing, ours) : ours;
4467
- }
4468
}
4469
}
4470
- return data
4471
}
4472
4473
/* */
4474
4475
- function installRenderHelpers (target) {
4476
- target._o = markOnce;
4477
- target._n = toNumber;
4478
- target._s = toString;
4479
- target._l = renderList;
4480
- target._t = renderSlot;
4481
- target._q = looseEqual;
4482
- target._i = looseIndexOf;
4483
- target._m = renderStatic;
4484
- target._f = resolveFilter;
4485
- target._k = checkKeyCodes;
4486
- target._b = bindObjectProps;
4487
- target._v = createTextVNode;
4488
- target._e = createEmptyVNode;
4489
- target._u = resolveScopedSlots;
4490
- target._g = bindObjectListeners;
4491
- }
4492
4493
- /* */
4494
4495
- function FunctionalRenderContext (
4496
- data,
4497
- props,
4498
- children,
4499
- parent,
4500
- Ctor
4501
- ) {
4502
- var options = Ctor.options;
4503
- // ensure the createElement function in functional components
4504
- // gets a unique context - this is necessary for correct named slot check
4505
- var contextVm;
4506
- if (hasOwn(parent, '_uid')) {
4507
- contextVm = Object.create(parent);
4508
- // $flow-disable-line
4509
- contextVm._original = parent;
4510
- } else {
4511
- // the context vm passed in is a functional context as well.
4512
- // in this case we want to make sure we are able to get a hold to the
4513
- // real context instance.
4514
- contextVm = parent;
4515
- // $flow-disable-line
4516
- parent = parent._original;
4517
}
4518
- var isCompiled = isTrue(options._compiled);
4519
- var needNormalization = !isCompiled;
4520
4521
- this.data = data;
4522
- this.props = props;
4523
- this.children = children;
4524
- this.parent = parent;
4525
- this.listeners = data.on || emptyObject;
4526
- this.injections = resolveInject(options.inject, parent);
4527
- this.slots = function () { return resolveSlots(children, parent); };
4528
4529
- // support for compiled functional template
4530
- if (isCompiled) {
4531
- // exposing $options for renderStatic()
4532
- this.$options = options;
4533
- // pre-resolve slots for renderSlot()
4534
- this.$slots = this.slots();
4535
- this.$scopedSlots = data.scopedSlots || emptyObject;
4536
- }
4537
4538
- if (options._scopeId) {
4539
- this._c = function (a, b, c, d) {
4540
- var vnode = createElement(contextVm, a, b, c, d, needNormalization);
4541
- if (vnode && !Array.isArray(vnode)) {
4542
- vnode.fnScopeId = options._scopeId;
4543
- vnode.fnContext = parent;
4544
- }
4545
- return vnode
4546
- };
4547
- } else {
4548
- this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
4549
- }
4550
}
4551
4552
- installRenderHelpers(FunctionalRenderContext.prototype);
4553
4554
- function createFunctionalComponent (
4555
- Ctor,
4556
- propsData,
4557
- data,
4558
- contextVm,
4559
- children
4560
- ) {
4561
- var options = Ctor.options;
4562
- var props = {};
4563
- var propOptions = options.props;
4564
- if (isDef(propOptions)) {
4565
- for (var key in propOptions) {
4566
- props[key] = validateProp(key, propOptions, propsData || emptyObject);
4567
}
4568
- } else {
4569
- if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
4570
- if (isDef(data.props)) { mergeProps(props, data.props); }
4571
}
4572
4573
- var renderContext = new FunctionalRenderContext(
4574
- data,
4575
- props,
4576
- children,
4577
- contextVm,
4578
- Ctor
4579
- );
4580
4581
- var vnode = options.render.call(null, renderContext._c, renderContext);
4582
4583
- if (vnode instanceof VNode) {
4584
- return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
4585
- } else if (Array.isArray(vnode)) {
4586
- var vnodes = normalizeChildren(vnode) || [];
4587
- var res = new Array(vnodes.length);
4588
- for (var i = 0; i < vnodes.length; i++) {
4589
- res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
4590
- }
4591
- return res
4592
}
4593
}
4594
4595
- function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
4596
- // #7817 clone node before setting fnContext, otherwise if the node is reused
4597
- // (e.g. it was from a cached normal slot) the fnContext causes named slots
4598
- // that should not be matched to match.
4599
- var clone = cloneVNode(vnode);
4600
- clone.fnContext = contextVm;
4601
- clone.fnOptions = options;
4602
- if (process.env.NODE_ENV !== 'production') {
4603
- (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
4604
}
4605
- if (data.slot) {
4606
- (clone.data || (clone.data = {})).slot = data.slot;
4607
}
4608
- return clone
4609
}
4610
4611
- function mergeProps (to, from) {
4612
- for (var key in from) {
4613
- to[camelize(key)] = from[key];
4614
}
4615
}
4616
4617
/* */
4618
4619
- /* */
4620
4621
- /* */
4622
4623
- /* */
4624
4625
- // inline hooks to be invoked on component VNodes during patch
4626
- var componentVNodeHooks = {
4627
- init: function init (vnode, hydrating) {
4628
- if (
4629
- vnode.componentInstance &&
4630
- !vnode.componentInstance._isDestroyed &&
4631
- vnode.data.keepAlive
4632
- ) {
4633
- // kept-alive components, treat as a patch
4634
- var mountedNode = vnode; // work around flow
4635
- componentVNodeHooks.prepatch(mountedNode, mountedNode);
4636
- } else {
4637
- var child = vnode.componentInstance = createComponentInstanceForVnode(
4638
- vnode,
4639
- activeInstance
4640
);
4641
- child.$mount(hydrating ? vnode.elm : undefined, hydrating);
4642
}
4643
- },
4644
4645
- prepatch: function prepatch (oldVnode, vnode) {
4646
- var options = vnode.componentOptions;
4647
- var child = vnode.componentInstance = oldVnode.componentInstance;
4648
- updateChildComponent(
4649
- child,
4650
- options.propsData, // updated props
4651
- options.listeners, // updated listeners
4652
- vnode, // new parent vnode
4653
- options.children // new children
4654
- );
4655
- },
4656
4657
- insert: function insert (vnode) {
4658
- var context = vnode.context;
4659
- var componentInstance = vnode.componentInstance;
4660
- if (!componentInstance._isMounted) {
4661
- componentInstance._isMounted = true;
4662
- callHook(componentInstance, 'mounted');
4663
}
4664
- if (vnode.data.keepAlive) {
4665
- if (context._isMounted) {
4666
- // vue-router#1212
4667
- // During updates, a kept-alive component's child components may
4668
- // change, so directly walking the tree here may call activated hooks
4669
- // on incorrect children. Instead we push them into a queue which will
4670
- // be processed after the whole patch process ended.
4671
- queueActivatedComponent(componentInstance);
4672
- } else {
4673
- activateChildComponent(componentInstance, true /* direct */);
4674
- }
4675
}
4676
- },
4677
4678
- destroy: function destroy (vnode) {
4679
- var componentInstance = vnode.componentInstance;
4680
- if (!componentInstance._isDestroyed) {
4681
- if (!vnode.data.keepAlive) {
4682
- componentInstance.$destroy();
4683
} else {
4684
- deactivateChildComponent(componentInstance, true /* direct */);
4685
}
4686
}
4687
}
4688
};
4689
4690
- var hooksToMerge = Object.keys(componentVNodeHooks);
4691
-
4692
- function createComponent (
4693
- Ctor,
4694
- data,
4695
- context,
4696
- children,
4697
- tag
4698
- ) {
4699
- if (isUndef(Ctor)) {
4700
- return
4701
- }
4702
-
4703
- var baseCtor = context.$options._base;
4704
4705
- // plain options object: turn it into a constructor
4706
- if (isObject(Ctor)) {
4707
- Ctor = baseCtor.extend(Ctor);
4708
}
4709
4710
- // if at this stage it's not a constructor or an async component factory,
4711
- // reject.
4712
- if (typeof Ctor !== 'function') {
4713
- if (process.env.NODE_ENV !== 'production') {
4714
- warn(("Invalid Component definition: " + (String(Ctor))), context);
4715
}
4716
- return
4717
- }
4718
-
4719
- // async component
4720
- var asyncFactory;
4721
- if (isUndef(Ctor.cid)) {
4722
- asyncFactory = Ctor;
4723
- Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
4724
- if (Ctor === undefined) {
4725
- // return a placeholder node for async component, which is rendered
4726
- // as a comment node but preserves all the raw information for the node.
4727
- // the information will be used for async server-rendering and hydration.
4728
- return createAsyncPlaceholder(
4729
- asyncFactory,
4730
- data,
4731
- context,
4732
- children,
4733
- tag
4734
- )
4735
}
4736
}
4737
4738
- data = data || {};
4739
-
4740
- // resolve constructor options in case global mixins are applied after
4741
- // component constructor creation
4742
- resolveConstructorOptions(Ctor);
4743
4744
- // transform component v-model data into props & events
4745
- if (isDef(data.model)) {
4746
- transformModel(Ctor.options, data);
4747
- }
4748
4749
- // extract props
4750
- var propsData = extractPropsFromVNodeData(data, Ctor, tag);
4751
4752
- // functional component
4753
- if (isTrue(Ctor.options.functional)) {
4754
- return createFunctionalComponent(Ctor, propsData, data, context, children)
4755
}
4756
-
4757
- // extract listeners, since these needs to be treated as
4758
- // child component listeners instead of DOM listeners
4759
- var listeners = data.on;
4760
- // replace with listeners with .native modifier
4761
- // so it gets processed during parent component patch.
4762
- data.on = data.nativeOn;
4763
-
4764
- if (isTrue(Ctor.options.abstract)) {
4765
- // abstract components do not keep anything
4766
- // other than props & listeners & slot
4767
-
4768
- // work around flow
4769
- var slot = data.slot;
4770
- data = {};
4771
- if (slot) {
4772
- data.slot = slot;
4773
- }
4774
}
4775
-
4776
- // install component management hooks onto the placeholder node
4777
- installComponentHooks(data);
4778
-
4779
- // return a placeholder vnode
4780
- var name = Ctor.options.name || tag;
4781
- var vnode = new VNode(
4782
- ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
4783
- data, undefined, undefined, undefined, context,
4784
- { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
4785
- asyncFactory
4786
- );
4787
-
4788
- return vnode
4789
}
4790
4791
- function createComponentInstanceForVnode (
4792
- vnode, // we know it's MountedComponentVNode but flow doesn't
4793
- parent // activeInstance in lifecycle state
4794
- ) {
4795
- var options = {
4796
- _isComponent: true,
4797
- _parentVnode: vnode,
4798
- parent: parent
4799
};
4800
- // check inline-template render functions
4801
- var inlineTemplate = vnode.data.inlineTemplate;
4802
- if (isDef(inlineTemplate)) {
4803
- options.render = inlineTemplate.render;
4804
- options.staticRenderFns = inlineTemplate.staticRenderFns;
4805
- }
4806
- return new vnode.componentOptions.Ctor(options)
4807
}
4808
4809
- function installComponentHooks (data) {
4810
- var hooks = data.hook || (data.hook = {});
4811
- for (var i = 0; i < hooksToMerge.length; i++) {
4812
- var key = hooksToMerge[i];
4813
- var existing = hooks[key];
4814
- var toMerge = componentVNodeHooks[key];
4815
- if (existing !== toMerge && !(existing && existing._merged)) {
4816
- hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
4817
}
4818
}
4819
}
4820
4821
- function mergeHook$1 (f1, f2) {
4822
- var merged = function (a, b) {
4823
- // flow complains about extra args which is why we use any
4824
- f1(a, b);
4825
- f2(a, b);
4826
- };
4827
- merged._merged = true;
4828
- return merged
4829
- }
4830
-
4831
- // transform component v-model info (value and callback) into
4832
- // prop and event handler respectively.
4833
- function transformModel (options, data) {
4834
- var prop = (options.model && options.model.prop) || 'value';
4835
- var event = (options.model && options.model.event) || 'input'
4836
- ;(data.props || (data.props = {}))[prop] = data.model.value;
4837
- var on = data.on || (data.on = {});
4838
- var existing = on[event];
4839
- var callback = data.model.callback;
4840
- if (isDef(existing)) {
4841
- if (
4842
- Array.isArray(existing)
4843
- ? existing.indexOf(callback) === -1
4844
- : existing !== callback
4845
- ) {
4846
- on[event] = [callback].concat(existing);
4847
- }
4848
- } else {
4849
- on[event] = callback;
4850
}
4851
}
4852
4853
- /* */
4854
4855
- var SIMPLE_NORMALIZE = 1;
4856
- var ALWAYS_NORMALIZE = 2;
4857
4858
- // wrapper function for providing a more flexible interface
4859
- // without getting yelled at by flow
4860
- function createElement (
4861
- context,
4862
- tag,
4863
- data,
4864
- children,
4865
- normalizationType,
4866
- alwaysNormalize
4867
- ) {
4868
- if (Array.isArray(data) || isPrimitive(data)) {
4869
- normalizationType = children;
4870
- children = data;
4871
- data = undefined;
4872
- }
4873
- if (isTrue(alwaysNormalize)) {
4874
- normalizationType = ALWAYS_NORMALIZE;