UNPKG

239 kBJavaScriptView Raw
1/*!
2 * Vue.js v2.6.12
3 * (c) 2014-2020 Evan You
4 * Released under the MIT License.
5 */
6(function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8 typeof define === 'function' && define.amd ? define(factory) :
9 (global = global || self, global.Vue = factory());
10}(this, function () { 'use strict';
11
12 /* */
13
14 var emptyObject = Object.freeze({});
15
16 // These helpers produce better VM code in JS engines due to their
17 // explicitness and function inlining.
18 function isUndef (v) {
19 return v === undefined || v === null
20 }
21
22 function isDef (v) {
23 return v !== undefined && v !== null
24 }
25
26 function isTrue (v) {
27 return v === true
28 }
29
30 function isFalse (v) {
31 return v === false
32 }
33
34 /**
35 * Check if value is primitive.
36 */
37 function isPrimitive (value) {
38 return (
39 typeof value === 'string' ||
40 typeof value === 'number' ||
41 // $flow-disable-line
42 typeof value === 'symbol' ||
43 typeof value === 'boolean'
44 )
45 }
46
47 /**
48 * Quick object check - this is primarily used to tell
49 * Objects from primitive values when we know the value
50 * is a JSON-compliant type.
51 */
52 function isObject (obj) {
53 return obj !== null && typeof obj === 'object'
54 }
55
56 /**
57 * Get the raw type string of a value, e.g., [object Object].
58 */
59 var _toString = Object.prototype.toString;
60
61 function toRawType (value) {
62 return _toString.call(value).slice(8, -1)
63 }
64
65 /**
66 * Strict object type check. Only returns true
67 * for plain JavaScript objects.
68 */
69 function isPlainObject (obj) {
70 return _toString.call(obj) === '[object Object]'
71 }
72
73 function isRegExp (v) {
74 return _toString.call(v) === '[object RegExp]'
75 }
76
77 /**
78 * Check if val is a valid array index.
79 */
80 function isValidArrayIndex (val) {
81 var n = parseFloat(String(val));
82 return n >= 0 && Math.floor(n) === n && isFinite(val)
83 }
84
85 function isPromise (val) {
86 return (
87 isDef(val) &&
88 typeof val.then === 'function' &&
89 typeof val.catch === 'function'
90 )
91 }
92
93 /**
94 * Convert a value to a string that is actually rendered.
95 */
96 function toString (val) {
97 return val == null
98 ? ''
99 : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
100 ? JSON.stringify(val, null, 2)
101 : String(val)
102 }
103
104 /**
105 * Convert an input value to a number for persistence.
106 * If the conversion fails, return original string.
107 */
108 function toNumber (val) {
109 var n = parseFloat(val);
110 return isNaN(n) ? val : n
111 }
112
113 /**
114 * Make a map and return a function for checking if a key
115 * is in that map.
116 */
117 function makeMap (
118 str,
119 expectsLowerCase
120 ) {
121 var map = Object.create(null);
122 var list = str.split(',');
123 for (var i = 0; i < list.length; i++) {
124 map[list[i]] = true;
125 }
126 return expectsLowerCase
127 ? function (val) { return map[val.toLowerCase()]; }
128 : function (val) { return map[val]; }
129 }
130
131 /**
132 * Check if a tag is a built-in tag.
133 */
134 var isBuiltInTag = makeMap('slot,component', true);
135
136 /**
137 * Check if an attribute is a reserved attribute.
138 */
139 var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
140
141 /**
142 * Remove an item from an array.
143 */
144 function remove (arr, item) {
145 if (arr.length) {
146 var index = arr.indexOf(item);
147 if (index > -1) {
148 return arr.splice(index, 1)
149 }
150 }
151 }
152
153 /**
154 * Check whether an object has the property.
155 */
156 var hasOwnProperty = Object.prototype.hasOwnProperty;
157 function hasOwn (obj, key) {
158 return hasOwnProperty.call(obj, key)
159 }
160
161 /**
162 * Create a cached version of a pure function.
163 */
164 function cached (fn) {
165 var cache = Object.create(null);
166 return (function cachedFn (str) {
167 var hit = cache[str];
168 return hit || (cache[str] = fn(str))
169 })
170 }
171
172 /**
173 * Camelize a hyphen-delimited string.
174 */
175 var camelizeRE = /-(\w)/g;
176 var camelize = cached(function (str) {
177 return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
178 });
179
180 /**
181 * Capitalize a string.
182 */
183 var capitalize = cached(function (str) {
184 return str.charAt(0).toUpperCase() + str.slice(1)
185 });
186
187 /**
188 * Hyphenate a camelCase string.
189 */
190 var hyphenateRE = /\B([A-Z])/g;
191 var hyphenate = cached(function (str) {
192 return str.replace(hyphenateRE, '-$1').toLowerCase()
193 });
194
195 /**
196 * Simple bind polyfill for environments that do not support it,
197 * e.g., PhantomJS 1.x. Technically, we don't need this anymore
198 * since native bind is now performant enough in most browsers.
199 * But removing it would mean breaking code that was able to run in
200 * PhantomJS 1.x, so this must be kept for backward compatibility.
201 */
202
203 /* istanbul ignore next */
204 function polyfillBind (fn, ctx) {
205 function boundFn (a) {
206 var l = arguments.length;
207 return l
208 ? l > 1
209 ? fn.apply(ctx, arguments)
210 : fn.call(ctx, a)
211 : fn.call(ctx)
212 }
213
214 boundFn._length = fn.length;
215 return boundFn
216 }
217
218 function nativeBind (fn, ctx) {
219 return fn.bind(ctx)
220 }
221
222 var bind = Function.prototype.bind
223 ? nativeBind
224 : polyfillBind;
225
226 /**
227 * Convert an Array-like object to a real Array.
228 */
229 function toArray (list, start) {
230 start = start || 0;
231 var i = list.length - start;
232 var ret = new Array(i);
233 while (i--) {
234 ret[i] = list[i + start];
235 }
236 return ret
237 }
238
239 /**
240 * Mix properties into target object.
241 */
242 function extend (to, _from) {
243 for (var key in _from) {
244 to[key] = _from[key];
245 }
246 return to
247 }
248
249 /**
250 * Merge an Array of Objects into a single Object.
251 */
252 function toObject (arr) {
253 var res = {};
254 for (var i = 0; i < arr.length; i++) {
255 if (arr[i]) {
256 extend(res, arr[i]);
257 }
258 }
259 return res
260 }
261
262 /* eslint-disable no-unused-vars */
263
264 /**
265 * Perform no operation.
266 * Stubbing args to make Flow happy without leaving useless transpiled code
267 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
268 */
269 function noop (a, b, c) {}
270
271 /**
272 * Always return false.
273 */
274 var no = function (a, b, c) { return false; };
275
276 /* eslint-enable no-unused-vars */
277
278 /**
279 * Return the same value.
280 */
281 var identity = function (_) { return _; };
282
283 /**
284 * Check if two values are loosely equal - that is,
285 * if they are plain objects, do they have the same shape?
286 */
287 function looseEqual (a, b) {
288 if (a === b) { return true }
289 var isObjectA = isObject(a);
290 var isObjectB = isObject(b);
291 if (isObjectA && isObjectB) {
292 try {
293 var isArrayA = Array.isArray(a);
294 var isArrayB = Array.isArray(b);
295 if (isArrayA && isArrayB) {
296 return a.length === b.length && a.every(function (e, i) {
297 return looseEqual(e, b[i])
298 })
299 } else if (a instanceof Date && b instanceof Date) {
300 return a.getTime() === b.getTime()
301 } else if (!isArrayA && !isArrayB) {
302 var keysA = Object.keys(a);
303 var keysB = Object.keys(b);
304 return keysA.length === keysB.length && keysA.every(function (key) {
305 return looseEqual(a[key], b[key])
306 })
307 } else {
308 /* istanbul ignore next */
309 return false
310 }
311 } catch (e) {
312 /* istanbul ignore next */
313 return false
314 }
315 } else if (!isObjectA && !isObjectB) {
316 return String(a) === String(b)
317 } else {
318 return false
319 }
320 }
321
322 /**
323 * Return the first index at which a loosely equal value can be
324 * found in the array (if value is a plain object, the array must
325 * contain an object of the same shape), or -1 if it is not present.
326 */
327 function looseIndexOf (arr, val) {
328 for (var i = 0; i < arr.length; i++) {
329 if (looseEqual(arr[i], val)) { return i }
330 }
331 return -1
332 }
333
334 /**
335 * Ensure a function is called only once.
336 */
337 function once (fn) {
338 var called = false;
339 return function () {
340 if (!called) {
341 called = true;
342 fn.apply(this, arguments);
343 }
344 }
345 }
346
347 var SSR_ATTR = 'data-server-rendered';
348
349 var ASSET_TYPES = [
350 'component',
351 'directive',
352 'filter'
353 ];
354
355 var LIFECYCLE_HOOKS = [
356 'beforeCreate',
357 'created',
358 'beforeMount',
359 'mounted',
360 'beforeUpdate',
361 'updated',
362 'beforeDestroy',
363 'destroyed',
364 'activated',
365 'deactivated',
366 'errorCaptured',
367 'serverPrefetch'
368 ];
369
370 /* */
371
372
373
374 var config = ({
375 /**
376 * Option merge strategies (used in core/util/options)
377 */
378 // $flow-disable-line
379 optionMergeStrategies: Object.create(null),
380
381 /**
382 * Whether to suppress warnings.
383 */
384 silent: false,
385
386 /**
387 * Show production mode tip message on boot?
388 */
389 productionTip: "development" !== 'production',
390
391 /**
392 * Whether to enable devtools
393 */
394 devtools: "development" !== 'production',
395
396 /**
397 * Whether to record perf
398 */
399 performance: false,
400
401 /**
402 * Error handler for watcher errors
403 */
404 errorHandler: null,
405
406 /**
407 * Warn handler for watcher warns
408 */
409 warnHandler: null,
410
411 /**
412 * Ignore certain custom elements
413 */
414 ignoredElements: [],
415
416 /**
417 * Custom user key aliases for v-on
418 */
419 // $flow-disable-line
420 keyCodes: Object.create(null),
421
422 /**
423 * Check if a tag is reserved so that it cannot be registered as a
424 * component. This is platform-dependent and may be overwritten.
425 */
426 isReservedTag: no,
427
428 /**
429 * Check if an attribute is reserved so that it cannot be used as a component
430 * prop. This is platform-dependent and may be overwritten.
431 */
432 isReservedAttr: no,
433
434 /**
435 * Check if a tag is an unknown element.
436 * Platform-dependent.
437 */
438 isUnknownElement: no,
439
440 /**
441 * Get the namespace of an element
442 */
443 getTagNamespace: noop,
444
445 /**
446 * Parse the real tag name for the specific platform.
447 */
448 parsePlatformTagName: identity,
449
450 /**
451 * Check if an attribute must be bound using property, e.g. value
452 * Platform-dependent.
453 */
454 mustUseProp: no,
455
456 /**
457 * Perform updates asynchronously. Intended to be used by Vue Test Utils
458 * This will significantly reduce performance if set to false.
459 */
460 async: true,
461
462 /**
463 * Exposed for legacy reasons
464 */
465 _lifecycleHooks: LIFECYCLE_HOOKS
466 });
467
468 /* */
469
470 /**
471 * unicode letters used for parsing html tags, component names and property paths.
472 * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
473 * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
474 */
475 var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
476
477 /**
478 * Check if a string starts with $ or _
479 */
480 function isReserved (str) {
481 var c = (str + '').charCodeAt(0);
482 return c === 0x24 || c === 0x5F
483 }
484
485 /**
486 * Define a property.
487 */
488 function def (obj, key, val, enumerable) {
489 Object.defineProperty(obj, key, {
490 value: val,
491 enumerable: !!enumerable,
492 writable: true,
493 configurable: true
494 });
495 }
496
497 /**
498 * Parse simple path.
499 */
500 var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
501 function parsePath (path) {
502 if (bailRE.test(path)) {
503 return
504 }
505 var segments = path.split('.');
506 return function (obj) {
507 for (var i = 0; i < segments.length; i++) {
508 if (!obj) { return }
509 obj = obj[segments[i]];
510 }
511 return obj
512 }
513 }
514
515 /* */
516
517 // can we use __proto__?
518 var hasProto = '__proto__' in {};
519
520 // Browser environment sniffing
521 var inBrowser = typeof window !== 'undefined';
522 var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
523 var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
524 var UA = inBrowser && window.navigator.userAgent.toLowerCase();
525 var isIE = UA && /msie|trident/.test(UA);
526 var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
527 var isEdge = UA && UA.indexOf('edge/') > 0;
528 var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
529 var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
530 var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
531 var isPhantomJS = UA && /phantomjs/.test(UA);
532 var isFF = UA && UA.match(/firefox\/(\d+)/);
533
534 // Firefox has a "watch" function on Object.prototype...
535 var nativeWatch = ({}).watch;
536
537 var supportsPassive = false;
538 if (inBrowser) {
539 try {
540 var opts = {};
541 Object.defineProperty(opts, 'passive', ({
542 get: function get () {
543 /* istanbul ignore next */
544 supportsPassive = true;
545 }
546 })); // https://github.com/facebook/flow/issues/285
547 window.addEventListener('test-passive', null, opts);
548 } catch (e) {}
549 }
550
551 // this needs to be lazy-evaled because vue may be required before
552 // vue-server-renderer can set VUE_ENV
553 var _isServer;
554 var isServerRendering = function () {
555 if (_isServer === undefined) {
556 /* istanbul ignore if */
557 if (!inBrowser && !inWeex && typeof global !== 'undefined') {
558 // detect presence of vue-server-renderer and avoid
559 // Webpack shimming the process
560 _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
561 } else {
562 _isServer = false;
563 }
564 }
565 return _isServer
566 };
567
568 // detect devtools
569 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
570
571 /* istanbul ignore next */
572 function isNative (Ctor) {
573 return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
574 }
575
576 var hasSymbol =
577 typeof Symbol !== 'undefined' && isNative(Symbol) &&
578 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
579
580 var _Set;
581 /* istanbul ignore if */ // $flow-disable-line
582 if (typeof Set !== 'undefined' && isNative(Set)) {
583 // use native Set when available.
584 _Set = Set;
585 } else {
586 // a non-standard Set polyfill that only works with primitive keys.
587 _Set = /*@__PURE__*/(function () {
588 function Set () {
589 this.set = Object.create(null);
590 }
591 Set.prototype.has = function has (key) {
592 return this.set[key] === true
593 };
594 Set.prototype.add = function add (key) {
595 this.set[key] = true;
596 };
597 Set.prototype.clear = function clear () {
598 this.set = Object.create(null);
599 };
600
601 return Set;
602 }());
603 }
604
605 /* */
606
607 var warn = noop;
608 var tip = noop;
609 var generateComponentTrace = (noop); // work around flow check
610 var formatComponentName = (noop);
611
612 {
613 var hasConsole = typeof console !== 'undefined';
614 var classifyRE = /(?:^|[-_])(\w)/g;
615 var classify = function (str) { return str
616 .replace(classifyRE, function (c) { return c.toUpperCase(); })
617 .replace(/[-_]/g, ''); };
618
619 warn = function (msg, vm) {
620 var trace = vm ? generateComponentTrace(vm) : '';
621
622 if (config.warnHandler) {
623 config.warnHandler.call(null, msg, vm, trace);
624 } else if (hasConsole && (!config.silent)) {
625 console.error(("[Vue warn]: " + msg + trace));
626 }
627 };
628
629 tip = function (msg, vm) {
630 if (hasConsole && (!config.silent)) {
631 console.warn("[Vue tip]: " + msg + (
632 vm ? generateComponentTrace(vm) : ''
633 ));
634 }
635 };
636
637 formatComponentName = function (vm, includeFile) {
638 if (vm.$root === vm) {
639 return '<Root>'
640 }
641 var options = typeof vm === 'function' && vm.cid != null
642 ? vm.options
643 : vm._isVue
644 ? vm.$options || vm.constructor.options
645 : vm;
646 var name = options.name || options._componentTag;
647 var file = options.__file;
648 if (!name && file) {
649 var match = file.match(/([^/\\]+)\.vue$/);
650 name = match && match[1];
651 }
652
653 return (
654 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
655 (file && includeFile !== false ? (" at " + file) : '')
656 )
657 };
658
659 var repeat = function (str, n) {
660 var res = '';
661 while (n) {
662 if (n % 2 === 1) { res += str; }
663 if (n > 1) { str += str; }
664 n >>= 1;
665 }
666 return res
667 };
668
669 generateComponentTrace = function (vm) {
670 if (vm._isVue && vm.$parent) {
671 var tree = [];
672 var currentRecursiveSequence = 0;
673 while (vm) {
674 if (tree.length > 0) {
675 var last = tree[tree.length - 1];
676 if (last.constructor === vm.constructor) {
677 currentRecursiveSequence++;
678 vm = vm.$parent;
679 continue
680 } else if (currentRecursiveSequence > 0) {
681 tree[tree.length - 1] = [last, currentRecursiveSequence];
682 currentRecursiveSequence = 0;
683 }
684 }
685 tree.push(vm);
686 vm = vm.$parent;
687 }
688 return '\n\nfound in\n\n' + tree
689 .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
690 ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
691 : formatComponentName(vm))); })
692 .join('\n')
693 } else {
694 return ("\n\n(found in " + (formatComponentName(vm)) + ")")
695 }
696 };
697 }
698
699 /* */
700
701 var uid = 0;
702
703 /**
704 * A dep is an observable that can have multiple
705 * directives subscribing to it.
706 */
707 var Dep = function Dep () {
708 this.id = uid++;
709 this.subs = [];
710 };
711
712 Dep.prototype.addSub = function addSub (sub) {
713 this.subs.push(sub);
714 };
715
716 Dep.prototype.removeSub = function removeSub (sub) {
717 remove(this.subs, sub);
718 };
719
720 Dep.prototype.depend = function depend () {
721 if (Dep.target) {
722 Dep.target.addDep(this);
723 }
724 };
725
726 Dep.prototype.notify = function notify () {
727 // stabilize the subscriber list first
728 var subs = this.subs.slice();
729 if (!config.async) {
730 // subs aren't sorted in scheduler if not running async
731 // we need to sort them now to make sure they fire in correct
732 // order
733 subs.sort(function (a, b) { return a.id - b.id; });
734 }
735 for (var i = 0, l = subs.length; i < l; i++) {
736 subs[i].update();
737 }
738 };
739
740 // The current target watcher being evaluated.
741 // This is globally unique because only one watcher
742 // can be evaluated at a time.
743 Dep.target = null;
744 var targetStack = [];
745
746 function pushTarget (target) {
747 targetStack.push(target);
748 Dep.target = target;
749 }
750
751 function popTarget () {
752 targetStack.pop();
753 Dep.target = targetStack[targetStack.length - 1];
754 }
755
756 /* */
757
758 var VNode = function VNode (
759 tag,
760 data,
761 children,
762 text,
763 elm,
764 context,
765 componentOptions,
766 asyncFactory
767 ) {
768 this.tag = tag;
769 this.data = data;
770 this.children = children;
771 this.text = text;
772 this.elm = elm;
773 this.ns = undefined;
774 this.context = context;
775 this.fnContext = undefined;
776 this.fnOptions = undefined;
777 this.fnScopeId = undefined;
778 this.key = data && data.key;
779 this.componentOptions = componentOptions;
780 this.componentInstance = undefined;
781 this.parent = undefined;
782 this.raw = false;
783 this.isStatic = false;
784 this.isRootInsert = true;
785 this.isComment = false;
786 this.isCloned = false;
787 this.isOnce = false;
788 this.asyncFactory = asyncFactory;
789 this.asyncMeta = undefined;
790 this.isAsyncPlaceholder = false;
791 };
792
793 var prototypeAccessors = { child: { configurable: true } };
794
795 // DEPRECATED: alias for componentInstance for backwards compat.
796 /* istanbul ignore next */
797 prototypeAccessors.child.get = function () {
798 return this.componentInstance
799 };
800
801 Object.defineProperties( VNode.prototype, prototypeAccessors );
802
803 var createEmptyVNode = function (text) {
804 if ( text === void 0 ) text = '';
805
806 var node = new VNode();
807 node.text = text;
808 node.isComment = true;
809 return node
810 };
811
812 function createTextVNode (val) {
813 return new VNode(undefined, undefined, undefined, String(val))
814 }
815
816 // optimized shallow clone
817 // used for static nodes and slot nodes because they may be reused across
818 // multiple renders, cloning them avoids errors when DOM manipulations rely
819 // on their elm reference.
820 function cloneVNode (vnode) {
821 var cloned = new VNode(
822 vnode.tag,
823 vnode.data,
824 // #7975
825 // clone children array to avoid mutating original in case of cloning
826 // a child.
827 vnode.children && vnode.children.slice(),
828 vnode.text,
829 vnode.elm,
830 vnode.context,
831 vnode.componentOptions,
832 vnode.asyncFactory
833 );
834 cloned.ns = vnode.ns;
835 cloned.isStatic = vnode.isStatic;
836 cloned.key = vnode.key;
837 cloned.isComment = vnode.isComment;
838 cloned.fnContext = vnode.fnContext;
839 cloned.fnOptions = vnode.fnOptions;
840 cloned.fnScopeId = vnode.fnScopeId;
841 cloned.asyncMeta = vnode.asyncMeta;
842 cloned.isCloned = true;
843 return cloned
844 }
845
846 /*
847 * not type checking this file because flow doesn't play well with
848 * dynamically accessing methods on Array prototype
849 */
850
851 var arrayProto = Array.prototype;
852 var arrayMethods = Object.create(arrayProto);
853
854 var methodsToPatch = [
855 'push',
856 'pop',
857 'shift',
858 'unshift',
859 'splice',
860 'sort',
861 'reverse'
862 ];
863
864 /**
865 * Intercept mutating methods and emit events
866 */
867 methodsToPatch.forEach(function (method) {
868 // cache original method
869 var original = arrayProto[method];
870 def(arrayMethods, method, function mutator () {
871 var args = [], len = arguments.length;
872 while ( len-- ) args[ len ] = arguments[ len ];
873
874 var result = original.apply(this, args);
875 var ob = this.__ob__;
876 var inserted;
877 switch (method) {
878 case 'push':
879 case 'unshift':
880 inserted = args;
881 break
882 case 'splice':
883 inserted = args.slice(2);
884 break
885 }
886 if (inserted) { ob.observeArray(inserted); }
887 // notify change
888 ob.dep.notify();
889 return result
890 });
891 });
892
893 /* */
894
895 var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
896
897 /**
898 * In some cases we may want to disable observation inside a component's
899 * update computation.
900 */
901 var shouldObserve = true;
902
903 function toggleObserving (value) {
904 shouldObserve = value;
905 }
906
907 /**
908 * Observer class that is attached to each observed
909 * object. Once attached, the observer converts the target
910 * object's property keys into getter/setters that
911 * collect dependencies and dispatch updates.
912 */
913 var Observer = function Observer (value) {
914 this.value = value;
915 this.dep = new Dep();
916 this.vmCount = 0;
917 def(value, '__ob__', this);
918 if (Array.isArray(value)) {
919 if (hasProto) {
920 protoAugment(value, arrayMethods);
921 } else {
922 copyAugment(value, arrayMethods, arrayKeys);
923 }
924 this.observeArray(value);
925 } else {
926 this.walk(value);
927 }
928 };
929
930 /**
931 * Walk through all properties and convert them into
932 * getter/setters. This method should only be called when
933 * value type is Object.
934 */
935 Observer.prototype.walk = function walk (obj) {
936 var keys = Object.keys(obj);
937 for (var i = 0; i < keys.length; i++) {
938 defineReactive$$1(obj, keys[i]);
939 }
940 };
941
942 /**
943 * Observe a list of Array items.
944 */
945 Observer.prototype.observeArray = function observeArray (items) {
946 for (var i = 0, l = items.length; i < l; i++) {
947 observe(items[i]);
948 }
949 };
950
951 // helpers
952
953 /**
954 * Augment a target Object or Array by intercepting
955 * the prototype chain using __proto__
956 */
957 function protoAugment (target, src) {
958 /* eslint-disable no-proto */
959 target.__proto__ = src;
960 /* eslint-enable no-proto */
961 }
962
963 /**
964 * Augment a target Object or Array by defining
965 * hidden properties.
966 */
967 /* istanbul ignore next */
968 function copyAugment (target, src, keys) {
969 for (var i = 0, l = keys.length; i < l; i++) {
970 var key = keys[i];
971 def(target, key, src[key]);
972 }
973 }
974
975 /**
976 * Attempt to create an observer instance for a value,
977 * returns the new observer if successfully observed,
978 * or the existing observer if the value already has one.
979 */
980 function observe (value, asRootData) {
981 if (!isObject(value) || value instanceof VNode) {
982 return
983 }
984 var ob;
985 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
986 ob = value.__ob__;
987 } else if (
988 shouldObserve &&
989 !isServerRendering() &&
990 (Array.isArray(value) || isPlainObject(value)) &&
991 Object.isExtensible(value) &&
992 !value._isVue
993 ) {
994 ob = new Observer(value);
995 }
996 if (asRootData && ob) {
997 ob.vmCount++;
998 }
999 return ob
1000 }
1001
1002 /**
1003 * Define a reactive property on an Object.
1004 */
1005 function defineReactive$$1 (
1006 obj,
1007 key,
1008 val,
1009 customSetter,
1010 shallow
1011 ) {
1012 var dep = new Dep();
1013
1014 var property = Object.getOwnPropertyDescriptor(obj, key);
1015 if (property && property.configurable === false) {
1016 return
1017 }
1018
1019 // cater for pre-defined getter/setters
1020 var getter = property && property.get;
1021 var setter = property && property.set;
1022 if ((!getter || setter) && arguments.length === 2) {
1023 val = obj[key];
1024 }
1025
1026 var childOb = !shallow && observe(val);
1027 Object.defineProperty(obj, key, {
1028 enumerable: true,
1029 configurable: true,
1030 get: function reactiveGetter () {
1031 var value = getter ? getter.call(obj) : val;
1032 if (Dep.target) {
1033 dep.depend();
1034 if (childOb) {
1035 childOb.dep.depend();
1036 if (Array.isArray(value)) {
1037 dependArray(value);
1038 }
1039 }
1040 }
1041 return value
1042 },
1043 set: function reactiveSetter (newVal) {
1044 var value = getter ? getter.call(obj) : val;
1045 /* eslint-disable no-self-compare */
1046 if (newVal === value || (newVal !== newVal && value !== value)) {
1047 return
1048 }
1049 /* eslint-enable no-self-compare */
1050 if (customSetter) {
1051 customSetter();
1052 }
1053 // #7981: for accessor properties without setter
1054 if (getter && !setter) { return }
1055 if (setter) {
1056 setter.call(obj, newVal);
1057 } else {
1058 val = newVal;
1059 }
1060 childOb = !shallow && observe(newVal);
1061 dep.notify();
1062 }
1063 });
1064 }
1065
1066 /**
1067 * Set a property on an object. Adds the new property and
1068 * triggers change notification if the property doesn't
1069 * already exist.
1070 */
1071 function set (target, key, val) {
1072 if (isUndef(target) || isPrimitive(target)
1073 ) {
1074 warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
1075 }
1076 if (Array.isArray(target) && isValidArrayIndex(key)) {
1077 target.length = Math.max(target.length, key);
1078 target.splice(key, 1, val);
1079 return val
1080 }
1081 if (key in target && !(key in Object.prototype)) {
1082 target[key] = val;
1083 return val
1084 }
1085 var ob = (target).__ob__;
1086 if (target._isVue || (ob && ob.vmCount)) {
1087 warn(
1088 'Avoid adding reactive properties to a Vue instance or its root $data ' +
1089 'at runtime - declare it upfront in the data option.'
1090 );
1091 return val
1092 }
1093 if (!ob) {
1094 target[key] = val;
1095 return val
1096 }
1097 defineReactive$$1(ob.value, key, val);
1098 ob.dep.notify();
1099 return val
1100 }
1101
1102 /**
1103 * Delete a property and trigger change if necessary.
1104 */
1105 function del (target, key) {
1106 if (isUndef(target) || isPrimitive(target)
1107 ) {
1108 warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
1109 }
1110 if (Array.isArray(target) && isValidArrayIndex(key)) {
1111 target.splice(key, 1);
1112 return
1113 }
1114 var ob = (target).__ob__;
1115 if (target._isVue || (ob && ob.vmCount)) {
1116 warn(
1117 'Avoid deleting properties on a Vue instance or its root $data ' +
1118 '- just set it to null.'
1119 );
1120 return
1121 }
1122 if (!hasOwn(target, key)) {
1123 return
1124 }
1125 delete target[key];
1126 if (!ob) {
1127 return
1128 }
1129 ob.dep.notify();
1130 }
1131
1132 /**
1133 * Collect dependencies on array elements when the array is touched, since
1134 * we cannot intercept array element access like property getters.
1135 */
1136 function dependArray (value) {
1137 for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
1138 e = value[i];
1139 e && e.__ob__ && e.__ob__.dep.depend();
1140 if (Array.isArray(e)) {
1141 dependArray(e);
1142 }
1143 }
1144 }
1145
1146 /* */
1147
1148 /**
1149 * Option overwriting strategies are functions that handle
1150 * how to merge a parent option value and a child option
1151 * value into the final value.
1152 */
1153 var strats = config.optionMergeStrategies;
1154
1155 /**
1156 * Options with restrictions
1157 */
1158 {
1159 strats.el = strats.propsData = function (parent, child, vm, key) {
1160 if (!vm) {
1161 warn(
1162 "option \"" + key + "\" can only be used during instance " +
1163 'creation with the `new` keyword.'
1164 );
1165 }
1166 return defaultStrat(parent, child)
1167 };
1168 }
1169
1170 /**
1171 * Helper that recursively merges two data objects together.
1172 */
1173 function mergeData (to, from) {
1174 if (!from) { return to }
1175 var key, toVal, fromVal;
1176
1177 var keys = hasSymbol
1178 ? Reflect.ownKeys(from)
1179 : Object.keys(from);
1180
1181 for (var i = 0; i < keys.length; i++) {
1182 key = keys[i];
1183 // in case the object is already observed...
1184 if (key === '__ob__') { continue }
1185 toVal = to[key];
1186 fromVal = from[key];
1187 if (!hasOwn(to, key)) {
1188 set(to, key, fromVal);
1189 } else if (
1190 toVal !== fromVal &&
1191 isPlainObject(toVal) &&
1192 isPlainObject(fromVal)
1193 ) {
1194 mergeData(toVal, fromVal);
1195 }
1196 }
1197 return to
1198 }
1199
1200 /**
1201 * Data
1202 */
1203 function mergeDataOrFn (
1204 parentVal,
1205 childVal,
1206 vm
1207 ) {
1208 if (!vm) {
1209 // in a Vue.extend merge, both should be functions
1210 if (!childVal) {
1211 return parentVal
1212 }
1213 if (!parentVal) {
1214 return childVal
1215 }
1216 // when parentVal & childVal are both present,
1217 // we need to return a function that returns the
1218 // merged result of both functions... no need to
1219 // check if parentVal is a function here because
1220 // it has to be a function to pass previous merges.
1221 return function mergedDataFn () {
1222 return mergeData(
1223 typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1224 typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1225 )
1226 }
1227 } else {
1228 return function mergedInstanceDataFn () {
1229 // instance merge
1230 var instanceData = typeof childVal === 'function'
1231 ? childVal.call(vm, vm)
1232 : childVal;
1233 var defaultData = typeof parentVal === 'function'
1234 ? parentVal.call(vm, vm)
1235 : parentVal;
1236 if (instanceData) {
1237 return mergeData(instanceData, defaultData)
1238 } else {
1239 return defaultData
1240 }
1241 }
1242 }
1243 }
1244
1245 strats.data = function (
1246 parentVal,
1247 childVal,
1248 vm
1249 ) {
1250 if (!vm) {
1251 if (childVal && typeof childVal !== 'function') {
1252 warn(
1253 'The "data" option should be a function ' +
1254 'that returns a per-instance value in component ' +
1255 'definitions.',
1256 vm
1257 );
1258
1259 return parentVal
1260 }
1261 return mergeDataOrFn(parentVal, childVal)
1262 }
1263
1264 return mergeDataOrFn(parentVal, childVal, vm)
1265 };
1266
1267 /**
1268 * Hooks and props are merged as arrays.
1269 */
1270 function mergeHook (
1271 parentVal,
1272 childVal
1273 ) {
1274 var res = childVal
1275 ? parentVal
1276 ? parentVal.concat(childVal)
1277 : Array.isArray(childVal)
1278 ? childVal
1279 : [childVal]
1280 : parentVal;
1281 return res
1282 ? dedupeHooks(res)
1283 : res
1284 }
1285
1286 function dedupeHooks (hooks) {
1287 var res = [];
1288 for (var i = 0; i < hooks.length; i++) {
1289 if (res.indexOf(hooks[i]) === -1) {
1290 res.push(hooks[i]);
1291 }
1292 }
1293 return res
1294 }
1295
1296 LIFECYCLE_HOOKS.forEach(function (hook) {
1297 strats[hook] = mergeHook;
1298 });
1299
1300 /**
1301 * Assets
1302 *
1303 * When a vm is present (instance creation), we need to do
1304 * a three-way merge between constructor options, instance
1305 * options and parent options.
1306 */
1307 function mergeAssets (
1308 parentVal,
1309 childVal,
1310 vm,
1311 key
1312 ) {
1313 var res = Object.create(parentVal || null);
1314 if (childVal) {
1315 assertObjectType(key, childVal, vm);
1316 return extend(res, childVal)
1317 } else {
1318 return res
1319 }
1320 }
1321
1322 ASSET_TYPES.forEach(function (type) {
1323 strats[type + 's'] = mergeAssets;
1324 });
1325
1326 /**
1327 * Watchers.
1328 *
1329 * Watchers hashes should not overwrite one
1330 * another, so we merge them as arrays.
1331 */
1332 strats.watch = function (
1333 parentVal,
1334 childVal,
1335 vm,
1336 key
1337 ) {
1338 // work around Firefox's Object.prototype.watch...
1339 if (parentVal === nativeWatch) { parentVal = undefined; }
1340 if (childVal === nativeWatch) { childVal = undefined; }
1341 /* istanbul ignore if */
1342 if (!childVal) { return Object.create(parentVal || null) }
1343 {
1344 assertObjectType(key, childVal, vm);
1345 }
1346 if (!parentVal) { return childVal }
1347 var ret = {};
1348 extend(ret, parentVal);
1349 for (var key$1 in childVal) {
1350 var parent = ret[key$1];
1351 var child = childVal[key$1];
1352 if (parent && !Array.isArray(parent)) {
1353 parent = [parent];
1354 }
1355 ret[key$1] = parent
1356 ? parent.concat(child)
1357 : Array.isArray(child) ? child : [child];
1358 }
1359 return ret
1360 };
1361
1362 /**
1363 * Other object hashes.
1364 */
1365 strats.props =
1366 strats.methods =
1367 strats.inject =
1368 strats.computed = function (
1369 parentVal,
1370 childVal,
1371 vm,
1372 key
1373 ) {
1374 if (childVal && "development" !== 'production') {
1375 assertObjectType(key, childVal, vm);
1376 }
1377 if (!parentVal) { return childVal }
1378 var ret = Object.create(null);
1379 extend(ret, parentVal);
1380 if (childVal) { extend(ret, childVal); }
1381 return ret
1382 };
1383 strats.provide = mergeDataOrFn;
1384
1385 /**
1386 * Default strategy.
1387 */
1388 var defaultStrat = function (parentVal, childVal) {
1389 return childVal === undefined
1390 ? parentVal
1391 : childVal
1392 };
1393
1394 /**
1395 * Validate component names
1396 */
1397 function checkComponents (options) {
1398 for (var key in options.components) {
1399 validateComponentName(key);
1400 }
1401 }
1402
1403 function validateComponentName (name) {
1404 if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
1405 warn(
1406 'Invalid component name: "' + name + '". Component names ' +
1407 'should conform to valid custom element name in html5 specification.'
1408 );
1409 }
1410 if (isBuiltInTag(name) || config.isReservedTag(name)) {
1411 warn(
1412 'Do not use built-in or reserved HTML elements as component ' +
1413 'id: ' + name
1414 );
1415 }
1416 }
1417
1418 /**
1419 * Ensure all props option syntax are normalized into the
1420 * Object-based format.
1421 */
1422 function normalizeProps (options, vm) {
1423 var props = options.props;
1424 if (!props) { return }
1425 var res = {};
1426 var i, val, name;
1427 if (Array.isArray(props)) {
1428 i = props.length;
1429 while (i--) {
1430 val = props[i];
1431 if (typeof val === 'string') {
1432 name = camelize(val);
1433 res[name] = { type: null };
1434 } else {
1435 warn('props must be strings when using array syntax.');
1436 }
1437 }
1438 } else if (isPlainObject(props)) {
1439 for (var key in props) {
1440 val = props[key];
1441 name = camelize(key);
1442 res[name] = isPlainObject(val)
1443 ? val
1444 : { type: val };
1445 }
1446 } else {
1447 warn(
1448 "Invalid value for option \"props\": expected an Array or an Object, " +
1449 "but got " + (toRawType(props)) + ".",
1450 vm
1451 );
1452 }
1453 options.props = res;
1454 }
1455
1456 /**
1457 * Normalize all injections into Object-based format
1458 */
1459 function normalizeInject (options, vm) {
1460 var inject = options.inject;
1461 if (!inject) { return }
1462 var normalized = options.inject = {};
1463 if (Array.isArray(inject)) {
1464 for (var i = 0; i < inject.length; i++) {
1465 normalized[inject[i]] = { from: inject[i] };
1466 }
1467 } else if (isPlainObject(inject)) {
1468 for (var key in inject) {
1469 var val = inject[key];
1470 normalized[key] = isPlainObject(val)
1471 ? extend({ from: key }, val)
1472 : { from: val };
1473 }
1474 } else {
1475 warn(
1476 "Invalid value for option \"inject\": expected an Array or an Object, " +
1477 "but got " + (toRawType(inject)) + ".",
1478 vm
1479 );
1480 }
1481 }
1482
1483 /**
1484 * Normalize raw function directives into object format.
1485 */
1486 function normalizeDirectives (options) {
1487 var dirs = options.directives;
1488 if (dirs) {
1489 for (var key in dirs) {
1490 var def$$1 = dirs[key];
1491 if (typeof def$$1 === 'function') {
1492 dirs[key] = { bind: def$$1, update: def$$1 };
1493 }
1494 }
1495 }
1496 }
1497
1498 function assertObjectType (name, value, vm) {
1499 if (!isPlainObject(value)) {
1500 warn(
1501 "Invalid value for option \"" + name + "\": expected an Object, " +
1502 "but got " + (toRawType(value)) + ".",
1503 vm
1504 );
1505 }
1506 }
1507
1508 /**
1509 * Merge two option objects into a new one.
1510 * Core utility used in both instantiation and inheritance.
1511 */
1512 function mergeOptions (
1513 parent,
1514 child,
1515 vm
1516 ) {
1517 {
1518 checkComponents(child);
1519 }
1520
1521 if (typeof child === 'function') {
1522 child = child.options;
1523 }
1524
1525 normalizeProps(child, vm);
1526 normalizeInject(child, vm);
1527 normalizeDirectives(child);
1528
1529 // Apply extends and mixins on the child options,
1530 // but only if it is a raw options object that isn't
1531 // the result of another mergeOptions call.
1532 // Only merged options has the _base property.
1533 if (!child._base) {
1534 if (child.extends) {
1535 parent = mergeOptions(parent, child.extends, vm);
1536 }
1537 if (child.mixins) {
1538 for (var i = 0, l = child.mixins.length; i < l; i++) {
1539 parent = mergeOptions(parent, child.mixins[i], vm);
1540 }
1541 }
1542 }
1543
1544 var options = {};
1545 var key;
1546 for (key in parent) {
1547 mergeField(key);
1548 }
1549 for (key in child) {
1550 if (!hasOwn(parent, key)) {
1551 mergeField(key);
1552 }
1553 }
1554 function mergeField (key) {
1555 var strat = strats[key] || defaultStrat;
1556 options[key] = strat(parent[key], child[key], vm, key);
1557 }
1558 return options
1559 }
1560
1561 /**
1562 * Resolve an asset.
1563 * This function is used because child instances need access
1564 * to assets defined in its ancestor chain.
1565 */
1566 function resolveAsset (
1567 options,
1568 type,
1569 id,
1570 warnMissing
1571 ) {
1572 /* istanbul ignore if */
1573 if (typeof id !== 'string') {
1574 return
1575 }
1576 var assets = options[type];
1577 // check local registration variations first
1578 if (hasOwn(assets, id)) { return assets[id] }
1579 var camelizedId = camelize(id);
1580 if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
1581 var PascalCaseId = capitalize(camelizedId);
1582 if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
1583 // fallback to prototype chain
1584 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
1585 if (warnMissing && !res) {
1586 warn(
1587 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
1588 options
1589 );
1590 }
1591 return res
1592 }
1593
1594 /* */
1595
1596
1597
1598 function validateProp (
1599 key,
1600 propOptions,
1601 propsData,
1602 vm
1603 ) {
1604 var prop = propOptions[key];
1605 var absent = !hasOwn(propsData, key);
1606 var value = propsData[key];
1607 // boolean casting
1608 var booleanIndex = getTypeIndex(Boolean, prop.type);
1609 if (booleanIndex > -1) {
1610 if (absent && !hasOwn(prop, 'default')) {
1611 value = false;
1612 } else if (value === '' || value === hyphenate(key)) {
1613 // only cast empty string / same name to boolean if
1614 // boolean has higher priority
1615 var stringIndex = getTypeIndex(String, prop.type);
1616 if (stringIndex < 0 || booleanIndex < stringIndex) {
1617 value = true;
1618 }
1619 }
1620 }
1621 // check default value
1622 if (value === undefined) {
1623 value = getPropDefaultValue(vm, prop, key);
1624 // since the default value is a fresh copy,
1625 // make sure to observe it.
1626 var prevShouldObserve = shouldObserve;
1627 toggleObserving(true);
1628 observe(value);
1629 toggleObserving(prevShouldObserve);
1630 }
1631 {
1632 assertProp(prop, key, value, vm, absent);
1633 }
1634 return value
1635 }
1636
1637 /**
1638 * Get the default value of a prop.
1639 */
1640 function getPropDefaultValue (vm, prop, key) {
1641 // no default, return undefined
1642 if (!hasOwn(prop, 'default')) {
1643 return undefined
1644 }
1645 var def = prop.default;
1646 // warn against non-factory defaults for Object & Array
1647 if (isObject(def)) {
1648 warn(
1649 'Invalid default value for prop "' + key + '": ' +
1650 'Props with type Object/Array must use a factory function ' +
1651 'to return the default value.',
1652 vm
1653 );
1654 }
1655 // the raw prop value was also undefined from previous render,
1656 // return previous default value to avoid unnecessary watcher trigger
1657 if (vm && vm.$options.propsData &&
1658 vm.$options.propsData[key] === undefined &&
1659 vm._props[key] !== undefined
1660 ) {
1661 return vm._props[key]
1662 }
1663 // call factory function for non-Function types
1664 // a value is Function if its prototype is function even across different execution context
1665 return typeof def === 'function' && getType(prop.type) !== 'Function'
1666 ? def.call(vm)
1667 : def
1668 }
1669
1670 /**
1671 * Assert whether a prop is valid.
1672 */
1673 function assertProp (
1674 prop,
1675 name,
1676 value,
1677 vm,
1678 absent
1679 ) {
1680 if (prop.required && absent) {
1681 warn(
1682 'Missing required prop: "' + name + '"',
1683 vm
1684 );
1685 return
1686 }
1687 if (value == null && !prop.required) {
1688 return
1689 }
1690 var type = prop.type;
1691 var valid = !type || type === true;
1692 var expectedTypes = [];
1693 if (type) {
1694 if (!Array.isArray(type)) {
1695 type = [type];
1696 }
1697 for (var i = 0; i < type.length && !valid; i++) {
1698 var assertedType = assertType(value, type[i]);
1699 expectedTypes.push(assertedType.expectedType || '');
1700 valid = assertedType.valid;
1701 }
1702 }
1703
1704 if (!valid) {
1705 warn(
1706 getInvalidTypeMessage(name, value, expectedTypes),
1707 vm
1708 );
1709 return
1710 }
1711 var validator = prop.validator;
1712 if (validator) {
1713 if (!validator(value)) {
1714 warn(
1715 'Invalid prop: custom validator check failed for prop "' + name + '".',
1716 vm
1717 );
1718 }
1719 }
1720 }
1721
1722 var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
1723
1724 function assertType (value, type) {
1725 var valid;
1726 var expectedType = getType(type);
1727 if (simpleCheckRE.test(expectedType)) {
1728 var t = typeof value;
1729 valid = t === expectedType.toLowerCase();
1730 // for primitive wrapper objects
1731 if (!valid && t === 'object') {
1732 valid = value instanceof type;
1733 }
1734 } else if (expectedType === 'Object') {
1735 valid = isPlainObject(value);
1736 } else if (expectedType === 'Array') {
1737 valid = Array.isArray(value);
1738 } else {
1739 valid = value instanceof type;
1740 }
1741 return {
1742 valid: valid,
1743 expectedType: expectedType
1744 }
1745 }
1746
1747 /**
1748 * Use function string name to check built-in types,
1749 * because a simple equality check will fail when running
1750 * across different vms / iframes.
1751 */
1752 function getType (fn) {
1753 var match = fn && fn.toString().match(/^\s*function (\w+)/);
1754 return match ? match[1] : ''
1755 }
1756
1757 function isSameType (a, b) {
1758 return getType(a) === getType(b)
1759 }
1760
1761 function getTypeIndex (type, expectedTypes) {
1762 if (!Array.isArray(expectedTypes)) {
1763 return isSameType(expectedTypes, type) ? 0 : -1
1764 }
1765 for (var i = 0, len = expectedTypes.length; i < len; i++) {
1766 if (isSameType(expectedTypes[i], type)) {
1767 return i
1768 }
1769 }
1770 return -1
1771 }
1772
1773 function getInvalidTypeMessage (name, value, expectedTypes) {
1774 var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
1775 " Expected " + (expectedTypes.map(capitalize).join(', '));
1776 var expectedType = expectedTypes[0];
1777 var receivedType = toRawType(value);
1778 var expectedValue = styleValue(value, expectedType);
1779 var receivedValue = styleValue(value, receivedType);
1780 // check if we need to specify expected value
1781 if (expectedTypes.length === 1 &&
1782 isExplicable(expectedType) &&
1783 !isBoolean(expectedType, receivedType)) {
1784 message += " with value " + expectedValue;
1785 }
1786 message += ", got " + receivedType + " ";
1787 // check if we need to specify received value
1788 if (isExplicable(receivedType)) {
1789 message += "with value " + receivedValue + ".";
1790 }
1791 return message
1792 }
1793
1794 function styleValue (value, type) {
1795 if (type === 'String') {
1796 return ("\"" + value + "\"")
1797 } else if (type === 'Number') {
1798 return ("" + (Number(value)))
1799 } else {
1800 return ("" + value)
1801 }
1802 }
1803
1804 function isExplicable (value) {
1805 var explicitTypes = ['string', 'number', 'boolean'];
1806 return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
1807 }
1808
1809 function isBoolean () {
1810 var args = [], len = arguments.length;
1811 while ( len-- ) args[ len ] = arguments[ len ];
1812
1813 return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
1814 }
1815
1816 /* */
1817
1818 function handleError (err, vm, info) {
1819 // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
1820 // See: https://github.com/vuejs/vuex/issues/1505
1821 pushTarget();
1822 try {
1823 if (vm) {
1824 var cur = vm;
1825 while ((cur = cur.$parent)) {
1826 var hooks = cur.$options.errorCaptured;
1827 if (hooks) {
1828 for (var i = 0; i < hooks.length; i++) {
1829 try {
1830 var capture = hooks[i].call(cur, err, vm, info) === false;
1831 if (capture) { return }
1832 } catch (e) {
1833 globalHandleError(e, cur, 'errorCaptured hook');
1834 }
1835 }
1836 }
1837 }
1838 }
1839 globalHandleError(err, vm, info);
1840 } finally {
1841 popTarget();
1842 }
1843 }
1844
1845 function invokeWithErrorHandling (
1846 handler,
1847 context,
1848 args,
1849 vm,
1850 info
1851 ) {
1852 var res;
1853 try {
1854 res = args ? handler.apply(context, args) : handler.call(context);
1855 if (res && !res._isVue && isPromise(res) && !res._handled) {
1856 res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
1857 // issue #9511
1858 // avoid catch triggering multiple times when nested calls
1859 res._handled = true;
1860 }
1861 } catch (e) {
1862 handleError(e, vm, info);
1863 }
1864 return res
1865 }
1866
1867 function globalHandleError (err, vm, info) {
1868 if (config.errorHandler) {
1869 try {
1870 return config.errorHandler.call(null, err, vm, info)
1871 } catch (e) {
1872 // if the user intentionally throws the original error in the handler,
1873 // do not log it twice
1874 if (e !== err) {
1875 logError(e, null, 'config.errorHandler');
1876 }
1877 }
1878 }
1879 logError(err, vm, info);
1880 }
1881
1882 function logError (err, vm, info) {
1883 {
1884 warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
1885 }
1886 /* istanbul ignore else */
1887 if ((inBrowser || inWeex) && typeof console !== 'undefined') {
1888 console.error(err);
1889 } else {
1890 throw err
1891 }
1892 }
1893
1894 /* */
1895
1896 var isUsingMicroTask = false;
1897
1898 var callbacks = [];
1899 var pending = false;
1900
1901 function flushCallbacks () {
1902 pending = false;
1903 var copies = callbacks.slice(0);
1904 callbacks.length = 0;
1905 for (var i = 0; i < copies.length; i++) {
1906 copies[i]();
1907 }
1908 }
1909
1910 // Here we have async deferring wrappers using microtasks.
1911 // In 2.5 we used (macro) tasks (in combination with microtasks).
1912 // However, it has subtle problems when state is changed right before repaint
1913 // (e.g. #6813, out-in transitions).
1914 // Also, using (macro) tasks in event handler would cause some weird behaviors
1915 // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
1916 // So we now use microtasks everywhere, again.
1917 // A major drawback of this tradeoff is that there are some scenarios
1918 // where microtasks have too high a priority and fire in between supposedly
1919 // sequential events (e.g. #4521, #6690, which have workarounds)
1920 // or even between bubbling of the same event (#6566).
1921 var timerFunc;
1922
1923 // The nextTick behavior leverages the microtask queue, which can be accessed
1924 // via either native Promise.then or MutationObserver.
1925 // MutationObserver has wider support, however it is seriously bugged in
1926 // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
1927 // completely stops working after triggering a few times... so, if native
1928 // Promise is available, we will use it:
1929 /* istanbul ignore next, $flow-disable-line */
1930 if (typeof Promise !== 'undefined' && isNative(Promise)) {
1931 var p = Promise.resolve();
1932 timerFunc = function () {
1933 p.then(flushCallbacks);
1934 // In problematic UIWebViews, Promise.then doesn't completely break, but
1935 // it can get stuck in a weird state where callbacks are pushed into the
1936 // microtask queue but the queue isn't being flushed, until the browser
1937 // needs to do some other work, e.g. handle a timer. Therefore we can
1938 // "force" the microtask queue to be flushed by adding an empty timer.
1939 if (isIOS) { setTimeout(noop); }
1940 };
1941 isUsingMicroTask = true;
1942 } else if (!isIE && typeof MutationObserver !== 'undefined' && (
1943 isNative(MutationObserver) ||
1944 // PhantomJS and iOS 7.x
1945 MutationObserver.toString() === '[object MutationObserverConstructor]'
1946 )) {
1947 // Use MutationObserver where native Promise is not available,
1948 // e.g. PhantomJS, iOS7, Android 4.4
1949 // (#6466 MutationObserver is unreliable in IE11)
1950 var counter = 1;
1951 var observer = new MutationObserver(flushCallbacks);
1952 var textNode = document.createTextNode(String(counter));
1953 observer.observe(textNode, {
1954 characterData: true
1955 });
1956 timerFunc = function () {
1957 counter = (counter + 1) % 2;
1958 textNode.data = String(counter);
1959 };
1960 isUsingMicroTask = true;
1961 } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
1962 // Fallback to setImmediate.
1963 // Technically it leverages the (macro) task queue,
1964 // but it is still a better choice than setTimeout.
1965 timerFunc = function () {
1966 setImmediate(flushCallbacks);
1967 };
1968 } else {
1969 // Fallback to setTimeout.
1970 timerFunc = function () {
1971 setTimeout(flushCallbacks, 0);
1972 };
1973 }
1974
1975 function nextTick (cb, ctx) {
1976 var _resolve;
1977 callbacks.push(function () {
1978 if (cb) {
1979 try {
1980 cb.call(ctx);
1981 } catch (e) {
1982 handleError(e, ctx, 'nextTick');
1983 }
1984 } else if (_resolve) {
1985 _resolve(ctx);
1986 }
1987 });
1988 if (!pending) {
1989 pending = true;
1990 timerFunc();
1991 }
1992 // $flow-disable-line
1993 if (!cb && typeof Promise !== 'undefined') {
1994 return new Promise(function (resolve) {
1995 _resolve = resolve;
1996 })
1997 }
1998 }
1999
2000 /* */
2001
2002 /* not type checking this file because flow doesn't play well with Proxy */
2003
2004 var initProxy;
2005
2006 {
2007 var allowedGlobals = makeMap(
2008 'Infinity,undefined,NaN,isFinite,isNaN,' +
2009 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
2010 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
2011 'require' // for Webpack/Browserify
2012 );
2013
2014 var warnNonPresent = function (target, key) {
2015 warn(
2016 "Property or method \"" + key + "\" is not defined on the instance but " +
2017 'referenced during render. Make sure that this property is reactive, ' +
2018 'either in the data option, or for class-based components, by ' +
2019 'initializing the property. ' +
2020 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
2021 target
2022 );
2023 };
2024
2025 var warnReservedPrefix = function (target, key) {
2026 warn(
2027 "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
2028 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
2029 'prevent conflicts with Vue internals. ' +
2030 'See: https://vuejs.org/v2/api/#data',
2031 target
2032 );
2033 };
2034
2035 var hasProxy =
2036 typeof Proxy !== 'undefined' && isNative(Proxy);
2037
2038 if (hasProxy) {
2039 var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
2040 config.keyCodes = new Proxy(config.keyCodes, {
2041 set: function set (target, key, value) {
2042 if (isBuiltInModifier(key)) {
2043 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
2044 return false
2045 } else {
2046 target[key] = value;
2047 return true
2048 }
2049 }
2050 });
2051 }
2052
2053 var hasHandler = {
2054 has: function has (target, key) {
2055 var has = key in target;
2056 var isAllowed = allowedGlobals(key) ||
2057 (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
2058 if (!has && !isAllowed) {
2059 if (key in target.$data) { warnReservedPrefix(target, key); }
2060 else { warnNonPresent(target, key); }
2061 }
2062 return has || !isAllowed
2063 }
2064 };
2065
2066 var getHandler = {
2067 get: function get (target, key) {
2068 if (typeof key === 'string' && !(key in target)) {
2069 if (key in target.$data) { warnReservedPrefix(target, key); }
2070 else { warnNonPresent(target, key); }
2071 }
2072 return target[key]
2073 }
2074 };
2075
2076 initProxy = function initProxy (vm) {
2077 if (hasProxy) {
2078 // determine which proxy handler to use
2079 var options = vm.$options;
2080 var handlers = options.render && options.render._withStripped
2081 ? getHandler
2082 : hasHandler;
2083 vm._renderProxy = new Proxy(vm, handlers);
2084 } else {
2085 vm._renderProxy = vm;
2086 }
2087 };
2088 }
2089
2090 /* */
2091
2092 var seenObjects = new _Set();
2093
2094 /**
2095 * Recursively traverse an object to evoke all converted
2096 * getters, so that every nested property inside the object
2097 * is collected as a "deep" dependency.
2098 */
2099 function traverse (val) {
2100 _traverse(val, seenObjects);
2101 seenObjects.clear();
2102 }
2103
2104 function _traverse (val, seen) {
2105 var i, keys;
2106 var isA = Array.isArray(val);
2107 if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
2108 return
2109 }
2110 if (val.__ob__) {
2111 var depId = val.__ob__.dep.id;
2112 if (seen.has(depId)) {
2113 return
2114 }
2115 seen.add(depId);
2116 }
2117 if (isA) {
2118 i = val.length;
2119 while (i--) { _traverse(val[i], seen); }
2120 } else {
2121 keys = Object.keys(val);
2122 i = keys.length;
2123 while (i--) { _traverse(val[keys[i]], seen); }
2124 }
2125 }
2126
2127 var mark;
2128 var measure;
2129
2130 {
2131 var perf = inBrowser && window.performance;
2132 /* istanbul ignore if */
2133 if (
2134 perf &&
2135 perf.mark &&
2136 perf.measure &&
2137 perf.clearMarks &&
2138 perf.clearMeasures
2139 ) {
2140 mark = function (tag) { return perf.mark(tag); };
2141 measure = function (name, startTag, endTag) {
2142 perf.measure(name, startTag, endTag);
2143 perf.clearMarks(startTag);
2144 perf.clearMarks(endTag);
2145 // perf.clearMeasures(name)
2146 };
2147 }
2148 }
2149
2150 /* */
2151
2152 var normalizeEvent = cached(function (name) {
2153 var passive = name.charAt(0) === '&';
2154 name = passive ? name.slice(1) : name;
2155 var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
2156 name = once$$1 ? name.slice(1) : name;
2157 var capture = name.charAt(0) === '!';
2158 name = capture ? name.slice(1) : name;
2159 return {
2160 name: name,
2161 once: once$$1,
2162 capture: capture,
2163 passive: passive
2164 }
2165 });
2166
2167 function createFnInvoker (fns, vm) {
2168 function invoker () {
2169 var arguments$1 = arguments;
2170
2171 var fns = invoker.fns;
2172 if (Array.isArray(fns)) {
2173 var cloned = fns.slice();
2174 for (var i = 0; i < cloned.length; i++) {
2175 invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
2176 }
2177 } else {
2178 // return handler return value for single handlers
2179 return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
2180 }
2181 }
2182 invoker.fns = fns;
2183 return invoker
2184 }
2185
2186 function updateListeners (
2187 on,
2188 oldOn,
2189 add,
2190 remove$$1,
2191 createOnceHandler,
2192 vm
2193 ) {
2194 var name, def$$1, cur, old, event;
2195 for (name in on) {
2196 def$$1 = cur = on[name];
2197 old = oldOn[name];
2198 event = normalizeEvent(name);
2199 if (isUndef(cur)) {
2200 warn(
2201 "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
2202 vm
2203 );
2204 } else if (isUndef(old)) {
2205 if (isUndef(cur.fns)) {
2206 cur = on[name] = createFnInvoker(cur, vm);
2207 }
2208 if (isTrue(event.once)) {
2209 cur = on[name] = createOnceHandler(event.name, cur, event.capture);
2210 }
2211 add(event.name, cur, event.capture, event.passive, event.params);
2212 } else if (cur !== old) {
2213 old.fns = cur;
2214 on[name] = old;
2215 }
2216 }
2217 for (name in oldOn) {
2218 if (isUndef(on[name])) {
2219 event = normalizeEvent(name);
2220 remove$$1(event.name, oldOn[name], event.capture);
2221 }
2222 }
2223 }
2224
2225 /* */
2226
2227 function mergeVNodeHook (def, hookKey, hook) {
2228 if (def instanceof VNode) {
2229 def = def.data.hook || (def.data.hook = {});
2230 }
2231 var invoker;
2232 var oldHook = def[hookKey];
2233
2234 function wrappedHook () {
2235 hook.apply(this, arguments);
2236 // important: remove merged hook to ensure it's called only once
2237 // and prevent memory leak
2238 remove(invoker.fns, wrappedHook);
2239 }
2240
2241 if (isUndef(oldHook)) {
2242 // no existing hook
2243 invoker = createFnInvoker([wrappedHook]);
2244 } else {
2245 /* istanbul ignore if */
2246 if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
2247 // already a merged invoker
2248 invoker = oldHook;
2249 invoker.fns.push(wrappedHook);
2250 } else {
2251 // existing plain hook
2252 invoker = createFnInvoker([oldHook, wrappedHook]);
2253 }
2254 }
2255
2256 invoker.merged = true;
2257 def[hookKey] = invoker;
2258 }
2259
2260 /* */
2261
2262 function extractPropsFromVNodeData (
2263 data,
2264 Ctor,
2265 tag
2266 ) {
2267 // we are only extracting raw values here.
2268 // validation and default values are handled in the child
2269 // component itself.
2270 var propOptions = Ctor.options.props;
2271 if (isUndef(propOptions)) {
2272 return
2273 }
2274 var res = {};
2275 var attrs = data.attrs;
2276 var props = data.props;
2277 if (isDef(attrs) || isDef(props)) {
2278 for (var key in propOptions) {
2279 var altKey = hyphenate(key);
2280 {
2281 var keyInLowerCase = key.toLowerCase();
2282 if (
2283 key !== keyInLowerCase &&
2284 attrs && hasOwn(attrs, keyInLowerCase)
2285 ) {
2286 tip(
2287 "Prop \"" + keyInLowerCase + "\" is passed to component " +
2288 (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
2289 " \"" + key + "\". " +
2290 "Note that HTML attributes are case-insensitive and camelCased " +
2291 "props need to use their kebab-case equivalents when using in-DOM " +
2292 "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
2293 );
2294 }
2295 }
2296 checkProp(res, props, key, altKey, true) ||
2297 checkProp(res, attrs, key, altKey, false);
2298 }
2299 }
2300 return res
2301 }
2302
2303 function checkProp (
2304 res,
2305 hash,
2306 key,
2307 altKey,
2308 preserve
2309 ) {
2310 if (isDef(hash)) {
2311 if (hasOwn(hash, key)) {
2312 res[key] = hash[key];
2313 if (!preserve) {
2314 delete hash[key];
2315 }
2316 return true
2317 } else if (hasOwn(hash, altKey)) {
2318 res[key] = hash[altKey];
2319 if (!preserve) {
2320 delete hash[altKey];
2321 }
2322 return true
2323 }
2324 }
2325 return false
2326 }
2327
2328 /* */
2329
2330 // The template compiler attempts to minimize the need for normalization by
2331 // statically analyzing the template at compile time.
2332 //
2333 // For plain HTML markup, normalization can be completely skipped because the
2334 // generated render function is guaranteed to return Array<VNode>. There are
2335 // two cases where extra normalization is needed:
2336
2337 // 1. When the children contains components - because a functional component
2338 // may return an Array instead of a single root. In this case, just a simple
2339 // normalization is needed - if any child is an Array, we flatten the whole
2340 // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
2341 // because functional components already normalize their own children.
2342 function simpleNormalizeChildren (children) {
2343 for (var i = 0; i < children.length; i++) {
2344 if (Array.isArray(children[i])) {
2345 return Array.prototype.concat.apply([], children)
2346 }
2347 }
2348 return children
2349 }
2350
2351 // 2. When the children contains constructs that always generated nested Arrays,
2352 // e.g. <template>, <slot>, v-for, or when the children is provided by user
2353 // with hand-written render functions / JSX. In such cases a full normalization
2354 // is needed to cater to all possible types of children values.
2355 function normalizeChildren (children) {
2356 return isPrimitive(children)
2357 ? [createTextVNode(children)]
2358 : Array.isArray(children)
2359 ? normalizeArrayChildren(children)
2360 : undefined
2361 }
2362
2363 function isTextNode (node) {
2364 return isDef(node) && isDef(node.text) && isFalse(node.isComment)
2365 }
2366
2367 function normalizeArrayChildren (children, nestedIndex) {
2368 var res = [];
2369 var i, c, lastIndex, last;
2370 for (i = 0; i < children.length; i++) {
2371 c = children[i];
2372 if (isUndef(c) || typeof c === 'boolean') { continue }
2373 lastIndex = res.length - 1;
2374 last = res[lastIndex];
2375 // nested
2376 if (Array.isArray(c)) {
2377 if (c.length > 0) {
2378 c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
2379 // merge adjacent text nodes
2380 if (isTextNode(c[0]) && isTextNode(last)) {
2381 res[lastIndex] = createTextVNode(last.text + (c[0]).text);
2382 c.shift();
2383 }
2384 res.push.apply(res, c);
2385 }
2386 } else if (isPrimitive(c)) {
2387 if (isTextNode(last)) {
2388 // merge adjacent text nodes
2389 // this is necessary for SSR hydration because text nodes are
2390 // essentially merged when rendered to HTML strings
2391 res[lastIndex] = createTextVNode(last.text + c);
2392 } else if (c !== '') {
2393 // convert primitive to vnode
2394 res.push(createTextVNode(c));
2395 }
2396 } else {
2397 if (isTextNode(c) && isTextNode(last)) {
2398 // merge adjacent text nodes
2399 res[lastIndex] = createTextVNode(last.text + c.text);
2400 } else {
2401 // default key for nested array children (likely generated by v-for)
2402 if (isTrue(children._isVList) &&
2403 isDef(c.tag) &&
2404 isUndef(c.key) &&
2405 isDef(nestedIndex)) {
2406 c.key = "__vlist" + nestedIndex + "_" + i + "__";
2407 }
2408 res.push(c);
2409 }
2410 }
2411 }
2412 return res
2413 }
2414
2415 /* */
2416
2417 function initProvide (vm) {
2418 var provide = vm.$options.provide;
2419 if (provide) {
2420 vm._provided = typeof provide === 'function'
2421 ? provide.call(vm)
2422 : provide;
2423 }
2424 }
2425
2426 function initInjections (vm) {
2427 var result = resolveInject(vm.$options.inject, vm);
2428 if (result) {
2429 toggleObserving(false);
2430 Object.keys(result).forEach(function (key) {
2431 /* istanbul ignore else */
2432 {
2433 defineReactive$$1(vm, key, result[key], function () {
2434 warn(
2435 "Avoid mutating an injected value directly since the changes will be " +
2436 "overwritten whenever the provided component re-renders. " +
2437 "injection being mutated: \"" + key + "\"",
2438 vm
2439 );
2440 });
2441 }
2442 });
2443 toggleObserving(true);
2444 }
2445 }
2446
2447 function resolveInject (inject, vm) {
2448 if (inject) {
2449 // inject is :any because flow is not smart enough to figure out cached
2450 var result = Object.create(null);
2451 var keys = hasSymbol
2452 ? Reflect.ownKeys(inject)
2453 : Object.keys(inject);
2454
2455 for (var i = 0; i < keys.length; i++) {
2456 var key = keys[i];
2457 // #6574 in case the inject object is observed...
2458 if (key === '__ob__') { continue }
2459 var provideKey = inject[key].from;
2460 var source = vm;
2461 while (source) {
2462 if (source._provided && hasOwn(source._provided, provideKey)) {
2463 result[key] = source._provided[provideKey];
2464 break
2465 }
2466 source = source.$parent;
2467 }
2468 if (!source) {
2469 if ('default' in inject[key]) {
2470 var provideDefault = inject[key].default;
2471 result[key] = typeof provideDefault === 'function'
2472 ? provideDefault.call(vm)
2473 : provideDefault;
2474 } else {
2475 warn(("Injection \"" + key + "\" not found"), vm);
2476 }
2477 }
2478 }
2479 return result
2480 }
2481 }
2482
2483 /* */
2484
2485
2486
2487 /**
2488 * Runtime helper for resolving raw children VNodes into a slot object.
2489 */
2490 function resolveSlots (
2491 children,
2492 context
2493 ) {
2494 if (!children || !children.length) {
2495 return {}
2496 }
2497 var slots = {};
2498 for (var i = 0, l = children.length; i < l; i++) {
2499 var child = children[i];
2500 var data = child.data;
2501 // remove slot attribute if the node is resolved as a Vue slot node
2502 if (data && data.attrs && data.attrs.slot) {
2503 delete data.attrs.slot;
2504 }
2505 // named slots should only be respected if the vnode was rendered in the
2506 // same context.
2507 if ((child.context === context || child.fnContext === context) &&
2508 data && data.slot != null
2509 ) {
2510 var name = data.slot;
2511 var slot = (slots[name] || (slots[name] = []));
2512 if (child.tag === 'template') {
2513 slot.push.apply(slot, child.children || []);
2514 } else {
2515 slot.push(child);
2516 }
2517 } else {
2518 (slots.default || (slots.default = [])).push(child);
2519 }
2520 }
2521 // ignore slots that contains only whitespace
2522 for (var name$1 in slots) {
2523 if (slots[name$1].every(isWhitespace)) {
2524 delete slots[name$1];
2525 }
2526 }
2527 return slots
2528 }
2529
2530 function isWhitespace (node) {
2531 return (node.isComment && !node.asyncFactory) || node.text === ' '
2532 }
2533
2534 /* */
2535
2536 function normalizeScopedSlots (
2537 slots,
2538 normalSlots,
2539 prevSlots
2540 ) {
2541 var res;
2542 var hasNormalSlots = Object.keys(normalSlots).length > 0;
2543 var isStable = slots ? !!slots.$stable : !hasNormalSlots;
2544 var key = slots && slots.$key;
2545 if (!slots) {
2546 res = {};
2547 } else if (slots._normalized) {
2548 // fast path 1: child component re-render only, parent did not change
2549 return slots._normalized
2550 } else if (
2551 isStable &&
2552 prevSlots &&
2553 prevSlots !== emptyObject &&
2554 key === prevSlots.$key &&
2555 !hasNormalSlots &&
2556 !prevSlots.$hasNormal
2557 ) {
2558 // fast path 2: stable scoped slots w/ no normal slots to proxy,
2559 // only need to normalize once
2560 return prevSlots
2561 } else {
2562 res = {};
2563 for (var key$1 in slots) {
2564 if (slots[key$1] && key$1[0] !== '$') {
2565 res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
2566 }
2567 }
2568 }
2569 // expose normal slots on scopedSlots
2570 for (var key$2 in normalSlots) {
2571 if (!(key$2 in res)) {
2572 res[key$2] = proxyNormalSlot(normalSlots, key$2);
2573 }
2574 }
2575 // avoriaz seems to mock a non-extensible $scopedSlots object
2576 // and when that is passed down this would cause an error
2577 if (slots && Object.isExtensible(slots)) {
2578 (slots)._normalized = res;
2579 }
2580 def(res, '$stable', isStable);
2581 def(res, '$key', key);
2582 def(res, '$hasNormal', hasNormalSlots);
2583 return res
2584 }
2585
2586 function normalizeScopedSlot(normalSlots, key, fn) {
2587 var normalized = function () {
2588 var res = arguments.length ? fn.apply(null, arguments) : fn({});
2589 res = res && typeof res === 'object' && !Array.isArray(res)
2590 ? [res] // single vnode
2591 : normalizeChildren(res);
2592 return res && (
2593 res.length === 0 ||
2594 (res.length === 1 && res[0].isComment) // #9658
2595 ) ? undefined
2596 : res
2597 };
2598 // this is a slot using the new v-slot syntax without scope. although it is
2599 // compiled as a scoped slot, render fn users would expect it to be present
2600 // on this.$slots because the usage is semantically a normal slot.
2601 if (fn.proxy) {
2602 Object.defineProperty(normalSlots, key, {
2603 get: normalized,
2604 enumerable: true,
2605 configurable: true
2606 });
2607 }
2608 return normalized
2609 }
2610
2611 function proxyNormalSlot(slots, key) {
2612 return function () { return slots[key]; }
2613 }
2614
2615 /* */
2616
2617 /**
2618 * Runtime helper for rendering v-for lists.
2619 */
2620 function renderList (
2621 val,
2622 render
2623 ) {
2624 var ret, i, l, keys, key;
2625 if (Array.isArray(val) || typeof val === 'string') {
2626 ret = new Array(val.length);
2627 for (i = 0, l = val.length; i < l; i++) {
2628 ret[i] = render(val[i], i);
2629 }
2630 } else if (typeof val === 'number') {
2631 ret = new Array(val);
2632 for (i = 0; i < val; i++) {
2633 ret[i] = render(i + 1, i);
2634 }
2635 } else if (isObject(val)) {
2636 if (hasSymbol && val[Symbol.iterator]) {
2637 ret = [];
2638 var iterator = val[Symbol.iterator]();
2639 var result = iterator.next();
2640 while (!result.done) {
2641 ret.push(render(result.value, ret.length));
2642 result = iterator.next();
2643 }
2644 } else {
2645 keys = Object.keys(val);
2646 ret = new Array(keys.length);
2647 for (i = 0, l = keys.length; i < l; i++) {
2648 key = keys[i];
2649 ret[i] = render(val[key], key, i);
2650 }
2651 }
2652 }
2653 if (!isDef(ret)) {
2654 ret = [];
2655 }
2656 (ret)._isVList = true;
2657 return ret
2658 }
2659
2660 /* */
2661
2662 /**
2663 * Runtime helper for rendering <slot>
2664 */
2665 function renderSlot (
2666 name,
2667 fallback,
2668 props,
2669 bindObject
2670 ) {
2671 var scopedSlotFn = this.$scopedSlots[name];
2672 var nodes;
2673 if (scopedSlotFn) { // scoped slot
2674 props = props || {};
2675 if (bindObject) {
2676 if (!isObject(bindObject)) {
2677 warn(
2678 'slot v-bind without argument expects an Object',
2679 this
2680 );
2681 }
2682 props = extend(extend({}, bindObject), props);
2683 }
2684 nodes = scopedSlotFn(props) || fallback;
2685 } else {
2686 nodes = this.$slots[name] || fallback;
2687 }
2688
2689 var target = props && props.slot;
2690 if (target) {
2691 return this.$createElement('template', { slot: target }, nodes)
2692 } else {
2693 return nodes
2694 }
2695 }
2696
2697 /* */
2698
2699 /**
2700 * Runtime helper for resolving filters
2701 */
2702 function resolveFilter (id) {
2703 return resolveAsset(this.$options, 'filters', id, true) || identity
2704 }
2705
2706 /* */
2707
2708 function isKeyNotMatch (expect, actual) {
2709 if (Array.isArray(expect)) {
2710 return expect.indexOf(actual) === -1
2711 } else {
2712 return expect !== actual
2713 }
2714 }
2715
2716 /**
2717 * Runtime helper for checking keyCodes from config.
2718 * exposed as Vue.prototype._k
2719 * passing in eventKeyName as last argument separately for backwards compat
2720 */
2721 function checkKeyCodes (
2722 eventKeyCode,
2723 key,
2724 builtInKeyCode,
2725 eventKeyName,
2726 builtInKeyName
2727 ) {
2728 var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
2729 if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
2730 return isKeyNotMatch(builtInKeyName, eventKeyName)
2731 } else if (mappedKeyCode) {
2732 return isKeyNotMatch(mappedKeyCode, eventKeyCode)
2733 } else if (eventKeyName) {
2734 return hyphenate(eventKeyName) !== key
2735 }
2736 }
2737
2738 /* */
2739
2740 /**
2741 * Runtime helper for merging v-bind="object" into a VNode's data.
2742 */
2743 function bindObjectProps (
2744 data,
2745 tag,
2746 value,
2747 asProp,
2748 isSync
2749 ) {
2750 if (value) {
2751 if (!isObject(value)) {
2752 warn(
2753 'v-bind without argument expects an Object or Array value',
2754 this
2755 );
2756 } else {
2757 if (Array.isArray(value)) {
2758 value = toObject(value);
2759 }
2760 var hash;
2761 var loop = function ( key ) {
2762 if (
2763 key === 'class' ||
2764 key === 'style' ||
2765 isReservedAttribute(key)
2766 ) {
2767 hash = data;
2768 } else {
2769 var type = data.attrs && data.attrs.type;
2770 hash = asProp || config.mustUseProp(tag, type, key)
2771 ? data.domProps || (data.domProps = {})
2772 : data.attrs || (data.attrs = {});
2773 }
2774 var camelizedKey = camelize(key);
2775 var hyphenatedKey = hyphenate(key);
2776 if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
2777 hash[key] = value[key];
2778
2779 if (isSync) {
2780 var on = data.on || (data.on = {});
2781 on[("update:" + key)] = function ($event) {
2782 value[key] = $event;
2783 };
2784 }
2785 }
2786 };
2787
2788 for (var key in value) loop( key );
2789 }
2790 }
2791 return data
2792 }
2793
2794 /* */
2795
2796 /**
2797 * Runtime helper for rendering static trees.
2798 */
2799 function renderStatic (
2800 index,
2801 isInFor
2802 ) {
2803 var cached = this._staticTrees || (this._staticTrees = []);
2804 var tree = cached[index];
2805 // if has already-rendered static tree and not inside v-for,
2806 // we can reuse the same tree.
2807 if (tree && !isInFor) {
2808 return tree
2809 }
2810 // otherwise, render a fresh tree.
2811 tree = cached[index] = this.$options.staticRenderFns[index].call(
2812 this._renderProxy,
2813 null,
2814 this // for render fns generated for functional component templates
2815 );
2816 markStatic(tree, ("__static__" + index), false);
2817 return tree
2818 }
2819
2820 /**
2821 * Runtime helper for v-once.
2822 * Effectively it means marking the node as static with a unique key.
2823 */
2824 function markOnce (
2825 tree,
2826 index,
2827 key
2828 ) {
2829 markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
2830 return tree
2831 }
2832
2833 function markStatic (
2834 tree,
2835 key,
2836 isOnce
2837 ) {
2838 if (Array.isArray(tree)) {
2839 for (var i = 0; i < tree.length; i++) {
2840 if (tree[i] && typeof tree[i] !== 'string') {
2841 markStaticNode(tree[i], (key + "_" + i), isOnce);
2842 }
2843 }
2844 } else {
2845 markStaticNode(tree, key, isOnce);
2846 }
2847 }
2848
2849 function markStaticNode (node, key, isOnce) {
2850 node.isStatic = true;
2851 node.key = key;
2852 node.isOnce = isOnce;
2853 }
2854
2855 /* */
2856
2857 function bindObjectListeners (data, value) {
2858 if (value) {
2859 if (!isPlainObject(value)) {
2860 warn(
2861 'v-on without argument expects an Object value',
2862 this
2863 );
2864 } else {
2865 var on = data.on = data.on ? extend({}, data.on) : {};
2866 for (var key in value) {
2867 var existing = on[key];
2868 var ours = value[key];
2869 on[key] = existing ? [].concat(existing, ours) : ours;
2870 }
2871 }
2872 }
2873 return data
2874 }
2875
2876 /* */
2877
2878 function resolveScopedSlots (
2879 fns, // see flow/vnode
2880 res,
2881 // the following are added in 2.6
2882 hasDynamicKeys,
2883 contentHashKey
2884 ) {
2885 res = res || { $stable: !hasDynamicKeys };
2886 for (var i = 0; i < fns.length; i++) {
2887 var slot = fns[i];
2888 if (Array.isArray(slot)) {
2889 resolveScopedSlots(slot, res, hasDynamicKeys);
2890 } else if (slot) {
2891 // marker for reverse proxying v-slot without scope on this.$slots
2892 if (slot.proxy) {
2893 slot.fn.proxy = true;
2894 }
2895 res[slot.key] = slot.fn;
2896 }
2897 }
2898 if (contentHashKey) {
2899 (res).$key = contentHashKey;
2900 }
2901 return res
2902 }
2903
2904 /* */
2905
2906 function bindDynamicKeys (baseObj, values) {
2907 for (var i = 0; i < values.length; i += 2) {
2908 var key = values[i];
2909 if (typeof key === 'string' && key) {
2910 baseObj[values[i]] = values[i + 1];
2911 } else if (key !== '' && key !== null) {
2912 // null is a special value for explicitly removing a binding
2913 warn(
2914 ("Invalid value for dynamic directive argument (expected string or null): " + key),
2915 this
2916 );
2917 }
2918 }
2919 return baseObj
2920 }
2921
2922 // helper to dynamically append modifier runtime markers to event names.
2923 // ensure only append when value is already string, otherwise it will be cast
2924 // to string and cause the type check to miss.
2925 function prependModifier (value, symbol) {
2926 return typeof value === 'string' ? symbol + value : value
2927 }
2928
2929 /* */
2930
2931 function installRenderHelpers (target) {
2932 target._o = markOnce;
2933 target._n = toNumber;
2934 target._s = toString;
2935 target._l = renderList;
2936 target._t = renderSlot;
2937 target._q = looseEqual;
2938 target._i = looseIndexOf;
2939 target._m = renderStatic;
2940 target._f = resolveFilter;
2941 target._k = checkKeyCodes;
2942 target._b = bindObjectProps;
2943 target._v = createTextVNode;
2944 target._e = createEmptyVNode;
2945 target._u = resolveScopedSlots;
2946 target._g = bindObjectListeners;
2947 target._d = bindDynamicKeys;
2948 target._p = prependModifier;
2949 }
2950
2951 /* */
2952
2953 function FunctionalRenderContext (
2954 data,
2955 props,
2956 children,
2957 parent,
2958 Ctor
2959 ) {
2960 var this$1 = this;
2961
2962 var options = Ctor.options;
2963 // ensure the createElement function in functional components
2964 // gets a unique context - this is necessary for correct named slot check
2965 var contextVm;
2966 if (hasOwn(parent, '_uid')) {
2967 contextVm = Object.create(parent);
2968 // $flow-disable-line
2969 contextVm._original = parent;
2970 } else {
2971 // the context vm passed in is a functional context as well.
2972 // in this case we want to make sure we are able to get a hold to the
2973 // real context instance.
2974 contextVm = parent;
2975 // $flow-disable-line
2976 parent = parent._original;
2977 }
2978 var isCompiled = isTrue(options._compiled);
2979 var needNormalization = !isCompiled;
2980
2981 this.data = data;
2982 this.props = props;
2983 this.children = children;
2984 this.parent = parent;
2985 this.listeners = data.on || emptyObject;
2986 this.injections = resolveInject(options.inject, parent);
2987 this.slots = function () {
2988 if (!this$1.$slots) {
2989 normalizeScopedSlots(
2990 data.scopedSlots,
2991 this$1.$slots = resolveSlots(children, parent)
2992 );
2993 }
2994 return this$1.$slots
2995 };
2996
2997 Object.defineProperty(this, 'scopedSlots', ({
2998 enumerable: true,
2999 get: function get () {
3000 return normalizeScopedSlots(data.scopedSlots, this.slots())
3001 }
3002 }));
3003
3004 // support for compiled functional template
3005 if (isCompiled) {
3006 // exposing $options for renderStatic()
3007 this.$options = options;
3008 // pre-resolve slots for renderSlot()
3009 this.$slots = this.slots();
3010 this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
3011 }
3012
3013 if (options._scopeId) {
3014 this._c = function (a, b, c, d) {
3015 var vnode = createElement(contextVm, a, b, c, d, needNormalization);
3016 if (vnode && !Array.isArray(vnode)) {
3017 vnode.fnScopeId = options._scopeId;
3018 vnode.fnContext = parent;
3019 }
3020 return vnode
3021 };
3022 } else {
3023 this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
3024 }
3025 }
3026
3027 installRenderHelpers(FunctionalRenderContext.prototype);
3028
3029 function createFunctionalComponent (
3030 Ctor,
3031 propsData,
3032 data,
3033 contextVm,
3034 children
3035 ) {
3036 var options = Ctor.options;
3037 var props = {};
3038 var propOptions = options.props;
3039 if (isDef(propOptions)) {
3040 for (var key in propOptions) {
3041 props[key] = validateProp(key, propOptions, propsData || emptyObject);
3042 }
3043 } else {
3044 if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
3045 if (isDef(data.props)) { mergeProps(props, data.props); }
3046 }
3047
3048 var renderContext = new FunctionalRenderContext(
3049 data,
3050 props,
3051 children,
3052 contextVm,
3053 Ctor
3054 );
3055
3056 var vnode = options.render.call(null, renderContext._c, renderContext);
3057
3058 if (vnode instanceof VNode) {
3059 return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
3060 } else if (Array.isArray(vnode)) {
3061 var vnodes = normalizeChildren(vnode) || [];
3062 var res = new Array(vnodes.length);
3063 for (var i = 0; i < vnodes.length; i++) {
3064 res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
3065 }
3066 return res
3067 }
3068 }
3069
3070 function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
3071 // #7817 clone node before setting fnContext, otherwise if the node is reused
3072 // (e.g. it was from a cached normal slot) the fnContext causes named slots
3073 // that should not be matched to match.
3074 var clone = cloneVNode(vnode);
3075 clone.fnContext = contextVm;
3076 clone.fnOptions = options;
3077 {
3078 (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
3079 }
3080 if (data.slot) {
3081 (clone.data || (clone.data = {})).slot = data.slot;
3082 }
3083 return clone
3084 }
3085
3086 function mergeProps (to, from) {
3087 for (var key in from) {
3088 to[camelize(key)] = from[key];
3089 }
3090 }
3091
3092 /* */
3093
3094 /* */
3095
3096 /* */
3097
3098 /* */
3099
3100 // inline hooks to be invoked on component VNodes during patch
3101 var componentVNodeHooks = {
3102 init: function init (vnode, hydrating) {
3103 if (
3104 vnode.componentInstance &&
3105 !vnode.componentInstance._isDestroyed &&
3106 vnode.data.keepAlive
3107 ) {
3108 // kept-alive components, treat as a patch
3109 var mountedNode = vnode; // work around flow
3110 componentVNodeHooks.prepatch(mountedNode, mountedNode);
3111 } else {
3112 var child = vnode.componentInstance = createComponentInstanceForVnode(
3113 vnode,
3114 activeInstance
3115 );
3116 child.$mount(hydrating ? vnode.elm : undefined, hydrating);
3117 }
3118 },
3119
3120 prepatch: function prepatch (oldVnode, vnode) {
3121 var options = vnode.componentOptions;
3122 var child = vnode.componentInstance = oldVnode.componentInstance;
3123 updateChildComponent(
3124 child,
3125 options.propsData, // updated props
3126 options.listeners, // updated listeners
3127 vnode, // new parent vnode
3128 options.children // new children
3129 );
3130 },
3131
3132 insert: function insert (vnode) {
3133 var context = vnode.context;
3134 var componentInstance = vnode.componentInstance;
3135 if (!componentInstance._isMounted) {
3136 componentInstance._isMounted = true;
3137 callHook(componentInstance, 'mounted');
3138 }
3139 if (vnode.data.keepAlive) {
3140 if (context._isMounted) {
3141 // vue-router#1212
3142 // During updates, a kept-alive component's child components may
3143 // change, so directly walking the tree here may call activated hooks
3144 // on incorrect children. Instead we push them into a queue which will
3145 // be processed after the whole patch process ended.
3146 queueActivatedComponent(componentInstance);
3147 } else {
3148 activateChildComponent(componentInstance, true /* direct */);
3149 }
3150 }
3151 },
3152
3153 destroy: function destroy (vnode) {
3154 var componentInstance = vnode.componentInstance;
3155 if (!componentInstance._isDestroyed) {
3156 if (!vnode.data.keepAlive) {
3157 componentInstance.$destroy();
3158 } else {
3159 deactivateChildComponent(componentInstance, true /* direct */);
3160 }
3161 }
3162 }
3163 };
3164
3165 var hooksToMerge = Object.keys(componentVNodeHooks);
3166
3167 function createComponent (
3168 Ctor,
3169 data,
3170 context,
3171 children,
3172 tag
3173 ) {
3174 if (isUndef(Ctor)) {
3175 return
3176 }
3177
3178 var baseCtor = context.$options._base;
3179
3180 // plain options object: turn it into a constructor
3181 if (isObject(Ctor)) {
3182 Ctor = baseCtor.extend(Ctor);
3183 }
3184
3185 // if at this stage it's not a constructor or an async component factory,
3186 // reject.
3187 if (typeof Ctor !== 'function') {
3188 {
3189 warn(("Invalid Component definition: " + (String(Ctor))), context);
3190 }
3191 return
3192 }
3193
3194 // async component
3195 var asyncFactory;
3196 if (isUndef(Ctor.cid)) {
3197 asyncFactory = Ctor;
3198 Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
3199 if (Ctor === undefined) {
3200 // return a placeholder node for async component, which is rendered
3201 // as a comment node but preserves all the raw information for the node.
3202 // the information will be used for async server-rendering and hydration.
3203 return createAsyncPlaceholder(
3204 asyncFactory,
3205 data,
3206 context,
3207 children,
3208 tag
3209 )
3210 }
3211 }
3212
3213 data = data || {};
3214
3215 // resolve constructor options in case global mixins are applied after
3216 // component constructor creation
3217 resolveConstructorOptions(Ctor);
3218
3219 // transform component v-model data into props & events
3220 if (isDef(data.model)) {
3221 transformModel(Ctor.options, data);
3222 }
3223
3224 // extract props
3225 var propsData = extractPropsFromVNodeData(data, Ctor, tag);
3226
3227 // functional component
3228 if (isTrue(Ctor.options.functional)) {
3229 return createFunctionalComponent(Ctor, propsData, data, context, children)
3230 }
3231
3232 // extract listeners, since these needs to be treated as
3233 // child component listeners instead of DOM listeners
3234 var listeners = data.on;
3235 // replace with listeners with .native modifier
3236 // so it gets processed during parent component patch.
3237 data.on = data.nativeOn;
3238
3239 if (isTrue(Ctor.options.abstract)) {
3240 // abstract components do not keep anything
3241 // other than props & listeners & slot
3242
3243 // work around flow
3244 var slot = data.slot;
3245 data = {};
3246 if (slot) {
3247 data.slot = slot;
3248 }
3249 }
3250
3251 // install component management hooks onto the placeholder node
3252 installComponentHooks(data);
3253
3254 // return a placeholder vnode
3255 var name = Ctor.options.name || tag;
3256 var vnode = new VNode(
3257 ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
3258 data, undefined, undefined, undefined, context,
3259 { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
3260 asyncFactory
3261 );
3262
3263 return vnode
3264 }
3265
3266 function createComponentInstanceForVnode (
3267 vnode, // we know it's MountedComponentVNode but flow doesn't
3268 parent // activeInstance in lifecycle state
3269 ) {
3270 var options = {
3271 _isComponent: true,
3272 _parentVnode: vnode,
3273 parent: parent
3274 };
3275 // check inline-template render functions
3276 var inlineTemplate = vnode.data.inlineTemplate;
3277 if (isDef(inlineTemplate)) {
3278 options.render = inlineTemplate.render;
3279 options.staticRenderFns = inlineTemplate.staticRenderFns;
3280 }
3281 return new vnode.componentOptions.Ctor(options)
3282 }
3283
3284 function installComponentHooks (data) {
3285 var hooks = data.hook || (data.hook = {});
3286 for (var i = 0; i < hooksToMerge.length; i++) {
3287 var key = hooksToMerge[i];
3288 var existing = hooks[key];
3289 var toMerge = componentVNodeHooks[key];
3290 if (existing !== toMerge && !(existing && existing._merged)) {
3291 hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
3292 }
3293 }
3294 }
3295
3296 function mergeHook$1 (f1, f2) {
3297 var merged = function (a, b) {
3298 // flow complains about extra args which is why we use any
3299 f1(a, b);
3300 f2(a, b);
3301 };
3302 merged._merged = true;
3303 return merged
3304 }
3305
3306 // transform component v-model info (value and callback) into
3307 // prop and event handler respectively.
3308 function transformModel (options, data) {
3309 var prop = (options.model && options.model.prop) || 'value';
3310 var event = (options.model && options.model.event) || 'input'
3311 ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
3312 var on = data.on || (data.on = {});
3313 var existing = on[event];
3314 var callback = data.model.callback;
3315 if (isDef(existing)) {
3316 if (
3317 Array.isArray(existing)
3318 ? existing.indexOf(callback) === -1
3319 : existing !== callback
3320 ) {
3321 on[event] = [callback].concat(existing);
3322 }
3323 } else {
3324 on[event] = callback;
3325 }
3326 }
3327
3328 /* */
3329
3330 var SIMPLE_NORMALIZE = 1;
3331 var ALWAYS_NORMALIZE = 2;
3332
3333 // wrapper function for providing a more flexible interface
3334 // without getting yelled at by flow
3335 function createElement (
3336 context,
3337 tag,
3338 data,
3339 children,
3340 normalizationType,
3341 alwaysNormalize
3342 ) {
3343 if (Array.isArray(data) || isPrimitive(data)) {
3344 normalizationType = children;
3345 children = data;
3346 data = undefined;
3347 }
3348 if (isTrue(alwaysNormalize)) {
3349 normalizationType = ALWAYS_NORMALIZE;
3350 }
3351 return _createElement(context, tag, data, children, normalizationType)
3352 }
3353
3354 function _createElement (
3355 context,
3356 tag,
3357 data,
3358 children,
3359 normalizationType
3360 ) {
3361 if (isDef(data) && isDef((data).__ob__)) {
3362 warn(
3363 "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
3364 'Always create fresh vnode data objects in each render!',
3365 context
3366 );
3367 return createEmptyVNode()
3368 }
3369 // object syntax in v-bind
3370 if (isDef(data) && isDef(data.is)) {
3371 tag = data.is;
3372 }
3373 if (!tag) {
3374 // in case of component :is set to falsy value
3375 return createEmptyVNode()
3376 }
3377 // warn against non-primitive key
3378 if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
3379 ) {
3380 {
3381 warn(
3382 'Avoid using non-primitive value as key, ' +
3383 'use string/number value instead.',
3384 context
3385 );
3386 }
3387 }
3388 // support single function children as default scoped slot
3389 if (Array.isArray(children) &&
3390 typeof children[0] === 'function'
3391 ) {
3392 data = data || {};
3393 data.scopedSlots = { default: children[0] };
3394 children.length = 0;
3395 }
3396 if (normalizationType === ALWAYS_NORMALIZE) {
3397 children = normalizeChildren(children);
3398 } else if (normalizationType === SIMPLE_NORMALIZE) {
3399 children = simpleNormalizeChildren(children);
3400 }
3401 var vnode, ns;
3402 if (typeof tag === 'string') {
3403 var Ctor;
3404 ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
3405 if (config.isReservedTag(tag)) {
3406 // platform built-in elements
3407 if (isDef(data) && isDef(data.nativeOn)) {
3408 warn(
3409 ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
3410 context
3411 );
3412 }
3413 vnode = new VNode(
3414 config.parsePlatformTagName(tag), data, children,
3415 undefined, undefined, context
3416 );
3417 } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
3418 // component
3419 vnode = createComponent(Ctor, data, context, children, tag);
3420 } else {
3421 // unknown or unlisted namespaced elements
3422 // check at runtime because it may get assigned a namespace when its
3423 // parent normalizes children
3424 vnode = new VNode(
3425 tag, data, children,
3426 undefined, undefined, context
3427 );
3428 }
3429 } else {
3430 // direct component options / constructor
3431 vnode = createComponent(tag, data, context, children);
3432 }
3433 if (Array.isArray(vnode)) {
3434 return vnode
3435 } else if (isDef(vnode)) {
3436 if (isDef(ns)) { applyNS(vnode, ns); }
3437 if (isDef(data)) { registerDeepBindings(data); }
3438 return vnode
3439 } else {
3440 return createEmptyVNode()
3441 }
3442 }
3443
3444 function applyNS (vnode, ns, force) {
3445 vnode.ns = ns;
3446 if (vnode.tag === 'foreignObject') {
3447 // use default namespace inside foreignObject
3448 ns = undefined;
3449 force = true;
3450 }
3451 if (isDef(vnode.children)) {
3452 for (var i = 0, l = vnode.children.length; i < l; i++) {
3453 var child = vnode.children[i];
3454 if (isDef(child.tag) && (
3455 isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
3456 applyNS(child, ns, force);
3457 }
3458 }
3459 }
3460 }
3461
3462 // ref #5318
3463 // necessary to ensure parent re-render when deep bindings like :style and
3464 // :class are used on slot nodes
3465 function registerDeepBindings (data) {
3466 if (isObject(data.style)) {
3467 traverse(data.style);
3468 }
3469 if (isObject(data.class)) {
3470 traverse(data.class);
3471 }
3472 }
3473
3474 /* */
3475
3476 function initRender (vm) {
3477 vm._vnode = null; // the root of the child tree
3478 vm._staticTrees = null; // v-once cached trees
3479 var options = vm.$options;
3480 var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
3481 var renderContext = parentVnode && parentVnode.context;
3482 vm.$slots = resolveSlots(options._renderChildren, renderContext);
3483 vm.$scopedSlots = emptyObject;
3484 // bind the createElement fn to this instance
3485 // so that we get proper render context inside it.
3486 // args order: tag, data, children, normalizationType, alwaysNormalize
3487 // internal version is used by render functions compiled from templates
3488 vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
3489 // normalization is always applied for the public version, used in
3490 // user-written render functions.
3491 vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
3492
3493 // $attrs & $listeners are exposed for easier HOC creation.
3494 // they need to be reactive so that HOCs using them are always updated
3495 var parentData = parentVnode && parentVnode.data;
3496
3497 /* istanbul ignore else */
3498 {
3499 defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
3500 !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
3501 }, true);
3502 defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
3503 !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
3504 }, true);
3505 }
3506 }
3507
3508 var currentRenderingInstance = null;
3509
3510 function renderMixin (Vue) {
3511 // install runtime convenience helpers
3512 installRenderHelpers(Vue.prototype);
3513
3514 Vue.prototype.$nextTick = function (fn) {
3515 return nextTick(fn, this)
3516 };
3517
3518 Vue.prototype._render = function () {
3519 var vm = this;
3520 var ref = vm.$options;
3521 var render = ref.render;
3522 var _parentVnode = ref._parentVnode;
3523
3524 if (_parentVnode) {
3525 vm.$scopedSlots = normalizeScopedSlots(
3526 _parentVnode.data.scopedSlots,
3527 vm.$slots,
3528 vm.$scopedSlots
3529 );
3530 }
3531
3532 // set parent vnode. this allows render functions to have access
3533 // to the data on the placeholder node.
3534 vm.$vnode = _parentVnode;
3535 // render self
3536 var vnode;
3537 try {
3538 // There's no need to maintain a stack because all render fns are called
3539 // separately from one another. Nested component's render fns are called
3540 // when parent component is patched.
3541 currentRenderingInstance = vm;
3542 vnode = render.call(vm._renderProxy, vm.$createElement);
3543 } catch (e) {
3544 handleError(e, vm, "render");
3545 // return error render result,
3546 // or previous vnode to prevent render error causing blank component
3547 /* istanbul ignore else */
3548 if (vm.$options.renderError) {
3549 try {
3550 vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
3551 } catch (e) {
3552 handleError(e, vm, "renderError");
3553 vnode = vm._vnode;
3554 }
3555 } else {
3556 vnode = vm._vnode;
3557 }
3558 } finally {
3559 currentRenderingInstance = null;
3560 }
3561 // if the returned array contains only a single node, allow it
3562 if (Array.isArray(vnode) && vnode.length === 1) {
3563 vnode = vnode[0];
3564 }
3565 // return empty vnode in case the render function errored out
3566 if (!(vnode instanceof VNode)) {
3567 if (Array.isArray(vnode)) {
3568 warn(
3569 'Multiple root nodes returned from render function. Render function ' +
3570 'should return a single root node.',
3571 vm
3572 );
3573 }
3574 vnode = createEmptyVNode();
3575 }
3576 // set parent
3577 vnode.parent = _parentVnode;
3578 return vnode
3579 };
3580 }
3581
3582 /* */
3583
3584 function ensureCtor (comp, base) {
3585 if (
3586 comp.__esModule ||
3587 (hasSymbol && comp[Symbol.toStringTag] === 'Module')
3588 ) {
3589 comp = comp.default;
3590 }
3591 return isObject(comp)
3592 ? base.extend(comp)
3593 : comp
3594 }
3595
3596 function createAsyncPlaceholder (
3597 factory,
3598 data,
3599 context,
3600 children,
3601 tag
3602 ) {
3603 var node = createEmptyVNode();
3604 node.asyncFactory = factory;
3605 node.asyncMeta = { data: data, context: context, children: children, tag: tag };
3606 return node
3607 }
3608
3609 function resolveAsyncComponent (
3610 factory,
3611 baseCtor
3612 ) {
3613 if (isTrue(factory.error) && isDef(factory.errorComp)) {
3614 return factory.errorComp
3615 }
3616
3617 if (isDef(factory.resolved)) {
3618 return factory.resolved
3619 }
3620
3621 var owner = currentRenderingInstance;
3622 if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
3623 // already pending
3624 factory.owners.push(owner);
3625 }
3626
3627 if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3628 return factory.loadingComp
3629 }
3630
3631 if (owner && !isDef(factory.owners)) {
3632 var owners = factory.owners = [owner];
3633 var sync = true;
3634 var timerLoading = null;
3635 var timerTimeout = null
3636
3637 ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
3638
3639 var forceRender = function (renderCompleted) {
3640 for (var i = 0, l = owners.length; i < l; i++) {
3641 (owners[i]).$forceUpdate();
3642 }
3643
3644 if (renderCompleted) {
3645 owners.length = 0;
3646 if (timerLoading !== null) {
3647 clearTimeout(timerLoading);
3648 timerLoading = null;
3649 }
3650 if (timerTimeout !== null) {
3651 clearTimeout(timerTimeout);
3652 timerTimeout = null;
3653 }
3654 }
3655 };
3656
3657 var resolve = once(function (res) {
3658 // cache resolved
3659 factory.resolved = ensureCtor(res, baseCtor);
3660 // invoke callbacks only if this is not a synchronous resolve
3661 // (async resolves are shimmed as synchronous during SSR)
3662 if (!sync) {
3663 forceRender(true);
3664 } else {
3665 owners.length = 0;
3666 }
3667 });
3668
3669 var reject = once(function (reason) {
3670 warn(
3671 "Failed to resolve async component: " + (String(factory)) +
3672 (reason ? ("\nReason: " + reason) : '')
3673 );
3674 if (isDef(factory.errorComp)) {
3675 factory.error = true;
3676 forceRender(true);
3677 }
3678 });
3679
3680 var res = factory(resolve, reject);
3681
3682 if (isObject(res)) {
3683 if (isPromise(res)) {
3684 // () => Promise
3685 if (isUndef(factory.resolved)) {
3686 res.then(resolve, reject);
3687 }
3688 } else if (isPromise(res.component)) {
3689 res.component.then(resolve, reject);
3690
3691 if (isDef(res.error)) {
3692 factory.errorComp = ensureCtor(res.error, baseCtor);
3693 }
3694
3695 if (isDef(res.loading)) {
3696 factory.loadingComp = ensureCtor(res.loading, baseCtor);
3697 if (res.delay === 0) {
3698 factory.loading = true;
3699 } else {
3700 timerLoading = setTimeout(function () {
3701 timerLoading = null;
3702 if (isUndef(factory.resolved) && isUndef(factory.error)) {
3703 factory.loading = true;
3704 forceRender(false);
3705 }
3706 }, res.delay || 200);
3707 }
3708 }
3709
3710 if (isDef(res.timeout)) {
3711 timerTimeout = setTimeout(function () {
3712 timerTimeout = null;
3713 if (isUndef(factory.resolved)) {
3714 reject(
3715 "timeout (" + (res.timeout) + "ms)"
3716 );
3717 }
3718 }, res.timeout);
3719 }
3720 }
3721 }
3722
3723 sync = false;
3724 // return in case resolved synchronously
3725 return factory.loading
3726 ? factory.loadingComp
3727 : factory.resolved
3728 }
3729 }
3730
3731 /* */
3732
3733 function isAsyncPlaceholder (node) {
3734 return node.isComment && node.asyncFactory
3735 }
3736
3737 /* */
3738
3739 function getFirstComponentChild (children) {
3740 if (Array.isArray(children)) {
3741 for (var i = 0; i < children.length; i++) {
3742 var c = children[i];
3743 if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
3744 return c
3745 }
3746 }
3747 }
3748 }
3749
3750 /* */
3751
3752 /* */
3753
3754 function initEvents (vm) {
3755 vm._events = Object.create(null);
3756 vm._hasHookEvent = false;
3757 // init parent attached events
3758 var listeners = vm.$options._parentListeners;
3759 if (listeners) {
3760 updateComponentListeners(vm, listeners);
3761 }
3762 }
3763
3764 var target;
3765
3766 function add (event, fn) {
3767 target.$on(event, fn);
3768 }
3769
3770 function remove$1 (event, fn) {
3771 target.$off(event, fn);
3772 }
3773
3774 function createOnceHandler (event, fn) {
3775 var _target = target;
3776 return function onceHandler () {
3777 var res = fn.apply(null, arguments);
3778 if (res !== null) {
3779 _target.$off(event, onceHandler);
3780 }
3781 }
3782 }
3783
3784 function updateComponentListeners (
3785 vm,
3786 listeners,
3787 oldListeners
3788 ) {
3789 target = vm;
3790 updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
3791 target = undefined;
3792 }
3793
3794 function eventsMixin (Vue) {
3795 var hookRE = /^hook:/;
3796 Vue.prototype.$on = function (event, fn) {
3797 var vm = this;
3798 if (Array.isArray(event)) {
3799 for (var i = 0, l = event.length; i < l; i++) {
3800 vm.$on(event[i], fn);
3801 }
3802 } else {
3803 (vm._events[event] || (vm._events[event] = [])).push(fn);
3804 // optimize hook:event cost by using a boolean flag marked at registration
3805 // instead of a hash lookup
3806 if (hookRE.test(event)) {
3807 vm._hasHookEvent = true;
3808 }
3809 }
3810 return vm
3811 };
3812
3813 Vue.prototype.$once = function (event, fn) {
3814 var vm = this;
3815 function on () {
3816 vm.$off(event, on);
3817 fn.apply(vm, arguments);
3818 }
3819 on.fn = fn;
3820 vm.$on(event, on);
3821 return vm
3822 };
3823
3824 Vue.prototype.$off = function (event, fn) {
3825 var vm = this;
3826 // all
3827 if (!arguments.length) {
3828 vm._events = Object.create(null);
3829 return vm
3830 }
3831 // array of events
3832 if (Array.isArray(event)) {
3833 for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
3834 vm.$off(event[i$1], fn);
3835 }
3836 return vm
3837 }
3838 // specific event
3839 var cbs = vm._events[event];
3840 if (!cbs) {
3841 return vm
3842 }
3843 if (!fn) {
3844 vm._events[event] = null;
3845 return vm
3846 }
3847 // specific handler
3848 var cb;
3849 var i = cbs.length;
3850 while (i--) {
3851 cb = cbs[i];
3852 if (cb === fn || cb.fn === fn) {
3853 cbs.splice(i, 1);
3854 break
3855 }
3856 }
3857 return vm
3858 };
3859
3860 Vue.prototype.$emit = function (event) {
3861 var vm = this;
3862 {
3863 var lowerCaseEvent = event.toLowerCase();
3864 if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
3865 tip(
3866 "Event \"" + lowerCaseEvent + "\" is emitted in component " +
3867 (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
3868 "Note that HTML attributes are case-insensitive and you cannot use " +
3869 "v-on to listen to camelCase events when using in-DOM templates. " +
3870 "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
3871 );
3872 }
3873 }
3874 var cbs = vm._events[event];
3875 if (cbs) {
3876 cbs = cbs.length > 1 ? toArray(cbs) : cbs;
3877 var args = toArray(arguments, 1);
3878 var info = "event handler for \"" + event + "\"";
3879 for (var i = 0, l = cbs.length; i < l; i++) {
3880 invokeWithErrorHandling(cbs[i], vm, args, vm, info);
3881 }
3882 }
3883 return vm
3884 };
3885 }
3886
3887 /* */
3888
3889 var activeInstance = null;
3890 var isUpdatingChildComponent = false;
3891
3892 function setActiveInstance(vm) {
3893 var prevActiveInstance = activeInstance;
3894 activeInstance = vm;
3895 return function () {
3896 activeInstance = prevActiveInstance;
3897 }
3898 }
3899
3900 function initLifecycle (vm) {
3901 var options = vm.$options;
3902
3903 // locate first non-abstract parent
3904 var parent = options.parent;
3905 if (parent && !options.abstract) {
3906 while (parent.$options.abstract && parent.$parent) {
3907 parent = parent.$parent;
3908 }
3909 parent.$children.push(vm);
3910 }
3911
3912 vm.$parent = parent;
3913 vm.$root = parent ? parent.$root : vm;
3914
3915 vm.$children = [];
3916 vm.$refs = {};
3917
3918 vm._watcher = null;
3919 vm._inactive = null;
3920 vm._directInactive = false;
3921 vm._isMounted = false;
3922 vm._isDestroyed = false;
3923 vm._isBeingDestroyed = false;
3924 }
3925
3926 function lifecycleMixin (Vue) {
3927 Vue.prototype._update = function (vnode, hydrating) {
3928 var vm = this;
3929 var prevEl = vm.$el;
3930 var prevVnode = vm._vnode;
3931 var restoreActiveInstance = setActiveInstance(vm);
3932 vm._vnode = vnode;
3933 // Vue.prototype.__patch__ is injected in entry points
3934 // based on the rendering backend used.
3935 if (!prevVnode) {
3936 // initial render
3937 vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
3938 } else {
3939 // updates
3940 vm.$el = vm.__patch__(prevVnode, vnode);
3941 }
3942 restoreActiveInstance();
3943 // update __vue__ reference
3944 if (prevEl) {
3945 prevEl.__vue__ = null;
3946 }
3947 if (vm.$el) {
3948 vm.$el.__vue__ = vm;
3949 }
3950 // if parent is an HOC, update its $el as well
3951 if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
3952 vm.$parent.$el = vm.$el;
3953 }
3954 // updated hook is called by the scheduler to ensure that children are
3955 // updated in a parent's updated hook.
3956 };
3957
3958 Vue.prototype.$forceUpdate = function () {
3959 var vm = this;
3960 if (vm._watcher) {
3961 vm._watcher.update();
3962 }
3963 };
3964
3965 Vue.prototype.$destroy = function () {
3966 var vm = this;
3967 if (vm._isBeingDestroyed) {
3968 return
3969 }
3970 callHook(vm, 'beforeDestroy');
3971 vm._isBeingDestroyed = true;
3972 // remove self from parent
3973 var parent = vm.$parent;
3974 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
3975 remove(parent.$children, vm);
3976 }
3977 // teardown watchers
3978 if (vm._watcher) {
3979 vm._watcher.teardown();
3980 }
3981 var i = vm._watchers.length;
3982 while (i--) {
3983 vm._watchers[i].teardown();
3984 }
3985 // remove reference from data ob
3986 // frozen object may not have observer.
3987 if (vm._data.__ob__) {
3988 vm._data.__ob__.vmCount--;
3989 }
3990 // call the last hook...
3991 vm._isDestroyed = true;
3992 // invoke destroy hooks on current rendered tree
3993 vm.__patch__(vm._vnode, null);
3994 // fire destroyed hook
3995 callHook(vm, 'destroyed');
3996 // turn off all instance listeners.
3997 vm.$off();
3998 // remove __vue__ reference
3999 if (vm.$el) {
4000 vm.$el.__vue__ = null;
4001 }
4002 // release circular reference (#6759)
4003 if (vm.$vnode) {
4004 vm.$vnode.parent = null;
4005 }
4006 };
4007 }
4008
4009 function mountComponent (
4010 vm,
4011 el,
4012 hydrating
4013 ) {
4014 vm.$el = el;
4015 if (!vm.$options.render) {
4016 vm.$options.render = createEmptyVNode;
4017 {
4018 /* istanbul ignore if */
4019 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
4020 vm.$options.el || el) {
4021 warn(
4022 'You are using the runtime-only build of Vue where the template ' +
4023 'compiler is not available. Either pre-compile the templates into ' +
4024 'render functions, or use the compiler-included build.',
4025 vm
4026 );
4027 } else {
4028 warn(
4029 'Failed to mount component: template or render function not defined.',
4030 vm
4031 );
4032 }
4033 }
4034 }
4035 callHook(vm, 'beforeMount');
4036
4037 var updateComponent;
4038 /* istanbul ignore if */
4039 if (config.performance && mark) {
4040 updateComponent = function () {
4041 var name = vm._name;
4042 var id = vm._uid;
4043 var startTag = "vue-perf-start:" + id;
4044 var endTag = "vue-perf-end:" + id;
4045
4046 mark(startTag);
4047 var vnode = vm._render();
4048 mark(endTag);
4049 measure(("vue " + name + " render"), startTag, endTag);
4050
4051 mark(startTag);
4052 vm._update(vnode, hydrating);
4053 mark(endTag);
4054 measure(("vue " + name + " patch"), startTag, endTag);
4055 };
4056 } else {
4057 updateComponent = function () {
4058 vm._update(vm._render(), hydrating);
4059 };
4060 }
4061
4062 // we set this to vm._watcher inside the watcher's constructor
4063 // since the watcher's initial patch may call $forceUpdate (e.g. inside child
4064 // component's mounted hook), which relies on vm._watcher being already defined
4065 new Watcher(vm, updateComponent, noop, {
4066 before: function before () {
4067 if (vm._isMounted && !vm._isDestroyed) {
4068 callHook(vm, 'beforeUpdate');
4069 }
4070 }
4071 }, true /* isRenderWatcher */);
4072 hydrating = false;
4073
4074 // manually mounted instance, call mounted on self
4075 // mounted is called for render-created child components in its inserted hook
4076 if (vm.$vnode == null) {
4077 vm._isMounted = true;
4078 callHook(vm, 'mounted');
4079 }
4080 return vm
4081 }
4082
4083 function updateChildComponent (
4084 vm,
4085 propsData,
4086 listeners,
4087 parentVnode,
4088 renderChildren
4089 ) {
4090 {
4091 isUpdatingChildComponent = true;
4092 }
4093
4094 // determine whether component has slot children
4095 // we need to do this before overwriting $options._renderChildren.
4096
4097 // check if there are dynamic scopedSlots (hand-written or compiled but with
4098 // dynamic slot names). Static scoped slots compiled from template has the
4099 // "$stable" marker.
4100 var newScopedSlots = parentVnode.data.scopedSlots;
4101 var oldScopedSlots = vm.$scopedSlots;
4102 var hasDynamicScopedSlot = !!(
4103 (newScopedSlots && !newScopedSlots.$stable) ||
4104 (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
4105 (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
4106 );
4107
4108 // Any static slot children from the parent may have changed during parent's
4109 // update. Dynamic scoped slots may also have changed. In such cases, a forced
4110 // update is necessary to ensure correctness.
4111 var needsForceUpdate = !!(
4112 renderChildren || // has new static slots
4113 vm.$options._renderChildren || // has old static slots
4114 hasDynamicScopedSlot
4115 );
4116
4117 vm.$options._parentVnode = parentVnode;
4118 vm.$vnode = parentVnode; // update vm's placeholder node without re-render
4119
4120 if (vm._vnode) { // update child tree's parent
4121 vm._vnode.parent = parentVnode;
4122 }
4123 vm.$options._renderChildren = renderChildren;
4124
4125 // update $attrs and $listeners hash
4126 // these are also reactive so they may trigger child update if the child
4127 // used them during render
4128 vm.$attrs = parentVnode.data.attrs || emptyObject;
4129 vm.$listeners = listeners || emptyObject;
4130
4131 // update props
4132 if (propsData && vm.$options.props) {
4133 toggleObserving(false);
4134 var props = vm._props;
4135 var propKeys = vm.$options._propKeys || [];
4136 for (var i = 0; i < propKeys.length; i++) {
4137 var key = propKeys[i];
4138 var propOptions = vm.$options.props; // wtf flow?
4139 props[key] = validateProp(key, propOptions, propsData, vm);
4140 }
4141 toggleObserving(true);
4142 // keep a copy of raw propsData
4143 vm.$options.propsData = propsData;
4144 }
4145
4146 // update listeners
4147 listeners = listeners || emptyObject;
4148 var oldListeners = vm.$options._parentListeners;
4149 vm.$options._parentListeners = listeners;
4150 updateComponentListeners(vm, listeners, oldListeners);
4151
4152 // resolve slots + force update if has children
4153 if (needsForceUpdate) {
4154 vm.$slots = resolveSlots(renderChildren, parentVnode.context);
4155 vm.$forceUpdate();
4156 }
4157
4158 {
4159 isUpdatingChildComponent = false;
4160 }
4161 }
4162
4163 function isInInactiveTree (vm) {
4164 while (vm && (vm = vm.$parent)) {
4165 if (vm._inactive) { return true }
4166 }
4167 return false
4168 }
4169
4170 function activateChildComponent (vm, direct) {
4171 if (direct) {
4172 vm._directInactive = false;
4173 if (isInInactiveTree(vm)) {
4174 return
4175 }
4176 } else if (vm._directInactive) {
4177 return
4178 }
4179 if (vm._inactive || vm._inactive === null) {
4180 vm._inactive = false;
4181 for (var i = 0; i < vm.$children.length; i++) {
4182 activateChildComponent(vm.$children[i]);
4183 }
4184 callHook(vm, 'activated');
4185 }
4186 }
4187
4188 function deactivateChildComponent (vm, direct) {
4189 if (direct) {
4190 vm._directInactive = true;
4191 if (isInInactiveTree(vm)) {
4192 return
4193 }
4194 }
4195 if (!vm._inactive) {
4196 vm._inactive = true;
4197 for (var i = 0; i < vm.$children.length; i++) {
4198 deactivateChildComponent(vm.$children[i]);
4199 }
4200 callHook(vm, 'deactivated');
4201 }
4202 }
4203
4204 function callHook (vm, hook) {
4205 // #7573 disable dep collection when invoking lifecycle hooks
4206 pushTarget();
4207 var handlers = vm.$options[hook];
4208 var info = hook + " hook";
4209 if (handlers) {
4210 for (var i = 0, j = handlers.length; i < j; i++) {
4211 invokeWithErrorHandling(handlers[i], vm, null, vm, info);
4212 }
4213 }
4214 if (vm._hasHookEvent) {
4215 vm.$emit('hook:' + hook);
4216 }
4217 popTarget();
4218 }
4219
4220 /* */
4221
4222 var MAX_UPDATE_COUNT = 100;
4223
4224 var queue = [];
4225 var activatedChildren = [];
4226 var has = {};
4227 var circular = {};
4228 var waiting = false;
4229 var flushing = false;
4230 var index = 0;
4231
4232 /**
4233 * Reset the scheduler's state.
4234 */
4235 function resetSchedulerState () {
4236 index = queue.length = activatedChildren.length = 0;
4237 has = {};
4238 {
4239 circular = {};
4240 }
4241 waiting = flushing = false;
4242 }
4243
4244 // Async edge case #6566 requires saving the timestamp when event listeners are
4245 // attached. However, calling performance.now() has a perf overhead especially
4246 // if the page has thousands of event listeners. Instead, we take a timestamp
4247 // every time the scheduler flushes and use that for all event listeners
4248 // attached during that flush.
4249 var currentFlushTimestamp = 0;
4250
4251 // Async edge case fix requires storing an event listener's attach timestamp.
4252 var getNow = Date.now;
4253
4254 // Determine what event timestamp the browser is using. Annoyingly, the
4255 // timestamp can either be hi-res (relative to page load) or low-res
4256 // (relative to UNIX epoch), so in order to compare time we have to use the
4257 // same timestamp type when saving the flush timestamp.
4258 // All IE versions use low-res event timestamps, and have problematic clock
4259 // implementations (#9632)
4260 if (inBrowser && !isIE) {
4261 var performance = window.performance;
4262 if (
4263 performance &&
4264 typeof performance.now === 'function' &&
4265 getNow() > document.createEvent('Event').timeStamp
4266 ) {
4267 // if the event timestamp, although evaluated AFTER the Date.now(), is
4268 // smaller than it, it means the event is using a hi-res timestamp,
4269 // and we need to use the hi-res version for event listener timestamps as
4270 // well.
4271 getNow = function () { return performance.now(); };
4272 }
4273 }
4274
4275 /**
4276 * Flush both queues and run the watchers.
4277 */
4278 function flushSchedulerQueue () {
4279 currentFlushTimestamp = getNow();
4280 flushing = true;
4281 var watcher, id;
4282
4283 // Sort queue before flush.
4284 // This ensures that:
4285 // 1. Components are updated from parent to child. (because parent is always
4286 // created before the child)
4287 // 2. A component's user watchers are run before its render watcher (because
4288 // user watchers are created before the render watcher)
4289 // 3. If a component is destroyed during a parent component's watcher run,
4290 // its watchers can be skipped.
4291 queue.sort(function (a, b) { return a.id - b.id; });
4292
4293 // do not cache length because more watchers might be pushed
4294 // as we run existing watchers
4295 for (index = 0; index < queue.length; index++) {
4296 watcher = queue[index];
4297 if (watcher.before) {
4298 watcher.before();
4299 }
4300 id = watcher.id;
4301 has[id] = null;
4302 watcher.run();
4303 // in dev build, check and stop circular updates.
4304 if (has[id] != null) {
4305 circular[id] = (circular[id] || 0) + 1;
4306 if (circular[id] > MAX_UPDATE_COUNT) {
4307 warn(
4308 'You may have an infinite update loop ' + (
4309 watcher.user
4310 ? ("in watcher with expression \"" + (watcher.expression) + "\"")
4311 : "in a component render function."
4312 ),
4313 watcher.vm
4314 );
4315 break
4316 }
4317 }
4318 }
4319
4320 // keep copies of post queues before resetting state
4321 var activatedQueue = activatedChildren.slice();
4322 var updatedQueue = queue.slice();
4323
4324 resetSchedulerState();
4325
4326 // call component updated and activated hooks
4327 callActivatedHooks(activatedQueue);
4328 callUpdatedHooks(updatedQueue);
4329
4330 // devtool hook
4331 /* istanbul ignore if */
4332 if (devtools && config.devtools) {
4333 devtools.emit('flush');
4334 }
4335 }
4336
4337 function callUpdatedHooks (queue) {
4338 var i = queue.length;
4339 while (i--) {
4340 var watcher = queue[i];
4341 var vm = watcher.vm;
4342 if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
4343 callHook(vm, 'updated');
4344 }
4345 }
4346 }
4347
4348 /**
4349 * Queue a kept-alive component that was activated during patch.
4350 * The queue will be processed after the entire tree has been patched.
4351 */
4352 function queueActivatedComponent (vm) {
4353 // setting _inactive to false here so that a render function can
4354 // rely on checking whether it's in an inactive tree (e.g. router-view)
4355 vm._inactive = false;
4356 activatedChildren.push(vm);
4357 }
4358
4359 function callActivatedHooks (queue) {
4360 for (var i = 0; i < queue.length; i++) {
4361 queue[i]._inactive = true;
4362 activateChildComponent(queue[i], true /* true */);
4363 }
4364 }
4365
4366 /**
4367 * Push a watcher into the watcher queue.
4368 * Jobs with duplicate IDs will be skipped unless it's
4369 * pushed when the queue is being flushed.
4370 */
4371 function queueWatcher (watcher) {
4372 var id = watcher.id;
4373 if (has[id] == null) {
4374 has[id] = true;
4375 if (!flushing) {
4376 queue.push(watcher);
4377 } else {
4378 // if already flushing, splice the watcher based on its id
4379 // if already past its id, it will be run next immediately.
4380 var i = queue.length - 1;
4381 while (i > index && queue[i].id > watcher.id) {
4382 i--;
4383 }
4384 queue.splice(i + 1, 0, watcher);
4385 }
4386 // queue the flush
4387 if (!waiting) {
4388 waiting = true;
4389
4390 if (!config.async) {
4391 flushSchedulerQueue();
4392 return
4393 }
4394 nextTick(flushSchedulerQueue);
4395 }
4396 }
4397 }
4398
4399 /* */
4400
4401
4402
4403 var uid$2 = 0;
4404
4405 /**
4406 * A watcher parses an expression, collects dependencies,
4407 * and fires callback when the expression value changes.
4408 * This is used for both the $watch() api and directives.
4409 */
4410 var Watcher = function Watcher (
4411 vm,
4412 expOrFn,
4413 cb,
4414 options,
4415 isRenderWatcher
4416 ) {
4417 this.vm = vm;
4418 if (isRenderWatcher) {
4419 vm._watcher = this;
4420 }
4421 vm._watchers.push(this);
4422 // options
4423 if (options) {
4424 this.deep = !!options.deep;
4425 this.user = !!options.user;
4426 this.lazy = !!options.lazy;
4427 this.sync = !!options.sync;
4428 this.before = options.before;
4429 } else {
4430 this.deep = this.user = this.lazy = this.sync = false;
4431 }
4432 this.cb = cb;
4433 this.id = ++uid$2; // uid for batching
4434 this.active = true;
4435 this.dirty = this.lazy; // for lazy watchers
4436 this.deps = [];
4437 this.newDeps = [];
4438 this.depIds = new _Set();
4439 this.newDepIds = new _Set();
4440 this.expression = expOrFn.toString();
4441 // parse expression for getter
4442 if (typeof expOrFn === 'function') {
4443 this.getter = expOrFn;
4444 } else {
4445 this.getter = parsePath(expOrFn);
4446 if (!this.getter) {
4447 this.getter = noop;
4448 warn(
4449 "Failed watching path: \"" + expOrFn + "\" " +
4450 'Watcher only accepts simple dot-delimited paths. ' +
4451 'For full control, use a function instead.',
4452 vm
4453 );
4454 }
4455 }
4456 this.value = this.lazy
4457 ? undefined
4458 : this.get();
4459 };
4460
4461 /**
4462 * Evaluate the getter, and re-collect dependencies.
4463 */
4464 Watcher.prototype.get = function get () {
4465 pushTarget(this);
4466 var value;
4467 var vm = this.vm;
4468 try {
4469 value = this.getter.call(vm, vm);
4470 } catch (e) {
4471 if (this.user) {
4472 handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
4473 } else {
4474 throw e
4475 }
4476 } finally {
4477 // "touch" every property so they are all tracked as
4478 // dependencies for deep watching
4479 if (this.deep) {
4480 traverse(value);
4481 }
4482 popTarget();
4483 this.cleanupDeps();
4484 }
4485 return value
4486 };
4487
4488 /**
4489 * Add a dependency to this directive.
4490 */
4491 Watcher.prototype.addDep = function addDep (dep) {
4492 var id = dep.id;
4493 if (!this.newDepIds.has(id)) {
4494 this.newDepIds.add(id);
4495 this.newDeps.push(dep);
4496 if (!this.depIds.has(id)) {
4497 dep.addSub(this);
4498 }
4499 }
4500 };
4501
4502 /**
4503 * Clean up for dependency collection.
4504 */
4505 Watcher.prototype.cleanupDeps = function cleanupDeps () {
4506 var i = this.deps.length;
4507 while (i--) {
4508 var dep = this.deps[i];
4509 if (!this.newDepIds.has(dep.id)) {
4510 dep.removeSub(this);
4511 }
4512 }
4513 var tmp = this.depIds;
4514 this.depIds = this.newDepIds;
4515 this.newDepIds = tmp;
4516 this.newDepIds.clear();
4517 tmp = this.deps;
4518 this.deps = this.newDeps;
4519 this.newDeps = tmp;
4520 this.newDeps.length = 0;
4521 };
4522
4523 /**
4524 * Subscriber interface.
4525 * Will be called when a dependency changes.
4526 */
4527 Watcher.prototype.update = function update () {
4528 /* istanbul ignore else */
4529 if (this.lazy) {
4530 this.dirty = true;
4531 } else if (this.sync) {
4532 this.run();
4533 } else {
4534 queueWatcher(this);
4535 }
4536 };
4537
4538 /**
4539 * Scheduler job interface.
4540 * Will be called by the scheduler.
4541 */
4542 Watcher.prototype.run = function run () {
4543 if (this.active) {
4544 var value = this.get();
4545 if (
4546 value !== this.value ||
4547 // Deep watchers and watchers on Object/Arrays should fire even
4548 // when the value is the same, because the value may
4549 // have mutated.
4550 isObject(value) ||
4551 this.deep
4552 ) {
4553 // set new value
4554 var oldValue = this.value;
4555 this.value = value;
4556 if (this.user) {
4557 try {
4558 this.cb.call(this.vm, value, oldValue);
4559 } catch (e) {
4560 handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
4561 }
4562 } else {
4563 this.cb.call(this.vm, value, oldValue);
4564 }
4565 }
4566 }
4567 };
4568
4569 /**
4570 * Evaluate the value of the watcher.
4571 * This only gets called for lazy watchers.
4572 */
4573 Watcher.prototype.evaluate = function evaluate () {
4574 this.value = this.get();
4575 this.dirty = false;
4576 };
4577
4578 /**
4579 * Depend on all deps collected by this watcher.
4580 */
4581 Watcher.prototype.depend = function depend () {
4582 var i = this.deps.length;
4583 while (i--) {
4584 this.deps[i].depend();
4585 }
4586 };
4587
4588 /**
4589 * Remove self from all dependencies' subscriber list.
4590 */
4591 Watcher.prototype.teardown = function teardown () {
4592 if (this.active) {
4593 // remove self from vm's watcher list
4594 // this is a somewhat expensive operation so we skip it
4595 // if the vm is being destroyed.
4596 if (!this.vm._isBeingDestroyed) {
4597 remove(this.vm._watchers, this);
4598 }
4599 var i = this.deps.length;
4600 while (i--) {
4601 this.deps[i].removeSub(this);
4602 }
4603 this.active = false;
4604 }
4605 };
4606
4607 /* */
4608
4609 var sharedPropertyDefinition = {
4610 enumerable: true,
4611 configurable: true,
4612 get: noop,
4613 set: noop
4614 };
4615
4616 function proxy (target, sourceKey, key) {
4617 sharedPropertyDefinition.get = function proxyGetter () {
4618 return this[sourceKey][key]
4619 };
4620 sharedPropertyDefinition.set = function proxySetter (val) {
4621 this[sourceKey][key] = val;
4622 };
4623 Object.defineProperty(target, key, sharedPropertyDefinition);
4624 }
4625
4626 function initState (vm) {
4627 vm._watchers = [];
4628 var opts = vm.$options;
4629 if (opts.props) { initProps(vm, opts.props); }
4630 if (opts.methods) { initMethods(vm, opts.methods); }
4631 if (opts.data) {
4632 initData(vm);
4633 } else {
4634 observe(vm._data = {}, true /* asRootData */);
4635 }
4636 if (opts.computed) { initComputed(vm, opts.computed); }
4637 if (opts.watch && opts.watch !== nativeWatch) {
4638 initWatch(vm, opts.watch);
4639 }
4640 }
4641
4642 function initProps (vm, propsOptions) {
4643 var propsData = vm.$options.propsData || {};
4644 var props = vm._props = {};
4645 // cache prop keys so that future props updates can iterate using Array
4646 // instead of dynamic object key enumeration.
4647 var keys = vm.$options._propKeys = [];
4648 var isRoot = !vm.$parent;
4649 // root instance props should be converted
4650 if (!isRoot) {
4651 toggleObserving(false);
4652 }
4653 var loop = function ( key ) {
4654 keys.push(key);
4655 var value = validateProp(key, propsOptions, propsData, vm);
4656 /* istanbul ignore else */
4657 {
4658 var hyphenatedKey = hyphenate(key);
4659 if (isReservedAttribute(hyphenatedKey) ||
4660 config.isReservedAttr(hyphenatedKey)) {
4661 warn(
4662 ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
4663 vm
4664 );
4665 }
4666 defineReactive$$1(props, key, value, function () {
4667 if (!isRoot && !isUpdatingChildComponent) {
4668 warn(
4669 "Avoid mutating a prop directly since the value will be " +
4670 "overwritten whenever the parent component re-renders. " +
4671 "Instead, use a data or computed property based on the prop's " +
4672 "value. Prop being mutated: \"" + key + "\"",
4673 vm
4674 );
4675 }
4676 });
4677 }
4678 // static props are already proxied on the component's prototype
4679 // during Vue.extend(). We only need to proxy props defined at
4680 // instantiation here.
4681 if (!(key in vm)) {
4682 proxy(vm, "_props", key);
4683 }
4684 };
4685
4686 for (var key in propsOptions) loop( key );
4687 toggleObserving(true);
4688 }
4689
4690 function initData (vm) {
4691 var data = vm.$options.data;
4692 data = vm._data = typeof data === 'function'
4693 ? getData(data, vm)
4694 : data || {};
4695 if (!isPlainObject(data)) {
4696 data = {};
4697 warn(
4698 'data functions should return an object:\n' +
4699 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
4700 vm
4701 );
4702 }
4703 // proxy data on instance
4704 var keys = Object.keys(data);
4705 var props = vm.$options.props;
4706 var methods = vm.$options.methods;
4707 var i = keys.length;
4708 while (i--) {
4709 var key = keys[i];
4710 {
4711 if (methods && hasOwn(methods, key)) {
4712 warn(
4713 ("Method \"" + key + "\" has already been defined as a data property."),
4714 vm
4715 );
4716 }
4717 }
4718 if (props && hasOwn(props, key)) {
4719 warn(
4720 "The data property \"" + key + "\" is already declared as a prop. " +
4721 "Use prop default value instead.",
4722 vm
4723 );
4724 } else if (!isReserved(key)) {
4725 proxy(vm, "_data", key);
4726 }
4727 }
4728 // observe data
4729 observe(data, true /* asRootData */);
4730 }
4731
4732 function getData (data, vm) {
4733 // #7573 disable dep collection when invoking data getters
4734 pushTarget();
4735 try {
4736 return data.call(vm, vm)
4737 } catch (e) {
4738 handleError(e, vm, "data()");
4739 return {}
4740 } finally {
4741 popTarget();
4742 }
4743 }
4744
4745 var computedWatcherOptions = { lazy: true };
4746
4747 function initComputed (vm, computed) {
4748 // $flow-disable-line
4749 var watchers = vm._computedWatchers = Object.create(null);
4750 // computed properties are just getters during SSR
4751 var isSSR = isServerRendering();
4752
4753 for (var key in computed) {
4754 var userDef = computed[key];
4755 var getter = typeof userDef === 'function' ? userDef : userDef.get;
4756 if (getter == null) {
4757 warn(
4758 ("Getter is missing for computed property \"" + key + "\"."),
4759 vm
4760 );
4761 }
4762
4763 if (!isSSR) {
4764 // create internal watcher for the computed property.
4765 watchers[key] = new Watcher(
4766 vm,
4767 getter || noop,
4768 noop,
4769 computedWatcherOptions
4770 );
4771 }
4772
4773 // component-defined computed properties are already defined on the
4774 // component prototype. We only need to define computed properties defined
4775 // at instantiation here.
4776 if (!(key in vm)) {
4777 defineComputed(vm, key, userDef);
4778 } else {
4779 if (key in vm.$data) {
4780 warn(("The computed property \"" + key + "\" is already defined in data."), vm);
4781 } else if (vm.$options.props && key in vm.$options.props) {
4782 warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
4783 }
4784 }
4785 }
4786 }
4787
4788 function defineComputed (
4789 target,
4790 key,
4791 userDef
4792 ) {
4793 var shouldCache = !isServerRendering();
4794 if (typeof userDef === 'function') {
4795 sharedPropertyDefinition.get = shouldCache
4796 ? createComputedGetter(key)
4797 : createGetterInvoker(userDef);
4798 sharedPropertyDefinition.set = noop;
4799 } else {
4800 sharedPropertyDefinition.get = userDef.get
4801 ? shouldCache && userDef.cache !== false
4802 ? createComputedGetter(key)
4803 : createGetterInvoker(userDef.get)
4804 : noop;
4805 sharedPropertyDefinition.set = userDef.set || noop;
4806 }
4807 if (sharedPropertyDefinition.set === noop) {
4808 sharedPropertyDefinition.set = function () {
4809 warn(
4810 ("Computed property \"" + key + "\" was assigned to but it has no setter."),
4811 this
4812 );
4813 };
4814 }
4815 Object.defineProperty(target, key, sharedPropertyDefinition);
4816 }
4817
4818 function createComputedGetter (key) {
4819 return function computedGetter () {
4820 var watcher = this._computedWatchers && this._computedWatchers[key];
4821 if (watcher) {
4822 if (watcher.dirty) {
4823 watcher.evaluate();
4824 }
4825 if (Dep.target) {
4826 watcher.depend();
4827 }
4828 return watcher.value
4829 }
4830 }
4831 }
4832
4833 function createGetterInvoker(fn) {
4834 return function computedGetter () {
4835 return fn.call(this, this)
4836 }
4837 }
4838
4839 function initMethods (vm, methods) {
4840 var props = vm.$options.props;
4841 for (var key in methods) {
4842 {
4843 if (typeof methods[key] !== 'function') {
4844 warn(
4845 "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
4846 "Did you reference the function correctly?",
4847 vm
4848 );
4849 }
4850 if (props && hasOwn(props, key)) {
4851 warn(
4852 ("Method \"" + key + "\" has already been defined as a prop."),
4853 vm
4854 );
4855 }
4856 if ((key in vm) && isReserved(key)) {
4857 warn(
4858 "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
4859 "Avoid defining component methods that start with _ or $."
4860 );
4861 }
4862 }
4863 vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
4864 }
4865 }
4866
4867 function initWatch (vm, watch) {
4868 for (var key in watch) {
4869 var handler = watch[key];
4870 if (Array.isArray(handler)) {
4871 for (var i = 0; i < handler.length; i++) {
4872 createWatcher(vm, key, handler[i]);
4873 }
4874 } else {
4875 createWatcher(vm, key, handler);
4876 }
4877 }
4878 }
4879
4880 function createWatcher (
4881 vm,
4882 expOrFn,
4883 handler,
4884 options
4885 ) {
4886 if (isPlainObject(handler)) {
4887 options = handler;
4888 handler = handler.handler;
4889 }
4890 if (typeof handler === 'string') {
4891 handler = vm[handler];
4892 }
4893 return vm.$watch(expOrFn, handler, options)
4894 }
4895
4896 function stateMixin (Vue) {
4897 // flow somehow has problems with directly declared definition object
4898 // when using Object.defineProperty, so we have to procedurally build up
4899 // the object here.
4900 var dataDef = {};
4901 dataDef.get = function () { return this._data };
4902 var propsDef = {};
4903 propsDef.get = function () { return this._props };
4904 {
4905 dataDef.set = function () {
4906 warn(
4907 'Avoid replacing instance root $data. ' +
4908 'Use nested data properties instead.',
4909 this
4910 );
4911 };
4912 propsDef.set = function () {
4913 warn("$props is readonly.", this);
4914 };
4915 }
4916 Object.defineProperty(Vue.prototype, '$data', dataDef);
4917 Object.defineProperty(Vue.prototype, '$props', propsDef);
4918
4919 Vue.prototype.$set = set;
4920 Vue.prototype.$delete = del;
4921
4922 Vue.prototype.$watch = function (
4923 expOrFn,
4924 cb,
4925 options
4926 ) {
4927 var vm = this;
4928 if (isPlainObject(cb)) {
4929 return createWatcher(vm, expOrFn, cb, options)
4930 }
4931 options = options || {};
4932 options.user = true;
4933 var watcher = new Watcher(vm, expOrFn, cb, options);
4934 if (options.immediate) {
4935 try {
4936 cb.call(vm, watcher.value);
4937 } catch (error) {
4938 handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
4939 }
4940 }
4941 return function unwatchFn () {
4942 watcher.teardown();
4943 }
4944 };
4945 }
4946
4947 /* */
4948
4949 var uid$3 = 0;
4950
4951 function initMixin (Vue) {
4952 Vue.prototype._init = function (options) {
4953 var vm = this;
4954 // a uid
4955 vm._uid = uid$3++;
4956
4957 var startTag, endTag;
4958 /* istanbul ignore if */
4959 if (config.performance && mark) {
4960 startTag = "vue-perf-start:" + (vm._uid);
4961 endTag = "vue-perf-end:" + (vm._uid);
4962 mark(startTag);
4963 }
4964
4965 // a flag to avoid this being observed
4966 vm._isVue = true;
4967 // merge options
4968 if (options && options._isComponent) {
4969 // optimize internal component instantiation
4970 // since dynamic options merging is pretty slow, and none of the
4971 // internal component options needs special treatment.
4972 initInternalComponent(vm, options);
4973 } else {
4974 vm.$options = mergeOptions(
4975 resolveConstructorOptions(vm.constructor),
4976 options || {},
4977 vm
4978 );
4979 }
4980 /* istanbul ignore else */
4981 {
4982 initProxy(vm);
4983 }
4984 // expose real self
4985 vm._self = vm;
4986 initLifecycle(vm);
4987 initEvents(vm);
4988 initRender(vm);
4989 callHook(vm, 'beforeCreate');
4990 initInjections(vm); // resolve injections before data/props
4991 initState(vm);
4992 initProvide(vm); // resolve provide after data/props
4993 callHook(vm, 'created');
4994
4995 /* istanbul ignore if */
4996 if (config.performance && mark) {
4997 vm._name = formatComponentName(vm, false);
4998 mark(endTag);
4999 measure(("vue " + (vm._name) + " init"), startTag, endTag);
5000 }
5001
5002 if (vm.$options.el) {
5003 vm.$mount(vm.$options.el);
5004 }
5005 };
5006 }
5007
5008 function initInternalComponent (vm, options) {
5009 var opts = vm.$options = Object.create(vm.constructor.options);
5010 // doing this because it's faster than dynamic enumeration.
5011 var parentVnode = options._parentVnode;
5012 opts.parent = options.parent;
5013 opts._parentVnode = parentVnode;
5014
5015 var vnodeComponentOptions = parentVnode.componentOptions;
5016 opts.propsData = vnodeComponentOptions.propsData;
5017 opts._parentListeners = vnodeComponentOptions.listeners;
5018 opts._renderChildren = vnodeComponentOptions.children;
5019 opts._componentTag = vnodeComponentOptions.tag;
5020
5021 if (options.render) {
5022 opts.render = options.render;
5023 opts.staticRenderFns = options.staticRenderFns;
5024 }
5025 }
5026
5027 function resolveConstructorOptions (Ctor) {
5028 var options = Ctor.options;
5029 if (Ctor.super) {
5030 var superOptions = resolveConstructorOptions(Ctor.super);
5031 var cachedSuperOptions = Ctor.superOptions;
5032 if (superOptions !== cachedSuperOptions) {
5033 // super option changed,
5034 // need to resolve new options.
5035 Ctor.superOptions = superOptions;
5036 // check if there are any late-modified/attached options (#4976)
5037 var modifiedOptions = resolveModifiedOptions(Ctor);
5038 // update base extend options
5039 if (modifiedOptions) {
5040 extend(Ctor.extendOptions, modifiedOptions);
5041 }
5042 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
5043 if (options.name) {
5044 options.components[options.name] = Ctor;
5045 }
5046 }
5047 }
5048 return options
5049 }
5050
5051 function resolveModifiedOptions (Ctor) {
5052 var modified;
5053 var latest = Ctor.options;
5054 var sealed = Ctor.sealedOptions;
5055 for (var key in latest) {
5056 if (latest[key] !== sealed[key]) {
5057 if (!modified) { modified = {}; }
5058 modified[key] = latest[key];
5059 }
5060 }
5061 return modified
5062 }
5063
5064 function Vue (options) {
5065 if (!(this instanceof Vue)
5066 ) {
5067 warn('Vue is a constructor and should be called with the `new` keyword');
5068 }
5069 this._init(options);
5070 }
5071
5072 initMixin(Vue);
5073 stateMixin(Vue);
5074 eventsMixin(Vue);
5075 lifecycleMixin(Vue);
5076 renderMixin(Vue);
5077
5078 /* */
5079
5080 function initUse (Vue) {
5081 Vue.use = function (plugin) {
5082 var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
5083 if (installedPlugins.indexOf(plugin) > -1) {
5084 return this
5085 }
5086
5087 // additional parameters
5088 var args = toArray(arguments, 1);
5089 args.unshift(this);
5090 if (typeof plugin.install === 'function') {
5091 plugin.install.apply(plugin, args);
5092 } else if (typeof plugin === 'function') {
5093 plugin.apply(null, args);
5094 }
5095 installedPlugins.push(plugin);
5096 return this
5097 };
5098 }
5099
5100 /* */
5101
5102 function initMixin$1 (Vue) {
5103 Vue.mixin = function (mixin) {
5104 this.options = mergeOptions(this.options, mixin);
5105 return this
5106 };
5107 }
5108
5109 /* */
5110
5111 function initExtend (Vue) {
5112 /**
5113 * Each instance constructor, including Vue, has a unique
5114 * cid. This enables us to create wrapped "child
5115 * constructors" for prototypal inheritance and cache them.
5116 */
5117 Vue.cid = 0;
5118 var cid = 1;
5119
5120 /**
5121 * Class inheritance
5122 */
5123 Vue.extend = function (extendOptions) {
5124 extendOptions = extendOptions || {};
5125 var Super = this;
5126 var SuperId = Super.cid;
5127 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
5128 if (cachedCtors[SuperId]) {
5129 return cachedCtors[SuperId]
5130 }
5131
5132 var name = extendOptions.name || Super.options.name;
5133 if (name) {
5134 validateComponentName(name);
5135 }
5136
5137 var Sub = function VueComponent (options) {
5138 this._init(options);
5139 };
5140 Sub.prototype = Object.create(Super.prototype);
5141 Sub.prototype.constructor = Sub;
5142 Sub.cid = cid++;
5143 Sub.options = mergeOptions(
5144 Super.options,
5145 extendOptions
5146 );
5147 Sub['super'] = Super;
5148
5149 // For props and computed properties, we define the proxy getters on
5150 // the Vue instances at extension time, on the extended prototype. This
5151 // avoids Object.defineProperty calls for each instance created.
5152 if (Sub.options.props) {
5153 initProps$1(Sub);
5154 }
5155 if (Sub.options.computed) {
5156 initComputed$1(Sub);
5157 }
5158
5159 // allow further extension/mixin/plugin usage
5160 Sub.extend = Super.extend;
5161 Sub.mixin = Super.mixin;
5162 Sub.use = Super.use;
5163
5164 // create asset registers, so extended classes
5165 // can have their private assets too.
5166 ASSET_TYPES.forEach(function (type) {
5167 Sub[type] = Super[type];
5168 });
5169 // enable recursive self-lookup
5170 if (name) {
5171 Sub.options.components[name] = Sub;
5172 }
5173
5174 // keep a reference to the super options at extension time.
5175 // later at instantiation we can check if Super's options have
5176 // been updated.
5177 Sub.superOptions = Super.options;
5178 Sub.extendOptions = extendOptions;
5179 Sub.sealedOptions = extend({}, Sub.options);
5180
5181 // cache constructor
5182 cachedCtors[SuperId] = Sub;
5183 return Sub
5184 };
5185 }
5186
5187 function initProps$1 (Comp) {
5188 var props = Comp.options.props;
5189 for (var key in props) {
5190 proxy(Comp.prototype, "_props", key);
5191 }
5192 }
5193
5194 function initComputed$1 (Comp) {
5195 var computed = Comp.options.computed;
5196 for (var key in computed) {
5197 defineComputed(Comp.prototype, key, computed[key]);
5198 }
5199 }
5200
5201 /* */
5202
5203 function initAssetRegisters (Vue) {
5204 /**
5205 * Create asset registration methods.
5206 */
5207 ASSET_TYPES.forEach(function (type) {
5208 Vue[type] = function (
5209 id,
5210 definition
5211 ) {
5212 if (!definition) {
5213 return this.options[type + 's'][id]
5214 } else {
5215 /* istanbul ignore if */
5216 if (type === 'component') {
5217 validateComponentName(id);
5218 }
5219 if (type === 'component' && isPlainObject(definition)) {
5220 definition.name = definition.name || id;
5221 definition = this.options._base.extend(definition);
5222 }
5223 if (type === 'directive' && typeof definition === 'function') {
5224 definition = { bind: definition, update: definition };
5225 }
5226 this.options[type + 's'][id] = definition;
5227 return definition
5228 }
5229 };
5230 });
5231 }
5232
5233 /* */
5234
5235
5236
5237 function getComponentName (opts) {
5238 return opts && (opts.Ctor.options.name || opts.tag)
5239 }
5240
5241 function matches (pattern, name) {
5242 if (Array.isArray(pattern)) {
5243 return pattern.indexOf(name) > -1
5244 } else if (typeof pattern === 'string') {
5245 return pattern.split(',').indexOf(name) > -1
5246 } else if (isRegExp(pattern)) {
5247 return pattern.test(name)
5248 }
5249 /* istanbul ignore next */
5250 return false
5251 }
5252
5253 function pruneCache (keepAliveInstance, filter) {
5254 var cache = keepAliveInstance.cache;
5255 var keys = keepAliveInstance.keys;
5256 var _vnode = keepAliveInstance._vnode;
5257 for (var key in cache) {
5258 var cachedNode = cache[key];
5259 if (cachedNode) {
5260 var name = getComponentName(cachedNode.componentOptions);
5261 if (name && !filter(name)) {
5262 pruneCacheEntry(cache, key, keys, _vnode);
5263 }
5264 }
5265 }
5266 }
5267
5268 function pruneCacheEntry (
5269 cache,
5270 key,
5271 keys,
5272 current
5273 ) {
5274 var cached$$1 = cache[key];
5275 if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
5276 cached$$1.componentInstance.$destroy();
5277 }
5278 cache[key] = null;
5279 remove(keys, key);
5280 }
5281
5282 var patternTypes = [String, RegExp, Array];
5283
5284 var KeepAlive = {
5285 name: 'keep-alive',
5286 abstract: true,
5287
5288 props: {
5289 include: patternTypes,
5290 exclude: patternTypes,
5291 max: [String, Number]
5292 },
5293
5294 created: function created () {
5295 this.cache = Object.create(null);
5296 this.keys = [];
5297 },
5298
5299 destroyed: function destroyed () {
5300 for (var key in this.cache) {
5301 pruneCacheEntry(this.cache, key, this.keys);
5302 }
5303 },
5304
5305 mounted: function mounted () {
5306 var this$1 = this;
5307
5308 this.$watch('include', function (val) {
5309 pruneCache(this$1, function (name) { return matches(val, name); });
5310 });
5311 this.$watch('exclude', function (val) {
5312 pruneCache(this$1, function (name) { return !matches(val, name); });
5313 });
5314 },
5315
5316 render: function render () {
5317 var slot = this.$slots.default;
5318 var vnode = getFirstComponentChild(slot);
5319 var componentOptions = vnode && vnode.componentOptions;
5320 if (componentOptions) {
5321 // check pattern
5322 var name = getComponentName(componentOptions);
5323 var ref = this;
5324 var include = ref.include;
5325 var exclude = ref.exclude;
5326 if (
5327 // not included
5328 (include && (!name || !matches(include, name))) ||
5329 // excluded
5330 (exclude && name && matches(exclude, name))
5331 ) {
5332 return vnode
5333 }
5334
5335 var ref$1 = this;
5336 var cache = ref$1.cache;
5337 var keys = ref$1.keys;
5338 var key = vnode.key == null
5339 // same constructor may get registered as different local components
5340 // so cid alone is not enough (#3269)
5341 ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
5342 : vnode.key;
5343 if (cache[key]) {
5344 vnode.componentInstance = cache[key].componentInstance;
5345 // make current key freshest
5346 remove(keys, key);
5347 keys.push(key);
5348 } else {
5349 cache[key] = vnode;
5350 keys.push(key);
5351 // prune oldest entry
5352 if (this.max && keys.length > parseInt(this.max)) {
5353 pruneCacheEntry(cache, keys[0], keys, this._vnode);
5354 }
5355 }
5356
5357 vnode.data.keepAlive = true;
5358 }
5359 return vnode || (slot && slot[0])
5360 }
5361 };
5362
5363 var builtInComponents = {
5364 KeepAlive: KeepAlive
5365 };
5366
5367 /* */
5368
5369 function initGlobalAPI (Vue) {
5370 // config
5371 var configDef = {};
5372 configDef.get = function () { return config; };
5373 {
5374 configDef.set = function () {
5375 warn(
5376 'Do not replace the Vue.config object, set individual fields instead.'
5377 );
5378 };
5379 }
5380 Object.defineProperty(Vue, 'config', configDef);
5381
5382 // exposed util methods.
5383 // NOTE: these are not considered part of the public API - avoid relying on
5384 // them unless you are aware of the risk.
5385 Vue.util = {
5386 warn: warn,
5387 extend: extend,
5388 mergeOptions: mergeOptions,
5389 defineReactive: defineReactive$$1
5390 };
5391
5392 Vue.set = set;
5393 Vue.delete = del;
5394 Vue.nextTick = nextTick;
5395
5396 // 2.6 explicit observable API
5397 Vue.observable = function (obj) {
5398 observe(obj);
5399 return obj
5400 };
5401
5402 Vue.options = Object.create(null);
5403 ASSET_TYPES.forEach(function (type) {
5404 Vue.options[type + 's'] = Object.create(null);
5405 });
5406
5407 // this is used to identify the "base" constructor to extend all plain-object
5408 // components with in Weex's multi-instance scenarios.
5409 Vue.options._base = Vue;
5410
5411 extend(Vue.options.components, builtInComponents);
5412
5413 initUse(Vue);
5414 initMixin$1(Vue);
5415 initExtend(Vue);
5416 initAssetRegisters(Vue);
5417 }
5418
5419 initGlobalAPI(Vue);
5420
5421 Object.defineProperty(Vue.prototype, '$isServer', {
5422 get: isServerRendering
5423 });
5424
5425 Object.defineProperty(Vue.prototype, '$ssrContext', {
5426 get: function get () {
5427 /* istanbul ignore next */
5428 return this.$vnode && this.$vnode.ssrContext
5429 }
5430 });
5431
5432 // expose FunctionalRenderContext for ssr runtime helper installation
5433 Object.defineProperty(Vue, 'FunctionalRenderContext', {
5434 value: FunctionalRenderContext
5435 });
5436
5437 Vue.version = '2.6.12';
5438
5439 /* */
5440
5441 // these are reserved for web because they are directly compiled away
5442 // during template compilation
5443 var isReservedAttr = makeMap('style,class');
5444
5445 // attributes that should be using props for binding
5446 var acceptValue = makeMap('input,textarea,option,select,progress');
5447 var mustUseProp = function (tag, type, attr) {
5448 return (
5449 (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
5450 (attr === 'selected' && tag === 'option') ||
5451 (attr === 'checked' && tag === 'input') ||
5452 (attr === 'muted' && tag === 'video')
5453 )
5454 };
5455
5456 var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
5457
5458 var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
5459
5460 var convertEnumeratedValue = function (key, value) {
5461 return isFalsyAttrValue(value) || value === 'false'
5462 ? 'false'
5463 // allow arbitrary string value for contenteditable
5464 : key === 'contenteditable' && isValidContentEditableValue(value)
5465 ? value
5466 : 'true'
5467 };
5468
5469 var isBooleanAttr = makeMap(
5470 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
5471 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
5472 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
5473 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
5474 'required,reversed,scoped,seamless,selected,sortable,translate,' +
5475 'truespeed,typemustmatch,visible'
5476 );
5477
5478 var xlinkNS = 'http://www.w3.org/1999/xlink';
5479
5480 var isXlink = function (name) {
5481 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
5482 };
5483
5484 var getXlinkProp = function (name) {
5485 return isXlink(name) ? name.slice(6, name.length) : ''
5486 };
5487
5488 var isFalsyAttrValue = function (val) {
5489 return val == null || val === false
5490 };
5491
5492 /* */
5493
5494 function genClassForVnode (vnode) {
5495 var data = vnode.data;
5496 var parentNode = vnode;
5497 var childNode = vnode;
5498 while (isDef(childNode.componentInstance)) {
5499 childNode = childNode.componentInstance._vnode;
5500 if (childNode && childNode.data) {
5501 data = mergeClassData(childNode.data, data);
5502 }
5503 }
5504 while (isDef(parentNode = parentNode.parent)) {
5505 if (parentNode && parentNode.data) {
5506 data = mergeClassData(data, parentNode.data);
5507 }
5508 }
5509 return renderClass(data.staticClass, data.class)
5510 }
5511
5512 function mergeClassData (child, parent) {
5513 return {
5514 staticClass: concat(child.staticClass, parent.staticClass),
5515 class: isDef(child.class)
5516 ? [child.class, parent.class]
5517 : parent.class
5518 }
5519 }
5520
5521 function renderClass (
5522 staticClass,
5523 dynamicClass
5524 ) {
5525 if (isDef(staticClass) || isDef(dynamicClass)) {
5526 return concat(staticClass, stringifyClass(dynamicClass))
5527 }
5528 /* istanbul ignore next */
5529 return ''
5530 }
5531
5532 function concat (a, b) {
5533 return a ? b ? (a + ' ' + b) : a : (b || '')
5534 }
5535
5536 function stringifyClass (value) {
5537 if (Array.isArray(value)) {
5538 return stringifyArray(value)
5539 }
5540 if (isObject(value)) {
5541 return stringifyObject(value)
5542 }
5543 if (typeof value === 'string') {
5544 return value
5545 }
5546 /* istanbul ignore next */
5547 return ''
5548 }
5549
5550 function stringifyArray (value) {
5551 var res = '';
5552 var stringified;
5553 for (var i = 0, l = value.length; i < l; i++) {
5554 if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
5555 if (res) { res += ' '; }
5556 res += stringified;
5557 }
5558 }
5559 return res
5560 }
5561
5562 function stringifyObject (value) {
5563 var res = '';
5564 for (var key in value) {
5565 if (value[key]) {
5566 if (res) { res += ' '; }
5567 res += key;
5568 }
5569 }
5570 return res
5571 }
5572
5573 /* */
5574
5575 var namespaceMap = {
5576 svg: 'http://www.w3.org/2000/svg',
5577 math: 'http://www.w3.org/1998/Math/MathML'
5578 };
5579
5580 var isHTMLTag = makeMap(
5581 'html,body,base,head,link,meta,style,title,' +
5582 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
5583 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
5584 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
5585 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
5586 'embed,object,param,source,canvas,script,noscript,del,ins,' +
5587 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
5588 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
5589 'output,progress,select,textarea,' +
5590 'details,dialog,menu,menuitem,summary,' +
5591 'content,element,shadow,template,blockquote,iframe,tfoot'
5592 );
5593
5594 // this map is intentionally selective, only covering SVG elements that may
5595 // contain child elements.
5596 var isSVG = makeMap(
5597 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
5598 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
5599 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
5600 true
5601 );
5602
5603 var isReservedTag = function (tag) {
5604 return isHTMLTag(tag) || isSVG(tag)
5605 };
5606
5607 function getTagNamespace (tag) {
5608 if (isSVG(tag)) {
5609 return 'svg'
5610 }
5611 // basic support for MathML
5612 // note it doesn't support other MathML elements being component roots
5613 if (tag === 'math') {
5614 return 'math'
5615 }
5616 }
5617
5618 var unknownElementCache = Object.create(null);
5619 function isUnknownElement (tag) {
5620 /* istanbul ignore if */
5621 if (!inBrowser) {
5622 return true
5623 }
5624 if (isReservedTag(tag)) {
5625 return false
5626 }
5627 tag = tag.toLowerCase();
5628 /* istanbul ignore if */
5629 if (unknownElementCache[tag] != null) {
5630 return unknownElementCache[tag]
5631 }
5632 var el = document.createElement(tag);
5633 if (tag.indexOf('-') > -1) {
5634 // http://stackoverflow.com/a/28210364/1070244
5635 return (unknownElementCache[tag] = (
5636 el.constructor === window.HTMLUnknownElement ||
5637 el.constructor === window.HTMLElement
5638 ))
5639 } else {
5640 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
5641 }
5642 }
5643
5644 var isTextInputType = makeMap('text,number,password,search,email,tel,url');
5645
5646 /* */
5647
5648 /**
5649 * Query an element selector if it's not an element already.
5650 */
5651 function query (el) {
5652 if (typeof el === 'string') {
5653 var selected = document.querySelector(el);
5654 if (!selected) {
5655 warn(
5656 'Cannot find element: ' + el
5657 );
5658 return document.createElement('div')
5659 }
5660 return selected
5661 } else {
5662 return el
5663 }
5664 }
5665
5666 /* */
5667
5668 function createElement$1 (tagName, vnode) {
5669 var elm = document.createElement(tagName);
5670 if (tagName !== 'select') {
5671 return elm
5672 }
5673 // false or null will remove the attribute but undefined will not
5674 if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
5675 elm.setAttribute('multiple', 'multiple');
5676 }
5677 return elm
5678 }
5679
5680 function createElementNS (namespace, tagName) {
5681 return document.createElementNS(namespaceMap[namespace], tagName)
5682 }
5683
5684 function createTextNode (text) {
5685 return document.createTextNode(text)
5686 }
5687
5688 function createComment (text) {
5689 return document.createComment(text)
5690 }
5691
5692 function insertBefore (parentNode, newNode, referenceNode) {
5693 parentNode.insertBefore(newNode, referenceNode);
5694 }
5695
5696 function removeChild (node, child) {
5697 node.removeChild(child);
5698 }
5699
5700 function appendChild (node, child) {
5701 node.appendChild(child);
5702 }
5703
5704 function parentNode (node) {
5705 return node.parentNode
5706 }
5707
5708 function nextSibling (node) {
5709 return node.nextSibling
5710 }
5711
5712 function tagName (node) {
5713 return node.tagName
5714 }
5715
5716 function setTextContent (node, text) {
5717 node.textContent = text;
5718 }
5719
5720 function setStyleScope (node, scopeId) {
5721 node.setAttribute(scopeId, '');
5722 }
5723
5724 var nodeOps = /*#__PURE__*/Object.freeze({
5725 createElement: createElement$1,
5726 createElementNS: createElementNS,
5727 createTextNode: createTextNode,
5728 createComment: createComment,
5729 insertBefore: insertBefore,
5730 removeChild: removeChild,
5731 appendChild: appendChild,
5732 parentNode: parentNode,
5733 nextSibling: nextSibling,
5734 tagName: tagName,
5735 setTextContent: setTextContent,
5736 setStyleScope: setStyleScope
5737 });
5738
5739 /* */
5740
5741 var ref = {
5742 create: function create (_, vnode) {
5743 registerRef(vnode);
5744 },
5745 update: function update (oldVnode, vnode) {
5746 if (oldVnode.data.ref !== vnode.data.ref) {
5747 registerRef(oldVnode, true);
5748 registerRef(vnode);
5749 }
5750 },
5751 destroy: function destroy (vnode) {
5752 registerRef(vnode, true);
5753 }
5754 };
5755
5756 function registerRef (vnode, isRemoval) {
5757 var key = vnode.data.ref;
5758 if (!isDef(key)) { return }
5759
5760 var vm = vnode.context;
5761 var ref = vnode.componentInstance || vnode.elm;
5762 var refs = vm.$refs;
5763 if (isRemoval) {
5764 if (Array.isArray(refs[key])) {
5765 remove(refs[key], ref);
5766 } else if (refs[key] === ref) {
5767 refs[key] = undefined;
5768 }
5769 } else {
5770 if (vnode.data.refInFor) {
5771 if (!Array.isArray(refs[key])) {
5772 refs[key] = [ref];
5773 } else if (refs[key].indexOf(ref) < 0) {
5774 // $flow-disable-line
5775 refs[key].push(ref);
5776 }
5777 } else {
5778 refs[key] = ref;
5779 }
5780 }
5781 }
5782
5783 /**
5784 * Virtual DOM patching algorithm based on Snabbdom by
5785 * Simon Friis Vindum (@paldepind)
5786 * Licensed under the MIT License
5787 * https://github.com/paldepind/snabbdom/blob/master/LICENSE
5788 *
5789 * modified by Evan You (@yyx990803)
5790 *
5791 * Not type-checking this because this file is perf-critical and the cost
5792 * of making flow understand it is not worth it.
5793 */
5794
5795 var emptyNode = new VNode('', {}, []);
5796
5797 var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
5798
5799 function sameVnode (a, b) {
5800 return (
5801 a.key === b.key && (
5802 (
5803 a.tag === b.tag &&
5804 a.isComment === b.isComment &&
5805 isDef(a.data) === isDef(b.data) &&
5806 sameInputType(a, b)
5807 ) || (
5808 isTrue(a.isAsyncPlaceholder) &&
5809 a.asyncFactory === b.asyncFactory &&
5810 isUndef(b.asyncFactory.error)
5811 )
5812 )
5813 )
5814 }
5815
5816 function sameInputType (a, b) {
5817 if (a.tag !== 'input') { return true }
5818 var i;
5819 var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
5820 var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
5821 return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
5822 }
5823
5824 function createKeyToOldIdx (children, beginIdx, endIdx) {
5825 var i, key;
5826 var map = {};
5827 for (i = beginIdx; i <= endIdx; ++i) {
5828 key = children[i].key;
5829 if (isDef(key)) { map[key] = i; }
5830 }
5831 return map
5832 }
5833
5834 function createPatchFunction (backend) {
5835 var i, j;
5836 var cbs = {};
5837
5838 var modules = backend.modules;
5839 var nodeOps = backend.nodeOps;
5840
5841 for (i = 0; i < hooks.length; ++i) {
5842 cbs[hooks[i]] = [];
5843 for (j = 0; j < modules.length; ++j) {
5844 if (isDef(modules[j][hooks[i]])) {
5845 cbs[hooks[i]].push(modules[j][hooks[i]]);
5846 }
5847 }
5848 }
5849
5850 function emptyNodeAt (elm) {
5851 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
5852 }
5853
5854 function createRmCb (childElm, listeners) {
5855 function remove$$1 () {
5856 if (--remove$$1.listeners === 0) {
5857 removeNode(childElm);
5858 }
5859 }
5860 remove$$1.listeners = listeners;
5861 return remove$$1
5862 }
5863
5864 function removeNode (el) {
5865 var parent = nodeOps.parentNode(el);
5866 // element may have already been removed due to v-html / v-text
5867 if (isDef(parent)) {
5868 nodeOps.removeChild(parent, el);
5869 }
5870 }
5871
5872 function isUnknownElement$$1 (vnode, inVPre) {
5873 return (
5874 !inVPre &&
5875 !vnode.ns &&
5876 !(
5877 config.ignoredElements.length &&
5878 config.ignoredElements.some(function (ignore) {
5879 return isRegExp(ignore)
5880 ? ignore.test(vnode.tag)
5881 : ignore === vnode.tag
5882 })
5883 ) &&
5884 config.isUnknownElement(vnode.tag)
5885 )
5886 }
5887
5888 var creatingElmInVPre = 0;
5889
5890 function createElm (
5891 vnode,
5892 insertedVnodeQueue,
5893 parentElm,
5894 refElm,
5895 nested,
5896 ownerArray,
5897 index
5898 ) {
5899 if (isDef(vnode.elm) && isDef(ownerArray)) {
5900 // This vnode was used in a previous render!
5901 // now it's used as a new node, overwriting its elm would cause
5902 // potential patch errors down the road when it's used as an insertion
5903 // reference node. Instead, we clone the node on-demand before creating
5904 // associated DOM element for it.
5905 vnode = ownerArray[index] = cloneVNode(vnode);
5906 }
5907
5908 vnode.isRootInsert = !nested; // for transition enter check
5909 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
5910 return
5911 }
5912
5913 var data = vnode.data;
5914 var children = vnode.children;
5915 var tag = vnode.tag;
5916 if (isDef(tag)) {
5917 {
5918 if (data && data.pre) {
5919 creatingElmInVPre++;
5920 }
5921 if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
5922 warn(
5923 'Unknown custom element: <' + tag + '> - did you ' +
5924 'register the component correctly? For recursive components, ' +
5925 'make sure to provide the "name" option.',
5926 vnode.context
5927 );
5928 }
5929 }
5930
5931 vnode.elm = vnode.ns
5932 ? nodeOps.createElementNS(vnode.ns, tag)
5933 : nodeOps.createElement(tag, vnode);
5934 setScope(vnode);
5935
5936 /* istanbul ignore if */
5937 {
5938 createChildren(vnode, children, insertedVnodeQueue);
5939 if (isDef(data)) {
5940 invokeCreateHooks(vnode, insertedVnodeQueue);
5941 }
5942 insert(parentElm, vnode.elm, refElm);
5943 }
5944
5945 if (data && data.pre) {
5946 creatingElmInVPre--;
5947 }
5948 } else if (isTrue(vnode.isComment)) {
5949 vnode.elm = nodeOps.createComment(vnode.text);
5950 insert(parentElm, vnode.elm, refElm);
5951 } else {
5952 vnode.elm = nodeOps.createTextNode(vnode.text);
5953 insert(parentElm, vnode.elm, refElm);
5954 }
5955 }
5956
5957 function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
5958 var i = vnode.data;
5959 if (isDef(i)) {
5960 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
5961 if (isDef(i = i.hook) && isDef(i = i.init)) {
5962 i(vnode, false /* hydrating */);
5963 }
5964 // after calling the init hook, if the vnode is a child component
5965 // it should've created a child instance and mounted it. the child
5966 // component also has set the placeholder vnode's elm.
5967 // in that case we can just return the element and be done.
5968 if (isDef(vnode.componentInstance)) {
5969 initComponent(vnode, insertedVnodeQueue);
5970 insert(parentElm, vnode.elm, refElm);
5971 if (isTrue(isReactivated)) {
5972 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
5973 }
5974 return true
5975 }
5976 }
5977 }
5978
5979 function initComponent (vnode, insertedVnodeQueue) {
5980 if (isDef(vnode.data.pendingInsert)) {
5981 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
5982 vnode.data.pendingInsert = null;
5983 }
5984 vnode.elm = vnode.componentInstance.$el;
5985 if (isPatchable(vnode)) {
5986 invokeCreateHooks(vnode, insertedVnodeQueue);
5987 setScope(vnode);
5988 } else {
5989 // empty component root.
5990 // skip all element-related modules except for ref (#3455)
5991 registerRef(vnode);
5992 // make sure to invoke the insert hook
5993 insertedVnodeQueue.push(vnode);
5994 }
5995 }
5996
5997 function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
5998 var i;
5999 // hack for #4339: a reactivated component with inner transition
6000 // does not trigger because the inner node's created hooks are not called
6001 // again. It's not ideal to involve module-specific logic in here but
6002 // there doesn't seem to be a better way to do it.
6003 var innerNode = vnode;
6004 while (innerNode.componentInstance) {
6005 innerNode = innerNode.componentInstance._vnode;
6006 if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
6007 for (i = 0; i < cbs.activate.length; ++i) {
6008 cbs.activate[i](emptyNode, innerNode);
6009 }
6010 insertedVnodeQueue.push(innerNode);
6011 break
6012 }
6013 }
6014 // unlike a newly created component,
6015 // a reactivated keep-alive component doesn't insert itself
6016 insert(parentElm, vnode.elm, refElm);
6017 }
6018
6019 function insert (parent, elm, ref$$1) {
6020 if (isDef(parent)) {
6021 if (isDef(ref$$1)) {
6022 if (nodeOps.parentNode(ref$$1) === parent) {
6023 nodeOps.insertBefore(parent, elm, ref$$1);
6024 }
6025 } else {
6026 nodeOps.appendChild(parent, elm);
6027 }
6028 }
6029 }
6030
6031 function createChildren (vnode, children, insertedVnodeQueue) {
6032 if (Array.isArray(children)) {
6033 {
6034 checkDuplicateKeys(children);
6035 }
6036 for (var i = 0; i < children.length; ++i) {
6037 createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
6038 }
6039 } else if (isPrimitive(vnode.text)) {
6040 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
6041 }
6042 }
6043
6044 function isPatchable (vnode) {
6045 while (vnode.componentInstance) {
6046 vnode = vnode.componentInstance._vnode;
6047 }
6048 return isDef(vnode.tag)
6049 }
6050
6051 function invokeCreateHooks (vnode, insertedVnodeQueue) {
6052 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
6053 cbs.create[i$1](emptyNode, vnode);
6054 }
6055 i = vnode.data.hook; // Reuse variable
6056 if (isDef(i)) {
6057 if (isDef(i.create)) { i.create(emptyNode, vnode); }
6058 if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
6059 }
6060 }
6061
6062 // set scope id attribute for scoped CSS.
6063 // this is implemented as a special case to avoid the overhead
6064 // of going through the normal attribute patching process.
6065 function setScope (vnode) {
6066 var i;
6067 if (isDef(i = vnode.fnScopeId)) {
6068 nodeOps.setStyleScope(vnode.elm, i);
6069 } else {
6070 var ancestor = vnode;
6071 while (ancestor) {
6072 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
6073 nodeOps.setStyleScope(vnode.elm, i);
6074 }
6075 ancestor = ancestor.parent;
6076 }
6077 }
6078 // for slot content they should also get the scopeId from the host instance.
6079 if (isDef(i = activeInstance) &&
6080 i !== vnode.context &&
6081 i !== vnode.fnContext &&
6082 isDef(i = i.$options._scopeId)
6083 ) {
6084 nodeOps.setStyleScope(vnode.elm, i);
6085 }
6086 }
6087
6088 function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
6089 for (; startIdx <= endIdx; ++startIdx) {
6090 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
6091 }
6092 }
6093
6094 function invokeDestroyHook (vnode) {
6095 var i, j;
6096 var data = vnode.data;
6097 if (isDef(data)) {
6098 if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
6099 for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
6100 }
6101 if (isDef(i = vnode.children)) {
6102 for (j = 0; j < vnode.children.length; ++j) {
6103 invokeDestroyHook(vnode.children[j]);
6104 }
6105 }
6106 }
6107
6108 function removeVnodes (vnodes, startIdx, endIdx) {
6109 for (; startIdx <= endIdx; ++startIdx) {
6110 var ch = vnodes[startIdx];
6111 if (isDef(ch)) {
6112 if (isDef(ch.tag)) {
6113 removeAndInvokeRemoveHook(ch);
6114 invokeDestroyHook(ch);
6115 } else { // Text node
6116 removeNode(ch.elm);
6117 }
6118 }
6119 }
6120 }
6121
6122 function removeAndInvokeRemoveHook (vnode, rm) {
6123 if (isDef(rm) || isDef(vnode.data)) {
6124 var i;
6125 var listeners = cbs.remove.length + 1;
6126 if (isDef(rm)) {
6127 // we have a recursively passed down rm callback
6128 // increase the listeners count
6129 rm.listeners += listeners;
6130 } else {
6131 // directly removing
6132 rm = createRmCb(vnode.elm, listeners);
6133 }
6134 // recursively invoke hooks on child component root node
6135 if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
6136 removeAndInvokeRemoveHook(i, rm);
6137 }
6138 for (i = 0; i < cbs.remove.length; ++i) {
6139 cbs.remove[i](vnode, rm);
6140 }
6141 if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
6142 i(vnode, rm);
6143 } else {
6144 rm();
6145 }
6146 } else {
6147 removeNode(vnode.elm);
6148 }
6149 }
6150
6151 function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
6152 var oldStartIdx = 0;
6153 var newStartIdx = 0;
6154 var oldEndIdx = oldCh.length - 1;
6155 var oldStartVnode = oldCh[0];
6156 var oldEndVnode = oldCh[oldEndIdx];
6157 var newEndIdx = newCh.length - 1;
6158 var newStartVnode = newCh[0];
6159 var newEndVnode = newCh[newEndIdx];
6160 var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
6161
6162 // removeOnly is a special flag used only by <transition-group>
6163 // to ensure removed elements stay in correct relative positions
6164 // during leaving transitions
6165 var canMove = !removeOnly;
6166
6167 {
6168 checkDuplicateKeys(newCh);
6169 }
6170
6171 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
6172 if (isUndef(oldStartVnode)) {
6173 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
6174 } else if (isUndef(oldEndVnode)) {
6175 oldEndVnode = oldCh[--oldEndIdx];
6176 } else if (sameVnode(oldStartVnode, newStartVnode)) {
6177 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
6178 oldStartVnode = oldCh[++oldStartIdx];
6179 newStartVnode = newCh[++newStartIdx];
6180 } else if (sameVnode(oldEndVnode, newEndVnode)) {
6181 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
6182 oldEndVnode = oldCh[--oldEndIdx];
6183 newEndVnode = newCh[--newEndIdx];
6184 } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
6185 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
6186 canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
6187 oldStartVnode = oldCh[++oldStartIdx];
6188 newEndVnode = newCh[--newEndIdx];
6189 } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
6190 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
6191 canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
6192 oldEndVnode = oldCh[--oldEndIdx];
6193 newStartVnode = newCh[++newStartIdx];
6194 } else {
6195 if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
6196 idxInOld = isDef(newStartVnode.key)
6197 ? oldKeyToIdx[newStartVnode.key]
6198 : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
6199 if (isUndef(idxInOld)) { // New element
6200 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
6201 } else {
6202 vnodeToMove = oldCh[idxInOld];
6203 if (sameVnode(vnodeToMove, newStartVnode)) {
6204 patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
6205 oldCh[idxInOld] = undefined;
6206 canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
6207 } else {
6208 // same key but different element. treat as new element
6209 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
6210 }
6211 }
6212 newStartVnode = newCh[++newStartIdx];
6213 }
6214 }
6215 if (oldStartIdx > oldEndIdx) {
6216 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
6217 addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
6218 } else if (newStartIdx > newEndIdx) {
6219 removeVnodes(oldCh, oldStartIdx, oldEndIdx);
6220 }
6221 }
6222
6223 function checkDuplicateKeys (children) {
6224 var seenKeys = {};
6225 for (var i = 0; i < children.length; i++) {
6226 var vnode = children[i];
6227 var key = vnode.key;
6228 if (isDef(key)) {
6229 if (seenKeys[key]) {
6230 warn(
6231 ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
6232 vnode.context
6233 );
6234 } else {
6235 seenKeys[key] = true;
6236 }
6237 }
6238 }
6239 }
6240
6241 function findIdxInOld (node, oldCh, start, end) {
6242 for (var i = start; i < end; i++) {
6243 var c = oldCh[i];
6244 if (isDef(c) && sameVnode(node, c)) { return i }
6245 }
6246 }
6247
6248 function patchVnode (
6249 oldVnode,
6250 vnode,
6251 insertedVnodeQueue,
6252 ownerArray,
6253 index,
6254 removeOnly
6255 ) {
6256 if (oldVnode === vnode) {
6257 return
6258 }
6259
6260 if (isDef(vnode.elm) && isDef(ownerArray)) {
6261 // clone reused vnode
6262 vnode = ownerArray[index] = cloneVNode(vnode);
6263 }
6264
6265 var elm = vnode.elm = oldVnode.elm;
6266
6267 if (isTrue(oldVnode.isAsyncPlaceholder)) {
6268 if (isDef(vnode.asyncFactory.resolved)) {
6269 hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
6270 } else {
6271 vnode.isAsyncPlaceholder = true;
6272 }
6273 return
6274 }
6275
6276 // reuse element for static trees.
6277 // note we only do this if the vnode is cloned -
6278 // if the new node is not cloned it means the render functions have been
6279 // reset by the hot-reload-api and we need to do a proper re-render.
6280 if (isTrue(vnode.isStatic) &&
6281 isTrue(oldVnode.isStatic) &&
6282 vnode.key === oldVnode.key &&
6283 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
6284 ) {
6285 vnode.componentInstance = oldVnode.componentInstance;
6286 return
6287 }
6288
6289 var i;
6290 var data = vnode.data;
6291 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
6292 i(oldVnode, vnode);
6293 }
6294
6295 var oldCh = oldVnode.children;
6296 var ch = vnode.children;
6297 if (isDef(data) && isPatchable(vnode)) {
6298 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
6299 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
6300 }
6301 if (isUndef(vnode.text)) {
6302 if (isDef(oldCh) && isDef(ch)) {
6303 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
6304 } else if (isDef(ch)) {
6305 {
6306 checkDuplicateKeys(ch);
6307 }
6308 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
6309 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
6310 } else if (isDef(oldCh)) {
6311 removeVnodes(oldCh, 0, oldCh.length - 1);
6312 } else if (isDef(oldVnode.text)) {
6313 nodeOps.setTextContent(elm, '');
6314 }
6315 } else if (oldVnode.text !== vnode.text) {
6316 nodeOps.setTextContent(elm, vnode.text);
6317 }
6318 if (isDef(data)) {
6319 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
6320 }
6321 }
6322
6323 function invokeInsertHook (vnode, queue, initial) {
6324 // delay insert hooks for component root nodes, invoke them after the
6325 // element is really inserted
6326 if (isTrue(initial) && isDef(vnode.parent)) {
6327 vnode.parent.data.pendingInsert = queue;
6328 } else {
6329 for (var i = 0; i < queue.length; ++i) {
6330 queue[i].data.hook.insert(queue[i]);
6331 }
6332 }
6333 }
6334
6335 var hydrationBailed = false;
6336 // list of modules that can skip create hook during hydration because they
6337 // are already rendered on the client or has no need for initialization
6338 // Note: style is excluded because it relies on initial clone for future
6339 // deep updates (#7063).
6340 var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
6341
6342 // Note: this is a browser-only function so we can assume elms are DOM nodes.
6343 function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
6344 var i;
6345 var tag = vnode.tag;
6346 var data = vnode.data;
6347 var children = vnode.children;
6348 inVPre = inVPre || (data && data.pre);
6349 vnode.elm = elm;
6350
6351 if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
6352 vnode.isAsyncPlaceholder = true;
6353 return true
6354 }
6355 // assert node match
6356 {
6357 if (!assertNodeMatch(elm, vnode, inVPre)) {
6358 return false
6359 }
6360 }
6361 if (isDef(data)) {
6362 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
6363 if (isDef(i = vnode.componentInstance)) {
6364 // child component. it should have hydrated its own tree.
6365 initComponent(vnode, insertedVnodeQueue);
6366 return true
6367 }
6368 }
6369 if (isDef(tag)) {
6370 if (isDef(children)) {
6371 // empty element, allow client to pick up and populate children
6372 if (!elm.hasChildNodes()) {
6373 createChildren(vnode, children, insertedVnodeQueue);
6374 } else {
6375 // v-html and domProps: innerHTML
6376 if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
6377 if (i !== elm.innerHTML) {
6378 /* istanbul ignore if */
6379 if (typeof console !== 'undefined' &&
6380 !hydrationBailed
6381 ) {
6382 hydrationBailed = true;
6383 console.warn('Parent: ', elm);
6384 console.warn('server innerHTML: ', i);
6385 console.warn('client innerHTML: ', elm.innerHTML);
6386 }
6387 return false
6388 }
6389 } else {
6390 // iterate and compare children lists
6391 var childrenMatch = true;
6392 var childNode = elm.firstChild;
6393 for (var i$1 = 0; i$1 < children.length; i$1++) {
6394 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
6395 childrenMatch = false;
6396 break
6397 }
6398 childNode = childNode.nextSibling;
6399 }
6400 // if childNode is not null, it means the actual childNodes list is
6401 // longer than the virtual children list.
6402 if (!childrenMatch || childNode) {
6403 /* istanbul ignore if */
6404 if (typeof console !== 'undefined' &&
6405 !hydrationBailed
6406 ) {
6407 hydrationBailed = true;
6408 console.warn('Parent: ', elm);
6409 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
6410 }
6411 return false
6412 }
6413 }
6414 }
6415 }
6416 if (isDef(data)) {
6417 var fullInvoke = false;
6418 for (var key in data) {
6419 if (!isRenderedModule(key)) {
6420 fullInvoke = true;
6421 invokeCreateHooks(vnode, insertedVnodeQueue);
6422 break
6423 }
6424 }
6425 if (!fullInvoke && data['class']) {
6426 // ensure collecting deps for deep class bindings for future updates
6427 traverse(data['class']);
6428 }
6429 }
6430 } else if (elm.data !== vnode.text) {
6431 elm.data = vnode.text;
6432 }
6433 return true
6434 }
6435
6436 function assertNodeMatch (node, vnode, inVPre) {
6437 if (isDef(vnode.tag)) {
6438 return vnode.tag.indexOf('vue-component') === 0 || (
6439 !isUnknownElement$$1(vnode, inVPre) &&
6440 vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
6441 )
6442 } else {
6443 return node.nodeType === (vnode.isComment ? 8 : 3)
6444 }
6445 }
6446
6447 return function patch (oldVnode, vnode, hydrating, removeOnly) {
6448 if (isUndef(vnode)) {
6449 if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
6450 return
6451 }
6452
6453 var isInitialPatch = false;
6454 var insertedVnodeQueue = [];
6455
6456 if (isUndef(oldVnode)) {
6457 // empty mount (likely as component), create new root element
6458 isInitialPatch = true;
6459 createElm(vnode, insertedVnodeQueue);
6460 } else {
6461 var isRealElement = isDef(oldVnode.nodeType);
6462 if (!isRealElement && sameVnode(oldVnode, vnode)) {
6463 // patch existing root node
6464 patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
6465 } else {
6466 if (isRealElement) {
6467 // mounting to a real element
6468 // check if this is server-rendered content and if we can perform
6469 // a successful hydration.
6470 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
6471 oldVnode.removeAttribute(SSR_ATTR);
6472 hydrating = true;
6473 }
6474 if (isTrue(hydrating)) {
6475 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
6476 invokeInsertHook(vnode, insertedVnodeQueue, true);
6477 return oldVnode
6478 } else {
6479 warn(
6480 'The client-side rendered virtual DOM tree is not matching ' +
6481 'server-rendered content. This is likely caused by incorrect ' +
6482 'HTML markup, for example nesting block-level elements inside ' +
6483 '<p>, or missing <tbody>. Bailing hydration and performing ' +
6484 'full client-side render.'
6485 );
6486 }
6487 }
6488 // either not server-rendered, or hydration failed.
6489 // create an empty node and replace it
6490 oldVnode = emptyNodeAt(oldVnode);
6491 }
6492
6493 // replacing existing element
6494 var oldElm = oldVnode.elm;
6495 var parentElm = nodeOps.parentNode(oldElm);
6496
6497 // create new node
6498 createElm(
6499 vnode,
6500 insertedVnodeQueue,
6501 // extremely rare edge case: do not insert if old element is in a
6502 // leaving transition. Only happens when combining transition +
6503 // keep-alive + HOCs. (#4590)
6504 oldElm._leaveCb ? null : parentElm,
6505 nodeOps.nextSibling(oldElm)
6506 );
6507
6508 // update parent placeholder node element, recursively
6509 if (isDef(vnode.parent)) {
6510 var ancestor = vnode.parent;
6511 var patchable = isPatchable(vnode);
6512 while (ancestor) {
6513 for (var i = 0; i < cbs.destroy.length; ++i) {
6514 cbs.destroy[i](ancestor);
6515 }
6516 ancestor.elm = vnode.elm;
6517 if (patchable) {
6518 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
6519 cbs.create[i$1](emptyNode, ancestor);
6520 }
6521 // #6513
6522 // invoke insert hooks that may have been merged by create hooks.
6523 // e.g. for directives that uses the "inserted" hook.
6524 var insert = ancestor.data.hook.insert;
6525 if (insert.merged) {
6526 // start at index 1 to avoid re-invoking component mounted hook
6527 for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
6528 insert.fns[i$2]();
6529 }
6530 }
6531 } else {
6532 registerRef(ancestor);
6533 }
6534 ancestor = ancestor.parent;
6535 }
6536 }
6537
6538 // destroy old node
6539 if (isDef(parentElm)) {
6540 removeVnodes([oldVnode], 0, 0);
6541 } else if (isDef(oldVnode.tag)) {
6542 invokeDestroyHook(oldVnode);
6543 }
6544 }
6545 }
6546
6547 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
6548 return vnode.elm
6549 }
6550 }
6551
6552 /* */
6553
6554 var directives = {
6555 create: updateDirectives,
6556 update: updateDirectives,
6557 destroy: function unbindDirectives (vnode) {
6558 updateDirectives(vnode, emptyNode);
6559 }
6560 };
6561
6562 function updateDirectives (oldVnode, vnode) {
6563 if (oldVnode.data.directives || vnode.data.directives) {
6564 _update(oldVnode, vnode);
6565 }
6566 }
6567
6568 function _update (oldVnode, vnode) {
6569 var isCreate = oldVnode === emptyNode;
6570 var isDestroy = vnode === emptyNode;
6571 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
6572 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
6573
6574 var dirsWithInsert = [];
6575 var dirsWithPostpatch = [];
6576
6577 var key, oldDir, dir;
6578 for (key in newDirs) {
6579 oldDir = oldDirs[key];
6580 dir = newDirs[key];
6581 if (!oldDir) {
6582 // new directive, bind
6583 callHook$1(dir, 'bind', vnode, oldVnode);
6584 if (dir.def && dir.def.inserted) {
6585 dirsWithInsert.push(dir);
6586 }
6587 } else {
6588 // existing directive, update
6589 dir.oldValue = oldDir.value;
6590 dir.oldArg = oldDir.arg;
6591 callHook$1(dir, 'update', vnode, oldVnode);
6592 if (dir.def && dir.def.componentUpdated) {
6593 dirsWithPostpatch.push(dir);
6594 }
6595 }
6596 }
6597
6598 if (dirsWithInsert.length) {
6599 var callInsert = function () {
6600 for (var i = 0; i < dirsWithInsert.length; i++) {
6601 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
6602 }
6603 };
6604 if (isCreate) {
6605 mergeVNodeHook(vnode, 'insert', callInsert);
6606 } else {
6607 callInsert();
6608 }
6609 }
6610
6611 if (dirsWithPostpatch.length) {
6612 mergeVNodeHook(vnode, 'postpatch', function () {
6613 for (var i = 0; i < dirsWithPostpatch.length; i++) {
6614 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
6615 }
6616 });
6617 }
6618
6619 if (!isCreate) {
6620 for (key in oldDirs) {
6621 if (!newDirs[key]) {
6622 // no longer present, unbind
6623 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
6624 }
6625 }
6626 }
6627 }
6628
6629 var emptyModifiers = Object.create(null);
6630
6631 function normalizeDirectives$1 (
6632 dirs,
6633 vm
6634 ) {
6635 var res = Object.create(null);
6636 if (!dirs) {
6637 // $flow-disable-line
6638 return res
6639 }
6640 var i, dir;
6641 for (i = 0; i < dirs.length; i++) {
6642 dir = dirs[i];
6643 if (!dir.modifiers) {
6644 // $flow-disable-line
6645 dir.modifiers = emptyModifiers;
6646 }
6647 res[getRawDirName(dir)] = dir;
6648 dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
6649 }
6650 // $flow-disable-line
6651 return res
6652 }
6653
6654 function getRawDirName (dir) {
6655 return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
6656 }
6657
6658 function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
6659 var fn = dir.def && dir.def[hook];
6660 if (fn) {
6661 try {
6662 fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
6663 } catch (e) {
6664 handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
6665 }
6666 }
6667 }
6668
6669 var baseModules = [
6670 ref,
6671 directives
6672 ];
6673
6674 /* */
6675
6676 function updateAttrs (oldVnode, vnode) {
6677 var opts = vnode.componentOptions;
6678 if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
6679 return
6680 }
6681 if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
6682 return
6683 }
6684 var key, cur, old;
6685 var elm = vnode.elm;
6686 var oldAttrs = oldVnode.data.attrs || {};
6687 var attrs = vnode.data.attrs || {};
6688 // clone observed objects, as the user probably wants to mutate it
6689 if (isDef(attrs.__ob__)) {
6690 attrs = vnode.data.attrs = extend({}, attrs);
6691 }
6692
6693 for (key in attrs) {
6694 cur = attrs[key];
6695 old = oldAttrs[key];
6696 if (old !== cur) {
6697 setAttr(elm, key, cur);
6698 }
6699 }
6700 // #4391: in IE9, setting type can reset value for input[type=radio]
6701 // #6666: IE/Edge forces progress value down to 1 before setting a max
6702 /* istanbul ignore if */
6703 if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
6704 setAttr(elm, 'value', attrs.value);
6705 }
6706 for (key in oldAttrs) {
6707 if (isUndef(attrs[key])) {
6708 if (isXlink(key)) {
6709 elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
6710 } else if (!isEnumeratedAttr(key)) {
6711 elm.removeAttribute(key);
6712 }
6713 }
6714 }
6715 }
6716
6717 function setAttr (el, key, value) {
6718 if (el.tagName.indexOf('-') > -1) {
6719 baseSetAttr(el, key, value);
6720 } else if (isBooleanAttr(key)) {
6721 // set attribute for blank value
6722 // e.g. <option disabled>Select one</option>
6723 if (isFalsyAttrValue(value)) {
6724 el.removeAttribute(key);
6725 } else {
6726 // technically allowfullscreen is a boolean attribute for <iframe>,
6727 // but Flash expects a value of "true" when used on <embed> tag
6728 value = key === 'allowfullscreen' && el.tagName === 'EMBED'
6729 ? 'true'
6730 : key;
6731 el.setAttribute(key, value);
6732 }
6733 } else if (isEnumeratedAttr(key)) {
6734 el.setAttribute(key, convertEnumeratedValue(key, value));
6735 } else if (isXlink(key)) {
6736 if (isFalsyAttrValue(value)) {
6737 el.removeAttributeNS(xlinkNS, getXlinkProp(key));
6738 } else {
6739 el.setAttributeNS(xlinkNS, key, value);
6740 }
6741 } else {
6742 baseSetAttr(el, key, value);
6743 }
6744 }
6745
6746 function baseSetAttr (el, key, value) {
6747 if (isFalsyAttrValue(value)) {
6748 el.removeAttribute(key);
6749 } else {
6750 // #7138: IE10 & 11 fires input event when setting placeholder on
6751 // <textarea>... block the first input event and remove the blocker
6752 // immediately.
6753 /* istanbul ignore if */
6754 if (
6755 isIE && !isIE9 &&
6756 el.tagName === 'TEXTAREA' &&
6757 key === 'placeholder' && value !== '' && !el.__ieph
6758 ) {
6759 var blocker = function (e) {
6760 e.stopImmediatePropagation();
6761 el.removeEventListener('input', blocker);
6762 };
6763 el.addEventListener('input', blocker);
6764 // $flow-disable-line
6765 el.__ieph = true; /* IE placeholder patched */
6766 }
6767 el.setAttribute(key, value);
6768 }
6769 }
6770
6771 var attrs = {
6772 create: updateAttrs,
6773 update: updateAttrs
6774 };
6775
6776 /* */
6777
6778 function updateClass (oldVnode, vnode) {
6779 var el = vnode.elm;
6780 var data = vnode.data;
6781 var oldData = oldVnode.data;
6782 if (
6783 isUndef(data.staticClass) &&
6784 isUndef(data.class) && (
6785 isUndef(oldData) || (
6786 isUndef(oldData.staticClass) &&
6787 isUndef(oldData.class)
6788 )
6789 )
6790 ) {
6791 return
6792 }
6793
6794 var cls = genClassForVnode(vnode);
6795
6796 // handle transition classes
6797 var transitionClass = el._transitionClasses;
6798 if (isDef(transitionClass)) {
6799 cls = concat(cls, stringifyClass(transitionClass));
6800 }
6801
6802 // set the class
6803 if (cls !== el._prevClass) {
6804 el.setAttribute('class', cls);
6805 el._prevClass = cls;
6806 }
6807 }
6808
6809 var klass = {
6810 create: updateClass,
6811 update: updateClass
6812 };
6813
6814 /* */
6815
6816 /* */
6817
6818 /* */
6819
6820 /* */
6821
6822 // in some cases, the event used has to be determined at runtime
6823 // so we used some reserved tokens during compile.
6824 var RANGE_TOKEN = '__r';
6825 var CHECKBOX_RADIO_TOKEN = '__c';
6826
6827 /* */
6828
6829 // normalize v-model event tokens that can only be determined at runtime.
6830 // it's important to place the event as the first in the array because
6831 // the whole point is ensuring the v-model callback gets called before
6832 // user-attached handlers.
6833 function normalizeEvents (on) {
6834 /* istanbul ignore if */
6835 if (isDef(on[RANGE_TOKEN])) {
6836 // IE input[type=range] only supports `change` event
6837 var event = isIE ? 'change' : 'input';
6838 on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
6839 delete on[RANGE_TOKEN];
6840 }
6841 // This was originally intended to fix #4521 but no longer necessary
6842 // after 2.5. Keeping it for backwards compat with generated code from < 2.4
6843 /* istanbul ignore if */
6844 if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
6845 on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
6846 delete on[CHECKBOX_RADIO_TOKEN];
6847 }
6848 }
6849
6850 var target$1;
6851
6852 function createOnceHandler$1 (event, handler, capture) {
6853 var _target = target$1; // save current target element in closure
6854 return function onceHandler () {
6855 var res = handler.apply(null, arguments);
6856 if (res !== null) {
6857 remove$2(event, onceHandler, capture, _target);
6858 }
6859 }
6860 }
6861
6862 // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
6863 // implementation and does not fire microtasks in between event propagation, so
6864 // safe to exclude.
6865 var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
6866
6867 function add$1 (
6868 name,
6869 handler,
6870 capture,
6871 passive
6872 ) {
6873 // async edge case #6566: inner click event triggers patch, event handler
6874 // attached to outer element during patch, and triggered again. This
6875 // happens because browsers fire microtask ticks between event propagation.
6876 // the solution is simple: we save the timestamp when a handler is attached,
6877 // and the handler would only fire if the event passed to it was fired
6878 // AFTER it was attached.
6879 if (useMicrotaskFix) {
6880 var attachedTimestamp = currentFlushTimestamp;
6881 var original = handler;
6882 handler = original._wrapper = function (e) {
6883 if (
6884 // no bubbling, should always fire.
6885 // this is just a safety net in case event.timeStamp is unreliable in
6886 // certain weird environments...
6887 e.target === e.currentTarget ||
6888 // event is fired after handler attachment
6889 e.timeStamp >= attachedTimestamp ||
6890 // bail for environments that have buggy event.timeStamp implementations
6891 // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
6892 // #9681 QtWebEngine event.timeStamp is negative value
6893 e.timeStamp <= 0 ||
6894 // #9448 bail if event is fired in another document in a multi-page
6895 // electron/nw.js app, since event.timeStamp will be using a different
6896 // starting reference
6897 e.target.ownerDocument !== document
6898 ) {
6899 return original.apply(this, arguments)
6900 }
6901 };
6902 }
6903 target$1.addEventListener(
6904 name,
6905 handler,
6906 supportsPassive
6907 ? { capture: capture, passive: passive }
6908 : capture
6909 );
6910 }
6911
6912 function remove$2 (
6913 name,
6914 handler,
6915 capture,
6916 _target
6917 ) {
6918 (_target || target$1).removeEventListener(
6919 name,
6920 handler._wrapper || handler,
6921 capture
6922 );
6923 }
6924
6925 function updateDOMListeners (oldVnode, vnode) {
6926 if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
6927 return
6928 }
6929 var on = vnode.data.on || {};
6930 var oldOn = oldVnode.data.on || {};
6931 target$1 = vnode.elm;
6932 normalizeEvents(on);
6933 updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
6934 target$1 = undefined;
6935 }
6936
6937 var events = {
6938 create: updateDOMListeners,
6939 update: updateDOMListeners
6940 };
6941
6942 /* */
6943
6944 var svgContainer;
6945
6946 function updateDOMProps (oldVnode, vnode) {
6947 if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
6948 return
6949 }
6950 var key, cur;
6951 var elm = vnode.elm;
6952 var oldProps = oldVnode.data.domProps || {};
6953 var props = vnode.data.domProps || {};
6954 // clone observed objects, as the user probably wants to mutate it
6955 if (isDef(props.__ob__)) {
6956 props = vnode.data.domProps = extend({}, props);
6957 }
6958
6959 for (key in oldProps) {
6960 if (!(key in props)) {
6961 elm[key] = '';
6962 }
6963 }
6964
6965 for (key in props) {
6966 cur = props[key];
6967 // ignore children if the node has textContent or innerHTML,
6968 // as these will throw away existing DOM nodes and cause removal errors
6969 // on subsequent patches (#3360)
6970 if (key === 'textContent' || key === 'innerHTML') {
6971 if (vnode.children) { vnode.children.length = 0; }
6972 if (cur === oldProps[key]) { continue }
6973 // #6601 work around Chrome version <= 55 bug where single textNode
6974 // replaced by innerHTML/textContent retains its parentNode property
6975 if (elm.childNodes.length === 1) {
6976 elm.removeChild(elm.childNodes[0]);
6977 }
6978 }
6979
6980 if (key === 'value' && elm.tagName !== 'PROGRESS') {
6981 // store value as _value as well since
6982 // non-string values will be stringified
6983 elm._value = cur;
6984 // avoid resetting cursor position when value is the same
6985 var strCur = isUndef(cur) ? '' : String(cur);
6986 if (shouldUpdateValue(elm, strCur)) {
6987 elm.value = strCur;
6988 }
6989 } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
6990 // IE doesn't support innerHTML for SVG elements
6991 svgContainer = svgContainer || document.createElement('div');
6992 svgContainer.innerHTML = "<svg>" + cur + "</svg>";
6993 var svg = svgContainer.firstChild;
6994 while (elm.firstChild) {
6995 elm.removeChild(elm.firstChild);
6996 }
6997 while (svg.firstChild) {
6998 elm.appendChild(svg.firstChild);
6999 }
7000 } else if (
7001 // skip the update if old and new VDOM state is the same.
7002 // `value` is handled separately because the DOM value may be temporarily
7003 // out of sync with VDOM state due to focus, composition and modifiers.
7004 // This #4521 by skipping the unnecessary `checked` update.
7005 cur !== oldProps[key]
7006 ) {
7007 // some property updates can throw
7008 // e.g. `value` on <progress> w/ non-finite value
7009 try {
7010 elm[key] = cur;
7011 } catch (e) {}
7012 }
7013 }
7014 }
7015
7016 // check platforms/web/util/attrs.js acceptValue
7017
7018
7019 function shouldUpdateValue (elm, checkVal) {
7020 return (!elm.composing && (
7021 elm.tagName === 'OPTION' ||
7022 isNotInFocusAndDirty(elm, checkVal) ||
7023 isDirtyWithModifiers(elm, checkVal)
7024 ))
7025 }
7026
7027 function isNotInFocusAndDirty (elm, checkVal) {
7028 // return true when textbox (.number and .trim) loses focus and its value is
7029 // not equal to the updated value
7030 var notInFocus = true;
7031 // #6157
7032 // work around IE bug when accessing document.activeElement in an iframe
7033 try { notInFocus = document.activeElement !== elm; } catch (e) {}
7034 return notInFocus && elm.value !== checkVal
7035 }
7036
7037 function isDirtyWithModifiers (elm, newVal) {
7038 var value = elm.value;
7039 var modifiers = elm._vModifiers; // injected by v-model runtime
7040 if (isDef(modifiers)) {
7041 if (modifiers.number) {
7042 return toNumber(value) !== toNumber(newVal)
7043 }
7044 if (modifiers.trim) {
7045 return value.trim() !== newVal.trim()
7046 }
7047 }
7048 return value !== newVal
7049 }
7050
7051 var domProps = {
7052 create: updateDOMProps,
7053 update: updateDOMProps
7054 };
7055
7056 /* */
7057
7058 var parseStyleText = cached(function (cssText) {
7059 var res = {};
7060 var listDelimiter = /;(?![^(]*\))/g;
7061 var propertyDelimiter = /:(.+)/;
7062 cssText.split(listDelimiter).forEach(function (item) {
7063 if (item) {
7064 var tmp = item.split(propertyDelimiter);
7065 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
7066 }
7067 });
7068 return res
7069 });
7070
7071 // merge static and dynamic style data on the same vnode
7072 function normalizeStyleData (data) {
7073 var style = normalizeStyleBinding(data.style);
7074 // static style is pre-processed into an object during compilation
7075 // and is always a fresh object, so it's safe to merge into it
7076 return data.staticStyle
7077 ? extend(data.staticStyle, style)
7078 : style
7079 }
7080
7081 // normalize possible array / string values into Object
7082 function normalizeStyleBinding (bindingStyle) {
7083 if (Array.isArray(bindingStyle)) {
7084 return toObject(bindingStyle)
7085 }
7086 if (typeof bindingStyle === 'string') {
7087 return parseStyleText(bindingStyle)
7088 }
7089 return bindingStyle
7090 }
7091
7092 /**
7093 * parent component style should be after child's
7094 * so that parent component's style could override it
7095 */
7096 function getStyle (vnode, checkChild) {
7097 var res = {};
7098 var styleData;
7099
7100 if (checkChild) {
7101 var childNode = vnode;
7102 while (childNode.componentInstance) {
7103 childNode = childNode.componentInstance._vnode;
7104 if (
7105 childNode && childNode.data &&
7106 (styleData = normalizeStyleData(childNode.data))
7107 ) {
7108 extend(res, styleData);
7109 }
7110 }
7111 }
7112
7113 if ((styleData = normalizeStyleData(vnode.data))) {
7114 extend(res, styleData);
7115 }
7116
7117 var parentNode = vnode;
7118 while ((parentNode = parentNode.parent)) {
7119 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
7120 extend(res, styleData);
7121 }
7122 }
7123 return res
7124 }
7125
7126 /* */
7127
7128 var cssVarRE = /^--/;
7129 var importantRE = /\s*!important$/;
7130 var setProp = function (el, name, val) {
7131 /* istanbul ignore if */
7132 if (cssVarRE.test(name)) {
7133 el.style.setProperty(name, val);
7134 } else if (importantRE.test(val)) {
7135 el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
7136 } else {
7137 var normalizedName = normalize(name);
7138 if (Array.isArray(val)) {
7139 // Support values array created by autoprefixer, e.g.
7140 // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
7141 // Set them one by one, and the browser will only set those it can recognize
7142 for (var i = 0, len = val.length; i < len; i++) {
7143 el.style[normalizedName] = val[i];
7144 }
7145 } else {
7146 el.style[normalizedName] = val;
7147 }
7148 }
7149 };
7150
7151 var vendorNames = ['Webkit', 'Moz', 'ms'];
7152
7153 var emptyStyle;
7154 var normalize = cached(function (prop) {
7155 emptyStyle = emptyStyle || document.createElement('div').style;
7156 prop = camelize(prop);
7157 if (prop !== 'filter' && (prop in emptyStyle)) {
7158 return prop
7159 }
7160 var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
7161 for (var i = 0; i < vendorNames.length; i++) {
7162 var name = vendorNames[i] + capName;
7163 if (name in emptyStyle) {
7164 return name
7165 }
7166 }
7167 });
7168
7169 function updateStyle (oldVnode, vnode) {
7170 var data = vnode.data;
7171 var oldData = oldVnode.data;
7172
7173 if (isUndef(data.staticStyle) && isUndef(data.style) &&
7174 isUndef(oldData.staticStyle) && isUndef(oldData.style)
7175 ) {
7176 return
7177 }
7178
7179 var cur, name;
7180 var el = vnode.elm;
7181 var oldStaticStyle = oldData.staticStyle;
7182 var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
7183
7184 // if static style exists, stylebinding already merged into it when doing normalizeStyleData
7185 var oldStyle = oldStaticStyle || oldStyleBinding;
7186
7187 var style = normalizeStyleBinding(vnode.data.style) || {};
7188
7189 // store normalized style under a different key for next diff
7190 // make sure to clone it if it's reactive, since the user likely wants
7191 // to mutate it.
7192 vnode.data.normalizedStyle = isDef(style.__ob__)
7193 ? extend({}, style)
7194 : style;
7195
7196 var newStyle = getStyle(vnode, true);
7197
7198 for (name in oldStyle) {
7199 if (isUndef(newStyle[name])) {
7200 setProp(el, name, '');
7201 }
7202 }
7203 for (name in newStyle) {
7204 cur = newStyle[name];
7205 if (cur !== oldStyle[name]) {
7206 // ie9 setting to null has no effect, must use empty string
7207 setProp(el, name, cur == null ? '' : cur);
7208 }
7209 }
7210 }
7211
7212 var style = {
7213 create: updateStyle,
7214 update: updateStyle
7215 };
7216
7217 /* */
7218
7219 var whitespaceRE = /\s+/;
7220
7221 /**
7222 * Add class with compatibility for SVG since classList is not supported on
7223 * SVG elements in IE
7224 */
7225 function addClass (el, cls) {
7226 /* istanbul ignore if */
7227 if (!cls || !(cls = cls.trim())) {
7228 return
7229 }
7230
7231 /* istanbul ignore else */
7232 if (el.classList) {
7233 if (cls.indexOf(' ') > -1) {
7234 cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
7235 } else {
7236 el.classList.add(cls);
7237 }
7238 } else {
7239 var cur = " " + (el.getAttribute('class') || '') + " ";
7240 if (cur.indexOf(' ' + cls + ' ') < 0) {
7241 el.setAttribute('class', (cur + cls).trim());
7242 }
7243 }
7244 }
7245
7246 /**
7247 * Remove class with compatibility for SVG since classList is not supported on
7248 * SVG elements in IE
7249 */
7250 function removeClass (el, cls) {
7251 /* istanbul ignore if */
7252 if (!cls || !(cls = cls.trim())) {
7253 return
7254 }
7255
7256 /* istanbul ignore else */
7257 if (el.classList) {
7258 if (cls.indexOf(' ') > -1) {
7259 cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
7260 } else {
7261 el.classList.remove(cls);
7262 }
7263 if (!el.classList.length) {
7264 el.removeAttribute('class');
7265 }
7266 } else {
7267 var cur = " " + (el.getAttribute('class') || '') + " ";
7268 var tar = ' ' + cls + ' ';
7269 while (cur.indexOf(tar) >= 0) {
7270 cur = cur.replace(tar, ' ');
7271 }
7272 cur = cur.trim();
7273 if (cur) {
7274 el.setAttribute('class', cur);
7275 } else {
7276 el.removeAttribute('class');
7277 }
7278 }
7279 }
7280
7281 /* */
7282
7283 function resolveTransition (def$$1) {
7284 if (!def$$1) {
7285 return
7286 }
7287 /* istanbul ignore else */
7288 if (typeof def$$1 === 'object') {
7289 var res = {};
7290 if (def$$1.css !== false) {
7291 extend(res, autoCssTransition(def$$1.name || 'v'));
7292 }
7293 extend(res, def$$1);
7294 return res
7295 } else if (typeof def$$1 === 'string') {
7296 return autoCssTransition(def$$1)
7297 }
7298 }
7299
7300 var autoCssTransition = cached(function (name) {
7301 return {
7302 enterClass: (name + "-enter"),
7303 enterToClass: (name + "-enter-to"),
7304 enterActiveClass: (name + "-enter-active"),
7305 leaveClass: (name + "-leave"),
7306 leaveToClass: (name + "-leave-to"),
7307 leaveActiveClass: (name + "-leave-active")
7308 }
7309 });
7310
7311 var hasTransition = inBrowser && !isIE9;
7312 var TRANSITION = 'transition';
7313 var ANIMATION = 'animation';
7314
7315 // Transition property/event sniffing
7316 var transitionProp = 'transition';
7317 var transitionEndEvent = 'transitionend';
7318 var animationProp = 'animation';
7319 var animationEndEvent = 'animationend';
7320 if (hasTransition) {
7321 /* istanbul ignore if */
7322 if (window.ontransitionend === undefined &&
7323 window.onwebkittransitionend !== undefined
7324 ) {
7325 transitionProp = 'WebkitTransition';
7326 transitionEndEvent = 'webkitTransitionEnd';
7327 }
7328 if (window.onanimationend === undefined &&
7329 window.onwebkitanimationend !== undefined
7330 ) {
7331 animationProp = 'WebkitAnimation';
7332 animationEndEvent = 'webkitAnimationEnd';
7333 }
7334 }
7335
7336 // binding to window is necessary to make hot reload work in IE in strict mode
7337 var raf = inBrowser
7338 ? window.requestAnimationFrame
7339 ? window.requestAnimationFrame.bind(window)
7340 : setTimeout
7341 : /* istanbul ignore next */ function (fn) { return fn(); };
7342
7343 function nextFrame (fn) {
7344 raf(function () {
7345 raf(fn);
7346 });
7347 }
7348
7349 function addTransitionClass (el, cls) {
7350 var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
7351 if (transitionClasses.indexOf(cls) < 0) {
7352 transitionClasses.push(cls);
7353 addClass(el, cls);
7354 }
7355 }
7356
7357 function removeTransitionClass (el, cls) {
7358 if (el._transitionClasses) {
7359 remove(el._transitionClasses, cls);
7360 }
7361 removeClass(el, cls);
7362 }
7363
7364 function whenTransitionEnds (
7365 el,
7366 expectedType,
7367 cb
7368 ) {
7369 var ref = getTransitionInfo(el, expectedType);
7370 var type = ref.type;
7371 var timeout = ref.timeout;
7372 var propCount = ref.propCount;
7373 if (!type) { return cb() }
7374 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
7375 var ended = 0;
7376 var end = function () {
7377 el.removeEventListener(event, onEnd);
7378 cb();
7379 };
7380 var onEnd = function (e) {
7381 if (e.target === el) {
7382 if (++ended >= propCount) {
7383 end();
7384 }
7385 }
7386 };
7387 setTimeout(function () {
7388 if (ended < propCount) {
7389 end();
7390 }
7391 }, timeout + 1);
7392 el.addEventListener(event, onEnd);
7393 }
7394
7395 var transformRE = /\b(transform|all)(,|$)/;
7396
7397 function getTransitionInfo (el, expectedType) {
7398 var styles = window.getComputedStyle(el);
7399 // JSDOM may return undefined for transition properties
7400 var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
7401 var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
7402 var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
7403 var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
7404 var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
7405 var animationTimeout = getTimeout(animationDelays, animationDurations);
7406
7407 var type;
7408 var timeout = 0;
7409 var propCount = 0;
7410 /* istanbul ignore if */
7411 if (expectedType === TRANSITION) {
7412 if (transitionTimeout > 0) {
7413 type = TRANSITION;
7414 timeout = transitionTimeout;
7415 propCount = transitionDurations.length;
7416 }
7417 } else if (expectedType === ANIMATION) {
7418 if (animationTimeout > 0) {
7419 type = ANIMATION;
7420 timeout = animationTimeout;
7421 propCount = animationDurations.length;
7422 }
7423 } else {
7424 timeout = Math.max(transitionTimeout, animationTimeout);
7425 type = timeout > 0
7426 ? transitionTimeout > animationTimeout
7427 ? TRANSITION
7428 : ANIMATION
7429 : null;
7430 propCount = type
7431 ? type === TRANSITION
7432 ? transitionDurations.length
7433 : animationDurations.length
7434 : 0;
7435 }
7436 var hasTransform =
7437 type === TRANSITION &&
7438 transformRE.test(styles[transitionProp + 'Property']);
7439 return {
7440 type: type,
7441 timeout: timeout,
7442 propCount: propCount,
7443 hasTransform: hasTransform
7444 }
7445 }
7446
7447 function getTimeout (delays, durations) {
7448 /* istanbul ignore next */
7449 while (delays.length < durations.length) {
7450 delays = delays.concat(delays);
7451 }
7452
7453 return Math.max.apply(null, durations.map(function (d, i) {
7454 return toMs(d) + toMs(delays[i])
7455 }))
7456 }
7457
7458 // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
7459 // in a locale-dependent way, using a comma instead of a dot.
7460 // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
7461 // as a floor function) causing unexpected behaviors
7462 function toMs (s) {
7463 return Number(s.slice(0, -1).replace(',', '.')) * 1000
7464 }
7465
7466 /* */
7467
7468 function enter (vnode, toggleDisplay) {
7469 var el = vnode.elm;
7470
7471 // call leave callback now
7472 if (isDef(el._leaveCb)) {
7473 el._leaveCb.cancelled = true;
7474 el._leaveCb();
7475 }
7476
7477 var data = resolveTransition(vnode.data.transition);
7478 if (isUndef(data)) {
7479 return
7480 }
7481
7482 /* istanbul ignore if */
7483 if (isDef(el._enterCb) || el.nodeType !== 1) {
7484 return
7485 }
7486
7487 var css = data.css;
7488 var type = data.type;
7489 var enterClass = data.enterClass;
7490 var enterToClass = data.enterToClass;
7491 var enterActiveClass = data.enterActiveClass;
7492 var appearClass = data.appearClass;
7493 var appearToClass = data.appearToClass;
7494 var appearActiveClass = data.appearActiveClass;
7495 var beforeEnter = data.beforeEnter;
7496 var enter = data.enter;
7497 var afterEnter = data.afterEnter;
7498 var enterCancelled = data.enterCancelled;
7499 var beforeAppear = data.beforeAppear;
7500 var appear = data.appear;
7501 var afterAppear = data.afterAppear;
7502 var appearCancelled = data.appearCancelled;
7503 var duration = data.duration;
7504
7505 // activeInstance will always be the <transition> component managing this
7506 // transition. One edge case to check is when the <transition> is placed
7507 // as the root node of a child component. In that case we need to check
7508 // <transition>'s parent for appear check.
7509 var context = activeInstance;
7510 var transitionNode = activeInstance.$vnode;
7511 while (transitionNode && transitionNode.parent) {
7512 context = transitionNode.context;
7513 transitionNode = transitionNode.parent;
7514 }
7515
7516 var isAppear = !context._isMounted || !vnode.isRootInsert;
7517
7518 if (isAppear && !appear && appear !== '') {
7519 return
7520 }
7521
7522 var startClass = isAppear && appearClass
7523 ? appearClass
7524 : enterClass;
7525 var activeClass = isAppear && appearActiveClass
7526 ? appearActiveClass
7527 : enterActiveClass;
7528 var toClass = isAppear && appearToClass
7529 ? appearToClass
7530 : enterToClass;
7531
7532 var beforeEnterHook = isAppear
7533 ? (beforeAppear || beforeEnter)
7534 : beforeEnter;
7535 var enterHook = isAppear
7536 ? (typeof appear === 'function' ? appear : enter)
7537 : enter;
7538 var afterEnterHook = isAppear
7539 ? (afterAppear || afterEnter)
7540 : afterEnter;
7541 var enterCancelledHook = isAppear
7542 ? (appearCancelled || enterCancelled)
7543 : enterCancelled;
7544
7545 var explicitEnterDuration = toNumber(
7546 isObject(duration)
7547 ? duration.enter
7548 : duration
7549 );
7550
7551 if (explicitEnterDuration != null) {
7552 checkDuration(explicitEnterDuration, 'enter', vnode);
7553 }
7554
7555 var expectsCSS = css !== false && !isIE9;
7556 var userWantsControl = getHookArgumentsLength(enterHook);
7557
7558 var cb = el._enterCb = once(function () {
7559 if (expectsCSS) {
7560 removeTransitionClass(el, toClass);
7561 removeTransitionClass(el, activeClass);
7562 }
7563 if (cb.cancelled) {
7564 if (expectsCSS) {
7565 removeTransitionClass(el, startClass);
7566 }
7567 enterCancelledHook && enterCancelledHook(el);
7568 } else {
7569 afterEnterHook && afterEnterHook(el);
7570 }
7571 el._enterCb = null;
7572 });
7573
7574 if (!vnode.data.show) {
7575 // remove pending leave element on enter by injecting an insert hook
7576 mergeVNodeHook(vnode, 'insert', function () {
7577 var parent = el.parentNode;
7578 var pendingNode = parent && parent._pending && parent._pending[vnode.key];
7579 if (pendingNode &&
7580 pendingNode.tag === vnode.tag &&
7581 pendingNode.elm._leaveCb
7582 ) {
7583 pendingNode.elm._leaveCb();
7584 }
7585 enterHook && enterHook(el, cb);
7586 });
7587 }
7588
7589 // start enter transition
7590 beforeEnterHook && beforeEnterHook(el);
7591 if (expectsCSS) {
7592 addTransitionClass(el, startClass);
7593 addTransitionClass(el, activeClass);
7594 nextFrame(function () {
7595 removeTransitionClass(el, startClass);
7596 if (!cb.cancelled) {
7597 addTransitionClass(el, toClass);
7598 if (!userWantsControl) {
7599 if (isValidDuration(explicitEnterDuration)) {
7600 setTimeout(cb, explicitEnterDuration);
7601 } else {
7602 whenTransitionEnds(el, type, cb);
7603 }
7604 }
7605 }
7606 });
7607 }
7608
7609 if (vnode.data.show) {
7610 toggleDisplay && toggleDisplay();
7611 enterHook && enterHook(el, cb);
7612 }
7613
7614 if (!expectsCSS && !userWantsControl) {
7615 cb();
7616 }
7617 }
7618
7619 function leave (vnode, rm) {
7620 var el = vnode.elm;
7621
7622 // call enter callback now
7623 if (isDef(el._enterCb)) {
7624 el._enterCb.cancelled = true;
7625 el._enterCb();
7626 }
7627
7628 var data = resolveTransition(vnode.data.transition);
7629 if (isUndef(data) || el.nodeType !== 1) {
7630 return rm()
7631 }
7632
7633 /* istanbul ignore if */
7634 if (isDef(el._leaveCb)) {
7635 return
7636 }
7637
7638 var css = data.css;
7639 var type = data.type;
7640 var leaveClass = data.leaveClass;
7641 var leaveToClass = data.leaveToClass;
7642 var leaveActiveClass = data.leaveActiveClass;
7643 var beforeLeave = data.beforeLeave;
7644 var leave = data.leave;
7645 var afterLeave = data.afterLeave;
7646 var leaveCancelled = data.leaveCancelled;
7647 var delayLeave = data.delayLeave;
7648 var duration = data.duration;
7649
7650 var expectsCSS = css !== false && !isIE9;
7651 var userWantsControl = getHookArgumentsLength(leave);
7652
7653 var explicitLeaveDuration = toNumber(
7654 isObject(duration)
7655 ? duration.leave
7656 : duration
7657 );
7658
7659 if (isDef(explicitLeaveDuration)) {
7660 checkDuration(explicitLeaveDuration, 'leave', vnode);
7661 }
7662
7663 var cb = el._leaveCb = once(function () {
7664 if (el.parentNode && el.parentNode._pending) {
7665 el.parentNode._pending[vnode.key] = null;
7666 }
7667 if (expectsCSS) {
7668 removeTransitionClass(el, leaveToClass);
7669 removeTransitionClass(el, leaveActiveClass);
7670 }
7671 if (cb.cancelled) {
7672 if (expectsCSS) {
7673 removeTransitionClass(el, leaveClass);
7674 }
7675 leaveCancelled && leaveCancelled(el);
7676 } else {
7677 rm();
7678 afterLeave && afterLeave(el);
7679 }
7680 el._leaveCb = null;
7681 });
7682
7683 if (delayLeave) {
7684 delayLeave(performLeave);
7685 } else {
7686 performLeave();
7687 }
7688
7689 function performLeave () {
7690 // the delayed leave may have already been cancelled
7691 if (cb.cancelled) {
7692 return
7693 }
7694 // record leaving element
7695 if (!vnode.data.show && el.parentNode) {
7696 (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
7697 }
7698 beforeLeave && beforeLeave(el);
7699 if (expectsCSS) {
7700 addTransitionClass(el, leaveClass);
7701 addTransitionClass(el, leaveActiveClass);
7702 nextFrame(function () {
7703 removeTransitionClass(el, leaveClass);
7704 if (!cb.cancelled) {
7705 addTransitionClass(el, leaveToClass);
7706 if (!userWantsControl) {
7707 if (isValidDuration(explicitLeaveDuration)) {
7708 setTimeout(cb, explicitLeaveDuration);
7709 } else {
7710 whenTransitionEnds(el, type, cb);
7711 }
7712 }
7713 }
7714 });
7715 }
7716 leave && leave(el, cb);
7717 if (!expectsCSS && !userWantsControl) {
7718 cb();
7719 }
7720 }
7721 }
7722
7723 // only used in dev mode
7724 function checkDuration (val, name, vnode) {
7725 if (typeof val !== 'number') {
7726 warn(
7727 "<transition> explicit " + name + " duration is not a valid number - " +
7728 "got " + (JSON.stringify(val)) + ".",
7729 vnode.context
7730 );
7731 } else if (isNaN(val)) {
7732 warn(
7733 "<transition> explicit " + name + " duration is NaN - " +
7734 'the duration expression might be incorrect.',
7735 vnode.context
7736 );
7737 }
7738 }
7739
7740 function isValidDuration (val) {
7741 return typeof val === 'number' && !isNaN(val)
7742 }
7743
7744 /**
7745 * Normalize a transition hook's argument length. The hook may be:
7746 * - a merged hook (invoker) with the original in .fns
7747 * - a wrapped component method (check ._length)
7748 * - a plain function (.length)
7749 */
7750 function getHookArgumentsLength (fn) {
7751 if (isUndef(fn)) {
7752 return false
7753 }
7754 var invokerFns = fn.fns;
7755 if (isDef(invokerFns)) {
7756 // invoker
7757 return getHookArgumentsLength(
7758 Array.isArray(invokerFns)
7759 ? invokerFns[0]
7760 : invokerFns
7761 )
7762 } else {
7763 return (fn._length || fn.length) > 1
7764 }
7765 }
7766
7767 function _enter (_, vnode) {
7768 if (vnode.data.show !== true) {
7769 enter(vnode);
7770 }
7771 }
7772
7773 var transition = inBrowser ? {
7774 create: _enter,
7775 activate: _enter,
7776 remove: function remove$$1 (vnode, rm) {
7777 /* istanbul ignore else */
7778 if (vnode.data.show !== true) {
7779 leave(vnode, rm);
7780 } else {
7781 rm();
7782 }
7783 }
7784 } : {};
7785
7786 var platformModules = [
7787 attrs,
7788 klass,
7789 events,
7790 domProps,
7791 style,
7792 transition
7793 ];
7794
7795 /* */
7796
7797 // the directive module should be applied last, after all
7798 // built-in modules have been applied.
7799 var modules = platformModules.concat(baseModules);
7800
7801 var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
7802
7803 /**
7804 * Not type checking this file because flow doesn't like attaching
7805 * properties to Elements.
7806 */
7807
7808 /* istanbul ignore if */
7809 if (isIE9) {
7810 // http://www.matts411.com/post/internet-explorer-9-oninput/
7811 document.addEventListener('selectionchange', function () {
7812 var el = document.activeElement;
7813 if (el && el.vmodel) {
7814 trigger(el, 'input');
7815 }
7816 });
7817 }
7818
7819 var directive = {
7820 inserted: function inserted (el, binding, vnode, oldVnode) {
7821 if (vnode.tag === 'select') {
7822 // #6903
7823 if (oldVnode.elm && !oldVnode.elm._vOptions) {
7824 mergeVNodeHook(vnode, 'postpatch', function () {
7825 directive.componentUpdated(el, binding, vnode);
7826 });
7827 } else {
7828 setSelected(el, binding, vnode.context);
7829 }
7830 el._vOptions = [].map.call(el.options, getValue);
7831 } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
7832 el._vModifiers = binding.modifiers;
7833 if (!binding.modifiers.lazy) {
7834 el.addEventListener('compositionstart', onCompositionStart);
7835 el.addEventListener('compositionend', onCompositionEnd);
7836 // Safari < 10.2 & UIWebView doesn't fire compositionend when
7837 // switching focus before confirming composition choice
7838 // this also fixes the issue where some browsers e.g. iOS Chrome
7839 // fires "change" instead of "input" on autocomplete.
7840 el.addEventListener('change', onCompositionEnd);
7841 /* istanbul ignore if */
7842 if (isIE9) {
7843 el.vmodel = true;
7844 }
7845 }
7846 }
7847 },
7848
7849 componentUpdated: function componentUpdated (el, binding, vnode) {
7850 if (vnode.tag === 'select') {
7851 setSelected(el, binding, vnode.context);
7852 // in case the options rendered by v-for have changed,
7853 // it's possible that the value is out-of-sync with the rendered options.
7854 // detect such cases and filter out values that no longer has a matching
7855 // option in the DOM.
7856 var prevOptions = el._vOptions;
7857 var curOptions = el._vOptions = [].map.call(el.options, getValue);
7858 if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
7859 // trigger change event if
7860 // no matching option found for at least one value
7861 var needReset = el.multiple
7862 ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
7863 : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
7864 if (needReset) {
7865 trigger(el, 'change');
7866 }
7867 }
7868 }
7869 }
7870 };
7871
7872 function setSelected (el, binding, vm) {
7873 actuallySetSelected(el, binding, vm);
7874 /* istanbul ignore if */
7875 if (isIE || isEdge) {
7876 setTimeout(function () {
7877 actuallySetSelected(el, binding, vm);
7878 }, 0);
7879 }
7880 }
7881
7882 function actuallySetSelected (el, binding, vm) {
7883 var value = binding.value;
7884 var isMultiple = el.multiple;
7885 if (isMultiple && !Array.isArray(value)) {
7886 warn(
7887 "<select multiple v-model=\"" + (binding.expression) + "\"> " +
7888 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
7889 vm
7890 );
7891 return
7892 }
7893 var selected, option;
7894 for (var i = 0, l = el.options.length; i < l; i++) {
7895 option = el.options[i];
7896 if (isMultiple) {
7897 selected = looseIndexOf(value, getValue(option)) > -1;
7898 if (option.selected !== selected) {
7899 option.selected = selected;
7900 }
7901 } else {
7902 if (looseEqual(getValue(option), value)) {
7903 if (el.selectedIndex !== i) {
7904 el.selectedIndex = i;
7905 }
7906 return
7907 }
7908 }
7909 }
7910 if (!isMultiple) {
7911 el.selectedIndex = -1;
7912 }
7913 }
7914
7915 function hasNoMatchingOption (value, options) {
7916 return options.every(function (o) { return !looseEqual(o, value); })
7917 }
7918
7919 function getValue (option) {
7920 return '_value' in option
7921 ? option._value
7922 : option.value
7923 }
7924
7925 function onCompositionStart (e) {
7926 e.target.composing = true;
7927 }
7928
7929 function onCompositionEnd (e) {
7930 // prevent triggering an input event for no reason
7931 if (!e.target.composing) { return }
7932 e.target.composing = false;
7933 trigger(e.target, 'input');
7934 }
7935
7936 function trigger (el, type) {
7937 var e = document.createEvent('HTMLEvents');
7938 e.initEvent(type, true, true);
7939 el.dispatchEvent(e);
7940 }
7941
7942 /* */
7943
7944 // recursively search for possible transition defined inside the component root
7945 function locateNode (vnode) {
7946 return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
7947 ? locateNode(vnode.componentInstance._vnode)
7948 : vnode
7949 }
7950
7951 var show = {
7952 bind: function bind (el, ref, vnode) {
7953 var value = ref.value;
7954
7955 vnode = locateNode(vnode);
7956 var transition$$1 = vnode.data && vnode.data.transition;
7957 var originalDisplay = el.__vOriginalDisplay =
7958 el.style.display === 'none' ? '' : el.style.display;
7959 if (value && transition$$1) {
7960 vnode.data.show = true;
7961 enter(vnode, function () {
7962 el.style.display = originalDisplay;
7963 });
7964 } else {
7965 el.style.display = value ? originalDisplay : 'none';
7966 }
7967 },
7968
7969 update: function update (el, ref, vnode) {
7970 var value = ref.value;
7971 var oldValue = ref.oldValue;
7972
7973 /* istanbul ignore if */
7974 if (!value === !oldValue) { return }
7975 vnode = locateNode(vnode);
7976 var transition$$1 = vnode.data && vnode.data.transition;
7977 if (transition$$1) {
7978 vnode.data.show = true;
7979 if (value) {
7980 enter(vnode, function () {
7981 el.style.display = el.__vOriginalDisplay;
7982 });
7983 } else {
7984 leave(vnode, function () {
7985 el.style.display = 'none';
7986 });
7987 }
7988 } else {
7989 el.style.display = value ? el.__vOriginalDisplay : 'none';
7990 }
7991 },
7992
7993 unbind: function unbind (
7994 el,
7995 binding,
7996 vnode,
7997 oldVnode,
7998 isDestroy
7999 ) {
8000 if (!isDestroy) {
8001 el.style.display = el.__vOriginalDisplay;
8002 }
8003 }
8004 };
8005
8006 var platformDirectives = {
8007 model: directive,
8008 show: show
8009 };
8010
8011 /* */
8012
8013 var transitionProps = {
8014 name: String,
8015 appear: Boolean,
8016 css: Boolean,
8017 mode: String,
8018 type: String,
8019 enterClass: String,
8020 leaveClass: String,
8021 enterToClass: String,
8022 leaveToClass: String,
8023 enterActiveClass: String,
8024 leaveActiveClass: String,
8025 appearClass: String,
8026 appearActiveClass: String,
8027 appearToClass: String,
8028 duration: [Number, String, Object]
8029 };
8030
8031 // in case the child is also an abstract component, e.g. <keep-alive>
8032 // we want to recursively retrieve the real component to be rendered
8033 function getRealChild (vnode) {
8034 var compOptions = vnode && vnode.componentOptions;
8035 if (compOptions && compOptions.Ctor.options.abstract) {
8036 return getRealChild(getFirstComponentChild(compOptions.children))
8037 } else {
8038 return vnode
8039 }
8040 }
8041
8042 function extractTransitionData (comp) {
8043 var data = {};
8044 var options = comp.$options;
8045 // props
8046 for (var key in options.propsData) {
8047 data[key] = comp[key];
8048 }
8049 // events.
8050 // extract listeners and pass them directly to the transition methods
8051 var listeners = options._parentListeners;
8052 for (var key$1 in listeners) {
8053 data[camelize(key$1)] = listeners[key$1];
8054 }
8055 return data
8056 }
8057
8058 function placeholder (h, rawChild) {
8059 if (/\d-keep-alive$/.test(rawChild.tag)) {
8060 return h('keep-alive', {
8061 props: rawChild.componentOptions.propsData
8062 })
8063 }
8064 }
8065
8066 function hasParentTransition (vnode) {
8067 while ((vnode = vnode.parent)) {
8068 if (vnode.data.transition) {
8069 return true
8070 }
8071 }
8072 }
8073
8074 function isSameChild (child, oldChild) {
8075 return oldChild.key === child.key && oldChild.tag === child.tag
8076 }
8077
8078 var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
8079
8080 var isVShowDirective = function (d) { return d.name === 'show'; };
8081
8082 var Transition = {
8083 name: 'transition',
8084 props: transitionProps,
8085 abstract: true,
8086
8087 render: function render (h) {
8088 var this$1 = this;
8089
8090 var children = this.$slots.default;
8091 if (!children) {
8092 return
8093 }
8094
8095 // filter out text nodes (possible whitespaces)
8096 children = children.filter(isNotTextNode);
8097 /* istanbul ignore if */
8098 if (!children.length) {
8099 return
8100 }
8101
8102 // warn multiple elements
8103 if (children.length > 1) {
8104 warn(
8105 '<transition> can only be used on a single element. Use ' +
8106 '<transition-group> for lists.',
8107 this.$parent
8108 );
8109 }
8110
8111 var mode = this.mode;
8112
8113 // warn invalid mode
8114 if (mode && mode !== 'in-out' && mode !== 'out-in'
8115 ) {
8116 warn(
8117 'invalid <transition> mode: ' + mode,
8118 this.$parent
8119 );
8120 }
8121
8122 var rawChild = children[0];
8123
8124 // if this is a component root node and the component's
8125 // parent container node also has transition, skip.
8126 if (hasParentTransition(this.$vnode)) {
8127 return rawChild
8128 }
8129
8130 // apply transition data to child
8131 // use getRealChild() to ignore abstract components e.g. keep-alive
8132 var child = getRealChild(rawChild);
8133 /* istanbul ignore if */
8134 if (!child) {
8135 return rawChild
8136 }
8137
8138 if (this._leaving) {
8139 return placeholder(h, rawChild)
8140 }
8141
8142 // ensure a key that is unique to the vnode type and to this transition
8143 // component instance. This key will be used to remove pending leaving nodes
8144 // during entering.
8145 var id = "__transition-" + (this._uid) + "-";
8146 child.key = child.key == null
8147 ? child.isComment
8148 ? id + 'comment'
8149 : id + child.tag
8150 : isPrimitive(child.key)
8151 ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
8152 : child.key;
8153
8154 var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
8155 var oldRawChild = this._vnode;
8156 var oldChild = getRealChild(oldRawChild);
8157
8158 // mark v-show
8159 // so that the transition module can hand over the control to the directive
8160 if (child.data.directives && child.data.directives.some(isVShowDirective)) {
8161 child.data.show = true;
8162 }
8163
8164 if (
8165 oldChild &&
8166 oldChild.data &&
8167 !isSameChild(child, oldChild) &&
8168 !isAsyncPlaceholder(oldChild) &&
8169 // #6687 component root is a comment node
8170 !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
8171 ) {
8172 // replace old child transition data with fresh one
8173 // important for dynamic transitions!
8174 var oldData = oldChild.data.transition = extend({}, data);
8175 // handle transition mode
8176 if (mode === 'out-in') {
8177 // return placeholder node and queue update when leave finishes
8178 this._leaving = true;
8179 mergeVNodeHook(oldData, 'afterLeave', function () {
8180 this$1._leaving = false;
8181 this$1.$forceUpdate();
8182 });
8183 return placeholder(h, rawChild)
8184 } else if (mode === 'in-out') {
8185 if (isAsyncPlaceholder(child)) {
8186 return oldRawChild
8187 }
8188 var delayedLeave;
8189 var performLeave = function () { delayedLeave(); };
8190 mergeVNodeHook(data, 'afterEnter', performLeave);
8191 mergeVNodeHook(data, 'enterCancelled', performLeave);
8192 mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
8193 }
8194 }
8195
8196 return rawChild
8197 }
8198 };
8199
8200 /* */
8201
8202 var props = extend({
8203 tag: String,
8204 moveClass: String
8205 }, transitionProps);
8206
8207 delete props.mode;
8208
8209 var TransitionGroup = {
8210 props: props,
8211
8212 beforeMount: function beforeMount () {
8213 var this$1 = this;
8214
8215 var update = this._update;
8216 this._update = function (vnode, hydrating) {
8217 var restoreActiveInstance = setActiveInstance(this$1);
8218 // force removing pass
8219 this$1.__patch__(
8220 this$1._vnode,
8221 this$1.kept,
8222 false, // hydrating
8223 true // removeOnly (!important, avoids unnecessary moves)
8224 );
8225 this$1._vnode = this$1.kept;
8226 restoreActiveInstance();
8227 update.call(this$1, vnode, hydrating);
8228 };
8229 },
8230
8231 render: function render (h) {
8232 var tag = this.tag || this.$vnode.data.tag || 'span';
8233 var map = Object.create(null);
8234 var prevChildren = this.prevChildren = this.children;
8235 var rawChildren = this.$slots.default || [];
8236 var children = this.children = [];
8237 var transitionData = extractTransitionData(this);
8238
8239 for (var i = 0; i < rawChildren.length; i++) {
8240 var c = rawChildren[i];
8241 if (c.tag) {
8242 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
8243 children.push(c);
8244 map[c.key] = c
8245 ;(c.data || (c.data = {})).transition = transitionData;
8246 } else {
8247 var opts = c.componentOptions;
8248 var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
8249 warn(("<transition-group> children must be keyed: <" + name + ">"));
8250 }
8251 }
8252 }
8253
8254 if (prevChildren) {
8255 var kept = [];
8256 var removed = [];
8257 for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
8258 var c$1 = prevChildren[i$1];
8259 c$1.data.transition = transitionData;
8260 c$1.data.pos = c$1.elm.getBoundingClientRect();
8261 if (map[c$1.key]) {
8262 kept.push(c$1);
8263 } else {
8264 removed.push(c$1);
8265 }
8266 }
8267 this.kept = h(tag, null, kept);
8268 this.removed = removed;
8269 }
8270
8271 return h(tag, null, children)
8272 },
8273
8274 updated: function updated () {
8275 var children = this.prevChildren;
8276 var moveClass = this.moveClass || ((this.name || 'v') + '-move');
8277 if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
8278 return
8279 }
8280
8281 // we divide the work into three loops to avoid mixing DOM reads and writes
8282 // in each iteration - which helps prevent layout thrashing.
8283 children.forEach(callPendingCbs);
8284 children.forEach(recordPosition);
8285 children.forEach(applyTranslation);
8286
8287 // force reflow to put everything in position
8288 // assign to this to avoid being removed in tree-shaking
8289 // $flow-disable-line
8290 this._reflow = document.body.offsetHeight;
8291
8292 children.forEach(function (c) {
8293 if (c.data.moved) {
8294 var el = c.elm;
8295 var s = el.style;
8296 addTransitionClass(el, moveClass);
8297 s.transform = s.WebkitTransform = s.transitionDuration = '';
8298 el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
8299 if (e && e.target !== el) {
8300 return
8301 }
8302 if (!e || /transform$/.test(e.propertyName)) {
8303 el.removeEventListener(transitionEndEvent, cb);
8304 el._moveCb = null;
8305 removeTransitionClass(el, moveClass);
8306 }
8307 });
8308 }
8309 });
8310 },
8311
8312 methods: {
8313 hasMove: function hasMove (el, moveClass) {
8314 /* istanbul ignore if */
8315 if (!hasTransition) {
8316 return false
8317 }
8318 /* istanbul ignore if */
8319 if (this._hasMove) {
8320 return this._hasMove
8321 }
8322 // Detect whether an element with the move class applied has
8323 // CSS transitions. Since the element may be inside an entering
8324 // transition at this very moment, we make a clone of it and remove
8325 // all other transition classes applied to ensure only the move class
8326 // is applied.
8327 var clone = el.cloneNode();
8328 if (el._transitionClasses) {
8329 el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
8330 }
8331 addClass(clone, moveClass);
8332 clone.style.display = 'none';
8333 this.$el.appendChild(clone);
8334 var info = getTransitionInfo(clone);
8335 this.$el.removeChild(clone);
8336 return (this._hasMove = info.hasTransform)
8337 }
8338 }
8339 };
8340
8341 function callPendingCbs (c) {
8342 /* istanbul ignore if */
8343 if (c.elm._moveCb) {
8344 c.elm._moveCb();
8345 }
8346 /* istanbul ignore if */
8347 if (c.elm._enterCb) {
8348 c.elm._enterCb();
8349 }
8350 }
8351
8352 function recordPosition (c) {
8353 c.data.newPos = c.elm.getBoundingClientRect();
8354 }
8355
8356 function applyTranslation (c) {
8357 var oldPos = c.data.pos;
8358 var newPos = c.data.newPos;
8359 var dx = oldPos.left - newPos.left;
8360 var dy = oldPos.top - newPos.top;
8361 if (dx || dy) {
8362 c.data.moved = true;
8363 var s = c.elm.style;
8364 s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
8365 s.transitionDuration = '0s';
8366 }
8367 }
8368
8369 var platformComponents = {
8370 Transition: Transition,
8371 TransitionGroup: TransitionGroup
8372 };
8373
8374 /* */
8375
8376 // install platform specific utils
8377 Vue.config.mustUseProp = mustUseProp;
8378 Vue.config.isReservedTag = isReservedTag;
8379 Vue.config.isReservedAttr = isReservedAttr;
8380 Vue.config.getTagNamespace = getTagNamespace;
8381 Vue.config.isUnknownElement = isUnknownElement;
8382
8383 // install platform runtime directives & components
8384 extend(Vue.options.directives, platformDirectives);
8385 extend(Vue.options.components, platformComponents);
8386
8387 // install platform patch function
8388 Vue.prototype.__patch__ = inBrowser ? patch : noop;
8389
8390 // public mount method
8391 Vue.prototype.$mount = function (
8392 el,
8393 hydrating
8394 ) {
8395 el = el && inBrowser ? query(el) : undefined;
8396 return mountComponent(this, el, hydrating)
8397 };
8398
8399 // devtools global hook
8400 /* istanbul ignore next */
8401 if (inBrowser) {
8402 setTimeout(function () {
8403 if (config.devtools) {
8404 if (devtools) {
8405 devtools.emit('init', Vue);
8406 } else {
8407 console[console.info ? 'info' : 'log'](
8408 'Download the Vue Devtools extension for a better development experience:\n' +
8409 'https://github.com/vuejs/vue-devtools'
8410 );
8411 }
8412 }
8413 if (config.productionTip !== false &&
8414 typeof console !== 'undefined'
8415 ) {
8416 console[console.info ? 'info' : 'log'](
8417 "You are running Vue in development mode.\n" +
8418 "Make sure to turn on production mode when deploying for production.\n" +
8419 "See more tips at https://vuejs.org/guide/deployment.html"
8420 );
8421 }
8422 }, 0);
8423 }
8424
8425 /* */
8426
8427 return Vue;
8428
8429}));