UNPKG

320 kBJavaScriptView Raw
1/*!
2 * Vue.js v2.6.12
3 * (c) 2014-2020 Evan You
4 * Released under the MIT License.
5 */
6'use strict';
7
8/* */
9
10var emptyObject = Object.freeze({});
11
12// These helpers produce better VM code in JS engines due to their
13// explicitness and function inlining.
14function isUndef (v) {
15 return v === undefined || v === null
16}
17
18function isDef (v) {
19 return v !== undefined && v !== null
20}
21
22function isTrue (v) {
23 return v === true
24}
25
26function isFalse (v) {
27 return v === false
28}
29
30/**
31 * Check if value is primitive.
32 */
33function isPrimitive (value) {
34 return (
35 typeof value === 'string' ||
36 typeof value === 'number' ||
37 // $flow-disable-line
38 typeof value === 'symbol' ||
39 typeof value === 'boolean'
40 )
41}
42
43/**
44 * Quick object check - this is primarily used to tell
45 * Objects from primitive values when we know the value
46 * is a JSON-compliant type.
47 */
48function isObject (obj) {
49 return obj !== null && typeof obj === 'object'
50}
51
52/**
53 * Get the raw type string of a value, e.g., [object Object].
54 */
55var _toString = Object.prototype.toString;
56
57function toRawType (value) {
58 return _toString.call(value).slice(8, -1)
59}
60
61/**
62 * Strict object type check. Only returns true
63 * for plain JavaScript objects.
64 */
65function isPlainObject (obj) {
66 return _toString.call(obj) === '[object Object]'
67}
68
69function isRegExp (v) {
70 return _toString.call(v) === '[object RegExp]'
71}
72
73/**
74 * Check if val is a valid array index.
75 */
76function isValidArrayIndex (val) {
77 var n = parseFloat(String(val));
78 return n >= 0 && Math.floor(n) === n && isFinite(val)
79}
80
81function isPromise (val) {
82 return (
83 isDef(val) &&
84 typeof val.then === 'function' &&
85 typeof val.catch === 'function'
86 )
87}
88
89/**
90 * Convert a value to a string that is actually rendered.
91 */
92function toString (val) {
93 return val == null
94 ? ''
95 : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
96 ? JSON.stringify(val, null, 2)
97 : String(val)
98}
99
100/**
101 * Convert an input value to a number for persistence.
102 * If the conversion fails, return original string.
103 */
104function toNumber (val) {
105 var n = parseFloat(val);
106 return isNaN(n) ? val : n
107}
108
109/**
110 * Make a map and return a function for checking if a key
111 * is in that map.
112 */
113function makeMap (
114 str,
115 expectsLowerCase
116) {
117 var map = Object.create(null);
118 var list = str.split(',');
119 for (var i = 0; i < list.length; i++) {
120 map[list[i]] = true;
121 }
122 return expectsLowerCase
123 ? function (val) { return map[val.toLowerCase()]; }
124 : function (val) { return map[val]; }
125}
126
127/**
128 * Check if a tag is a built-in tag.
129 */
130var isBuiltInTag = makeMap('slot,component', true);
131
132/**
133 * Check if an attribute is a reserved attribute.
134 */
135var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
136
137/**
138 * Remove an item from an array.
139 */
140function remove (arr, item) {
141 if (arr.length) {
142 var index = arr.indexOf(item);
143 if (index > -1) {
144 return arr.splice(index, 1)
145 }
146 }
147}
148
149/**
150 * Check whether an object has the property.
151 */
152var hasOwnProperty = Object.prototype.hasOwnProperty;
153function hasOwn (obj, key) {
154 return hasOwnProperty.call(obj, key)
155}
156
157/**
158 * Create a cached version of a pure function.
159 */
160function cached (fn) {
161 var cache = Object.create(null);
162 return (function cachedFn (str) {
163 var hit = cache[str];
164 return hit || (cache[str] = fn(str))
165 })
166}
167
168/**
169 * Camelize a hyphen-delimited string.
170 */
171var camelizeRE = /-(\w)/g;
172var camelize = cached(function (str) {
173 return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
174});
175
176/**
177 * Capitalize a string.
178 */
179var capitalize = cached(function (str) {
180 return str.charAt(0).toUpperCase() + str.slice(1)
181});
182
183/**
184 * Hyphenate a camelCase string.
185 */
186var hyphenateRE = /\B([A-Z])/g;
187var hyphenate = cached(function (str) {
188 return str.replace(hyphenateRE, '-$1').toLowerCase()
189});
190
191/**
192 * Simple bind polyfill for environments that do not support it,
193 * e.g., PhantomJS 1.x. Technically, we don't need this anymore
194 * since native bind is now performant enough in most browsers.
195 * But removing it would mean breaking code that was able to run in
196 * PhantomJS 1.x, so this must be kept for backward compatibility.
197 */
198
199/* istanbul ignore next */
200function polyfillBind (fn, ctx) {
201 function boundFn (a) {
202 var l = arguments.length;
203 return l
204 ? l > 1
205 ? fn.apply(ctx, arguments)
206 : fn.call(ctx, a)
207 : fn.call(ctx)
208 }
209
210 boundFn._length = fn.length;
211 return boundFn
212}
213
214function nativeBind (fn, ctx) {
215 return fn.bind(ctx)
216}
217
218var bind = Function.prototype.bind
219 ? nativeBind
220 : polyfillBind;
221
222/**
223 * Convert an Array-like object to a real Array.
224 */
225function toArray (list, start) {
226 start = start || 0;
227 var i = list.length - start;
228 var ret = new Array(i);
229 while (i--) {
230 ret[i] = list[i + start];
231 }
232 return ret
233}
234
235/**
236 * Mix properties into target object.
237 */
238function extend (to, _from) {
239 for (var key in _from) {
240 to[key] = _from[key];
241 }
242 return to
243}
244
245/**
246 * Merge an Array of Objects into a single Object.
247 */
248function toObject (arr) {
249 var res = {};
250 for (var i = 0; i < arr.length; i++) {
251 if (arr[i]) {
252 extend(res, arr[i]);
253 }
254 }
255 return res
256}
257
258/* eslint-disable no-unused-vars */
259
260/**
261 * Perform no operation.
262 * Stubbing args to make Flow happy without leaving useless transpiled code
263 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
264 */
265function noop (a, b, c) {}
266
267/**
268 * Always return false.
269 */
270var no = function (a, b, c) { return false; };
271
272/* eslint-enable no-unused-vars */
273
274/**
275 * Return the same value.
276 */
277var identity = function (_) { return _; };
278
279/**
280 * Generate a string containing static keys from compiler modules.
281 */
282function genStaticKeys (modules) {
283 return modules.reduce(function (keys, m) {
284 return keys.concat(m.staticKeys || [])
285 }, []).join(',')
286}
287
288/**
289 * Check if two values are loosely equal - that is,
290 * if they are plain objects, do they have the same shape?
291 */
292function looseEqual (a, b) {
293 if (a === b) { return true }
294 var isObjectA = isObject(a);
295 var isObjectB = isObject(b);
296 if (isObjectA && isObjectB) {
297 try {
298 var isArrayA = Array.isArray(a);
299 var isArrayB = Array.isArray(b);
300 if (isArrayA && isArrayB) {
301 return a.length === b.length && a.every(function (e, i) {
302 return looseEqual(e, b[i])
303 })
304 } else if (a instanceof Date && b instanceof Date) {
305 return a.getTime() === b.getTime()
306 } else if (!isArrayA && !isArrayB) {
307 var keysA = Object.keys(a);
308 var keysB = Object.keys(b);
309 return keysA.length === keysB.length && keysA.every(function (key) {
310 return looseEqual(a[key], b[key])
311 })
312 } else {
313 /* istanbul ignore next */
314 return false
315 }
316 } catch (e) {
317 /* istanbul ignore next */
318 return false
319 }
320 } else if (!isObjectA && !isObjectB) {
321 return String(a) === String(b)
322 } else {
323 return false
324 }
325}
326
327/**
328 * Return the first index at which a loosely equal value can be
329 * found in the array (if value is a plain object, the array must
330 * contain an object of the same shape), or -1 if it is not present.
331 */
332function looseIndexOf (arr, val) {
333 for (var i = 0; i < arr.length; i++) {
334 if (looseEqual(arr[i], val)) { return i }
335 }
336 return -1
337}
338
339/**
340 * Ensure a function is called only once.
341 */
342function once (fn) {
343 var called = false;
344 return function () {
345 if (!called) {
346 called = true;
347 fn.apply(this, arguments);
348 }
349 }
350}
351
352var SSR_ATTR = 'data-server-rendered';
353
354var ASSET_TYPES = [
355 'component',
356 'directive',
357 'filter'
358];
359
360var LIFECYCLE_HOOKS = [
361 'beforeCreate',
362 'created',
363 'beforeMount',
364 'mounted',
365 'beforeUpdate',
366 'updated',
367 'beforeDestroy',
368 'destroyed',
369 'activated',
370 'deactivated',
371 'errorCaptured',
372 'serverPrefetch'
373];
374
375/* */
376
377
378
379var config = ({
380 /**
381 * Option merge strategies (used in core/util/options)
382 */
383 // $flow-disable-line
384 optionMergeStrategies: Object.create(null),
385
386 /**
387 * Whether to suppress warnings.
388 */
389 silent: false,
390
391 /**
392 * Show production mode tip message on boot?
393 */
394 productionTip: "development" !== 'production',
395
396 /**
397 * Whether to enable devtools
398 */
399 devtools: "development" !== 'production',
400
401 /**
402 * Whether to record perf
403 */
404 performance: false,
405
406 /**
407 * Error handler for watcher errors
408 */
409 errorHandler: null,
410
411 /**
412 * Warn handler for watcher warns
413 */
414 warnHandler: null,
415
416 /**
417 * Ignore certain custom elements
418 */
419 ignoredElements: [],
420
421 /**
422 * Custom user key aliases for v-on
423 */
424 // $flow-disable-line
425 keyCodes: Object.create(null),
426
427 /**
428 * Check if a tag is reserved so that it cannot be registered as a
429 * component. This is platform-dependent and may be overwritten.
430 */
431 isReservedTag: no,
432
433 /**
434 * Check if an attribute is reserved so that it cannot be used as a component
435 * prop. This is platform-dependent and may be overwritten.
436 */
437 isReservedAttr: no,
438
439 /**
440 * Check if a tag is an unknown element.
441 * Platform-dependent.
442 */
443 isUnknownElement: no,
444
445 /**
446 * Get the namespace of an element
447 */
448 getTagNamespace: noop,
449
450 /**
451 * Parse the real tag name for the specific platform.
452 */
453 parsePlatformTagName: identity,
454
455 /**
456 * Check if an attribute must be bound using property, e.g. value
457 * Platform-dependent.
458 */
459 mustUseProp: no,
460
461 /**
462 * Perform updates asynchronously. Intended to be used by Vue Test Utils
463 * This will significantly reduce performance if set to false.
464 */
465 async: true,
466
467 /**
468 * Exposed for legacy reasons
469 */
470 _lifecycleHooks: LIFECYCLE_HOOKS
471});
472
473/* */
474
475/**
476 * unicode letters used for parsing html tags, component names and property paths.
477 * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
478 * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
479 */
480var 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/;
481
482/**
483 * Check if a string starts with $ or _
484 */
485function isReserved (str) {
486 var c = (str + '').charCodeAt(0);
487 return c === 0x24 || c === 0x5F
488}
489
490/**
491 * Define a property.
492 */
493function def (obj, key, val, enumerable) {
494 Object.defineProperty(obj, key, {
495 value: val,
496 enumerable: !!enumerable,
497 writable: true,
498 configurable: true
499 });
500}
501
502/**
503 * Parse simple path.
504 */
505var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
506function parsePath (path) {
507 if (bailRE.test(path)) {
508 return
509 }
510 var segments = path.split('.');
511 return function (obj) {
512 for (var i = 0; i < segments.length; i++) {
513 if (!obj) { return }
514 obj = obj[segments[i]];
515 }
516 return obj
517 }
518}
519
520/* */
521
522// can we use __proto__?
523var hasProto = '__proto__' in {};
524
525// Browser environment sniffing
526var inBrowser = typeof window !== 'undefined';
527var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
528var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
529var UA = inBrowser && window.navigator.userAgent.toLowerCase();
530var isIE = UA && /msie|trident/.test(UA);
531var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
532var isEdge = UA && UA.indexOf('edge/') > 0;
533var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
534var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
535var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
536var isPhantomJS = UA && /phantomjs/.test(UA);
537var isFF = UA && UA.match(/firefox\/(\d+)/);
538
539// Firefox has a "watch" function on Object.prototype...
540var nativeWatch = ({}).watch;
541
542var supportsPassive = false;
543if (inBrowser) {
544 try {
545 var opts = {};
546 Object.defineProperty(opts, 'passive', ({
547 get: function get () {
548 /* istanbul ignore next */
549 supportsPassive = true;
550 }
551 })); // https://github.com/facebook/flow/issues/285
552 window.addEventListener('test-passive', null, opts);
553 } catch (e) {}
554}
555
556// this needs to be lazy-evaled because vue may be required before
557// vue-server-renderer can set VUE_ENV
558var _isServer;
559var isServerRendering = function () {
560 if (_isServer === undefined) {
561 /* istanbul ignore if */
562 if (!inBrowser && !inWeex && typeof global !== 'undefined') {
563 // detect presence of vue-server-renderer and avoid
564 // Webpack shimming the process
565 _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
566 } else {
567 _isServer = false;
568 }
569 }
570 return _isServer
571};
572
573// detect devtools
574var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
575
576/* istanbul ignore next */
577function isNative (Ctor) {
578 return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
579}
580
581var hasSymbol =
582 typeof Symbol !== 'undefined' && isNative(Symbol) &&
583 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
584
585var _Set;
586/* istanbul ignore if */ // $flow-disable-line
587if (typeof Set !== 'undefined' && isNative(Set)) {
588 // use native Set when available.
589 _Set = Set;
590} else {
591 // a non-standard Set polyfill that only works with primitive keys.
592 _Set = /*@__PURE__*/(function () {
593 function Set () {
594 this.set = Object.create(null);
595 }
596 Set.prototype.has = function has (key) {
597 return this.set[key] === true
598 };
599 Set.prototype.add = function add (key) {
600 this.set[key] = true;
601 };
602 Set.prototype.clear = function clear () {
603 this.set = Object.create(null);
604 };
605
606 return Set;
607 }());
608}
609
610/* */
611
612var warn = noop;
613var tip = noop;
614var generateComponentTrace = (noop); // work around flow check
615var formatComponentName = (noop);
616
617{
618 var hasConsole = typeof console !== 'undefined';
619 var classifyRE = /(?:^|[-_])(\w)/g;
620 var classify = function (str) { return str
621 .replace(classifyRE, function (c) { return c.toUpperCase(); })
622 .replace(/[-_]/g, ''); };
623
624 warn = function (msg, vm) {
625 var trace = vm ? generateComponentTrace(vm) : '';
626
627 if (config.warnHandler) {
628 config.warnHandler.call(null, msg, vm, trace);
629 } else if (hasConsole && (!config.silent)) {
630 console.error(("[Vue warn]: " + msg + trace));
631 }
632 };
633
634 tip = function (msg, vm) {
635 if (hasConsole && (!config.silent)) {
636 console.warn("[Vue tip]: " + msg + (
637 vm ? generateComponentTrace(vm) : ''
638 ));
639 }
640 };
641
642 formatComponentName = function (vm, includeFile) {
643 if (vm.$root === vm) {
644 return '<Root>'
645 }
646 var options = typeof vm === 'function' && vm.cid != null
647 ? vm.options
648 : vm._isVue
649 ? vm.$options || vm.constructor.options
650 : vm;
651 var name = options.name || options._componentTag;
652 var file = options.__file;
653 if (!name && file) {
654 var match = file.match(/([^/\\]+)\.vue$/);
655 name = match && match[1];
656 }
657
658 return (
659 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
660 (file && includeFile !== false ? (" at " + file) : '')
661 )
662 };
663
664 var repeat = function (str, n) {
665 var res = '';
666 while (n) {
667 if (n % 2 === 1) { res += str; }
668 if (n > 1) { str += str; }
669 n >>= 1;
670 }
671 return res
672 };
673
674 generateComponentTrace = function (vm) {
675 if (vm._isVue && vm.$parent) {
676 var tree = [];
677 var currentRecursiveSequence = 0;
678 while (vm) {
679 if (tree.length > 0) {
680 var last = tree[tree.length - 1];
681 if (last.constructor === vm.constructor) {
682 currentRecursiveSequence++;
683 vm = vm.$parent;
684 continue
685 } else if (currentRecursiveSequence > 0) {
686 tree[tree.length - 1] = [last, currentRecursiveSequence];
687 currentRecursiveSequence = 0;
688 }
689 }
690 tree.push(vm);
691 vm = vm.$parent;
692 }
693 return '\n\nfound in\n\n' + tree
694 .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
695 ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
696 : formatComponentName(vm))); })
697 .join('\n')
698 } else {
699 return ("\n\n(found in " + (formatComponentName(vm)) + ")")
700 }
701 };
702}
703
704/* */
705
706var uid = 0;
707
708/**
709 * A dep is an observable that can have multiple
710 * directives subscribing to it.
711 */
712var Dep = function Dep () {
713 this.id = uid++;
714 this.subs = [];
715};
716
717Dep.prototype.addSub = function addSub (sub) {
718 this.subs.push(sub);
719};
720
721Dep.prototype.removeSub = function removeSub (sub) {
722 remove(this.subs, sub);
723};
724
725Dep.prototype.depend = function depend () {
726 if (Dep.target) {
727 Dep.target.addDep(this);
728 }
729};
730
731Dep.prototype.notify = function notify () {
732 // stabilize the subscriber list first
733 var subs = this.subs.slice();
734 if (!config.async) {
735 // subs aren't sorted in scheduler if not running async
736 // we need to sort them now to make sure they fire in correct
737 // order
738 subs.sort(function (a, b) { return a.id - b.id; });
739 }
740 for (var i = 0, l = subs.length; i < l; i++) {
741 subs[i].update();
742 }
743};
744
745// The current target watcher being evaluated.
746// This is globally unique because only one watcher
747// can be evaluated at a time.
748Dep.target = null;
749var targetStack = [];
750
751function pushTarget (target) {
752 targetStack.push(target);
753 Dep.target = target;
754}
755
756function popTarget () {
757 targetStack.pop();
758 Dep.target = targetStack[targetStack.length - 1];
759}
760
761/* */
762
763var VNode = function VNode (
764 tag,
765 data,
766 children,
767 text,
768 elm,
769 context,
770 componentOptions,
771 asyncFactory
772) {
773 this.tag = tag;
774 this.data = data;
775 this.children = children;
776 this.text = text;
777 this.elm = elm;
778 this.ns = undefined;
779 this.context = context;
780 this.fnContext = undefined;
781 this.fnOptions = undefined;
782 this.fnScopeId = undefined;
783 this.key = data && data.key;
784 this.componentOptions = componentOptions;
785 this.componentInstance = undefined;
786 this.parent = undefined;
787 this.raw = false;
788 this.isStatic = false;
789 this.isRootInsert = true;
790 this.isComment = false;
791 this.isCloned = false;
792 this.isOnce = false;
793 this.asyncFactory = asyncFactory;
794 this.asyncMeta = undefined;
795 this.isAsyncPlaceholder = false;
796};
797
798var prototypeAccessors = { child: { configurable: true } };
799
800// DEPRECATED: alias for componentInstance for backwards compat.
801/* istanbul ignore next */
802prototypeAccessors.child.get = function () {
803 return this.componentInstance
804};
805
806Object.defineProperties( VNode.prototype, prototypeAccessors );
807
808var createEmptyVNode = function (text) {
809 if ( text === void 0 ) text = '';
810
811 var node = new VNode();
812 node.text = text;
813 node.isComment = true;
814 return node
815};
816
817function createTextVNode (val) {
818 return new VNode(undefined, undefined, undefined, String(val))
819}
820
821// optimized shallow clone
822// used for static nodes and slot nodes because they may be reused across
823// multiple renders, cloning them avoids errors when DOM manipulations rely
824// on their elm reference.
825function cloneVNode (vnode) {
826 var cloned = new VNode(
827 vnode.tag,
828 vnode.data,
829 // #7975
830 // clone children array to avoid mutating original in case of cloning
831 // a child.
832 vnode.children && vnode.children.slice(),
833 vnode.text,
834 vnode.elm,
835 vnode.context,
836 vnode.componentOptions,
837 vnode.asyncFactory
838 );
839 cloned.ns = vnode.ns;
840 cloned.isStatic = vnode.isStatic;
841 cloned.key = vnode.key;
842 cloned.isComment = vnode.isComment;
843 cloned.fnContext = vnode.fnContext;
844 cloned.fnOptions = vnode.fnOptions;
845 cloned.fnScopeId = vnode.fnScopeId;
846 cloned.asyncMeta = vnode.asyncMeta;
847 cloned.isCloned = true;
848 return cloned
849}
850
851/*
852 * not type checking this file because flow doesn't play well with
853 * dynamically accessing methods on Array prototype
854 */
855
856var arrayProto = Array.prototype;
857var arrayMethods = Object.create(arrayProto);
858
859var methodsToPatch = [
860 'push',
861 'pop',
862 'shift',
863 'unshift',
864 'splice',
865 'sort',
866 'reverse'
867];
868
869/**
870 * Intercept mutating methods and emit events
871 */
872methodsToPatch.forEach(function (method) {
873 // cache original method
874 var original = arrayProto[method];
875 def(arrayMethods, method, function mutator () {
876 var args = [], len = arguments.length;
877 while ( len-- ) args[ len ] = arguments[ len ];
878
879 var result = original.apply(this, args);
880 var ob = this.__ob__;
881 var inserted;
882 switch (method) {
883 case 'push':
884 case 'unshift':
885 inserted = args;
886 break
887 case 'splice':
888 inserted = args.slice(2);
889 break
890 }
891 if (inserted) { ob.observeArray(inserted); }
892 // notify change
893 ob.dep.notify();
894 return result
895 });
896});
897
898/* */
899
900var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
901
902/**
903 * In some cases we may want to disable observation inside a component's
904 * update computation.
905 */
906var shouldObserve = true;
907
908function toggleObserving (value) {
909 shouldObserve = value;
910}
911
912/**
913 * Observer class that is attached to each observed
914 * object. Once attached, the observer converts the target
915 * object's property keys into getter/setters that
916 * collect dependencies and dispatch updates.
917 */
918var Observer = function Observer (value) {
919 this.value = value;
920 this.dep = new Dep();
921 this.vmCount = 0;
922 def(value, '__ob__', this);
923 if (Array.isArray(value)) {
924 if (hasProto) {
925 protoAugment(value, arrayMethods);
926 } else {
927 copyAugment(value, arrayMethods, arrayKeys);
928 }
929 this.observeArray(value);
930 } else {
931 this.walk(value);
932 }
933};
934
935/**
936 * Walk through all properties and convert them into
937 * getter/setters. This method should only be called when
938 * value type is Object.
939 */
940Observer.prototype.walk = function walk (obj) {
941 var keys = Object.keys(obj);
942 for (var i = 0; i < keys.length; i++) {
943 defineReactive$$1(obj, keys[i]);
944 }
945};
946
947/**
948 * Observe a list of Array items.
949 */
950Observer.prototype.observeArray = function observeArray (items) {
951 for (var i = 0, l = items.length; i < l; i++) {
952 observe(items[i]);
953 }
954};
955
956// helpers
957
958/**
959 * Augment a target Object or Array by intercepting
960 * the prototype chain using __proto__
961 */
962function protoAugment (target, src) {
963 /* eslint-disable no-proto */
964 target.__proto__ = src;
965 /* eslint-enable no-proto */
966}
967
968/**
969 * Augment a target Object or Array by defining
970 * hidden properties.
971 */
972/* istanbul ignore next */
973function copyAugment (target, src, keys) {
974 for (var i = 0, l = keys.length; i < l; i++) {
975 var key = keys[i];
976 def(target, key, src[key]);
977 }
978}
979
980/**
981 * Attempt to create an observer instance for a value,
982 * returns the new observer if successfully observed,
983 * or the existing observer if the value already has one.
984 */
985function observe (value, asRootData) {
986 if (!isObject(value) || value instanceof VNode) {
987 return
988 }
989 var ob;
990 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
991 ob = value.__ob__;
992 } else if (
993 shouldObserve &&
994 !isServerRendering() &&
995 (Array.isArray(value) || isPlainObject(value)) &&
996 Object.isExtensible(value) &&
997 !value._isVue
998 ) {
999 ob = new Observer(value);
1000 }
1001 if (asRootData && ob) {
1002 ob.vmCount++;
1003 }
1004 return ob
1005}
1006
1007/**
1008 * Define a reactive property on an Object.
1009 */
1010function defineReactive$$1 (
1011 obj,
1012 key,
1013 val,
1014 customSetter,
1015 shallow
1016) {
1017 var dep = new Dep();
1018
1019 var property = Object.getOwnPropertyDescriptor(obj, key);
1020 if (property && property.configurable === false) {
1021 return
1022 }
1023
1024 // cater for pre-defined getter/setters
1025 var getter = property && property.get;
1026 var setter = property && property.set;
1027 if ((!getter || setter) && arguments.length === 2) {
1028 val = obj[key];
1029 }
1030
1031 var childOb = !shallow && observe(val);
1032 Object.defineProperty(obj, key, {
1033 enumerable: true,
1034 configurable: true,
1035 get: function reactiveGetter () {
1036 var value = getter ? getter.call(obj) : val;
1037 if (Dep.target) {
1038 dep.depend();
1039 if (childOb) {
1040 childOb.dep.depend();
1041 if (Array.isArray(value)) {
1042 dependArray(value);
1043 }
1044 }
1045 }
1046 return value
1047 },
1048 set: function reactiveSetter (newVal) {
1049 var value = getter ? getter.call(obj) : val;
1050 /* eslint-disable no-self-compare */
1051 if (newVal === value || (newVal !== newVal && value !== value)) {
1052 return
1053 }
1054 /* eslint-enable no-self-compare */
1055 if (customSetter) {
1056 customSetter();
1057 }
1058 // #7981: for accessor properties without setter
1059 if (getter && !setter) { return }
1060 if (setter) {
1061 setter.call(obj, newVal);
1062 } else {
1063 val = newVal;
1064 }
1065 childOb = !shallow && observe(newVal);
1066 dep.notify();
1067 }
1068 });
1069}
1070
1071/**
1072 * Set a property on an object. Adds the new property and
1073 * triggers change notification if the property doesn't
1074 * already exist.
1075 */
1076function set (target, key, val) {
1077 if (isUndef(target) || isPrimitive(target)
1078 ) {
1079 warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
1080 }
1081 if (Array.isArray(target) && isValidArrayIndex(key)) {
1082 target.length = Math.max(target.length, key);
1083 target.splice(key, 1, val);
1084 return val
1085 }
1086 if (key in target && !(key in Object.prototype)) {
1087 target[key] = val;
1088 return val
1089 }
1090 var ob = (target).__ob__;
1091 if (target._isVue || (ob && ob.vmCount)) {
1092 warn(
1093 'Avoid adding reactive properties to a Vue instance or its root $data ' +
1094 'at runtime - declare it upfront in the data option.'
1095 );
1096 return val
1097 }
1098 if (!ob) {
1099 target[key] = val;
1100 return val
1101 }
1102 defineReactive$$1(ob.value, key, val);
1103 ob.dep.notify();
1104 return val
1105}
1106
1107/**
1108 * Delete a property and trigger change if necessary.
1109 */
1110function del (target, key) {
1111 if (isUndef(target) || isPrimitive(target)
1112 ) {
1113 warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
1114 }
1115 if (Array.isArray(target) && isValidArrayIndex(key)) {
1116 target.splice(key, 1);
1117 return
1118 }
1119 var ob = (target).__ob__;
1120 if (target._isVue || (ob && ob.vmCount)) {
1121 warn(
1122 'Avoid deleting properties on a Vue instance or its root $data ' +
1123 '- just set it to null.'
1124 );
1125 return
1126 }
1127 if (!hasOwn(target, key)) {
1128 return
1129 }
1130 delete target[key];
1131 if (!ob) {
1132 return
1133 }
1134 ob.dep.notify();
1135}
1136
1137/**
1138 * Collect dependencies on array elements when the array is touched, since
1139 * we cannot intercept array element access like property getters.
1140 */
1141function dependArray (value) {
1142 for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
1143 e = value[i];
1144 e && e.__ob__ && e.__ob__.dep.depend();
1145 if (Array.isArray(e)) {
1146 dependArray(e);
1147 }
1148 }
1149}
1150
1151/* */
1152
1153/**
1154 * Option overwriting strategies are functions that handle
1155 * how to merge a parent option value and a child option
1156 * value into the final value.
1157 */
1158var strats = config.optionMergeStrategies;
1159
1160/**
1161 * Options with restrictions
1162 */
1163{
1164 strats.el = strats.propsData = function (parent, child, vm, key) {
1165 if (!vm) {
1166 warn(
1167 "option \"" + key + "\" can only be used during instance " +
1168 'creation with the `new` keyword.'
1169 );
1170 }
1171 return defaultStrat(parent, child)
1172 };
1173}
1174
1175/**
1176 * Helper that recursively merges two data objects together.
1177 */
1178function mergeData (to, from) {
1179 if (!from) { return to }
1180 var key, toVal, fromVal;
1181
1182 var keys = hasSymbol
1183 ? Reflect.ownKeys(from)
1184 : Object.keys(from);
1185
1186 for (var i = 0; i < keys.length; i++) {
1187 key = keys[i];
1188 // in case the object is already observed...
1189 if (key === '__ob__') { continue }
1190 toVal = to[key];
1191 fromVal = from[key];
1192 if (!hasOwn(to, key)) {
1193 set(to, key, fromVal);
1194 } else if (
1195 toVal !== fromVal &&
1196 isPlainObject(toVal) &&
1197 isPlainObject(fromVal)
1198 ) {
1199 mergeData(toVal, fromVal);
1200 }
1201 }
1202 return to
1203}
1204
1205/**
1206 * Data
1207 */
1208function mergeDataOrFn (
1209 parentVal,
1210 childVal,
1211 vm
1212) {
1213 if (!vm) {
1214 // in a Vue.extend merge, both should be functions
1215 if (!childVal) {
1216 return parentVal
1217 }
1218 if (!parentVal) {
1219 return childVal
1220 }
1221 // when parentVal & childVal are both present,
1222 // we need to return a function that returns the
1223 // merged result of both functions... no need to
1224 // check if parentVal is a function here because
1225 // it has to be a function to pass previous merges.
1226 return function mergedDataFn () {
1227 return mergeData(
1228 typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1229 typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1230 )
1231 }
1232 } else {
1233 return function mergedInstanceDataFn () {
1234 // instance merge
1235 var instanceData = typeof childVal === 'function'
1236 ? childVal.call(vm, vm)
1237 : childVal;
1238 var defaultData = typeof parentVal === 'function'
1239 ? parentVal.call(vm, vm)
1240 : parentVal;
1241 if (instanceData) {
1242 return mergeData(instanceData, defaultData)
1243 } else {
1244 return defaultData
1245 }
1246 }
1247 }
1248}
1249
1250strats.data = function (
1251 parentVal,
1252 childVal,
1253 vm
1254) {
1255 if (!vm) {
1256 if (childVal && typeof childVal !== 'function') {
1257 warn(
1258 'The "data" option should be a function ' +
1259 'that returns a per-instance value in component ' +
1260 'definitions.',
1261 vm
1262 );
1263
1264 return parentVal
1265 }
1266 return mergeDataOrFn(parentVal, childVal)
1267 }
1268
1269 return mergeDataOrFn(parentVal, childVal, vm)
1270};
1271
1272/**
1273 * Hooks and props are merged as arrays.
1274 */
1275function mergeHook (
1276 parentVal,
1277 childVal
1278) {
1279 var res = childVal
1280 ? parentVal
1281 ? parentVal.concat(childVal)
1282 : Array.isArray(childVal)
1283 ? childVal
1284 : [childVal]
1285 : parentVal;
1286 return res
1287 ? dedupeHooks(res)
1288 : res
1289}
1290
1291function dedupeHooks (hooks) {
1292 var res = [];
1293 for (var i = 0; i < hooks.length; i++) {
1294 if (res.indexOf(hooks[i]) === -1) {
1295 res.push(hooks[i]);
1296 }
1297 }
1298 return res
1299}
1300
1301LIFECYCLE_HOOKS.forEach(function (hook) {
1302 strats[hook] = mergeHook;
1303});
1304
1305/**
1306 * Assets
1307 *
1308 * When a vm is present (instance creation), we need to do
1309 * a three-way merge between constructor options, instance
1310 * options and parent options.
1311 */
1312function mergeAssets (
1313 parentVal,
1314 childVal,
1315 vm,
1316 key
1317) {
1318 var res = Object.create(parentVal || null);
1319 if (childVal) {
1320 assertObjectType(key, childVal, vm);
1321 return extend(res, childVal)
1322 } else {
1323 return res
1324 }
1325}
1326
1327ASSET_TYPES.forEach(function (type) {
1328 strats[type + 's'] = mergeAssets;
1329});
1330
1331/**
1332 * Watchers.
1333 *
1334 * Watchers hashes should not overwrite one
1335 * another, so we merge them as arrays.
1336 */
1337strats.watch = function (
1338 parentVal,
1339 childVal,
1340 vm,
1341 key
1342) {
1343 // work around Firefox's Object.prototype.watch...
1344 if (parentVal === nativeWatch) { parentVal = undefined; }
1345 if (childVal === nativeWatch) { childVal = undefined; }
1346 /* istanbul ignore if */
1347 if (!childVal) { return Object.create(parentVal || null) }
1348 {
1349 assertObjectType(key, childVal, vm);
1350 }
1351 if (!parentVal) { return childVal }
1352 var ret = {};
1353 extend(ret, parentVal);
1354 for (var key$1 in childVal) {
1355 var parent = ret[key$1];
1356 var child = childVal[key$1];
1357 if (parent && !Array.isArray(parent)) {
1358 parent = [parent];
1359 }
1360 ret[key$1] = parent
1361 ? parent.concat(child)
1362 : Array.isArray(child) ? child : [child];
1363 }
1364 return ret
1365};
1366
1367/**
1368 * Other object hashes.
1369 */
1370strats.props =
1371strats.methods =
1372strats.inject =
1373strats.computed = function (
1374 parentVal,
1375 childVal,
1376 vm,
1377 key
1378) {
1379 if (childVal && "development" !== 'production') {
1380 assertObjectType(key, childVal, vm);
1381 }
1382 if (!parentVal) { return childVal }
1383 var ret = Object.create(null);
1384 extend(ret, parentVal);
1385 if (childVal) { extend(ret, childVal); }
1386 return ret
1387};
1388strats.provide = mergeDataOrFn;
1389
1390/**
1391 * Default strategy.
1392 */
1393var defaultStrat = function (parentVal, childVal) {
1394 return childVal === undefined
1395 ? parentVal
1396 : childVal
1397};
1398
1399/**
1400 * Validate component names
1401 */
1402function checkComponents (options) {
1403 for (var key in options.components) {
1404 validateComponentName(key);
1405 }
1406}
1407
1408function validateComponentName (name) {
1409 if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
1410 warn(
1411 'Invalid component name: "' + name + '". Component names ' +
1412 'should conform to valid custom element name in html5 specification.'
1413 );
1414 }
1415 if (isBuiltInTag(name) || config.isReservedTag(name)) {
1416 warn(
1417 'Do not use built-in or reserved HTML elements as component ' +
1418 'id: ' + name
1419 );
1420 }
1421}
1422
1423/**
1424 * Ensure all props option syntax are normalized into the
1425 * Object-based format.
1426 */
1427function normalizeProps (options, vm) {
1428 var props = options.props;
1429 if (!props) { return }
1430 var res = {};
1431 var i, val, name;
1432 if (Array.isArray(props)) {
1433 i = props.length;
1434 while (i--) {
1435 val = props[i];
1436 if (typeof val === 'string') {
1437 name = camelize(val);
1438 res[name] = { type: null };
1439 } else {
1440 warn('props must be strings when using array syntax.');
1441 }
1442 }
1443 } else if (isPlainObject(props)) {
1444 for (var key in props) {
1445 val = props[key];
1446 name = camelize(key);
1447 res[name] = isPlainObject(val)
1448 ? val
1449 : { type: val };
1450 }
1451 } else {
1452 warn(
1453 "Invalid value for option \"props\": expected an Array or an Object, " +
1454 "but got " + (toRawType(props)) + ".",
1455 vm
1456 );
1457 }
1458 options.props = res;
1459}
1460
1461/**
1462 * Normalize all injections into Object-based format
1463 */
1464function normalizeInject (options, vm) {
1465 var inject = options.inject;
1466 if (!inject) { return }
1467 var normalized = options.inject = {};
1468 if (Array.isArray(inject)) {
1469 for (var i = 0; i < inject.length; i++) {
1470 normalized[inject[i]] = { from: inject[i] };
1471 }
1472 } else if (isPlainObject(inject)) {
1473 for (var key in inject) {
1474 var val = inject[key];
1475 normalized[key] = isPlainObject(val)
1476 ? extend({ from: key }, val)
1477 : { from: val };
1478 }
1479 } else {
1480 warn(
1481 "Invalid value for option \"inject\": expected an Array or an Object, " +
1482 "but got " + (toRawType(inject)) + ".",
1483 vm
1484 );
1485 }
1486}
1487
1488/**
1489 * Normalize raw function directives into object format.
1490 */
1491function normalizeDirectives (options) {
1492 var dirs = options.directives;
1493 if (dirs) {
1494 for (var key in dirs) {
1495 var def$$1 = dirs[key];
1496 if (typeof def$$1 === 'function') {
1497 dirs[key] = { bind: def$$1, update: def$$1 };
1498 }
1499 }
1500 }
1501}
1502
1503function assertObjectType (name, value, vm) {
1504 if (!isPlainObject(value)) {
1505 warn(
1506 "Invalid value for option \"" + name + "\": expected an Object, " +
1507 "but got " + (toRawType(value)) + ".",
1508 vm
1509 );
1510 }
1511}
1512
1513/**
1514 * Merge two option objects into a new one.
1515 * Core utility used in both instantiation and inheritance.
1516 */
1517function mergeOptions (
1518 parent,
1519 child,
1520 vm
1521) {
1522 {
1523 checkComponents(child);
1524 }
1525
1526 if (typeof child === 'function') {
1527 child = child.options;
1528 }
1529
1530 normalizeProps(child, vm);
1531 normalizeInject(child, vm);
1532 normalizeDirectives(child);
1533
1534 // Apply extends and mixins on the child options,
1535 // but only if it is a raw options object that isn't
1536 // the result of another mergeOptions call.
1537 // Only merged options has the _base property.
1538 if (!child._base) {
1539 if (child.extends) {
1540 parent = mergeOptions(parent, child.extends, vm);
1541 }
1542 if (child.mixins) {
1543 for (var i = 0, l = child.mixins.length; i < l; i++) {
1544 parent = mergeOptions(parent, child.mixins[i], vm);
1545 }
1546 }
1547 }
1548
1549 var options = {};
1550 var key;
1551 for (key in parent) {
1552 mergeField(key);
1553 }
1554 for (key in child) {
1555 if (!hasOwn(parent, key)) {
1556 mergeField(key);
1557 }
1558 }
1559 function mergeField (key) {
1560 var strat = strats[key] || defaultStrat;
1561 options[key] = strat(parent[key], child[key], vm, key);
1562 }
1563 return options
1564}
1565
1566/**
1567 * Resolve an asset.
1568 * This function is used because child instances need access
1569 * to assets defined in its ancestor chain.
1570 */
1571function resolveAsset (
1572 options,
1573 type,
1574 id,
1575 warnMissing
1576) {
1577 /* istanbul ignore if */
1578 if (typeof id !== 'string') {
1579 return
1580 }
1581 var assets = options[type];
1582 // check local registration variations first
1583 if (hasOwn(assets, id)) { return assets[id] }
1584 var camelizedId = camelize(id);
1585 if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
1586 var PascalCaseId = capitalize(camelizedId);
1587 if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
1588 // fallback to prototype chain
1589 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
1590 if (warnMissing && !res) {
1591 warn(
1592 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
1593 options
1594 );
1595 }
1596 return res
1597}
1598
1599/* */
1600
1601
1602
1603function validateProp (
1604 key,
1605 propOptions,
1606 propsData,
1607 vm
1608) {
1609 var prop = propOptions[key];
1610 var absent = !hasOwn(propsData, key);
1611 var value = propsData[key];
1612 // boolean casting
1613 var booleanIndex = getTypeIndex(Boolean, prop.type);
1614 if (booleanIndex > -1) {
1615 if (absent && !hasOwn(prop, 'default')) {
1616 value = false;
1617 } else if (value === '' || value === hyphenate(key)) {
1618 // only cast empty string / same name to boolean if
1619 // boolean has higher priority
1620 var stringIndex = getTypeIndex(String, prop.type);
1621 if (stringIndex < 0 || booleanIndex < stringIndex) {
1622 value = true;
1623 }
1624 }
1625 }
1626 // check default value
1627 if (value === undefined) {
1628 value = getPropDefaultValue(vm, prop, key);
1629 // since the default value is a fresh copy,
1630 // make sure to observe it.
1631 var prevShouldObserve = shouldObserve;
1632 toggleObserving(true);
1633 observe(value);
1634 toggleObserving(prevShouldObserve);
1635 }
1636 {
1637 assertProp(prop, key, value, vm, absent);
1638 }
1639 return value
1640}
1641
1642/**
1643 * Get the default value of a prop.
1644 */
1645function getPropDefaultValue (vm, prop, key) {
1646 // no default, return undefined
1647 if (!hasOwn(prop, 'default')) {
1648 return undefined
1649 }
1650 var def = prop.default;
1651 // warn against non-factory defaults for Object & Array
1652 if (isObject(def)) {
1653 warn(
1654 'Invalid default value for prop "' + key + '": ' +
1655 'Props with type Object/Array must use a factory function ' +
1656 'to return the default value.',
1657 vm
1658 );
1659 }
1660 // the raw prop value was also undefined from previous render,
1661 // return previous default value to avoid unnecessary watcher trigger
1662 if (vm && vm.$options.propsData &&
1663 vm.$options.propsData[key] === undefined &&
1664 vm._props[key] !== undefined
1665 ) {
1666 return vm._props[key]
1667 }
1668 // call factory function for non-Function types
1669 // a value is Function if its prototype is function even across different execution context
1670 return typeof def === 'function' && getType(prop.type) !== 'Function'
1671 ? def.call(vm)
1672 : def
1673}
1674
1675/**
1676 * Assert whether a prop is valid.
1677 */
1678function assertProp (
1679 prop,
1680 name,
1681 value,
1682 vm,
1683 absent
1684) {
1685 if (prop.required && absent) {
1686 warn(
1687 'Missing required prop: "' + name + '"',
1688 vm
1689 );
1690 return
1691 }
1692 if (value == null && !prop.required) {
1693 return
1694 }
1695 var type = prop.type;
1696 var valid = !type || type === true;
1697 var expectedTypes = [];
1698 if (type) {
1699 if (!Array.isArray(type)) {
1700 type = [type];
1701 }
1702 for (var i = 0; i < type.length && !valid; i++) {
1703 var assertedType = assertType(value, type[i]);
1704 expectedTypes.push(assertedType.expectedType || '');
1705 valid = assertedType.valid;
1706 }
1707 }
1708
1709 if (!valid) {
1710 warn(
1711 getInvalidTypeMessage(name, value, expectedTypes),
1712 vm
1713 );
1714 return
1715 }
1716 var validator = prop.validator;
1717 if (validator) {
1718 if (!validator(value)) {
1719 warn(
1720 'Invalid prop: custom validator check failed for prop "' + name + '".',
1721 vm
1722 );
1723 }
1724 }
1725}
1726
1727var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
1728
1729function assertType (value, type) {
1730 var valid;
1731 var expectedType = getType(type);
1732 if (simpleCheckRE.test(expectedType)) {
1733 var t = typeof value;
1734 valid = t === expectedType.toLowerCase();
1735 // for primitive wrapper objects
1736 if (!valid && t === 'object') {
1737 valid = value instanceof type;
1738 }
1739 } else if (expectedType === 'Object') {
1740 valid = isPlainObject(value);
1741 } else if (expectedType === 'Array') {
1742 valid = Array.isArray(value);
1743 } else {
1744 valid = value instanceof type;
1745 }
1746 return {
1747 valid: valid,
1748 expectedType: expectedType
1749 }
1750}
1751
1752/**
1753 * Use function string name to check built-in types,
1754 * because a simple equality check will fail when running
1755 * across different vms / iframes.
1756 */
1757function getType (fn) {
1758 var match = fn && fn.toString().match(/^\s*function (\w+)/);
1759 return match ? match[1] : ''
1760}
1761
1762function isSameType (a, b) {
1763 return getType(a) === getType(b)
1764}
1765
1766function getTypeIndex (type, expectedTypes) {
1767 if (!Array.isArray(expectedTypes)) {
1768 return isSameType(expectedTypes, type) ? 0 : -1
1769 }
1770 for (var i = 0, len = expectedTypes.length; i < len; i++) {
1771 if (isSameType(expectedTypes[i], type)) {
1772 return i
1773 }
1774 }
1775 return -1
1776}
1777
1778function getInvalidTypeMessage (name, value, expectedTypes) {
1779 var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
1780 " Expected " + (expectedTypes.map(capitalize).join(', '));
1781 var expectedType = expectedTypes[0];
1782 var receivedType = toRawType(value);
1783 var expectedValue = styleValue(value, expectedType);
1784 var receivedValue = styleValue(value, receivedType);
1785 // check if we need to specify expected value
1786 if (expectedTypes.length === 1 &&
1787 isExplicable(expectedType) &&
1788 !isBoolean(expectedType, receivedType)) {
1789 message += " with value " + expectedValue;
1790 }
1791 message += ", got " + receivedType + " ";
1792 // check if we need to specify received value
1793 if (isExplicable(receivedType)) {
1794 message += "with value " + receivedValue + ".";
1795 }
1796 return message
1797}
1798
1799function styleValue (value, type) {
1800 if (type === 'String') {
1801 return ("\"" + value + "\"")
1802 } else if (type === 'Number') {
1803 return ("" + (Number(value)))
1804 } else {
1805 return ("" + value)
1806 }
1807}
1808
1809function isExplicable (value) {
1810 var explicitTypes = ['string', 'number', 'boolean'];
1811 return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
1812}
1813
1814function isBoolean () {
1815 var args = [], len = arguments.length;
1816 while ( len-- ) args[ len ] = arguments[ len ];
1817
1818 return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
1819}
1820
1821/* */
1822
1823function handleError (err, vm, info) {
1824 // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
1825 // See: https://github.com/vuejs/vuex/issues/1505
1826 pushTarget();
1827 try {
1828 if (vm) {
1829 var cur = vm;
1830 while ((cur = cur.$parent)) {
1831 var hooks = cur.$options.errorCaptured;
1832 if (hooks) {
1833 for (var i = 0; i < hooks.length; i++) {
1834 try {
1835 var capture = hooks[i].call(cur, err, vm, info) === false;
1836 if (capture) { return }
1837 } catch (e) {
1838 globalHandleError(e, cur, 'errorCaptured hook');
1839 }
1840 }
1841 }
1842 }
1843 }
1844 globalHandleError(err, vm, info);
1845 } finally {
1846 popTarget();
1847 }
1848}
1849
1850function invokeWithErrorHandling (
1851 handler,
1852 context,
1853 args,
1854 vm,
1855 info
1856) {
1857 var res;
1858 try {
1859 res = args ? handler.apply(context, args) : handler.call(context);
1860 if (res && !res._isVue && isPromise(res) && !res._handled) {
1861 res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
1862 // issue #9511
1863 // avoid catch triggering multiple times when nested calls
1864 res._handled = true;
1865 }
1866 } catch (e) {
1867 handleError(e, vm, info);
1868 }
1869 return res
1870}
1871
1872function globalHandleError (err, vm, info) {
1873 if (config.errorHandler) {
1874 try {
1875 return config.errorHandler.call(null, err, vm, info)
1876 } catch (e) {
1877 // if the user intentionally throws the original error in the handler,
1878 // do not log it twice
1879 if (e !== err) {
1880 logError(e, null, 'config.errorHandler');
1881 }
1882 }
1883 }
1884 logError(err, vm, info);
1885}
1886
1887function logError (err, vm, info) {
1888 {
1889 warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
1890 }
1891 /* istanbul ignore else */
1892 if ((inBrowser || inWeex) && typeof console !== 'undefined') {
1893 console.error(err);
1894 } else {
1895 throw err
1896 }
1897}
1898
1899/* */
1900
1901var isUsingMicroTask = false;
1902
1903var callbacks = [];
1904var pending = false;
1905
1906function flushCallbacks () {
1907 pending = false;
1908 var copies = callbacks.slice(0);
1909 callbacks.length = 0;
1910 for (var i = 0; i < copies.length; i++) {
1911 copies[i]();
1912 }
1913}
1914
1915// Here we have async deferring wrappers using microtasks.
1916// In 2.5 we used (macro) tasks (in combination with microtasks).
1917// However, it has subtle problems when state is changed right before repaint
1918// (e.g. #6813, out-in transitions).
1919// Also, using (macro) tasks in event handler would cause some weird behaviors
1920// that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
1921// So we now use microtasks everywhere, again.
1922// A major drawback of this tradeoff is that there are some scenarios
1923// where microtasks have too high a priority and fire in between supposedly
1924// sequential events (e.g. #4521, #6690, which have workarounds)
1925// or even between bubbling of the same event (#6566).
1926var timerFunc;
1927
1928// The nextTick behavior leverages the microtask queue, which can be accessed
1929// via either native Promise.then or MutationObserver.
1930// MutationObserver has wider support, however it is seriously bugged in
1931// UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
1932// completely stops working after triggering a few times... so, if native
1933// Promise is available, we will use it:
1934/* istanbul ignore next, $flow-disable-line */
1935if (typeof Promise !== 'undefined' && isNative(Promise)) {
1936 var p = Promise.resolve();
1937 timerFunc = function () {
1938 p.then(flushCallbacks);
1939 // In problematic UIWebViews, Promise.then doesn't completely break, but
1940 // it can get stuck in a weird state where callbacks are pushed into the
1941 // microtask queue but the queue isn't being flushed, until the browser
1942 // needs to do some other work, e.g. handle a timer. Therefore we can
1943 // "force" the microtask queue to be flushed by adding an empty timer.
1944 if (isIOS) { setTimeout(noop); }
1945 };
1946 isUsingMicroTask = true;
1947} else if (!isIE && typeof MutationObserver !== 'undefined' && (
1948 isNative(MutationObserver) ||
1949 // PhantomJS and iOS 7.x
1950 MutationObserver.toString() === '[object MutationObserverConstructor]'
1951)) {
1952 // Use MutationObserver where native Promise is not available,
1953 // e.g. PhantomJS, iOS7, Android 4.4
1954 // (#6466 MutationObserver is unreliable in IE11)
1955 var counter = 1;
1956 var observer = new MutationObserver(flushCallbacks);
1957 var textNode = document.createTextNode(String(counter));
1958 observer.observe(textNode, {
1959 characterData: true
1960 });
1961 timerFunc = function () {
1962 counter = (counter + 1) % 2;
1963 textNode.data = String(counter);
1964 };
1965 isUsingMicroTask = true;
1966} else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
1967 // Fallback to setImmediate.
1968 // Technically it leverages the (macro) task queue,
1969 // but it is still a better choice than setTimeout.
1970 timerFunc = function () {
1971 setImmediate(flushCallbacks);
1972 };
1973} else {
1974 // Fallback to setTimeout.
1975 timerFunc = function () {
1976 setTimeout(flushCallbacks, 0);
1977 };
1978}
1979
1980function nextTick (cb, ctx) {
1981 var _resolve;
1982 callbacks.push(function () {
1983 if (cb) {
1984 try {
1985 cb.call(ctx);
1986 } catch (e) {
1987 handleError(e, ctx, 'nextTick');
1988 }
1989 } else if (_resolve) {
1990 _resolve(ctx);
1991 }
1992 });
1993 if (!pending) {
1994 pending = true;
1995 timerFunc();
1996 }
1997 // $flow-disable-line
1998 if (!cb && typeof Promise !== 'undefined') {
1999 return new Promise(function (resolve) {
2000 _resolve = resolve;
2001 })
2002 }
2003}
2004
2005/* */
2006
2007var mark;
2008var measure;
2009
2010{
2011 var perf = inBrowser && window.performance;
2012 /* istanbul ignore if */
2013 if (
2014 perf &&
2015 perf.mark &&
2016 perf.measure &&
2017 perf.clearMarks &&
2018 perf.clearMeasures
2019 ) {
2020 mark = function (tag) { return perf.mark(tag); };
2021 measure = function (name, startTag, endTag) {
2022 perf.measure(name, startTag, endTag);
2023 perf.clearMarks(startTag);
2024 perf.clearMarks(endTag);
2025 // perf.clearMeasures(name)
2026 };
2027 }
2028}
2029
2030/* not type checking this file because flow doesn't play well with Proxy */
2031
2032var initProxy;
2033
2034{
2035 var allowedGlobals = makeMap(
2036 'Infinity,undefined,NaN,isFinite,isNaN,' +
2037 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
2038 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
2039 'require' // for Webpack/Browserify
2040 );
2041
2042 var warnNonPresent = function (target, key) {
2043 warn(
2044 "Property or method \"" + key + "\" is not defined on the instance but " +
2045 'referenced during render. Make sure that this property is reactive, ' +
2046 'either in the data option, or for class-based components, by ' +
2047 'initializing the property. ' +
2048 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
2049 target
2050 );
2051 };
2052
2053 var warnReservedPrefix = function (target, key) {
2054 warn(
2055 "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
2056 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
2057 'prevent conflicts with Vue internals. ' +
2058 'See: https://vuejs.org/v2/api/#data',
2059 target
2060 );
2061 };
2062
2063 var hasProxy =
2064 typeof Proxy !== 'undefined' && isNative(Proxy);
2065
2066 if (hasProxy) {
2067 var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
2068 config.keyCodes = new Proxy(config.keyCodes, {
2069 set: function set (target, key, value) {
2070 if (isBuiltInModifier(key)) {
2071 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
2072 return false
2073 } else {
2074 target[key] = value;
2075 return true
2076 }
2077 }
2078 });
2079 }
2080
2081 var hasHandler = {
2082 has: function has (target, key) {
2083 var has = key in target;
2084 var isAllowed = allowedGlobals(key) ||
2085 (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
2086 if (!has && !isAllowed) {
2087 if (key in target.$data) { warnReservedPrefix(target, key); }
2088 else { warnNonPresent(target, key); }
2089 }
2090 return has || !isAllowed
2091 }
2092 };
2093
2094 var getHandler = {
2095 get: function get (target, key) {
2096 if (typeof key === 'string' && !(key in target)) {
2097 if (key in target.$data) { warnReservedPrefix(target, key); }
2098 else { warnNonPresent(target, key); }
2099 }
2100 return target[key]
2101 }
2102 };
2103
2104 initProxy = function initProxy (vm) {
2105 if (hasProxy) {
2106 // determine which proxy handler to use
2107 var options = vm.$options;
2108 var handlers = options.render && options.render._withStripped
2109 ? getHandler
2110 : hasHandler;
2111 vm._renderProxy = new Proxy(vm, handlers);
2112 } else {
2113 vm._renderProxy = vm;
2114 }
2115 };
2116}
2117
2118/* */
2119
2120var seenObjects = new _Set();
2121
2122/**
2123 * Recursively traverse an object to evoke all converted
2124 * getters, so that every nested property inside the object
2125 * is collected as a "deep" dependency.
2126 */
2127function traverse (val) {
2128 _traverse(val, seenObjects);
2129 seenObjects.clear();
2130}
2131
2132function _traverse (val, seen) {
2133 var i, keys;
2134 var isA = Array.isArray(val);
2135 if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
2136 return
2137 }
2138 if (val.__ob__) {
2139 var depId = val.__ob__.dep.id;
2140 if (seen.has(depId)) {
2141 return
2142 }
2143 seen.add(depId);
2144 }
2145 if (isA) {
2146 i = val.length;
2147 while (i--) { _traverse(val[i], seen); }
2148 } else {
2149 keys = Object.keys(val);
2150 i = keys.length;
2151 while (i--) { _traverse(val[keys[i]], seen); }
2152 }
2153}
2154
2155/* */
2156
2157var normalizeEvent = cached(function (name) {
2158 var passive = name.charAt(0) === '&';
2159 name = passive ? name.slice(1) : name;
2160 var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
2161 name = once$$1 ? name.slice(1) : name;
2162 var capture = name.charAt(0) === '!';
2163 name = capture ? name.slice(1) : name;
2164 return {
2165 name: name,
2166 once: once$$1,
2167 capture: capture,
2168 passive: passive
2169 }
2170});
2171
2172function createFnInvoker (fns, vm) {
2173 function invoker () {
2174 var arguments$1 = arguments;
2175
2176 var fns = invoker.fns;
2177 if (Array.isArray(fns)) {
2178 var cloned = fns.slice();
2179 for (var i = 0; i < cloned.length; i++) {
2180 invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
2181 }
2182 } else {
2183 // return handler return value for single handlers
2184 return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
2185 }
2186 }
2187 invoker.fns = fns;
2188 return invoker
2189}
2190
2191function updateListeners (
2192 on,
2193 oldOn,
2194 add,
2195 remove$$1,
2196 createOnceHandler,
2197 vm
2198) {
2199 var name, def$$1, cur, old, event;
2200 for (name in on) {
2201 def$$1 = cur = on[name];
2202 old = oldOn[name];
2203 event = normalizeEvent(name);
2204 if (isUndef(cur)) {
2205 warn(
2206 "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
2207 vm
2208 );
2209 } else if (isUndef(old)) {
2210 if (isUndef(cur.fns)) {
2211 cur = on[name] = createFnInvoker(cur, vm);
2212 }
2213 if (isTrue(event.once)) {
2214 cur = on[name] = createOnceHandler(event.name, cur, event.capture);
2215 }
2216 add(event.name, cur, event.capture, event.passive, event.params);
2217 } else if (cur !== old) {
2218 old.fns = cur;
2219 on[name] = old;
2220 }
2221 }
2222 for (name in oldOn) {
2223 if (isUndef(on[name])) {
2224 event = normalizeEvent(name);
2225 remove$$1(event.name, oldOn[name], event.capture);
2226 }
2227 }
2228}
2229
2230/* */
2231
2232function mergeVNodeHook (def, hookKey, hook) {
2233 if (def instanceof VNode) {
2234 def = def.data.hook || (def.data.hook = {});
2235 }
2236 var invoker;
2237 var oldHook = def[hookKey];
2238
2239 function wrappedHook () {
2240 hook.apply(this, arguments);
2241 // important: remove merged hook to ensure it's called only once
2242 // and prevent memory leak
2243 remove(invoker.fns, wrappedHook);
2244 }
2245
2246 if (isUndef(oldHook)) {
2247 // no existing hook
2248 invoker = createFnInvoker([wrappedHook]);
2249 } else {
2250 /* istanbul ignore if */
2251 if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
2252 // already a merged invoker
2253 invoker = oldHook;
2254 invoker.fns.push(wrappedHook);
2255 } else {
2256 // existing plain hook
2257 invoker = createFnInvoker([oldHook, wrappedHook]);
2258 }
2259 }
2260
2261 invoker.merged = true;
2262 def[hookKey] = invoker;
2263}
2264
2265/* */
2266
2267function extractPropsFromVNodeData (
2268 data,
2269 Ctor,
2270 tag
2271) {
2272 // we are only extracting raw values here.
2273 // validation and default values are handled in the child
2274 // component itself.
2275 var propOptions = Ctor.options.props;
2276 if (isUndef(propOptions)) {
2277 return
2278 }
2279 var res = {};
2280 var attrs = data.attrs;
2281 var props = data.props;
2282 if (isDef(attrs) || isDef(props)) {
2283 for (var key in propOptions) {
2284 var altKey = hyphenate(key);
2285 {
2286 var keyInLowerCase = key.toLowerCase();
2287 if (
2288 key !== keyInLowerCase &&
2289 attrs && hasOwn(attrs, keyInLowerCase)
2290 ) {
2291 tip(
2292 "Prop \"" + keyInLowerCase + "\" is passed to component " +
2293 (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
2294 " \"" + key + "\". " +
2295 "Note that HTML attributes are case-insensitive and camelCased " +
2296 "props need to use their kebab-case equivalents when using in-DOM " +
2297 "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
2298 );
2299 }
2300 }
2301 checkProp(res, props, key, altKey, true) ||
2302 checkProp(res, attrs, key, altKey, false);
2303 }
2304 }
2305 return res
2306}
2307
2308function checkProp (
2309 res,
2310 hash,
2311 key,
2312 altKey,
2313 preserve
2314) {
2315 if (isDef(hash)) {
2316 if (hasOwn(hash, key)) {
2317 res[key] = hash[key];
2318 if (!preserve) {
2319 delete hash[key];
2320 }
2321 return true
2322 } else if (hasOwn(hash, altKey)) {
2323 res[key] = hash[altKey];
2324 if (!preserve) {
2325 delete hash[altKey];
2326 }
2327 return true
2328 }
2329 }
2330 return false
2331}
2332
2333/* */
2334
2335// The template compiler attempts to minimize the need for normalization by
2336// statically analyzing the template at compile time.
2337//
2338// For plain HTML markup, normalization can be completely skipped because the
2339// generated render function is guaranteed to return Array<VNode>. There are
2340// two cases where extra normalization is needed:
2341
2342// 1. When the children contains components - because a functional component
2343// may return an Array instead of a single root. In this case, just a simple
2344// normalization is needed - if any child is an Array, we flatten the whole
2345// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
2346// because functional components already normalize their own children.
2347function simpleNormalizeChildren (children) {
2348 for (var i = 0; i < children.length; i++) {
2349 if (Array.isArray(children[i])) {
2350 return Array.prototype.concat.apply([], children)
2351 }
2352 }
2353 return children
2354}
2355
2356// 2. When the children contains constructs that always generated nested Arrays,
2357// e.g. <template>, <slot>, v-for, or when the children is provided by user
2358// with hand-written render functions / JSX. In such cases a full normalization
2359// is needed to cater to all possible types of children values.
2360function normalizeChildren (children) {
2361 return isPrimitive(children)
2362 ? [createTextVNode(children)]
2363 : Array.isArray(children)
2364 ? normalizeArrayChildren(children)
2365 : undefined
2366}
2367
2368function isTextNode (node) {
2369 return isDef(node) && isDef(node.text) && isFalse(node.isComment)
2370}
2371
2372function normalizeArrayChildren (children, nestedIndex) {
2373 var res = [];
2374 var i, c, lastIndex, last;
2375 for (i = 0; i < children.length; i++) {
2376 c = children[i];
2377 if (isUndef(c) || typeof c === 'boolean') { continue }
2378 lastIndex = res.length - 1;
2379 last = res[lastIndex];
2380 // nested
2381 if (Array.isArray(c)) {
2382 if (c.length > 0) {
2383 c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
2384 // merge adjacent text nodes
2385 if (isTextNode(c[0]) && isTextNode(last)) {
2386 res[lastIndex] = createTextVNode(last.text + (c[0]).text);
2387 c.shift();
2388 }
2389 res.push.apply(res, c);
2390 }
2391 } else if (isPrimitive(c)) {
2392 if (isTextNode(last)) {
2393 // merge adjacent text nodes
2394 // this is necessary for SSR hydration because text nodes are
2395 // essentially merged when rendered to HTML strings
2396 res[lastIndex] = createTextVNode(last.text + c);
2397 } else if (c !== '') {
2398 // convert primitive to vnode
2399 res.push(createTextVNode(c));
2400 }
2401 } else {
2402 if (isTextNode(c) && isTextNode(last)) {
2403 // merge adjacent text nodes
2404 res[lastIndex] = createTextVNode(last.text + c.text);
2405 } else {
2406 // default key for nested array children (likely generated by v-for)
2407 if (isTrue(children._isVList) &&
2408 isDef(c.tag) &&
2409 isUndef(c.key) &&
2410 isDef(nestedIndex)) {
2411 c.key = "__vlist" + nestedIndex + "_" + i + "__";
2412 }
2413 res.push(c);
2414 }
2415 }
2416 }
2417 return res
2418}
2419
2420/* */
2421
2422function initProvide (vm) {
2423 var provide = vm.$options.provide;
2424 if (provide) {
2425 vm._provided = typeof provide === 'function'
2426 ? provide.call(vm)
2427 : provide;
2428 }
2429}
2430
2431function initInjections (vm) {
2432 var result = resolveInject(vm.$options.inject, vm);
2433 if (result) {
2434 toggleObserving(false);
2435 Object.keys(result).forEach(function (key) {
2436 /* istanbul ignore else */
2437 {
2438 defineReactive$$1(vm, key, result[key], function () {
2439 warn(
2440 "Avoid mutating an injected value directly since the changes will be " +
2441 "overwritten whenever the provided component re-renders. " +
2442 "injection being mutated: \"" + key + "\"",
2443 vm
2444 );
2445 });
2446 }
2447 });
2448 toggleObserving(true);
2449 }
2450}
2451
2452function resolveInject (inject, vm) {
2453 if (inject) {
2454 // inject is :any because flow is not smart enough to figure out cached
2455 var result = Object.create(null);
2456 var keys = hasSymbol
2457 ? Reflect.ownKeys(inject)
2458 : Object.keys(inject);
2459
2460 for (var i = 0; i < keys.length; i++) {
2461 var key = keys[i];
2462 // #6574 in case the inject object is observed...
2463 if (key === '__ob__') { continue }
2464 var provideKey = inject[key].from;
2465 var source = vm;
2466 while (source) {
2467 if (source._provided && hasOwn(source._provided, provideKey)) {
2468 result[key] = source._provided[provideKey];
2469 break
2470 }
2471 source = source.$parent;
2472 }
2473 if (!source) {
2474 if ('default' in inject[key]) {
2475 var provideDefault = inject[key].default;
2476 result[key] = typeof provideDefault === 'function'
2477 ? provideDefault.call(vm)
2478 : provideDefault;
2479 } else {
2480 warn(("Injection \"" + key + "\" not found"), vm);
2481 }
2482 }
2483 }
2484 return result
2485 }
2486}
2487
2488/* */
2489
2490
2491
2492/**
2493 * Runtime helper for resolving raw children VNodes into a slot object.
2494 */
2495function resolveSlots (
2496 children,
2497 context
2498) {
2499 if (!children || !children.length) {
2500 return {}
2501 }
2502 var slots = {};
2503 for (var i = 0, l = children.length; i < l; i++) {
2504 var child = children[i];
2505 var data = child.data;
2506 // remove slot attribute if the node is resolved as a Vue slot node
2507 if (data && data.attrs && data.attrs.slot) {
2508 delete data.attrs.slot;
2509 }
2510 // named slots should only be respected if the vnode was rendered in the
2511 // same context.
2512 if ((child.context === context || child.fnContext === context) &&
2513 data && data.slot != null
2514 ) {
2515 var name = data.slot;
2516 var slot = (slots[name] || (slots[name] = []));
2517 if (child.tag === 'template') {
2518 slot.push.apply(slot, child.children || []);
2519 } else {
2520 slot.push(child);
2521 }
2522 } else {
2523 (slots.default || (slots.default = [])).push(child);
2524 }
2525 }
2526 // ignore slots that contains only whitespace
2527 for (var name$1 in slots) {
2528 if (slots[name$1].every(isWhitespace)) {
2529 delete slots[name$1];
2530 }
2531 }
2532 return slots
2533}
2534
2535function isWhitespace (node) {
2536 return (node.isComment && !node.asyncFactory) || node.text === ' '
2537}
2538
2539/* */
2540
2541function normalizeScopedSlots (
2542 slots,
2543 normalSlots,
2544 prevSlots
2545) {
2546 var res;
2547 var hasNormalSlots = Object.keys(normalSlots).length > 0;
2548 var isStable = slots ? !!slots.$stable : !hasNormalSlots;
2549 var key = slots && slots.$key;
2550 if (!slots) {
2551 res = {};
2552 } else if (slots._normalized) {
2553 // fast path 1: child component re-render only, parent did not change
2554 return slots._normalized
2555 } else if (
2556 isStable &&
2557 prevSlots &&
2558 prevSlots !== emptyObject &&
2559 key === prevSlots.$key &&
2560 !hasNormalSlots &&
2561 !prevSlots.$hasNormal
2562 ) {
2563 // fast path 2: stable scoped slots w/ no normal slots to proxy,
2564 // only need to normalize once
2565 return prevSlots
2566 } else {
2567 res = {};
2568 for (var key$1 in slots) {
2569 if (slots[key$1] && key$1[0] !== '$') {
2570 res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
2571 }
2572 }
2573 }
2574 // expose normal slots on scopedSlots
2575 for (var key$2 in normalSlots) {
2576 if (!(key$2 in res)) {
2577 res[key$2] = proxyNormalSlot(normalSlots, key$2);
2578 }
2579 }
2580 // avoriaz seems to mock a non-extensible $scopedSlots object
2581 // and when that is passed down this would cause an error
2582 if (slots && Object.isExtensible(slots)) {
2583 (slots)._normalized = res;
2584 }
2585 def(res, '$stable', isStable);
2586 def(res, '$key', key);
2587 def(res, '$hasNormal', hasNormalSlots);
2588 return res
2589}
2590
2591function normalizeScopedSlot(normalSlots, key, fn) {
2592 var normalized = function () {
2593 var res = arguments.length ? fn.apply(null, arguments) : fn({});
2594 res = res && typeof res === 'object' && !Array.isArray(res)
2595 ? [res] // single vnode
2596 : normalizeChildren(res);
2597 return res && (
2598 res.length === 0 ||
2599 (res.length === 1 && res[0].isComment) // #9658
2600 ) ? undefined
2601 : res
2602 };
2603 // this is a slot using the new v-slot syntax without scope. although it is
2604 // compiled as a scoped slot, render fn users would expect it to be present
2605 // on this.$slots because the usage is semantically a normal slot.
2606 if (fn.proxy) {
2607 Object.defineProperty(normalSlots, key, {
2608 get: normalized,
2609 enumerable: true,
2610 configurable: true
2611 });
2612 }
2613 return normalized
2614}
2615
2616function proxyNormalSlot(slots, key) {
2617 return function () { return slots[key]; }
2618}
2619
2620/* */
2621
2622/**
2623 * Runtime helper for rendering v-for lists.
2624 */
2625function renderList (
2626 val,
2627 render
2628) {
2629 var ret, i, l, keys, key;
2630 if (Array.isArray(val) || typeof val === 'string') {
2631 ret = new Array(val.length);
2632 for (i = 0, l = val.length; i < l; i++) {
2633 ret[i] = render(val[i], i);
2634 }
2635 } else if (typeof val === 'number') {
2636 ret = new Array(val);
2637 for (i = 0; i < val; i++) {
2638 ret[i] = render(i + 1, i);
2639 }
2640 } else if (isObject(val)) {
2641 if (hasSymbol && val[Symbol.iterator]) {
2642 ret = [];
2643 var iterator = val[Symbol.iterator]();
2644 var result = iterator.next();
2645 while (!result.done) {
2646 ret.push(render(result.value, ret.length));
2647 result = iterator.next();
2648 }
2649 } else {
2650 keys = Object.keys(val);
2651 ret = new Array(keys.length);
2652 for (i = 0, l = keys.length; i < l; i++) {
2653 key = keys[i];
2654 ret[i] = render(val[key], key, i);
2655 }
2656 }
2657 }
2658 if (!isDef(ret)) {
2659 ret = [];
2660 }
2661 (ret)._isVList = true;
2662 return ret
2663}
2664
2665/* */
2666
2667/**
2668 * Runtime helper for rendering <slot>
2669 */
2670function renderSlot (
2671 name,
2672 fallback,
2673 props,
2674 bindObject
2675) {
2676 var scopedSlotFn = this.$scopedSlots[name];
2677 var nodes;
2678 if (scopedSlotFn) { // scoped slot
2679 props = props || {};
2680 if (bindObject) {
2681 if (!isObject(bindObject)) {
2682 warn(
2683 'slot v-bind without argument expects an Object',
2684 this
2685 );
2686 }
2687 props = extend(extend({}, bindObject), props);
2688 }
2689 nodes = scopedSlotFn(props) || fallback;
2690 } else {
2691 nodes = this.$slots[name] || fallback;
2692 }
2693
2694 var target = props && props.slot;
2695 if (target) {
2696 return this.$createElement('template', { slot: target }, nodes)
2697 } else {
2698 return nodes
2699 }
2700}
2701
2702/* */
2703
2704/**
2705 * Runtime helper for resolving filters
2706 */
2707function resolveFilter (id) {
2708 return resolveAsset(this.$options, 'filters', id, true) || identity
2709}
2710
2711/* */
2712
2713function isKeyNotMatch (expect, actual) {
2714 if (Array.isArray(expect)) {
2715 return expect.indexOf(actual) === -1
2716 } else {
2717 return expect !== actual
2718 }
2719}
2720
2721/**
2722 * Runtime helper for checking keyCodes from config.
2723 * exposed as Vue.prototype._k
2724 * passing in eventKeyName as last argument separately for backwards compat
2725 */
2726function checkKeyCodes (
2727 eventKeyCode,
2728 key,
2729 builtInKeyCode,
2730 eventKeyName,
2731 builtInKeyName
2732) {
2733 var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
2734 if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
2735 return isKeyNotMatch(builtInKeyName, eventKeyName)
2736 } else if (mappedKeyCode) {
2737 return isKeyNotMatch(mappedKeyCode, eventKeyCode)
2738 } else if (eventKeyName) {
2739 return hyphenate(eventKeyName) !== key
2740 }
2741}
2742
2743/* */
2744
2745/**
2746 * Runtime helper for merging v-bind="object" into a VNode's data.
2747 */
2748function bindObjectProps (
2749 data,
2750 tag,
2751 value,
2752 asProp,
2753 isSync
2754) {
2755 if (value) {
2756 if (!isObject(value)) {
2757 warn(
2758 'v-bind without argument expects an Object or Array value',
2759 this
2760 );
2761 } else {
2762 if (Array.isArray(value)) {
2763 value = toObject(value);
2764 }
2765 var hash;
2766 var loop = function ( key ) {
2767 if (
2768 key === 'class' ||
2769 key === 'style' ||
2770 isReservedAttribute(key)
2771 ) {
2772 hash = data;
2773 } else {
2774 var type = data.attrs && data.attrs.type;
2775 hash = asProp || config.mustUseProp(tag, type, key)
2776 ? data.domProps || (data.domProps = {})
2777 : data.attrs || (data.attrs = {});
2778 }
2779 var camelizedKey = camelize(key);
2780 var hyphenatedKey = hyphenate(key);
2781 if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
2782 hash[key] = value[key];
2783
2784 if (isSync) {
2785 var on = data.on || (data.on = {});
2786 on[("update:" + key)] = function ($event) {
2787 value[key] = $event;
2788 };
2789 }
2790 }
2791 };
2792
2793 for (var key in value) loop( key );
2794 }
2795 }
2796 return data
2797}
2798
2799/* */
2800
2801/**
2802 * Runtime helper for rendering static trees.
2803 */
2804function renderStatic (
2805 index,
2806 isInFor
2807) {
2808 var cached = this._staticTrees || (this._staticTrees = []);
2809 var tree = cached[index];
2810 // if has already-rendered static tree and not inside v-for,
2811 // we can reuse the same tree.
2812 if (tree && !isInFor) {
2813 return tree
2814 }
2815 // otherwise, render a fresh tree.
2816 tree = cached[index] = this.$options.staticRenderFns[index].call(
2817 this._renderProxy,
2818 null,
2819 this // for render fns generated for functional component templates
2820 );
2821 markStatic(tree, ("__static__" + index), false);
2822 return tree
2823}
2824
2825/**
2826 * Runtime helper for v-once.
2827 * Effectively it means marking the node as static with a unique key.
2828 */
2829function markOnce (
2830 tree,
2831 index,
2832 key
2833) {
2834 markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
2835 return tree
2836}
2837
2838function markStatic (
2839 tree,
2840 key,
2841 isOnce
2842) {
2843 if (Array.isArray(tree)) {
2844 for (var i = 0; i < tree.length; i++) {
2845 if (tree[i] && typeof tree[i] !== 'string') {
2846 markStaticNode(tree[i], (key + "_" + i), isOnce);
2847 }
2848 }
2849 } else {
2850 markStaticNode(tree, key, isOnce);
2851 }
2852}
2853
2854function markStaticNode (node, key, isOnce) {
2855 node.isStatic = true;
2856 node.key = key;
2857 node.isOnce = isOnce;
2858}
2859
2860/* */
2861
2862function bindObjectListeners (data, value) {
2863 if (value) {
2864 if (!isPlainObject(value)) {
2865 warn(
2866 'v-on without argument expects an Object value',
2867 this
2868 );
2869 } else {
2870 var on = data.on = data.on ? extend({}, data.on) : {};
2871 for (var key in value) {
2872 var existing = on[key];
2873 var ours = value[key];
2874 on[key] = existing ? [].concat(existing, ours) : ours;
2875 }
2876 }
2877 }
2878 return data
2879}
2880
2881/* */
2882
2883function resolveScopedSlots (
2884 fns, // see flow/vnode
2885 res,
2886 // the following are added in 2.6
2887 hasDynamicKeys,
2888 contentHashKey
2889) {
2890 res = res || { $stable: !hasDynamicKeys };
2891 for (var i = 0; i < fns.length; i++) {
2892 var slot = fns[i];
2893 if (Array.isArray(slot)) {
2894 resolveScopedSlots(slot, res, hasDynamicKeys);
2895 } else if (slot) {
2896 // marker for reverse proxying v-slot without scope on this.$slots
2897 if (slot.proxy) {
2898 slot.fn.proxy = true;
2899 }
2900 res[slot.key] = slot.fn;
2901 }
2902 }
2903 if (contentHashKey) {
2904 (res).$key = contentHashKey;
2905 }
2906 return res
2907}
2908
2909/* */
2910
2911function bindDynamicKeys (baseObj, values) {
2912 for (var i = 0; i < values.length; i += 2) {
2913 var key = values[i];
2914 if (typeof key === 'string' && key) {
2915 baseObj[values[i]] = values[i + 1];
2916 } else if (key !== '' && key !== null) {
2917 // null is a special value for explicitly removing a binding
2918 warn(
2919 ("Invalid value for dynamic directive argument (expected string or null): " + key),
2920 this
2921 );
2922 }
2923 }
2924 return baseObj
2925}
2926
2927// helper to dynamically append modifier runtime markers to event names.
2928// ensure only append when value is already string, otherwise it will be cast
2929// to string and cause the type check to miss.
2930function prependModifier (value, symbol) {
2931 return typeof value === 'string' ? symbol + value : value
2932}
2933
2934/* */
2935
2936function installRenderHelpers (target) {
2937 target._o = markOnce;
2938 target._n = toNumber;
2939 target._s = toString;
2940 target._l = renderList;
2941 target._t = renderSlot;
2942 target._q = looseEqual;
2943 target._i = looseIndexOf;
2944 target._m = renderStatic;
2945 target._f = resolveFilter;
2946 target._k = checkKeyCodes;
2947 target._b = bindObjectProps;
2948 target._v = createTextVNode;
2949 target._e = createEmptyVNode;
2950 target._u = resolveScopedSlots;
2951 target._g = bindObjectListeners;
2952 target._d = bindDynamicKeys;
2953 target._p = prependModifier;
2954}
2955
2956/* */
2957
2958function FunctionalRenderContext (
2959 data,
2960 props,
2961 children,
2962 parent,
2963 Ctor
2964) {
2965 var this$1 = this;
2966
2967 var options = Ctor.options;
2968 // ensure the createElement function in functional components
2969 // gets a unique context - this is necessary for correct named slot check
2970 var contextVm;
2971 if (hasOwn(parent, '_uid')) {
2972 contextVm = Object.create(parent);
2973 // $flow-disable-line
2974 contextVm._original = parent;
2975 } else {
2976 // the context vm passed in is a functional context as well.
2977 // in this case we want to make sure we are able to get a hold to the
2978 // real context instance.
2979 contextVm = parent;
2980 // $flow-disable-line
2981 parent = parent._original;
2982 }
2983 var isCompiled = isTrue(options._compiled);
2984 var needNormalization = !isCompiled;
2985
2986 this.data = data;
2987 this.props = props;
2988 this.children = children;
2989 this.parent = parent;
2990 this.listeners = data.on || emptyObject;
2991 this.injections = resolveInject(options.inject, parent);
2992 this.slots = function () {
2993 if (!this$1.$slots) {
2994 normalizeScopedSlots(
2995 data.scopedSlots,
2996 this$1.$slots = resolveSlots(children, parent)
2997 );
2998 }
2999 return this$1.$slots
3000 };
3001
3002 Object.defineProperty(this, 'scopedSlots', ({
3003 enumerable: true,
3004 get: function get () {
3005 return normalizeScopedSlots(data.scopedSlots, this.slots())
3006 }
3007 }));
3008
3009 // support for compiled functional template
3010 if (isCompiled) {
3011 // exposing $options for renderStatic()
3012 this.$options = options;
3013 // pre-resolve slots for renderSlot()
3014 this.$slots = this.slots();
3015 this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
3016 }
3017
3018 if (options._scopeId) {
3019 this._c = function (a, b, c, d) {
3020 var vnode = createElement(contextVm, a, b, c, d, needNormalization);
3021 if (vnode && !Array.isArray(vnode)) {
3022 vnode.fnScopeId = options._scopeId;
3023 vnode.fnContext = parent;
3024 }
3025 return vnode
3026 };
3027 } else {
3028 this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
3029 }
3030}
3031
3032installRenderHelpers(FunctionalRenderContext.prototype);
3033
3034function createFunctionalComponent (
3035 Ctor,
3036 propsData,
3037 data,
3038 contextVm,
3039 children
3040) {
3041 var options = Ctor.options;
3042 var props = {};
3043 var propOptions = options.props;
3044 if (isDef(propOptions)) {
3045 for (var key in propOptions) {
3046 props[key] = validateProp(key, propOptions, propsData || emptyObject);
3047 }
3048 } else {
3049 if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
3050 if (isDef(data.props)) { mergeProps(props, data.props); }
3051 }
3052
3053 var renderContext = new FunctionalRenderContext(
3054 data,
3055 props,
3056 children,
3057 contextVm,
3058 Ctor
3059 );
3060
3061 var vnode = options.render.call(null, renderContext._c, renderContext);
3062
3063 if (vnode instanceof VNode) {
3064 return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
3065 } else if (Array.isArray(vnode)) {
3066 var vnodes = normalizeChildren(vnode) || [];
3067 var res = new Array(vnodes.length);
3068 for (var i = 0; i < vnodes.length; i++) {
3069 res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
3070 }
3071 return res
3072 }
3073}
3074
3075function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
3076 // #7817 clone node before setting fnContext, otherwise if the node is reused
3077 // (e.g. it was from a cached normal slot) the fnContext causes named slots
3078 // that should not be matched to match.
3079 var clone = cloneVNode(vnode);
3080 clone.fnContext = contextVm;
3081 clone.fnOptions = options;
3082 {
3083 (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
3084 }
3085 if (data.slot) {
3086 (clone.data || (clone.data = {})).slot = data.slot;
3087 }
3088 return clone
3089}
3090
3091function mergeProps (to, from) {
3092 for (var key in from) {
3093 to[camelize(key)] = from[key];
3094 }
3095}
3096
3097/* */
3098
3099/* */
3100
3101/* */
3102
3103/* */
3104
3105// inline hooks to be invoked on component VNodes during patch
3106var componentVNodeHooks = {
3107 init: function init (vnode, hydrating) {
3108 if (
3109 vnode.componentInstance &&
3110 !vnode.componentInstance._isDestroyed &&
3111 vnode.data.keepAlive
3112 ) {
3113 // kept-alive components, treat as a patch
3114 var mountedNode = vnode; // work around flow
3115 componentVNodeHooks.prepatch(mountedNode, mountedNode);
3116 } else {
3117 var child = vnode.componentInstance = createComponentInstanceForVnode(
3118 vnode,
3119 activeInstance
3120 );
3121 child.$mount(hydrating ? vnode.elm : undefined, hydrating);
3122 }
3123 },
3124
3125 prepatch: function prepatch (oldVnode, vnode) {
3126 var options = vnode.componentOptions;
3127 var child = vnode.componentInstance = oldVnode.componentInstance;
3128 updateChildComponent(
3129 child,
3130 options.propsData, // updated props
3131 options.listeners, // updated listeners
3132 vnode, // new parent vnode
3133 options.children // new children
3134 );
3135 },
3136
3137 insert: function insert (vnode) {
3138 var context = vnode.context;
3139 var componentInstance = vnode.componentInstance;
3140 if (!componentInstance._isMounted) {
3141 componentInstance._isMounted = true;
3142 callHook(componentInstance, 'mounted');
3143 }
3144 if (vnode.data.keepAlive) {
3145 if (context._isMounted) {
3146 // vue-router#1212
3147 // During updates, a kept-alive component's child components may
3148 // change, so directly walking the tree here may call activated hooks
3149 // on incorrect children. Instead we push them into a queue which will
3150 // be processed after the whole patch process ended.
3151 queueActivatedComponent(componentInstance);
3152 } else {
3153 activateChildComponent(componentInstance, true /* direct */);
3154 }
3155 }
3156 },
3157
3158 destroy: function destroy (vnode) {
3159 var componentInstance = vnode.componentInstance;
3160 if (!componentInstance._isDestroyed) {
3161 if (!vnode.data.keepAlive) {
3162 componentInstance.$destroy();
3163 } else {
3164 deactivateChildComponent(componentInstance, true /* direct */);
3165 }
3166 }
3167 }
3168};
3169
3170var hooksToMerge = Object.keys(componentVNodeHooks);
3171
3172function createComponent (
3173 Ctor,
3174 data,
3175 context,
3176 children,
3177 tag
3178) {
3179 if (isUndef(Ctor)) {
3180 return
3181 }
3182
3183 var baseCtor = context.$options._base;
3184
3185 // plain options object: turn it into a constructor
3186 if (isObject(Ctor)) {
3187 Ctor = baseCtor.extend(Ctor);
3188 }
3189
3190 // if at this stage it's not a constructor or an async component factory,
3191 // reject.
3192 if (typeof Ctor !== 'function') {
3193 {
3194 warn(("Invalid Component definition: " + (String(Ctor))), context);
3195 }
3196 return
3197 }
3198
3199 // async component
3200 var asyncFactory;
3201 if (isUndef(Ctor.cid)) {
3202 asyncFactory = Ctor;
3203 Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
3204 if (Ctor === undefined) {
3205 // return a placeholder node for async component, which is rendered
3206 // as a comment node but preserves all the raw information for the node.
3207 // the information will be used for async server-rendering and hydration.
3208 return createAsyncPlaceholder(
3209 asyncFactory,
3210 data,
3211 context,
3212 children,
3213 tag
3214 )
3215 }
3216 }
3217
3218 data = data || {};
3219
3220 // resolve constructor options in case global mixins are applied after
3221 // component constructor creation
3222 resolveConstructorOptions(Ctor);
3223
3224 // transform component v-model data into props & events
3225 if (isDef(data.model)) {
3226 transformModel(Ctor.options, data);
3227 }
3228
3229 // extract props
3230 var propsData = extractPropsFromVNodeData(data, Ctor, tag);
3231
3232 // functional component
3233 if (isTrue(Ctor.options.functional)) {
3234 return createFunctionalComponent(Ctor, propsData, data, context, children)
3235 }
3236
3237 // extract listeners, since these needs to be treated as
3238 // child component listeners instead of DOM listeners
3239 var listeners = data.on;
3240 // replace with listeners with .native modifier
3241 // so it gets processed during parent component patch.
3242 data.on = data.nativeOn;
3243
3244 if (isTrue(Ctor.options.abstract)) {
3245 // abstract components do not keep anything
3246 // other than props & listeners & slot
3247
3248 // work around flow
3249 var slot = data.slot;
3250 data = {};
3251 if (slot) {
3252 data.slot = slot;
3253 }
3254 }
3255
3256 // install component management hooks onto the placeholder node
3257 installComponentHooks(data);
3258
3259 // return a placeholder vnode
3260 var name = Ctor.options.name || tag;
3261 var vnode = new VNode(
3262 ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
3263 data, undefined, undefined, undefined, context,
3264 { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
3265 asyncFactory
3266 );
3267
3268 return vnode
3269}
3270
3271function createComponentInstanceForVnode (
3272 vnode, // we know it's MountedComponentVNode but flow doesn't
3273 parent // activeInstance in lifecycle state
3274) {
3275 var options = {
3276 _isComponent: true,
3277 _parentVnode: vnode,
3278 parent: parent
3279 };
3280 // check inline-template render functions
3281 var inlineTemplate = vnode.data.inlineTemplate;
3282 if (isDef(inlineTemplate)) {
3283 options.render = inlineTemplate.render;
3284 options.staticRenderFns = inlineTemplate.staticRenderFns;
3285 }
3286 return new vnode.componentOptions.Ctor(options)
3287}
3288
3289function installComponentHooks (data) {
3290 var hooks = data.hook || (data.hook = {});
3291 for (var i = 0; i < hooksToMerge.length; i++) {
3292 var key = hooksToMerge[i];
3293 var existing = hooks[key];
3294 var toMerge = componentVNodeHooks[key];
3295 if (existing !== toMerge && !(existing && existing._merged)) {
3296 hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
3297 }
3298 }
3299}
3300
3301function mergeHook$1 (f1, f2) {
3302 var merged = function (a, b) {
3303 // flow complains about extra args which is why we use any
3304 f1(a, b);
3305 f2(a, b);
3306 };
3307 merged._merged = true;
3308 return merged
3309}
3310
3311// transform component v-model info (value and callback) into
3312// prop and event handler respectively.
3313function transformModel (options, data) {
3314 var prop = (options.model && options.model.prop) || 'value';
3315 var event = (options.model && options.model.event) || 'input'
3316 ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
3317 var on = data.on || (data.on = {});
3318 var existing = on[event];
3319 var callback = data.model.callback;
3320 if (isDef(existing)) {
3321 if (
3322 Array.isArray(existing)
3323 ? existing.indexOf(callback) === -1
3324 : existing !== callback
3325 ) {
3326 on[event] = [callback].concat(existing);
3327 }
3328 } else {
3329 on[event] = callback;
3330 }
3331}
3332
3333/* */
3334
3335var SIMPLE_NORMALIZE = 1;
3336var ALWAYS_NORMALIZE = 2;
3337
3338// wrapper function for providing a more flexible interface
3339// without getting yelled at by flow
3340function createElement (
3341 context,
3342 tag,
3343 data,
3344 children,
3345 normalizationType,
3346 alwaysNormalize
3347) {
3348 if (Array.isArray(data) || isPrimitive(data)) {
3349 normalizationType = children;
3350 children = data;
3351 data = undefined;
3352 }
3353 if (isTrue(alwaysNormalize)) {
3354 normalizationType = ALWAYS_NORMALIZE;
3355 }
3356 return _createElement(context, tag, data, children, normalizationType)
3357}
3358
3359function _createElement (
3360 context,
3361 tag,
3362 data,
3363 children,
3364 normalizationType
3365) {
3366 if (isDef(data) && isDef((data).__ob__)) {
3367 warn(
3368 "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
3369 'Always create fresh vnode data objects in each render!',
3370 context
3371 );
3372 return createEmptyVNode()
3373 }
3374 // object syntax in v-bind
3375 if (isDef(data) && isDef(data.is)) {
3376 tag = data.is;
3377 }
3378 if (!tag) {
3379 // in case of component :is set to falsy value
3380 return createEmptyVNode()
3381 }
3382 // warn against non-primitive key
3383 if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
3384 ) {
3385 {
3386 warn(
3387 'Avoid using non-primitive value as key, ' +
3388 'use string/number value instead.',
3389 context
3390 );
3391 }
3392 }
3393 // support single function children as default scoped slot
3394 if (Array.isArray(children) &&
3395 typeof children[0] === 'function'
3396 ) {
3397 data = data || {};
3398 data.scopedSlots = { default: children[0] };
3399 children.length = 0;
3400 }
3401 if (normalizationType === ALWAYS_NORMALIZE) {
3402 children = normalizeChildren(children);
3403 } else if (normalizationType === SIMPLE_NORMALIZE) {
3404 children = simpleNormalizeChildren(children);
3405 }
3406 var vnode, ns;
3407 if (typeof tag === 'string') {
3408 var Ctor;
3409 ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
3410 if (config.isReservedTag(tag)) {
3411 // platform built-in elements
3412 if (isDef(data) && isDef(data.nativeOn)) {
3413 warn(
3414 ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
3415 context
3416 );
3417 }
3418 vnode = new VNode(
3419 config.parsePlatformTagName(tag), data, children,
3420 undefined, undefined, context
3421 );
3422 } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
3423 // component
3424 vnode = createComponent(Ctor, data, context, children, tag);
3425 } else {
3426 // unknown or unlisted namespaced elements
3427 // check at runtime because it may get assigned a namespace when its
3428 // parent normalizes children
3429 vnode = new VNode(
3430 tag, data, children,
3431 undefined, undefined, context
3432 );
3433 }
3434 } else {
3435 // direct component options / constructor
3436 vnode = createComponent(tag, data, context, children);
3437 }
3438 if (Array.isArray(vnode)) {
3439 return vnode
3440 } else if (isDef(vnode)) {
3441 if (isDef(ns)) { applyNS(vnode, ns); }
3442 if (isDef(data)) { registerDeepBindings(data); }
3443 return vnode
3444 } else {
3445 return createEmptyVNode()
3446 }
3447}
3448
3449function applyNS (vnode, ns, force) {
3450 vnode.ns = ns;
3451 if (vnode.tag === 'foreignObject') {
3452 // use default namespace inside foreignObject
3453 ns = undefined;
3454 force = true;
3455 }
3456 if (isDef(vnode.children)) {
3457 for (var i = 0, l = vnode.children.length; i < l; i++) {
3458 var child = vnode.children[i];
3459 if (isDef(child.tag) && (
3460 isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
3461 applyNS(child, ns, force);
3462 }
3463 }
3464 }
3465}
3466
3467// ref #5318
3468// necessary to ensure parent re-render when deep bindings like :style and
3469// :class are used on slot nodes
3470function registerDeepBindings (data) {
3471 if (isObject(data.style)) {
3472 traverse(data.style);
3473 }
3474 if (isObject(data.class)) {
3475 traverse(data.class);
3476 }
3477}
3478
3479/* */
3480
3481function initRender (vm) {
3482 vm._vnode = null; // the root of the child tree
3483 vm._staticTrees = null; // v-once cached trees
3484 var options = vm.$options;
3485 var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
3486 var renderContext = parentVnode && parentVnode.context;
3487 vm.$slots = resolveSlots(options._renderChildren, renderContext);
3488 vm.$scopedSlots = emptyObject;
3489 // bind the createElement fn to this instance
3490 // so that we get proper render context inside it.
3491 // args order: tag, data, children, normalizationType, alwaysNormalize
3492 // internal version is used by render functions compiled from templates
3493 vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
3494 // normalization is always applied for the public version, used in
3495 // user-written render functions.
3496 vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
3497
3498 // $attrs & $listeners are exposed for easier HOC creation.
3499 // they need to be reactive so that HOCs using them are always updated
3500 var parentData = parentVnode && parentVnode.data;
3501
3502 /* istanbul ignore else */
3503 {
3504 defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
3505 !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
3506 }, true);
3507 defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
3508 !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
3509 }, true);
3510 }
3511}
3512
3513var currentRenderingInstance = null;
3514
3515function renderMixin (Vue) {
3516 // install runtime convenience helpers
3517 installRenderHelpers(Vue.prototype);
3518
3519 Vue.prototype.$nextTick = function (fn) {
3520 return nextTick(fn, this)
3521 };
3522
3523 Vue.prototype._render = function () {
3524 var vm = this;
3525 var ref = vm.$options;
3526 var render = ref.render;
3527 var _parentVnode = ref._parentVnode;
3528
3529 if (_parentVnode) {
3530 vm.$scopedSlots = normalizeScopedSlots(
3531 _parentVnode.data.scopedSlots,
3532 vm.$slots,
3533 vm.$scopedSlots
3534 );
3535 }
3536
3537 // set parent vnode. this allows render functions to have access
3538 // to the data on the placeholder node.
3539 vm.$vnode = _parentVnode;
3540 // render self
3541 var vnode;
3542 try {
3543 // There's no need to maintain a stack because all render fns are called
3544 // separately from one another. Nested component's render fns are called
3545 // when parent component is patched.
3546 currentRenderingInstance = vm;
3547 vnode = render.call(vm._renderProxy, vm.$createElement);
3548 } catch (e) {
3549 handleError(e, vm, "render");
3550 // return error render result,
3551 // or previous vnode to prevent render error causing blank component
3552 /* istanbul ignore else */
3553 if (vm.$options.renderError) {
3554 try {
3555 vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
3556 } catch (e) {
3557 handleError(e, vm, "renderError");
3558 vnode = vm._vnode;
3559 }
3560 } else {
3561 vnode = vm._vnode;
3562 }
3563 } finally {
3564 currentRenderingInstance = null;
3565 }
3566 // if the returned array contains only a single node, allow it
3567 if (Array.isArray(vnode) && vnode.length === 1) {
3568 vnode = vnode[0];
3569 }
3570 // return empty vnode in case the render function errored out
3571 if (!(vnode instanceof VNode)) {
3572 if (Array.isArray(vnode)) {
3573 warn(
3574 'Multiple root nodes returned from render function. Render function ' +
3575 'should return a single root node.',
3576 vm
3577 );
3578 }
3579 vnode = createEmptyVNode();
3580 }
3581 // set parent
3582 vnode.parent = _parentVnode;
3583 return vnode
3584 };
3585}
3586
3587/* */
3588
3589function ensureCtor (comp, base) {
3590 if (
3591 comp.__esModule ||
3592 (hasSymbol && comp[Symbol.toStringTag] === 'Module')
3593 ) {
3594 comp = comp.default;
3595 }
3596 return isObject(comp)
3597 ? base.extend(comp)
3598 : comp
3599}
3600
3601function createAsyncPlaceholder (
3602 factory,
3603 data,
3604 context,
3605 children,
3606 tag
3607) {
3608 var node = createEmptyVNode();
3609 node.asyncFactory = factory;
3610 node.asyncMeta = { data: data, context: context, children: children, tag: tag };
3611 return node
3612}
3613
3614function resolveAsyncComponent (
3615 factory,
3616 baseCtor
3617) {
3618 if (isTrue(factory.error) && isDef(factory.errorComp)) {
3619 return factory.errorComp
3620 }
3621
3622 if (isDef(factory.resolved)) {
3623 return factory.resolved
3624 }
3625
3626 var owner = currentRenderingInstance;
3627 if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
3628 // already pending
3629 factory.owners.push(owner);
3630 }
3631
3632 if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3633 return factory.loadingComp
3634 }
3635
3636 if (owner && !isDef(factory.owners)) {
3637 var owners = factory.owners = [owner];
3638 var sync = true;
3639 var timerLoading = null;
3640 var timerTimeout = null
3641
3642 ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
3643
3644 var forceRender = function (renderCompleted) {
3645 for (var i = 0, l = owners.length; i < l; i++) {
3646 (owners[i]).$forceUpdate();
3647 }
3648
3649 if (renderCompleted) {
3650 owners.length = 0;
3651 if (timerLoading !== null) {
3652 clearTimeout(timerLoading);
3653 timerLoading = null;
3654 }
3655 if (timerTimeout !== null) {
3656 clearTimeout(timerTimeout);
3657 timerTimeout = null;
3658 }
3659 }
3660 };
3661
3662 var resolve = once(function (res) {
3663 // cache resolved
3664 factory.resolved = ensureCtor(res, baseCtor);
3665 // invoke callbacks only if this is not a synchronous resolve
3666 // (async resolves are shimmed as synchronous during SSR)
3667 if (!sync) {
3668 forceRender(true);
3669 } else {
3670 owners.length = 0;
3671 }
3672 });
3673
3674 var reject = once(function (reason) {
3675 warn(
3676 "Failed to resolve async component: " + (String(factory)) +
3677 (reason ? ("\nReason: " + reason) : '')
3678 );
3679 if (isDef(factory.errorComp)) {
3680 factory.error = true;
3681 forceRender(true);
3682 }
3683 });
3684
3685 var res = factory(resolve, reject);
3686
3687 if (isObject(res)) {
3688 if (isPromise(res)) {
3689 // () => Promise
3690 if (isUndef(factory.resolved)) {
3691 res.then(resolve, reject);
3692 }
3693 } else if (isPromise(res.component)) {
3694 res.component.then(resolve, reject);
3695
3696 if (isDef(res.error)) {
3697 factory.errorComp = ensureCtor(res.error, baseCtor);
3698 }
3699
3700 if (isDef(res.loading)) {
3701 factory.loadingComp = ensureCtor(res.loading, baseCtor);
3702 if (res.delay === 0) {
3703 factory.loading = true;
3704 } else {
3705 timerLoading = setTimeout(function () {
3706 timerLoading = null;
3707 if (isUndef(factory.resolved) && isUndef(factory.error)) {
3708 factory.loading = true;
3709 forceRender(false);
3710 }
3711 }, res.delay || 200);
3712 }
3713 }
3714
3715 if (isDef(res.timeout)) {
3716 timerTimeout = setTimeout(function () {
3717 timerTimeout = null;
3718 if (isUndef(factory.resolved)) {
3719 reject(
3720 "timeout (" + (res.timeout) + "ms)"
3721 );
3722 }
3723 }, res.timeout);
3724 }
3725 }
3726 }
3727
3728 sync = false;
3729 // return in case resolved synchronously
3730 return factory.loading
3731 ? factory.loadingComp
3732 : factory.resolved
3733 }
3734}
3735
3736/* */
3737
3738function isAsyncPlaceholder (node) {
3739 return node.isComment && node.asyncFactory
3740}
3741
3742/* */
3743
3744function getFirstComponentChild (children) {
3745 if (Array.isArray(children)) {
3746 for (var i = 0; i < children.length; i++) {
3747 var c = children[i];
3748 if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
3749 return c
3750 }
3751 }
3752 }
3753}
3754
3755/* */
3756
3757/* */
3758
3759function initEvents (vm) {
3760 vm._events = Object.create(null);
3761 vm._hasHookEvent = false;
3762 // init parent attached events
3763 var listeners = vm.$options._parentListeners;
3764 if (listeners) {
3765 updateComponentListeners(vm, listeners);
3766 }
3767}
3768
3769var target;
3770
3771function add (event, fn) {
3772 target.$on(event, fn);
3773}
3774
3775function remove$1 (event, fn) {
3776 target.$off(event, fn);
3777}
3778
3779function createOnceHandler (event, fn) {
3780 var _target = target;
3781 return function onceHandler () {
3782 var res = fn.apply(null, arguments);
3783 if (res !== null) {
3784 _target.$off(event, onceHandler);
3785 }
3786 }
3787}
3788
3789function updateComponentListeners (
3790 vm,
3791 listeners,
3792 oldListeners
3793) {
3794 target = vm;
3795 updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
3796 target = undefined;
3797}
3798
3799function eventsMixin (Vue) {
3800 var hookRE = /^hook:/;
3801 Vue.prototype.$on = function (event, fn) {
3802 var vm = this;
3803 if (Array.isArray(event)) {
3804 for (var i = 0, l = event.length; i < l; i++) {
3805 vm.$on(event[i], fn);
3806 }
3807 } else {
3808 (vm._events[event] || (vm._events[event] = [])).push(fn);
3809 // optimize hook:event cost by using a boolean flag marked at registration
3810 // instead of a hash lookup
3811 if (hookRE.test(event)) {
3812 vm._hasHookEvent = true;
3813 }
3814 }
3815 return vm
3816 };
3817
3818 Vue.prototype.$once = function (event, fn) {
3819 var vm = this;
3820 function on () {
3821 vm.$off(event, on);
3822 fn.apply(vm, arguments);
3823 }
3824 on.fn = fn;
3825 vm.$on(event, on);
3826 return vm
3827 };
3828
3829 Vue.prototype.$off = function (event, fn) {
3830 var vm = this;
3831 // all
3832 if (!arguments.length) {
3833 vm._events = Object.create(null);
3834 return vm
3835 }
3836 // array of events
3837 if (Array.isArray(event)) {
3838 for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
3839 vm.$off(event[i$1], fn);
3840 }
3841 return vm
3842 }
3843 // specific event
3844 var cbs = vm._events[event];
3845 if (!cbs) {
3846 return vm
3847 }
3848 if (!fn) {
3849 vm._events[event] = null;
3850 return vm
3851 }
3852 // specific handler
3853 var cb;
3854 var i = cbs.length;
3855 while (i--) {
3856 cb = cbs[i];
3857 if (cb === fn || cb.fn === fn) {
3858 cbs.splice(i, 1);
3859 break
3860 }
3861 }
3862 return vm
3863 };
3864
3865 Vue.prototype.$emit = function (event) {
3866 var vm = this;
3867 {
3868 var lowerCaseEvent = event.toLowerCase();
3869 if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
3870 tip(
3871 "Event \"" + lowerCaseEvent + "\" is emitted in component " +
3872 (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
3873 "Note that HTML attributes are case-insensitive and you cannot use " +
3874 "v-on to listen to camelCase events when using in-DOM templates. " +
3875 "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
3876 );
3877 }
3878 }
3879 var cbs = vm._events[event];
3880 if (cbs) {
3881 cbs = cbs.length > 1 ? toArray(cbs) : cbs;
3882 var args = toArray(arguments, 1);
3883 var info = "event handler for \"" + event + "\"";
3884 for (var i = 0, l = cbs.length; i < l; i++) {
3885 invokeWithErrorHandling(cbs[i], vm, args, vm, info);
3886 }
3887 }
3888 return vm
3889 };
3890}
3891
3892/* */
3893
3894var activeInstance = null;
3895var isUpdatingChildComponent = false;
3896
3897function setActiveInstance(vm) {
3898 var prevActiveInstance = activeInstance;
3899 activeInstance = vm;
3900 return function () {
3901 activeInstance = prevActiveInstance;
3902 }
3903}
3904
3905function initLifecycle (vm) {
3906 var options = vm.$options;
3907
3908 // locate first non-abstract parent
3909 var parent = options.parent;
3910 if (parent && !options.abstract) {
3911 while (parent.$options.abstract && parent.$parent) {
3912 parent = parent.$parent;
3913 }
3914 parent.$children.push(vm);
3915 }
3916
3917 vm.$parent = parent;
3918 vm.$root = parent ? parent.$root : vm;
3919
3920 vm.$children = [];
3921 vm.$refs = {};
3922
3923 vm._watcher = null;
3924 vm._inactive = null;
3925 vm._directInactive = false;
3926 vm._isMounted = false;
3927 vm._isDestroyed = false;
3928 vm._isBeingDestroyed = false;
3929}
3930
3931function lifecycleMixin (Vue) {
3932 Vue.prototype._update = function (vnode, hydrating) {
3933 var vm = this;
3934 var prevEl = vm.$el;
3935 var prevVnode = vm._vnode;
3936 var restoreActiveInstance = setActiveInstance(vm);
3937 vm._vnode = vnode;
3938 // Vue.prototype.__patch__ is injected in entry points
3939 // based on the rendering backend used.
3940 if (!prevVnode) {
3941 // initial render
3942 vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
3943 } else {
3944 // updates
3945 vm.$el = vm.__patch__(prevVnode, vnode);
3946 }
3947 restoreActiveInstance();
3948 // update __vue__ reference
3949 if (prevEl) {
3950 prevEl.__vue__ = null;
3951 }
3952 if (vm.$el) {
3953 vm.$el.__vue__ = vm;
3954 }
3955 // if parent is an HOC, update its $el as well
3956 if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
3957 vm.$parent.$el = vm.$el;
3958 }
3959 // updated hook is called by the scheduler to ensure that children are
3960 // updated in a parent's updated hook.
3961 };
3962
3963 Vue.prototype.$forceUpdate = function () {
3964 var vm = this;
3965 if (vm._watcher) {
3966 vm._watcher.update();
3967 }
3968 };
3969
3970 Vue.prototype.$destroy = function () {
3971 var vm = this;
3972 if (vm._isBeingDestroyed) {
3973 return
3974 }
3975 callHook(vm, 'beforeDestroy');
3976 vm._isBeingDestroyed = true;
3977 // remove self from parent
3978 var parent = vm.$parent;
3979 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
3980 remove(parent.$children, vm);
3981 }
3982 // teardown watchers
3983 if (vm._watcher) {
3984 vm._watcher.teardown();
3985 }
3986 var i = vm._watchers.length;
3987 while (i--) {
3988 vm._watchers[i].teardown();
3989 }
3990 // remove reference from data ob
3991 // frozen object may not have observer.
3992 if (vm._data.__ob__) {
3993 vm._data.__ob__.vmCount--;
3994 }
3995 // call the last hook...
3996 vm._isDestroyed = true;
3997 // invoke destroy hooks on current rendered tree
3998 vm.__patch__(vm._vnode, null);
3999 // fire destroyed hook
4000 callHook(vm, 'destroyed');
4001 // turn off all instance listeners.
4002 vm.$off();
4003 // remove __vue__ reference
4004 if (vm.$el) {
4005 vm.$el.__vue__ = null;
4006 }
4007 // release circular reference (#6759)
4008 if (vm.$vnode) {
4009 vm.$vnode.parent = null;
4010 }
4011 };
4012}
4013
4014function mountComponent (
4015 vm,
4016 el,
4017 hydrating
4018) {
4019 vm.$el = el;
4020 if (!vm.$options.render) {
4021 vm.$options.render = createEmptyVNode;
4022 {
4023 /* istanbul ignore if */
4024 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
4025 vm.$options.el || el) {
4026 warn(
4027 'You are using the runtime-only build of Vue where the template ' +
4028 'compiler is not available. Either pre-compile the templates into ' +
4029 'render functions, or use the compiler-included build.',
4030 vm
4031 );
4032 } else {
4033 warn(
4034 'Failed to mount component: template or render function not defined.',
4035 vm
4036 );
4037 }
4038 }
4039 }
4040 callHook(vm, 'beforeMount');
4041
4042 var updateComponent;
4043 /* istanbul ignore if */
4044 if (config.performance && mark) {
4045 updateComponent = function () {
4046 var name = vm._name;
4047 var id = vm._uid;
4048 var startTag = "vue-perf-start:" + id;
4049 var endTag = "vue-perf-end:" + id;
4050
4051 mark(startTag);
4052 var vnode = vm._render();
4053 mark(endTag);
4054 measure(("vue " + name + " render"), startTag, endTag);
4055
4056 mark(startTag);
4057 vm._update(vnode, hydrating);
4058 mark(endTag);
4059 measure(("vue " + name + " patch"), startTag, endTag);
4060 };
4061 } else {
4062 updateComponent = function () {
4063 vm._update(vm._render(), hydrating);
4064 };
4065 }
4066
4067 // we set this to vm._watcher inside the watcher's constructor
4068 // since the watcher's initial patch may call $forceUpdate (e.g. inside child
4069 // component's mounted hook), which relies on vm._watcher being already defined
4070 new Watcher(vm, updateComponent, noop, {
4071 before: function before () {
4072 if (vm._isMounted && !vm._isDestroyed) {
4073 callHook(vm, 'beforeUpdate');
4074 }
4075 }
4076 }, true /* isRenderWatcher */);
4077 hydrating = false;
4078
4079 // manually mounted instance, call mounted on self
4080 // mounted is called for render-created child components in its inserted hook
4081 if (vm.$vnode == null) {
4082 vm._isMounted = true;
4083 callHook(vm, 'mounted');
4084 }
4085 return vm
4086}
4087
4088function updateChildComponent (
4089 vm,
4090 propsData,
4091 listeners,
4092 parentVnode,
4093 renderChildren
4094) {
4095 {
4096 isUpdatingChildComponent = true;
4097 }
4098
4099 // determine whether component has slot children
4100 // we need to do this before overwriting $options._renderChildren.
4101
4102 // check if there are dynamic scopedSlots (hand-written or compiled but with
4103 // dynamic slot names). Static scoped slots compiled from template has the
4104 // "$stable" marker.
4105 var newScopedSlots = parentVnode.data.scopedSlots;
4106 var oldScopedSlots = vm.$scopedSlots;
4107 var hasDynamicScopedSlot = !!(
4108 (newScopedSlots && !newScopedSlots.$stable) ||
4109 (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
4110 (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
4111 );
4112
4113 // Any static slot children from the parent may have changed during parent's
4114 // update. Dynamic scoped slots may also have changed. In such cases, a forced
4115 // update is necessary to ensure correctness.
4116 var needsForceUpdate = !!(
4117 renderChildren || // has new static slots
4118 vm.$options._renderChildren || // has old static slots
4119 hasDynamicScopedSlot
4120 );
4121
4122 vm.$options._parentVnode = parentVnode;
4123 vm.$vnode = parentVnode; // update vm's placeholder node without re-render
4124
4125 if (vm._vnode) { // update child tree's parent
4126 vm._vnode.parent = parentVnode;
4127 }
4128 vm.$options._renderChildren = renderChildren;
4129
4130 // update $attrs and $listeners hash
4131 // these are also reactive so they may trigger child update if the child
4132 // used them during render
4133 vm.$attrs = parentVnode.data.attrs || emptyObject;
4134 vm.$listeners = listeners || emptyObject;
4135
4136 // update props
4137 if (propsData && vm.$options.props) {
4138 toggleObserving(false);
4139 var props = vm._props;
4140 var propKeys = vm.$options._propKeys || [];
4141 for (var i = 0; i < propKeys.length; i++) {
4142 var key = propKeys[i];
4143 var propOptions = vm.$options.props; // wtf flow?
4144 props[key] = validateProp(key, propOptions, propsData, vm);
4145 }
4146 toggleObserving(true);
4147 // keep a copy of raw propsData
4148 vm.$options.propsData = propsData;
4149 }
4150
4151 // update listeners
4152 listeners = listeners || emptyObject;
4153 var oldListeners = vm.$options._parentListeners;
4154 vm.$options._parentListeners = listeners;
4155 updateComponentListeners(vm, listeners, oldListeners);
4156
4157 // resolve slots + force update if has children
4158 if (needsForceUpdate) {
4159 vm.$slots = resolveSlots(renderChildren, parentVnode.context);
4160 vm.$forceUpdate();
4161 }
4162
4163 {
4164 isUpdatingChildComponent = false;
4165 }
4166}
4167
4168function isInInactiveTree (vm) {
4169 while (vm && (vm = vm.$parent)) {
4170 if (vm._inactive) { return true }
4171 }
4172 return false
4173}
4174
4175function activateChildComponent (vm, direct) {
4176 if (direct) {
4177 vm._directInactive = false;
4178 if (isInInactiveTree(vm)) {
4179 return
4180 }
4181 } else if (vm._directInactive) {
4182 return
4183 }
4184 if (vm._inactive || vm._inactive === null) {
4185 vm._inactive = false;
4186 for (var i = 0; i < vm.$children.length; i++) {
4187 activateChildComponent(vm.$children[i]);
4188 }
4189 callHook(vm, 'activated');
4190 }
4191}
4192
4193function deactivateChildComponent (vm, direct) {
4194 if (direct) {
4195 vm._directInactive = true;
4196 if (isInInactiveTree(vm)) {
4197 return
4198 }
4199 }
4200 if (!vm._inactive) {
4201 vm._inactive = true;
4202 for (var i = 0; i < vm.$children.length; i++) {
4203 deactivateChildComponent(vm.$children[i]);
4204 }
4205 callHook(vm, 'deactivated');
4206 }
4207}
4208
4209function callHook (vm, hook) {
4210 // #7573 disable dep collection when invoking lifecycle hooks
4211 pushTarget();
4212 var handlers = vm.$options[hook];
4213 var info = hook + " hook";
4214 if (handlers) {
4215 for (var i = 0, j = handlers.length; i < j; i++) {
4216 invokeWithErrorHandling(handlers[i], vm, null, vm, info);
4217 }
4218 }
4219 if (vm._hasHookEvent) {
4220 vm.$emit('hook:' + hook);
4221 }
4222 popTarget();
4223}
4224
4225/* */
4226
4227var MAX_UPDATE_COUNT = 100;
4228
4229var queue = [];
4230var activatedChildren = [];
4231var has = {};
4232var circular = {};
4233var waiting = false;
4234var flushing = false;
4235var index = 0;
4236
4237/**
4238 * Reset the scheduler's state.
4239 */
4240function resetSchedulerState () {
4241 index = queue.length = activatedChildren.length = 0;
4242 has = {};
4243 {
4244 circular = {};
4245 }
4246 waiting = flushing = false;
4247}
4248
4249// Async edge case #6566 requires saving the timestamp when event listeners are
4250// attached. However, calling performance.now() has a perf overhead especially
4251// if the page has thousands of event listeners. Instead, we take a timestamp
4252// every time the scheduler flushes and use that for all event listeners
4253// attached during that flush.
4254var currentFlushTimestamp = 0;
4255
4256// Async edge case fix requires storing an event listener's attach timestamp.
4257var getNow = Date.now;
4258
4259// Determine what event timestamp the browser is using. Annoyingly, the
4260// timestamp can either be hi-res (relative to page load) or low-res
4261// (relative to UNIX epoch), so in order to compare time we have to use the
4262// same timestamp type when saving the flush timestamp.
4263// All IE versions use low-res event timestamps, and have problematic clock
4264// implementations (#9632)
4265if (inBrowser && !isIE) {
4266 var performance = window.performance;
4267 if (
4268 performance &&
4269 typeof performance.now === 'function' &&
4270 getNow() > document.createEvent('Event').timeStamp
4271 ) {
4272 // if the event timestamp, although evaluated AFTER the Date.now(), is
4273 // smaller than it, it means the event is using a hi-res timestamp,
4274 // and we need to use the hi-res version for event listener timestamps as
4275 // well.
4276 getNow = function () { return performance.now(); };
4277 }
4278}
4279
4280/**
4281 * Flush both queues and run the watchers.
4282 */
4283function flushSchedulerQueue () {
4284 currentFlushTimestamp = getNow();
4285 flushing = true;
4286 var watcher, id;
4287
4288 // Sort queue before flush.
4289 // This ensures that:
4290 // 1. Components are updated from parent to child. (because parent is always
4291 // created before the child)
4292 // 2. A component's user watchers are run before its render watcher (because
4293 // user watchers are created before the render watcher)
4294 // 3. If a component is destroyed during a parent component's watcher run,
4295 // its watchers can be skipped.
4296 queue.sort(function (a, b) { return a.id - b.id; });
4297
4298 // do not cache length because more watchers might be pushed
4299 // as we run existing watchers
4300 for (index = 0; index < queue.length; index++) {
4301 watcher = queue[index];
4302 if (watcher.before) {
4303 watcher.before();
4304 }
4305 id = watcher.id;
4306 has[id] = null;
4307 watcher.run();
4308 // in dev build, check and stop circular updates.
4309 if (has[id] != null) {
4310 circular[id] = (circular[id] || 0) + 1;
4311 if (circular[id] > MAX_UPDATE_COUNT) {
4312 warn(
4313 'You may have an infinite update loop ' + (
4314 watcher.user
4315 ? ("in watcher with expression \"" + (watcher.expression) + "\"")
4316 : "in a component render function."
4317 ),
4318 watcher.vm
4319 );
4320 break
4321 }
4322 }
4323 }
4324
4325 // keep copies of post queues before resetting state
4326 var activatedQueue = activatedChildren.slice();
4327 var updatedQueue = queue.slice();
4328
4329 resetSchedulerState();
4330
4331 // call component updated and activated hooks
4332 callActivatedHooks(activatedQueue);
4333 callUpdatedHooks(updatedQueue);
4334
4335 // devtool hook
4336 /* istanbul ignore if */
4337 if (devtools && config.devtools) {
4338 devtools.emit('flush');
4339 }
4340}
4341
4342function callUpdatedHooks (queue) {
4343 var i = queue.length;
4344 while (i--) {
4345 var watcher = queue[i];
4346 var vm = watcher.vm;
4347 if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
4348 callHook(vm, 'updated');
4349 }
4350 }
4351}
4352
4353/**
4354 * Queue a kept-alive component that was activated during patch.
4355 * The queue will be processed after the entire tree has been patched.
4356 */
4357function queueActivatedComponent (vm) {
4358 // setting _inactive to false here so that a render function can
4359 // rely on checking whether it's in an inactive tree (e.g. router-view)
4360 vm._inactive = false;
4361 activatedChildren.push(vm);
4362}
4363
4364function callActivatedHooks (queue) {
4365 for (var i = 0; i < queue.length; i++) {
4366 queue[i]._inactive = true;
4367 activateChildComponent(queue[i], true /* true */);
4368 }
4369}
4370
4371/**
4372 * Push a watcher into the watcher queue.
4373 * Jobs with duplicate IDs will be skipped unless it's
4374 * pushed when the queue is being flushed.
4375 */
4376function queueWatcher (watcher) {
4377 var id = watcher.id;
4378 if (has[id] == null) {
4379 has[id] = true;
4380 if (!flushing) {
4381 queue.push(watcher);
4382 } else {
4383 // if already flushing, splice the watcher based on its id
4384 // if already past its id, it will be run next immediately.
4385 var i = queue.length - 1;
4386 while (i > index && queue[i].id > watcher.id) {
4387 i--;
4388 }
4389 queue.splice(i + 1, 0, watcher);
4390 }
4391 // queue the flush
4392 if (!waiting) {
4393 waiting = true;
4394
4395 if (!config.async) {
4396 flushSchedulerQueue();
4397 return
4398 }
4399 nextTick(flushSchedulerQueue);
4400 }
4401 }
4402}
4403
4404/* */
4405
4406
4407
4408var uid$2 = 0;
4409
4410/**
4411 * A watcher parses an expression, collects dependencies,
4412 * and fires callback when the expression value changes.
4413 * This is used for both the $watch() api and directives.
4414 */
4415var Watcher = function Watcher (
4416 vm,
4417 expOrFn,
4418 cb,
4419 options,
4420 isRenderWatcher
4421) {
4422 this.vm = vm;
4423 if (isRenderWatcher) {
4424 vm._watcher = this;
4425 }
4426 vm._watchers.push(this);
4427 // options
4428 if (options) {
4429 this.deep = !!options.deep;
4430 this.user = !!options.user;
4431 this.lazy = !!options.lazy;
4432 this.sync = !!options.sync;
4433 this.before = options.before;
4434 } else {
4435 this.deep = this.user = this.lazy = this.sync = false;
4436 }
4437 this.cb = cb;
4438 this.id = ++uid$2; // uid for batching
4439 this.active = true;
4440 this.dirty = this.lazy; // for lazy watchers
4441 this.deps = [];
4442 this.newDeps = [];
4443 this.depIds = new _Set();
4444 this.newDepIds = new _Set();
4445 this.expression = expOrFn.toString();
4446 // parse expression for getter
4447 if (typeof expOrFn === 'function') {
4448 this.getter = expOrFn;
4449 } else {
4450 this.getter = parsePath(expOrFn);
4451 if (!this.getter) {
4452 this.getter = noop;
4453 warn(
4454 "Failed watching path: \"" + expOrFn + "\" " +
4455 'Watcher only accepts simple dot-delimited paths. ' +
4456 'For full control, use a function instead.',
4457 vm
4458 );
4459 }
4460 }
4461 this.value = this.lazy
4462 ? undefined
4463 : this.get();
4464};
4465
4466/**
4467 * Evaluate the getter, and re-collect dependencies.
4468 */
4469Watcher.prototype.get = function get () {
4470 pushTarget(this);
4471 var value;
4472 var vm = this.vm;
4473 try {
4474 value = this.getter.call(vm, vm);
4475 } catch (e) {
4476 if (this.user) {
4477 handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
4478 } else {
4479 throw e
4480 }
4481 } finally {
4482 // "touch" every property so they are all tracked as
4483 // dependencies for deep watching
4484 if (this.deep) {
4485 traverse(value);
4486 }
4487 popTarget();
4488 this.cleanupDeps();
4489 }
4490 return value
4491};
4492
4493/**
4494 * Add a dependency to this directive.
4495 */
4496Watcher.prototype.addDep = function addDep (dep) {
4497 var id = dep.id;
4498 if (!this.newDepIds.has(id)) {
4499 this.newDepIds.add(id);
4500 this.newDeps.push(dep);
4501 if (!this.depIds.has(id)) {
4502 dep.addSub(this);
4503 }
4504 }
4505};
4506
4507/**
4508 * Clean up for dependency collection.
4509 */
4510Watcher.prototype.cleanupDeps = function cleanupDeps () {
4511 var i = this.deps.length;
4512 while (i--) {
4513 var dep = this.deps[i];
4514 if (!this.newDepIds.has(dep.id)) {
4515 dep.removeSub(this);
4516 }
4517 }
4518 var tmp = this.depIds;
4519 this.depIds = this.newDepIds;
4520 this.newDepIds = tmp;
4521 this.newDepIds.clear();
4522 tmp = this.deps;
4523 this.deps = this.newDeps;
4524 this.newDeps = tmp;
4525 this.newDeps.length = 0;
4526};
4527
4528/**
4529 * Subscriber interface.
4530 * Will be called when a dependency changes.
4531 */
4532Watcher.prototype.update = function update () {
4533 /* istanbul ignore else */
4534 if (this.lazy) {
4535 this.dirty = true;
4536 } else if (this.sync) {
4537 this.run();
4538 } else {
4539 queueWatcher(this);
4540 }
4541};
4542
4543/**
4544 * Scheduler job interface.
4545 * Will be called by the scheduler.
4546 */
4547Watcher.prototype.run = function run () {
4548 if (this.active) {
4549 var value = this.get();
4550 if (
4551 value !== this.value ||
4552 // Deep watchers and watchers on Object/Arrays should fire even
4553 // when the value is the same, because the value may
4554 // have mutated.
4555 isObject(value) ||
4556 this.deep
4557 ) {
4558 // set new value
4559 var oldValue = this.value;
4560 this.value = value;
4561 if (this.user) {
4562 try {
4563 this.cb.call(this.vm, value, oldValue);
4564 } catch (e) {
4565 handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
4566 }
4567 } else {
4568 this.cb.call(this.vm, value, oldValue);
4569 }
4570 }
4571 }
4572};
4573
4574/**
4575 * Evaluate the value of the watcher.
4576 * This only gets called for lazy watchers.
4577 */
4578Watcher.prototype.evaluate = function evaluate () {
4579 this.value = this.get();
4580 this.dirty = false;
4581};
4582
4583/**
4584 * Depend on all deps collected by this watcher.
4585 */
4586Watcher.prototype.depend = function depend () {
4587 var i = this.deps.length;
4588 while (i--) {
4589 this.deps[i].depend();
4590 }
4591};
4592
4593/**
4594 * Remove self from all dependencies' subscriber list.
4595 */
4596Watcher.prototype.teardown = function teardown () {
4597 if (this.active) {
4598 // remove self from vm's watcher list
4599 // this is a somewhat expensive operation so we skip it
4600 // if the vm is being destroyed.
4601 if (!this.vm._isBeingDestroyed) {
4602 remove(this.vm._watchers, this);
4603 }
4604 var i = this.deps.length;
4605 while (i--) {
4606 this.deps[i].removeSub(this);
4607 }
4608 this.active = false;
4609 }
4610};
4611
4612/* */
4613
4614var sharedPropertyDefinition = {
4615 enumerable: true,
4616 configurable: true,
4617 get: noop,
4618 set: noop
4619};
4620
4621function proxy (target, sourceKey, key) {
4622 sharedPropertyDefinition.get = function proxyGetter () {
4623 return this[sourceKey][key]
4624 };
4625 sharedPropertyDefinition.set = function proxySetter (val) {
4626 this[sourceKey][key] = val;
4627 };
4628 Object.defineProperty(target, key, sharedPropertyDefinition);
4629}
4630
4631function initState (vm) {
4632 vm._watchers = [];
4633 var opts = vm.$options;
4634 if (opts.props) { initProps(vm, opts.props); }
4635 if (opts.methods) { initMethods(vm, opts.methods); }
4636 if (opts.data) {
4637 initData(vm);
4638 } else {
4639 observe(vm._data = {}, true /* asRootData */);
4640 }
4641 if (opts.computed) { initComputed(vm, opts.computed); }
4642 if (opts.watch && opts.watch !== nativeWatch) {
4643 initWatch(vm, opts.watch);
4644 }
4645}
4646
4647function initProps (vm, propsOptions) {
4648 var propsData = vm.$options.propsData || {};
4649 var props = vm._props = {};
4650 // cache prop keys so that future props updates can iterate using Array
4651 // instead of dynamic object key enumeration.
4652 var keys = vm.$options._propKeys = [];
4653 var isRoot = !vm.$parent;
4654 // root instance props should be converted
4655 if (!isRoot) {
4656 toggleObserving(false);
4657 }
4658 var loop = function ( key ) {
4659 keys.push(key);
4660 var value = validateProp(key, propsOptions, propsData, vm);
4661 /* istanbul ignore else */
4662 {
4663 var hyphenatedKey = hyphenate(key);
4664 if (isReservedAttribute(hyphenatedKey) ||
4665 config.isReservedAttr(hyphenatedKey)) {
4666 warn(
4667 ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
4668 vm
4669 );
4670 }
4671 defineReactive$$1(props, key, value, function () {
4672 if (!isRoot && !isUpdatingChildComponent) {
4673 warn(
4674 "Avoid mutating a prop directly since the value will be " +
4675 "overwritten whenever the parent component re-renders. " +
4676 "Instead, use a data or computed property based on the prop's " +
4677 "value. Prop being mutated: \"" + key + "\"",
4678 vm
4679 );
4680 }
4681 });
4682 }
4683 // static props are already proxied on the component's prototype
4684 // during Vue.extend(). We only need to proxy props defined at
4685 // instantiation here.
4686 if (!(key in vm)) {
4687 proxy(vm, "_props", key);
4688 }
4689 };
4690
4691 for (var key in propsOptions) loop( key );
4692 toggleObserving(true);
4693}
4694
4695function initData (vm) {
4696 var data = vm.$options.data;
4697 data = vm._data = typeof data === 'function'
4698 ? getData(data, vm)
4699 : data || {};
4700 if (!isPlainObject(data)) {
4701 data = {};
4702 warn(
4703 'data functions should return an object:\n' +
4704 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
4705 vm
4706 );
4707 }
4708 // proxy data on instance
4709 var keys = Object.keys(data);
4710 var props = vm.$options.props;
4711 var methods = vm.$options.methods;
4712 var i = keys.length;
4713 while (i--) {
4714 var key = keys[i];
4715 {
4716 if (methods && hasOwn(methods, key)) {
4717 warn(
4718 ("Method \"" + key + "\" has already been defined as a data property."),
4719 vm
4720 );
4721 }
4722 }
4723 if (props && hasOwn(props, key)) {
4724 warn(
4725 "The data property \"" + key + "\" is already declared as a prop. " +
4726 "Use prop default value instead.",
4727 vm
4728 );
4729 } else if (!isReserved(key)) {
4730 proxy(vm, "_data", key);
4731 }
4732 }
4733 // observe data
4734 observe(data, true /* asRootData */);
4735}
4736
4737function getData (data, vm) {
4738 // #7573 disable dep collection when invoking data getters
4739 pushTarget();
4740 try {
4741 return data.call(vm, vm)
4742 } catch (e) {
4743 handleError(e, vm, "data()");
4744 return {}
4745 } finally {
4746 popTarget();
4747 }
4748}
4749
4750var computedWatcherOptions = { lazy: true };
4751
4752function initComputed (vm, computed) {
4753 // $flow-disable-line
4754 var watchers = vm._computedWatchers = Object.create(null);
4755 // computed properties are just getters during SSR
4756 var isSSR = isServerRendering();
4757
4758 for (var key in computed) {
4759 var userDef = computed[key];
4760 var getter = typeof userDef === 'function' ? userDef : userDef.get;
4761 if (getter == null) {
4762 warn(
4763 ("Getter is missing for computed property \"" + key + "\"."),
4764 vm
4765 );
4766 }
4767
4768 if (!isSSR) {
4769 // create internal watcher for the computed property.
4770 watchers[key] = new Watcher(
4771 vm,
4772 getter || noop,
4773 noop,
4774 computedWatcherOptions
4775 );
4776 }
4777
4778 // component-defined computed properties are already defined on the
4779 // component prototype. We only need to define computed properties defined
4780 // at instantiation here.
4781 if (!(key in vm)) {
4782 defineComputed(vm, key, userDef);
4783 } else {
4784 if (key in vm.$data) {
4785 warn(("The computed property \"" + key + "\" is already defined in data."), vm);
4786 } else if (vm.$options.props && key in vm.$options.props) {
4787 warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
4788 }
4789 }
4790 }
4791}
4792
4793function defineComputed (
4794 target,
4795 key,
4796 userDef
4797) {
4798 var shouldCache = !isServerRendering();
4799 if (typeof userDef === 'function') {
4800 sharedPropertyDefinition.get = shouldCache
4801 ? createComputedGetter(key)
4802 : createGetterInvoker(userDef);
4803 sharedPropertyDefinition.set = noop;
4804 } else {
4805 sharedPropertyDefinition.get = userDef.get
4806 ? shouldCache && userDef.cache !== false
4807 ? createComputedGetter(key)
4808 : createGetterInvoker(userDef.get)
4809 : noop;
4810 sharedPropertyDefinition.set = userDef.set || noop;
4811 }
4812 if (sharedPropertyDefinition.set === noop) {
4813 sharedPropertyDefinition.set = function () {
4814 warn(
4815 ("Computed property \"" + key + "\" was assigned to but it has no setter."),
4816 this
4817 );
4818 };
4819 }
4820 Object.defineProperty(target, key, sharedPropertyDefinition);
4821}
4822
4823function createComputedGetter (key) {
4824 return function computedGetter () {
4825 var watcher = this._computedWatchers && this._computedWatchers[key];
4826 if (watcher) {
4827 if (watcher.dirty) {
4828 watcher.evaluate();
4829 }
4830 if (Dep.target) {
4831 watcher.depend();
4832 }
4833 return watcher.value
4834 }
4835 }
4836}
4837
4838function createGetterInvoker(fn) {
4839 return function computedGetter () {
4840 return fn.call(this, this)
4841 }
4842}
4843
4844function initMethods (vm, methods) {
4845 var props = vm.$options.props;
4846 for (var key in methods) {
4847 {
4848 if (typeof methods[key] !== 'function') {
4849 warn(
4850 "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
4851 "Did you reference the function correctly?",
4852 vm
4853 );
4854 }
4855 if (props && hasOwn(props, key)) {
4856 warn(
4857 ("Method \"" + key + "\" has already been defined as a prop."),
4858 vm
4859 );
4860 }
4861 if ((key in vm) && isReserved(key)) {
4862 warn(
4863 "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
4864 "Avoid defining component methods that start with _ or $."
4865 );
4866 }
4867 }
4868 vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
4869 }
4870}
4871
4872function initWatch (vm, watch) {
4873 for (var key in watch) {
4874 var handler = watch[key];
4875 if (Array.isArray(handler)) {
4876 for (var i = 0; i < handler.length; i++) {
4877 createWatcher(vm, key, handler[i]);
4878 }
4879 } else {
4880 createWatcher(vm, key, handler);
4881 }
4882 }
4883}
4884
4885function createWatcher (
4886 vm,
4887 expOrFn,
4888 handler,
4889 options
4890) {
4891 if (isPlainObject(handler)) {
4892 options = handler;
4893 handler = handler.handler;
4894 }
4895 if (typeof handler === 'string') {
4896 handler = vm[handler];
4897 }
4898 return vm.$watch(expOrFn, handler, options)
4899}
4900
4901function stateMixin (Vue) {
4902 // flow somehow has problems with directly declared definition object
4903 // when using Object.defineProperty, so we have to procedurally build up
4904 // the object here.
4905 var dataDef = {};
4906 dataDef.get = function () { return this._data };
4907 var propsDef = {};
4908 propsDef.get = function () { return this._props };
4909 {
4910 dataDef.set = function () {
4911 warn(
4912 'Avoid replacing instance root $data. ' +
4913 'Use nested data properties instead.',
4914 this
4915 );
4916 };
4917 propsDef.set = function () {
4918 warn("$props is readonly.", this);
4919 };
4920 }
4921 Object.defineProperty(Vue.prototype, '$data', dataDef);
4922 Object.defineProperty(Vue.prototype, '$props', propsDef);
4923
4924 Vue.prototype.$set = set;
4925 Vue.prototype.$delete = del;
4926
4927 Vue.prototype.$watch = function (
4928 expOrFn,
4929 cb,
4930 options
4931 ) {
4932 var vm = this;
4933 if (isPlainObject(cb)) {
4934 return createWatcher(vm, expOrFn, cb, options)
4935 }
4936 options = options || {};
4937 options.user = true;
4938 var watcher = new Watcher(vm, expOrFn, cb, options);
4939 if (options.immediate) {
4940 try {
4941 cb.call(vm, watcher.value);
4942 } catch (error) {
4943 handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
4944 }
4945 }
4946 return function unwatchFn () {
4947 watcher.teardown();
4948 }
4949 };
4950}
4951
4952/* */
4953
4954var uid$3 = 0;
4955
4956function initMixin (Vue) {
4957 Vue.prototype._init = function (options) {
4958 var vm = this;
4959 // a uid
4960 vm._uid = uid$3++;
4961
4962 var startTag, endTag;
4963 /* istanbul ignore if */
4964 if (config.performance && mark) {
4965 startTag = "vue-perf-start:" + (vm._uid);
4966 endTag = "vue-perf-end:" + (vm._uid);
4967 mark(startTag);
4968 }
4969
4970 // a flag to avoid this being observed
4971 vm._isVue = true;
4972 // merge options
4973 if (options && options._isComponent) {
4974 // optimize internal component instantiation
4975 // since dynamic options merging is pretty slow, and none of the
4976 // internal component options needs special treatment.
4977 initInternalComponent(vm, options);
4978 } else {
4979 vm.$options = mergeOptions(
4980 resolveConstructorOptions(vm.constructor),
4981 options || {},
4982 vm
4983 );
4984 }
4985 /* istanbul ignore else */
4986 {
4987 initProxy(vm);
4988 }
4989 // expose real self
4990 vm._self = vm;
4991 initLifecycle(vm);
4992 initEvents(vm);
4993 initRender(vm);
4994 callHook(vm, 'beforeCreate');
4995 initInjections(vm); // resolve injections before data/props
4996 initState(vm);
4997 initProvide(vm); // resolve provide after data/props
4998 callHook(vm, 'created');
4999
5000 /* istanbul ignore if */
5001 if (config.performance && mark) {
5002 vm._name = formatComponentName(vm, false);
5003 mark(endTag);
5004 measure(("vue " + (vm._name) + " init"), startTag, endTag);
5005 }
5006
5007 if (vm.$options.el) {
5008 vm.$mount(vm.$options.el);
5009 }
5010 };
5011}
5012
5013function initInternalComponent (vm, options) {
5014 var opts = vm.$options = Object.create(vm.constructor.options);
5015 // doing this because it's faster than dynamic enumeration.
5016 var parentVnode = options._parentVnode;
5017 opts.parent = options.parent;
5018 opts._parentVnode = parentVnode;
5019
5020 var vnodeComponentOptions = parentVnode.componentOptions;
5021 opts.propsData = vnodeComponentOptions.propsData;
5022 opts._parentListeners = vnodeComponentOptions.listeners;
5023 opts._renderChildren = vnodeComponentOptions.children;
5024 opts._componentTag = vnodeComponentOptions.tag;
5025
5026 if (options.render) {
5027 opts.render = options.render;
5028 opts.staticRenderFns = options.staticRenderFns;
5029 }
5030}
5031
5032function resolveConstructorOptions (Ctor) {
5033 var options = Ctor.options;
5034 if (Ctor.super) {
5035 var superOptions = resolveConstructorOptions(Ctor.super);
5036 var cachedSuperOptions = Ctor.superOptions;
5037 if (superOptions !== cachedSuperOptions) {
5038 // super option changed,
5039 // need to resolve new options.
5040 Ctor.superOptions = superOptions;
5041 // check if there are any late-modified/attached options (#4976)
5042 var modifiedOptions = resolveModifiedOptions(Ctor);
5043 // update base extend options
5044 if (modifiedOptions) {
5045 extend(Ctor.extendOptions, modifiedOptions);
5046 }
5047 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
5048 if (options.name) {
5049 options.components[options.name] = Ctor;
5050 }
5051 }
5052 }
5053 return options
5054}
5055
5056function resolveModifiedOptions (Ctor) {
5057 var modified;
5058 var latest = Ctor.options;
5059 var sealed = Ctor.sealedOptions;
5060 for (var key in latest) {
5061 if (latest[key] !== sealed[key]) {
5062 if (!modified) { modified = {}; }
5063 modified[key] = latest[key];
5064 }
5065 }
5066 return modified
5067}
5068
5069function Vue (options) {
5070 if (!(this instanceof Vue)
5071 ) {
5072 warn('Vue is a constructor and should be called with the `new` keyword');
5073 }
5074 this._init(options);
5075}
5076
5077initMixin(Vue);
5078stateMixin(Vue);
5079eventsMixin(Vue);
5080lifecycleMixin(Vue);
5081renderMixin(Vue);
5082
5083/* */
5084
5085function initUse (Vue) {
5086 Vue.use = function (plugin) {
5087 var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
5088 if (installedPlugins.indexOf(plugin) > -1) {
5089 return this
5090 }
5091
5092 // additional parameters
5093 var args = toArray(arguments, 1);
5094 args.unshift(this);
5095 if (typeof plugin.install === 'function') {
5096 plugin.install.apply(plugin, args);
5097 } else if (typeof plugin === 'function') {
5098 plugin.apply(null, args);
5099 }
5100 installedPlugins.push(plugin);
5101 return this
5102 };
5103}
5104
5105/* */
5106
5107function initMixin$1 (Vue) {
5108 Vue.mixin = function (mixin) {
5109 this.options = mergeOptions(this.options, mixin);
5110 return this
5111 };
5112}
5113
5114/* */
5115
5116function initExtend (Vue) {
5117 /**
5118 * Each instance constructor, including Vue, has a unique
5119 * cid. This enables us to create wrapped "child
5120 * constructors" for prototypal inheritance and cache them.
5121 */
5122 Vue.cid = 0;
5123 var cid = 1;
5124
5125 /**
5126 * Class inheritance
5127 */
5128 Vue.extend = function (extendOptions) {
5129 extendOptions = extendOptions || {};
5130 var Super = this;
5131 var SuperId = Super.cid;
5132 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
5133 if (cachedCtors[SuperId]) {
5134 return cachedCtors[SuperId]
5135 }
5136
5137 var name = extendOptions.name || Super.options.name;
5138 if (name) {
5139 validateComponentName(name);
5140 }
5141
5142 var Sub = function VueComponent (options) {
5143 this._init(options);
5144 };
5145 Sub.prototype = Object.create(Super.prototype);
5146 Sub.prototype.constructor = Sub;
5147 Sub.cid = cid++;
5148 Sub.options = mergeOptions(
5149 Super.options,
5150 extendOptions
5151 );
5152 Sub['super'] = Super;
5153
5154 // For props and computed properties, we define the proxy getters on
5155 // the Vue instances at extension time, on the extended prototype. This
5156 // avoids Object.defineProperty calls for each instance created.
5157 if (Sub.options.props) {
5158 initProps$1(Sub);
5159 }
5160 if (Sub.options.computed) {
5161 initComputed$1(Sub);
5162 }
5163
5164 // allow further extension/mixin/plugin usage
5165 Sub.extend = Super.extend;
5166 Sub.mixin = Super.mixin;
5167 Sub.use = Super.use;
5168
5169 // create asset registers, so extended classes
5170 // can have their private assets too.
5171 ASSET_TYPES.forEach(function (type) {
5172 Sub[type] = Super[type];
5173 });
5174 // enable recursive self-lookup
5175 if (name) {
5176 Sub.options.components[name] = Sub;
5177 }
5178
5179 // keep a reference to the super options at extension time.
5180 // later at instantiation we can check if Super's options have
5181 // been updated.
5182 Sub.superOptions = Super.options;
5183 Sub.extendOptions = extendOptions;
5184 Sub.sealedOptions = extend({}, Sub.options);
5185
5186 // cache constructor
5187 cachedCtors[SuperId] = Sub;
5188 return Sub
5189 };
5190}
5191
5192function initProps$1 (Comp) {
5193 var props = Comp.options.props;
5194 for (var key in props) {
5195 proxy(Comp.prototype, "_props", key);
5196 }
5197}
5198
5199function initComputed$1 (Comp) {
5200 var computed = Comp.options.computed;
5201 for (var key in computed) {
5202 defineComputed(Comp.prototype, key, computed[key]);
5203 }
5204}
5205
5206/* */
5207
5208function initAssetRegisters (Vue) {
5209 /**
5210 * Create asset registration methods.
5211 */
5212 ASSET_TYPES.forEach(function (type) {
5213 Vue[type] = function (
5214 id,
5215 definition
5216 ) {
5217 if (!definition) {
5218 return this.options[type + 's'][id]
5219 } else {
5220 /* istanbul ignore if */
5221 if (type === 'component') {
5222 validateComponentName(id);
5223 }
5224 if (type === 'component' && isPlainObject(definition)) {
5225 definition.name = definition.name || id;
5226 definition = this.options._base.extend(definition);
5227 }
5228 if (type === 'directive' && typeof definition === 'function') {
5229 definition = { bind: definition, update: definition };
5230 }
5231 this.options[type + 's'][id] = definition;
5232 return definition
5233 }
5234 };
5235 });
5236}
5237
5238/* */
5239
5240
5241
5242function getComponentName (opts) {
5243 return opts && (opts.Ctor.options.name || opts.tag)
5244}
5245
5246function matches (pattern, name) {
5247 if (Array.isArray(pattern)) {
5248 return pattern.indexOf(name) > -1
5249 } else if (typeof pattern === 'string') {
5250 return pattern.split(',').indexOf(name) > -1
5251 } else if (isRegExp(pattern)) {
5252 return pattern.test(name)
5253 }
5254 /* istanbul ignore next */
5255 return false
5256}
5257
5258function pruneCache (keepAliveInstance, filter) {
5259 var cache = keepAliveInstance.cache;
5260 var keys = keepAliveInstance.keys;
5261 var _vnode = keepAliveInstance._vnode;
5262 for (var key in cache) {
5263 var cachedNode = cache[key];
5264 if (cachedNode) {
5265 var name = getComponentName(cachedNode.componentOptions);
5266 if (name && !filter(name)) {
5267 pruneCacheEntry(cache, key, keys, _vnode);
5268 }
5269 }
5270 }
5271}
5272
5273function pruneCacheEntry (
5274 cache,
5275 key,
5276 keys,
5277 current
5278) {
5279 var cached$$1 = cache[key];
5280 if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
5281 cached$$1.componentInstance.$destroy();
5282 }
5283 cache[key] = null;
5284 remove(keys, key);
5285}
5286
5287var patternTypes = [String, RegExp, Array];
5288
5289var KeepAlive = {
5290 name: 'keep-alive',
5291 abstract: true,
5292
5293 props: {
5294 include: patternTypes,
5295 exclude: patternTypes,
5296 max: [String, Number]
5297 },
5298
5299 created: function created () {
5300 this.cache = Object.create(null);
5301 this.keys = [];
5302 },
5303
5304 destroyed: function destroyed () {
5305 for (var key in this.cache) {
5306 pruneCacheEntry(this.cache, key, this.keys);
5307 }
5308 },
5309
5310 mounted: function mounted () {
5311 var this$1 = this;
5312
5313 this.$watch('include', function (val) {
5314 pruneCache(this$1, function (name) { return matches(val, name); });
5315 });
5316 this.$watch('exclude', function (val) {
5317 pruneCache(this$1, function (name) { return !matches(val, name); });
5318 });
5319 },
5320
5321 render: function render () {
5322 var slot = this.$slots.default;
5323 var vnode = getFirstComponentChild(slot);
5324 var componentOptions = vnode && vnode.componentOptions;
5325 if (componentOptions) {
5326 // check pattern
5327 var name = getComponentName(componentOptions);
5328 var ref = this;
5329 var include = ref.include;
5330 var exclude = ref.exclude;
5331 if (
5332 // not included
5333 (include && (!name || !matches(include, name))) ||
5334 // excluded
5335 (exclude && name && matches(exclude, name))
5336 ) {
5337 return vnode
5338 }
5339
5340 var ref$1 = this;
5341 var cache = ref$1.cache;
5342 var keys = ref$1.keys;
5343 var key = vnode.key == null
5344 // same constructor may get registered as different local components
5345 // so cid alone is not enough (#3269)
5346 ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
5347 : vnode.key;
5348 if (cache[key]) {
5349 vnode.componentInstance = cache[key].componentInstance;
5350 // make current key freshest
5351 remove(keys, key);
5352 keys.push(key);
5353 } else {
5354 cache[key] = vnode;
5355 keys.push(key);
5356 // prune oldest entry
5357 if (this.max && keys.length > parseInt(this.max)) {
5358 pruneCacheEntry(cache, keys[0], keys, this._vnode);
5359 }
5360 }
5361
5362 vnode.data.keepAlive = true;
5363 }
5364 return vnode || (slot && slot[0])
5365 }
5366};
5367
5368var builtInComponents = {
5369 KeepAlive: KeepAlive
5370};
5371
5372/* */
5373
5374function initGlobalAPI (Vue) {
5375 // config
5376 var configDef = {};
5377 configDef.get = function () { return config; };
5378 {
5379 configDef.set = function () {
5380 warn(
5381 'Do not replace the Vue.config object, set individual fields instead.'
5382 );
5383 };
5384 }
5385 Object.defineProperty(Vue, 'config', configDef);
5386
5387 // exposed util methods.
5388 // NOTE: these are not considered part of the public API - avoid relying on
5389 // them unless you are aware of the risk.
5390 Vue.util = {
5391 warn: warn,
5392 extend: extend,
5393 mergeOptions: mergeOptions,
5394 defineReactive: defineReactive$$1
5395 };
5396
5397 Vue.set = set;
5398 Vue.delete = del;
5399 Vue.nextTick = nextTick;
5400
5401 // 2.6 explicit observable API
5402 Vue.observable = function (obj) {
5403 observe(obj);
5404 return obj
5405 };
5406
5407 Vue.options = Object.create(null);
5408 ASSET_TYPES.forEach(function (type) {
5409 Vue.options[type + 's'] = Object.create(null);
5410 });
5411
5412 // this is used to identify the "base" constructor to extend all plain-object
5413 // components with in Weex's multi-instance scenarios.
5414 Vue.options._base = Vue;
5415
5416 extend(Vue.options.components, builtInComponents);
5417
5418 initUse(Vue);
5419 initMixin$1(Vue);
5420 initExtend(Vue);
5421 initAssetRegisters(Vue);
5422}
5423
5424initGlobalAPI(Vue);
5425
5426Object.defineProperty(Vue.prototype, '$isServer', {
5427 get: isServerRendering
5428});
5429
5430Object.defineProperty(Vue.prototype, '$ssrContext', {
5431 get: function get () {
5432 /* istanbul ignore next */
5433 return this.$vnode && this.$vnode.ssrContext
5434 }
5435});
5436
5437// expose FunctionalRenderContext for ssr runtime helper installation
5438Object.defineProperty(Vue, 'FunctionalRenderContext', {
5439 value: FunctionalRenderContext
5440});
5441
5442Vue.version = '2.6.12';
5443
5444/* */
5445
5446// these are reserved for web because they are directly compiled away
5447// during template compilation
5448var isReservedAttr = makeMap('style,class');
5449
5450// attributes that should be using props for binding
5451var acceptValue = makeMap('input,textarea,option,select,progress');
5452var mustUseProp = function (tag, type, attr) {
5453 return (
5454 (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
5455 (attr === 'selected' && tag === 'option') ||
5456 (attr === 'checked' && tag === 'input') ||
5457 (attr === 'muted' && tag === 'video')
5458 )
5459};
5460
5461var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
5462
5463var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
5464
5465var convertEnumeratedValue = function (key, value) {
5466 return isFalsyAttrValue(value) || value === 'false'
5467 ? 'false'
5468 // allow arbitrary string value for contenteditable
5469 : key === 'contenteditable' && isValidContentEditableValue(value)
5470 ? value
5471 : 'true'
5472};
5473
5474var isBooleanAttr = makeMap(
5475 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
5476 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
5477 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
5478 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
5479 'required,reversed,scoped,seamless,selected,sortable,translate,' +
5480 'truespeed,typemustmatch,visible'
5481);
5482
5483var xlinkNS = 'http://www.w3.org/1999/xlink';
5484
5485var isXlink = function (name) {
5486 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
5487};
5488
5489var getXlinkProp = function (name) {
5490 return isXlink(name) ? name.slice(6, name.length) : ''
5491};
5492
5493var isFalsyAttrValue = function (val) {
5494 return val == null || val === false
5495};
5496
5497/* */
5498
5499function genClassForVnode (vnode) {
5500 var data = vnode.data;
5501 var parentNode = vnode;
5502 var childNode = vnode;
5503 while (isDef(childNode.componentInstance)) {
5504 childNode = childNode.componentInstance._vnode;
5505 if (childNode && childNode.data) {
5506 data = mergeClassData(childNode.data, data);
5507 }
5508 }
5509 while (isDef(parentNode = parentNode.parent)) {
5510 if (parentNode && parentNode.data) {
5511 data = mergeClassData(data, parentNode.data);
5512 }
5513 }
5514 return renderClass(data.staticClass, data.class)
5515}
5516
5517function mergeClassData (child, parent) {
5518 return {
5519 staticClass: concat(child.staticClass, parent.staticClass),
5520 class: isDef(child.class)
5521 ? [child.class, parent.class]
5522 : parent.class
5523 }
5524}
5525
5526function renderClass (
5527 staticClass,
5528 dynamicClass
5529) {
5530 if (isDef(staticClass) || isDef(dynamicClass)) {
5531 return concat(staticClass, stringifyClass(dynamicClass))
5532 }
5533 /* istanbul ignore next */
5534 return ''
5535}
5536
5537function concat (a, b) {
5538 return a ? b ? (a + ' ' + b) : a : (b || '')
5539}
5540
5541function stringifyClass (value) {
5542 if (Array.isArray(value)) {
5543 return stringifyArray(value)
5544 }
5545 if (isObject(value)) {
5546 return stringifyObject(value)
5547 }
5548 if (typeof value === 'string') {
5549 return value
5550 }
5551 /* istanbul ignore next */
5552 return ''
5553}
5554
5555function stringifyArray (value) {
5556 var res = '';
5557 var stringified;
5558 for (var i = 0, l = value.length; i < l; i++) {
5559 if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
5560 if (res) { res += ' '; }
5561 res += stringified;
5562 }
5563 }
5564 return res
5565}
5566
5567function stringifyObject (value) {
5568 var res = '';
5569 for (var key in value) {
5570 if (value[key]) {
5571 if (res) { res += ' '; }
5572 res += key;
5573 }
5574 }
5575 return res
5576}
5577
5578/* */
5579
5580var namespaceMap = {
5581 svg: 'http://www.w3.org/2000/svg',
5582 math: 'http://www.w3.org/1998/Math/MathML'
5583};
5584
5585var isHTMLTag = makeMap(
5586 'html,body,base,head,link,meta,style,title,' +
5587 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
5588 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
5589 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
5590 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
5591 'embed,object,param,source,canvas,script,noscript,del,ins,' +
5592 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
5593 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
5594 'output,progress,select,textarea,' +
5595 'details,dialog,menu,menuitem,summary,' +
5596 'content,element,shadow,template,blockquote,iframe,tfoot'
5597);
5598
5599// this map is intentionally selective, only covering SVG elements that may
5600// contain child elements.
5601var isSVG = makeMap(
5602 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
5603 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
5604 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
5605 true
5606);
5607
5608var isPreTag = function (tag) { return tag === 'pre'; };
5609
5610var isReservedTag = function (tag) {
5611 return isHTMLTag(tag) || isSVG(tag)
5612};
5613
5614function getTagNamespace (tag) {
5615 if (isSVG(tag)) {
5616 return 'svg'
5617 }
5618 // basic support for MathML
5619 // note it doesn't support other MathML elements being component roots
5620 if (tag === 'math') {
5621 return 'math'
5622 }
5623}
5624
5625var unknownElementCache = Object.create(null);
5626function isUnknownElement (tag) {
5627 /* istanbul ignore if */
5628 if (!inBrowser) {
5629 return true
5630 }
5631 if (isReservedTag(tag)) {
5632 return false
5633 }
5634 tag = tag.toLowerCase();
5635 /* istanbul ignore if */
5636 if (unknownElementCache[tag] != null) {
5637 return unknownElementCache[tag]
5638 }
5639 var el = document.createElement(tag);
5640 if (tag.indexOf('-') > -1) {
5641 // http://stackoverflow.com/a/28210364/1070244
5642 return (unknownElementCache[tag] = (
5643 el.constructor === window.HTMLUnknownElement ||
5644 el.constructor === window.HTMLElement
5645 ))
5646 } else {
5647 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
5648 }
5649}
5650
5651var isTextInputType = makeMap('text,number,password,search,email,tel,url');
5652
5653/* */
5654
5655/**
5656 * Query an element selector if it's not an element already.
5657 */
5658function query (el) {
5659 if (typeof el === 'string') {
5660 var selected = document.querySelector(el);
5661 if (!selected) {
5662 warn(
5663 'Cannot find element: ' + el
5664 );
5665 return document.createElement('div')
5666 }
5667 return selected
5668 } else {
5669 return el
5670 }
5671}
5672
5673/* */
5674
5675function createElement$1 (tagName, vnode) {
5676 var elm = document.createElement(tagName);
5677 if (tagName !== 'select') {
5678 return elm
5679 }
5680 // false or null will remove the attribute but undefined will not
5681 if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
5682 elm.setAttribute('multiple', 'multiple');
5683 }
5684 return elm
5685}
5686
5687function createElementNS (namespace, tagName) {
5688 return document.createElementNS(namespaceMap[namespace], tagName)
5689}
5690
5691function createTextNode (text) {
5692 return document.createTextNode(text)
5693}
5694
5695function createComment (text) {
5696 return document.createComment(text)
5697}
5698
5699function insertBefore (parentNode, newNode, referenceNode) {
5700 parentNode.insertBefore(newNode, referenceNode);
5701}
5702
5703function removeChild (node, child) {
5704 node.removeChild(child);
5705}
5706
5707function appendChild (node, child) {
5708 node.appendChild(child);
5709}
5710
5711function parentNode (node) {
5712 return node.parentNode
5713}
5714
5715function nextSibling (node) {
5716 return node.nextSibling
5717}
5718
5719function tagName (node) {
5720 return node.tagName
5721}
5722
5723function setTextContent (node, text) {
5724 node.textContent = text;
5725}
5726
5727function setStyleScope (node, scopeId) {
5728 node.setAttribute(scopeId, '');
5729}
5730
5731var nodeOps = /*#__PURE__*/Object.freeze({
5732 createElement: createElement$1,
5733 createElementNS: createElementNS,
5734 createTextNode: createTextNode,
5735 createComment: createComment,
5736 insertBefore: insertBefore,
5737 removeChild: removeChild,
5738 appendChild: appendChild,
5739 parentNode: parentNode,
5740 nextSibling: nextSibling,
5741 tagName: tagName,
5742 setTextContent: setTextContent,
5743 setStyleScope: setStyleScope
5744});
5745
5746/* */
5747
5748var ref = {
5749 create: function create (_, vnode) {
5750 registerRef(vnode);
5751 },
5752 update: function update (oldVnode, vnode) {
5753 if (oldVnode.data.ref !== vnode.data.ref) {
5754 registerRef(oldVnode, true);
5755 registerRef(vnode);
5756 }
5757 },
5758 destroy: function destroy (vnode) {
5759 registerRef(vnode, true);
5760 }
5761};
5762
5763function registerRef (vnode, isRemoval) {
5764 var key = vnode.data.ref;
5765 if (!isDef(key)) { return }
5766
5767 var vm = vnode.context;
5768 var ref = vnode.componentInstance || vnode.elm;
5769 var refs = vm.$refs;
5770 if (isRemoval) {
5771 if (Array.isArray(refs[key])) {
5772 remove(refs[key], ref);
5773 } else if (refs[key] === ref) {
5774 refs[key] = undefined;
5775 }
5776 } else {
5777 if (vnode.data.refInFor) {
5778 if (!Array.isArray(refs[key])) {
5779 refs[key] = [ref];
5780 } else if (refs[key].indexOf(ref) < 0) {
5781 // $flow-disable-line
5782 refs[key].push(ref);
5783 }
5784 } else {
5785 refs[key] = ref;
5786 }
5787 }
5788}
5789
5790/**
5791 * Virtual DOM patching algorithm based on Snabbdom by
5792 * Simon Friis Vindum (@paldepind)
5793 * Licensed under the MIT License
5794 * https://github.com/paldepind/snabbdom/blob/master/LICENSE
5795 *
5796 * modified by Evan You (@yyx990803)
5797 *
5798 * Not type-checking this because this file is perf-critical and the cost
5799 * of making flow understand it is not worth it.
5800 */
5801
5802var emptyNode = new VNode('', {}, []);
5803
5804var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
5805
5806function sameVnode (a, b) {
5807 return (
5808 a.key === b.key && (
5809 (
5810 a.tag === b.tag &&
5811 a.isComment === b.isComment &&
5812 isDef(a.data) === isDef(b.data) &&
5813 sameInputType(a, b)
5814 ) || (
5815 isTrue(a.isAsyncPlaceholder) &&
5816 a.asyncFactory === b.asyncFactory &&
5817 isUndef(b.asyncFactory.error)
5818 )
5819 )
5820 )
5821}
5822
5823function sameInputType (a, b) {
5824 if (a.tag !== 'input') { return true }
5825 var i;
5826 var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
5827 var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
5828 return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
5829}
5830
5831function createKeyToOldIdx (children, beginIdx, endIdx) {
5832 var i, key;
5833 var map = {};
5834 for (i = beginIdx; i <= endIdx; ++i) {
5835 key = children[i].key;
5836 if (isDef(key)) { map[key] = i; }
5837 }
5838 return map
5839}
5840
5841function createPatchFunction (backend) {
5842 var i, j;
5843 var cbs = {};
5844
5845 var modules = backend.modules;
5846 var nodeOps = backend.nodeOps;
5847
5848 for (i = 0; i < hooks.length; ++i) {
5849 cbs[hooks[i]] = [];
5850 for (j = 0; j < modules.length; ++j) {
5851 if (isDef(modules[j][hooks[i]])) {
5852 cbs[hooks[i]].push(modules[j][hooks[i]]);
5853 }
5854 }
5855 }
5856
5857 function emptyNodeAt (elm) {
5858 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
5859 }
5860
5861 function createRmCb (childElm, listeners) {
5862 function remove$$1 () {
5863 if (--remove$$1.listeners === 0) {
5864 removeNode(childElm);
5865 }
5866 }
5867 remove$$1.listeners = listeners;
5868 return remove$$1
5869 }
5870
5871 function removeNode (el) {
5872 var parent = nodeOps.parentNode(el);
5873 // element may have already been removed due to v-html / v-text
5874 if (isDef(parent)) {
5875 nodeOps.removeChild(parent, el);
5876 }
5877 }
5878
5879 function isUnknownElement$$1 (vnode, inVPre) {
5880 return (
5881 !inVPre &&
5882 !vnode.ns &&
5883 !(
5884 config.ignoredElements.length &&
5885 config.ignoredElements.some(function (ignore) {
5886 return isRegExp(ignore)
5887 ? ignore.test(vnode.tag)
5888 : ignore === vnode.tag
5889 })
5890 ) &&
5891 config.isUnknownElement(vnode.tag)
5892 )
5893 }
5894
5895 var creatingElmInVPre = 0;
5896
5897 function createElm (
5898 vnode,
5899 insertedVnodeQueue,
5900 parentElm,
5901 refElm,
5902 nested,
5903 ownerArray,
5904 index
5905 ) {
5906 if (isDef(vnode.elm) && isDef(ownerArray)) {
5907 // This vnode was used in a previous render!
5908 // now it's used as a new node, overwriting its elm would cause
5909 // potential patch errors down the road when it's used as an insertion
5910 // reference node. Instead, we clone the node on-demand before creating
5911 // associated DOM element for it.
5912 vnode = ownerArray[index] = cloneVNode(vnode);
5913 }
5914
5915 vnode.isRootInsert = !nested; // for transition enter check
5916 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
5917 return
5918 }
5919
5920 var data = vnode.data;
5921 var children = vnode.children;
5922 var tag = vnode.tag;
5923 if (isDef(tag)) {
5924 {
5925 if (data && data.pre) {
5926 creatingElmInVPre++;
5927 }
5928 if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
5929 warn(
5930 'Unknown custom element: <' + tag + '> - did you ' +
5931 'register the component correctly? For recursive components, ' +
5932 'make sure to provide the "name" option.',
5933 vnode.context
5934 );
5935 }
5936 }
5937
5938 vnode.elm = vnode.ns
5939 ? nodeOps.createElementNS(vnode.ns, tag)
5940 : nodeOps.createElement(tag, vnode);
5941 setScope(vnode);
5942
5943 /* istanbul ignore if */
5944 {
5945 createChildren(vnode, children, insertedVnodeQueue);
5946 if (isDef(data)) {
5947 invokeCreateHooks(vnode, insertedVnodeQueue);
5948 }
5949 insert(parentElm, vnode.elm, refElm);
5950 }
5951
5952 if (data && data.pre) {
5953 creatingElmInVPre--;
5954 }
5955 } else if (isTrue(vnode.isComment)) {
5956 vnode.elm = nodeOps.createComment(vnode.text);
5957 insert(parentElm, vnode.elm, refElm);
5958 } else {
5959 vnode.elm = nodeOps.createTextNode(vnode.text);
5960 insert(parentElm, vnode.elm, refElm);
5961 }
5962 }
5963
5964 function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
5965 var i = vnode.data;
5966 if (isDef(i)) {
5967 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
5968 if (isDef(i = i.hook) && isDef(i = i.init)) {
5969 i(vnode, false /* hydrating */);
5970 }
5971 // after calling the init hook, if the vnode is a child component
5972 // it should've created a child instance and mounted it. the child
5973 // component also has set the placeholder vnode's elm.
5974 // in that case we can just return the element and be done.
5975 if (isDef(vnode.componentInstance)) {
5976 initComponent(vnode, insertedVnodeQueue);
5977 insert(parentElm, vnode.elm, refElm);
5978 if (isTrue(isReactivated)) {
5979 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
5980 }
5981 return true
5982 }
5983 }
5984 }
5985
5986 function initComponent (vnode, insertedVnodeQueue) {
5987 if (isDef(vnode.data.pendingInsert)) {
5988 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
5989 vnode.data.pendingInsert = null;
5990 }
5991 vnode.elm = vnode.componentInstance.$el;
5992 if (isPatchable(vnode)) {
5993 invokeCreateHooks(vnode, insertedVnodeQueue);
5994 setScope(vnode);
5995 } else {
5996 // empty component root.
5997 // skip all element-related modules except for ref (#3455)
5998 registerRef(vnode);
5999 // make sure to invoke the insert hook
6000 insertedVnodeQueue.push(vnode);
6001 }
6002 }
6003
6004 function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
6005 var i;
6006 // hack for #4339: a reactivated component with inner transition
6007 // does not trigger because the inner node's created hooks are not called
6008 // again. It's not ideal to involve module-specific logic in here but
6009 // there doesn't seem to be a better way to do it.
6010 var innerNode = vnode;
6011 while (innerNode.componentInstance) {
6012 innerNode = innerNode.componentInstance._vnode;
6013 if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
6014 for (i = 0; i < cbs.activate.length; ++i) {
6015 cbs.activate[i](emptyNode, innerNode);
6016 }
6017 insertedVnodeQueue.push(innerNode);
6018 break
6019 }
6020 }
6021 // unlike a newly created component,
6022 // a reactivated keep-alive component doesn't insert itself
6023 insert(parentElm, vnode.elm, refElm);
6024 }
6025
6026 function insert (parent, elm, ref$$1) {
6027 if (isDef(parent)) {
6028 if (isDef(ref$$1)) {
6029 if (nodeOps.parentNode(ref$$1) === parent) {
6030 nodeOps.insertBefore(parent, elm, ref$$1);
6031 }
6032 } else {
6033 nodeOps.appendChild(parent, elm);
6034 }
6035 }
6036 }
6037
6038 function createChildren (vnode, children, insertedVnodeQueue) {
6039 if (Array.isArray(children)) {
6040 {
6041 checkDuplicateKeys(children);
6042 }
6043 for (var i = 0; i < children.length; ++i) {
6044 createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
6045 }
6046 } else if (isPrimitive(vnode.text)) {
6047 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
6048 }
6049 }
6050
6051 function isPatchable (vnode) {
6052 while (vnode.componentInstance) {
6053 vnode = vnode.componentInstance._vnode;
6054 }
6055 return isDef(vnode.tag)
6056 }
6057
6058 function invokeCreateHooks (vnode, insertedVnodeQueue) {
6059 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
6060 cbs.create[i$1](emptyNode, vnode);
6061 }
6062 i = vnode.data.hook; // Reuse variable
6063 if (isDef(i)) {
6064 if (isDef(i.create)) { i.create(emptyNode, vnode); }
6065 if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
6066 }
6067 }
6068
6069 // set scope id attribute for scoped CSS.
6070 // this is implemented as a special case to avoid the overhead
6071 // of going through the normal attribute patching process.
6072 function setScope (vnode) {
6073 var i;
6074 if (isDef(i = vnode.fnScopeId)) {
6075 nodeOps.setStyleScope(vnode.elm, i);
6076 } else {
6077 var ancestor = vnode;
6078 while (ancestor) {
6079 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
6080 nodeOps.setStyleScope(vnode.elm, i);
6081 }
6082 ancestor = ancestor.parent;
6083 }
6084 }
6085 // for slot content they should also get the scopeId from the host instance.
6086 if (isDef(i = activeInstance) &&
6087 i !== vnode.context &&
6088 i !== vnode.fnContext &&
6089 isDef(i = i.$options._scopeId)
6090 ) {
6091 nodeOps.setStyleScope(vnode.elm, i);
6092 }
6093 }
6094
6095 function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
6096 for (; startIdx <= endIdx; ++startIdx) {
6097 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
6098 }
6099 }
6100
6101 function invokeDestroyHook (vnode) {
6102 var i, j;
6103 var data = vnode.data;
6104 if (isDef(data)) {
6105 if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
6106 for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
6107 }
6108 if (isDef(i = vnode.children)) {
6109 for (j = 0; j < vnode.children.length; ++j) {
6110 invokeDestroyHook(vnode.children[j]);
6111 }
6112 }
6113 }
6114
6115 function removeVnodes (vnodes, startIdx, endIdx) {
6116 for (; startIdx <= endIdx; ++startIdx) {
6117 var ch = vnodes[startIdx];
6118 if (isDef(ch)) {
6119 if (isDef(ch.tag)) {
6120 removeAndInvokeRemoveHook(ch);
6121 invokeDestroyHook(ch);
6122 } else { // Text node
6123 removeNode(ch.elm);
6124 }
6125 }
6126 }
6127 }
6128
6129 function removeAndInvokeRemoveHook (vnode, rm) {
6130 if (isDef(rm) || isDef(vnode.data)) {
6131 var i;
6132 var listeners = cbs.remove.length + 1;
6133 if (isDef(rm)) {
6134 // we have a recursively passed down rm callback
6135 // increase the listeners count
6136 rm.listeners += listeners;
6137 } else {
6138 // directly removing
6139 rm = createRmCb(vnode.elm, listeners);
6140 }
6141 // recursively invoke hooks on child component root node
6142 if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
6143 removeAndInvokeRemoveHook(i, rm);
6144 }
6145 for (i = 0; i < cbs.remove.length; ++i) {
6146 cbs.remove[i](vnode, rm);
6147 }
6148 if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
6149 i(vnode, rm);
6150 } else {
6151 rm();
6152 }
6153 } else {
6154 removeNode(vnode.elm);
6155 }
6156 }
6157
6158 function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
6159 var oldStartIdx = 0;
6160 var newStartIdx = 0;
6161 var oldEndIdx = oldCh.length - 1;
6162 var oldStartVnode = oldCh[0];
6163 var oldEndVnode = oldCh[oldEndIdx];
6164 var newEndIdx = newCh.length - 1;
6165 var newStartVnode = newCh[0];
6166 var newEndVnode = newCh[newEndIdx];
6167 var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
6168
6169 // removeOnly is a special flag used only by <transition-group>
6170 // to ensure removed elements stay in correct relative positions
6171 // during leaving transitions
6172 var canMove = !removeOnly;
6173
6174 {
6175 checkDuplicateKeys(newCh);
6176 }
6177
6178 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
6179 if (isUndef(oldStartVnode)) {
6180 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
6181 } else if (isUndef(oldEndVnode)) {
6182 oldEndVnode = oldCh[--oldEndIdx];
6183 } else if (sameVnode(oldStartVnode, newStartVnode)) {
6184 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
6185 oldStartVnode = oldCh[++oldStartIdx];
6186 newStartVnode = newCh[++newStartIdx];
6187 } else if (sameVnode(oldEndVnode, newEndVnode)) {
6188 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
6189 oldEndVnode = oldCh[--oldEndIdx];
6190 newEndVnode = newCh[--newEndIdx];
6191 } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
6192 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
6193 canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
6194 oldStartVnode = oldCh[++oldStartIdx];
6195 newEndVnode = newCh[--newEndIdx];
6196 } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
6197 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
6198 canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
6199 oldEndVnode = oldCh[--oldEndIdx];
6200 newStartVnode = newCh[++newStartIdx];
6201 } else {
6202 if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
6203 idxInOld = isDef(newStartVnode.key)
6204 ? oldKeyToIdx[newStartVnode.key]
6205 : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
6206 if (isUndef(idxInOld)) { // New element
6207 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
6208 } else {
6209 vnodeToMove = oldCh[idxInOld];
6210 if (sameVnode(vnodeToMove, newStartVnode)) {
6211 patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
6212 oldCh[idxInOld] = undefined;
6213 canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
6214 } else {
6215 // same key but different element. treat as new element
6216 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
6217 }
6218 }
6219 newStartVnode = newCh[++newStartIdx];
6220 }
6221 }
6222 if (oldStartIdx > oldEndIdx) {
6223 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
6224 addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
6225 } else if (newStartIdx > newEndIdx) {
6226 removeVnodes(oldCh, oldStartIdx, oldEndIdx);
6227 }
6228 }
6229
6230 function checkDuplicateKeys (children) {
6231 var seenKeys = {};
6232 for (var i = 0; i < children.length; i++) {
6233 var vnode = children[i];
6234 var key = vnode.key;
6235 if (isDef(key)) {
6236 if (seenKeys[key]) {
6237 warn(
6238 ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
6239 vnode.context
6240 );
6241 } else {
6242 seenKeys[key] = true;
6243 }
6244 }
6245 }
6246 }
6247
6248 function findIdxInOld (node, oldCh, start, end) {
6249 for (var i = start; i < end; i++) {
6250 var c = oldCh[i];
6251 if (isDef(c) && sameVnode(node, c)) { return i }
6252 }
6253 }
6254
6255 function patchVnode (
6256 oldVnode,
6257 vnode,
6258 insertedVnodeQueue,
6259 ownerArray,
6260 index,
6261 removeOnly
6262 ) {
6263 if (oldVnode === vnode) {
6264 return
6265 }
6266
6267 if (isDef(vnode.elm) && isDef(ownerArray)) {
6268 // clone reused vnode
6269 vnode = ownerArray[index] = cloneVNode(vnode);
6270 }
6271
6272 var elm = vnode.elm = oldVnode.elm;
6273
6274 if (isTrue(oldVnode.isAsyncPlaceholder)) {
6275 if (isDef(vnode.asyncFactory.resolved)) {
6276 hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
6277 } else {
6278 vnode.isAsyncPlaceholder = true;
6279 }
6280 return
6281 }
6282
6283 // reuse element for static trees.
6284 // note we only do this if the vnode is cloned -
6285 // if the new node is not cloned it means the render functions have been
6286 // reset by the hot-reload-api and we need to do a proper re-render.
6287 if (isTrue(vnode.isStatic) &&
6288 isTrue(oldVnode.isStatic) &&
6289 vnode.key === oldVnode.key &&
6290 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
6291 ) {
6292 vnode.componentInstance = oldVnode.componentInstance;
6293 return
6294 }
6295
6296 var i;
6297 var data = vnode.data;
6298 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
6299 i(oldVnode, vnode);
6300 }
6301
6302 var oldCh = oldVnode.children;
6303 var ch = vnode.children;
6304 if (isDef(data) && isPatchable(vnode)) {
6305 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
6306 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
6307 }
6308 if (isUndef(vnode.text)) {
6309 if (isDef(oldCh) && isDef(ch)) {
6310 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
6311 } else if (isDef(ch)) {
6312 {
6313 checkDuplicateKeys(ch);
6314 }
6315 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
6316 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
6317 } else if (isDef(oldCh)) {
6318 removeVnodes(oldCh, 0, oldCh.length - 1);
6319 } else if (isDef(oldVnode.text)) {
6320 nodeOps.setTextContent(elm, '');
6321 }
6322 } else if (oldVnode.text !== vnode.text) {
6323 nodeOps.setTextContent(elm, vnode.text);
6324 }
6325 if (isDef(data)) {
6326 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
6327 }
6328 }
6329
6330 function invokeInsertHook (vnode, queue, initial) {
6331 // delay insert hooks for component root nodes, invoke them after the
6332 // element is really inserted
6333 if (isTrue(initial) && isDef(vnode.parent)) {
6334 vnode.parent.data.pendingInsert = queue;
6335 } else {
6336 for (var i = 0; i < queue.length; ++i) {
6337 queue[i].data.hook.insert(queue[i]);
6338 }
6339 }
6340 }
6341
6342 var hydrationBailed = false;
6343 // list of modules that can skip create hook during hydration because they
6344 // are already rendered on the client or has no need for initialization
6345 // Note: style is excluded because it relies on initial clone for future
6346 // deep updates (#7063).
6347 var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
6348
6349 // Note: this is a browser-only function so we can assume elms are DOM nodes.
6350 function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
6351 var i;
6352 var tag = vnode.tag;
6353 var data = vnode.data;
6354 var children = vnode.children;
6355 inVPre = inVPre || (data && data.pre);
6356 vnode.elm = elm;
6357
6358 if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
6359 vnode.isAsyncPlaceholder = true;
6360 return true
6361 }
6362 // assert node match
6363 {
6364 if (!assertNodeMatch(elm, vnode, inVPre)) {
6365 return false
6366 }
6367 }
6368 if (isDef(data)) {
6369 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
6370 if (isDef(i = vnode.componentInstance)) {
6371 // child component. it should have hydrated its own tree.
6372 initComponent(vnode, insertedVnodeQueue);
6373 return true
6374 }
6375 }
6376 if (isDef(tag)) {
6377 if (isDef(children)) {
6378 // empty element, allow client to pick up and populate children
6379 if (!elm.hasChildNodes()) {
6380 createChildren(vnode, children, insertedVnodeQueue);
6381 } else {
6382 // v-html and domProps: innerHTML
6383 if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
6384 if (i !== elm.innerHTML) {
6385 /* istanbul ignore if */
6386 if (typeof console !== 'undefined' &&
6387 !hydrationBailed
6388 ) {
6389 hydrationBailed = true;
6390 console.warn('Parent: ', elm);
6391 console.warn('server innerHTML: ', i);
6392 console.warn('client innerHTML: ', elm.innerHTML);
6393 }
6394 return false
6395 }
6396 } else {
6397 // iterate and compare children lists
6398 var childrenMatch = true;
6399 var childNode = elm.firstChild;
6400 for (var i$1 = 0; i$1 < children.length; i$1++) {
6401 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
6402 childrenMatch = false;
6403 break
6404 }
6405 childNode = childNode.nextSibling;
6406 }
6407 // if childNode is not null, it means the actual childNodes list is
6408 // longer than the virtual children list.
6409 if (!childrenMatch || childNode) {
6410 /* istanbul ignore if */
6411 if (typeof console !== 'undefined' &&
6412 !hydrationBailed
6413 ) {
6414 hydrationBailed = true;
6415 console.warn('Parent: ', elm);
6416 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
6417 }
6418 return false
6419 }
6420 }
6421 }
6422 }
6423 if (isDef(data)) {
6424 var fullInvoke = false;
6425 for (var key in data) {
6426 if (!isRenderedModule(key)) {
6427 fullInvoke = true;
6428 invokeCreateHooks(vnode, insertedVnodeQueue);
6429 break
6430 }
6431 }
6432 if (!fullInvoke && data['class']) {
6433 // ensure collecting deps for deep class bindings for future updates
6434 traverse(data['class']);
6435 }
6436 }
6437 } else if (elm.data !== vnode.text) {
6438 elm.data = vnode.text;
6439 }
6440 return true
6441 }
6442
6443 function assertNodeMatch (node, vnode, inVPre) {
6444 if (isDef(vnode.tag)) {
6445 return vnode.tag.indexOf('vue-component') === 0 || (
6446 !isUnknownElement$$1(vnode, inVPre) &&
6447 vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
6448 )
6449 } else {
6450 return node.nodeType === (vnode.isComment ? 8 : 3)
6451 }
6452 }
6453
6454 return function patch (oldVnode, vnode, hydrating, removeOnly) {
6455 if (isUndef(vnode)) {
6456 if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
6457 return
6458 }
6459
6460 var isInitialPatch = false;
6461 var insertedVnodeQueue = [];
6462
6463 if (isUndef(oldVnode)) {
6464 // empty mount (likely as component), create new root element
6465 isInitialPatch = true;
6466 createElm(vnode, insertedVnodeQueue);
6467 } else {
6468 var isRealElement = isDef(oldVnode.nodeType);
6469 if (!isRealElement && sameVnode(oldVnode, vnode)) {
6470 // patch existing root node
6471 patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
6472 } else {
6473 if (isRealElement) {
6474 // mounting to a real element
6475 // check if this is server-rendered content and if we can perform
6476 // a successful hydration.
6477 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
6478 oldVnode.removeAttribute(SSR_ATTR);
6479 hydrating = true;
6480 }
6481 if (isTrue(hydrating)) {
6482 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
6483 invokeInsertHook(vnode, insertedVnodeQueue, true);
6484 return oldVnode
6485 } else {
6486 warn(
6487 'The client-side rendered virtual DOM tree is not matching ' +
6488 'server-rendered content. This is likely caused by incorrect ' +
6489 'HTML markup, for example nesting block-level elements inside ' +
6490 '<p>, or missing <tbody>. Bailing hydration and performing ' +
6491 'full client-side render.'
6492 );
6493 }
6494 }
6495 // either not server-rendered, or hydration failed.
6496 // create an empty node and replace it
6497 oldVnode = emptyNodeAt(oldVnode);
6498 }
6499
6500 // replacing existing element
6501 var oldElm = oldVnode.elm;
6502 var parentElm = nodeOps.parentNode(oldElm);
6503
6504 // create new node
6505 createElm(
6506 vnode,
6507 insertedVnodeQueue,
6508 // extremely rare edge case: do not insert if old element is in a
6509 // leaving transition. Only happens when combining transition +
6510 // keep-alive + HOCs. (#4590)
6511 oldElm._leaveCb ? null : parentElm,
6512 nodeOps.nextSibling(oldElm)
6513 );
6514
6515 // update parent placeholder node element, recursively
6516 if (isDef(vnode.parent)) {
6517 var ancestor = vnode.parent;
6518 var patchable = isPatchable(vnode);
6519 while (ancestor) {
6520 for (var i = 0; i < cbs.destroy.length; ++i) {
6521 cbs.destroy[i](ancestor);
6522 }
6523 ancestor.elm = vnode.elm;
6524 if (patchable) {
6525 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
6526 cbs.create[i$1](emptyNode, ancestor);
6527 }
6528 // #6513
6529 // invoke insert hooks that may have been merged by create hooks.
6530 // e.g. for directives that uses the "inserted" hook.
6531 var insert = ancestor.data.hook.insert;
6532 if (insert.merged) {
6533 // start at index 1 to avoid re-invoking component mounted hook
6534 for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
6535 insert.fns[i$2]();
6536 }
6537 }
6538 } else {
6539 registerRef(ancestor);
6540 }
6541 ancestor = ancestor.parent;
6542 }
6543 }
6544
6545 // destroy old node
6546 if (isDef(parentElm)) {
6547 removeVnodes([oldVnode], 0, 0);
6548 } else if (isDef(oldVnode.tag)) {
6549 invokeDestroyHook(oldVnode);
6550 }
6551 }
6552 }
6553
6554 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
6555 return vnode.elm
6556 }
6557}
6558
6559/* */
6560
6561var directives = {
6562 create: updateDirectives,
6563 update: updateDirectives,
6564 destroy: function unbindDirectives (vnode) {
6565 updateDirectives(vnode, emptyNode);
6566 }
6567};
6568
6569function updateDirectives (oldVnode, vnode) {
6570 if (oldVnode.data.directives || vnode.data.directives) {
6571 _update(oldVnode, vnode);
6572 }
6573}
6574
6575function _update (oldVnode, vnode) {
6576 var isCreate = oldVnode === emptyNode;
6577 var isDestroy = vnode === emptyNode;
6578 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
6579 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
6580
6581 var dirsWithInsert = [];
6582 var dirsWithPostpatch = [];
6583
6584 var key, oldDir, dir;
6585 for (key in newDirs) {
6586 oldDir = oldDirs[key];
6587 dir = newDirs[key];
6588 if (!oldDir) {
6589 // new directive, bind
6590 callHook$1(dir, 'bind', vnode, oldVnode);
6591 if (dir.def && dir.def.inserted) {
6592 dirsWithInsert.push(dir);
6593 }
6594 } else {
6595 // existing directive, update
6596 dir.oldValue = oldDir.value;
6597 dir.oldArg = oldDir.arg;
6598 callHook$1(dir, 'update', vnode, oldVnode);
6599 if (dir.def && dir.def.componentUpdated) {
6600 dirsWithPostpatch.push(dir);
6601 }
6602 }
6603 }
6604
6605 if (dirsWithInsert.length) {
6606 var callInsert = function () {
6607 for (var i = 0; i < dirsWithInsert.length; i++) {
6608 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
6609 }
6610 };
6611 if (isCreate) {
6612 mergeVNodeHook(vnode, 'insert', callInsert);
6613 } else {
6614 callInsert();
6615 }
6616 }
6617
6618 if (dirsWithPostpatch.length) {
6619 mergeVNodeHook(vnode, 'postpatch', function () {
6620 for (var i = 0; i < dirsWithPostpatch.length; i++) {
6621 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
6622 }
6623 });
6624 }
6625
6626 if (!isCreate) {
6627 for (key in oldDirs) {
6628 if (!newDirs[key]) {
6629 // no longer present, unbind
6630 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
6631 }
6632 }
6633 }
6634}
6635
6636var emptyModifiers = Object.create(null);
6637
6638function normalizeDirectives$1 (
6639 dirs,
6640 vm
6641) {
6642 var res = Object.create(null);
6643 if (!dirs) {
6644 // $flow-disable-line
6645 return res
6646 }
6647 var i, dir;
6648 for (i = 0; i < dirs.length; i++) {
6649 dir = dirs[i];
6650 if (!dir.modifiers) {
6651 // $flow-disable-line
6652 dir.modifiers = emptyModifiers;
6653 }
6654 res[getRawDirName(dir)] = dir;
6655 dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
6656 }
6657 // $flow-disable-line
6658 return res
6659}
6660
6661function getRawDirName (dir) {
6662 return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
6663}
6664
6665function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
6666 var fn = dir.def && dir.def[hook];
6667 if (fn) {
6668 try {
6669 fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
6670 } catch (e) {
6671 handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
6672 }
6673 }
6674}
6675
6676var baseModules = [
6677 ref,
6678 directives
6679];
6680
6681/* */
6682
6683function updateAttrs (oldVnode, vnode) {
6684 var opts = vnode.componentOptions;
6685 if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
6686 return
6687 }
6688 if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
6689 return
6690 }
6691 var key, cur, old;
6692 var elm = vnode.elm;
6693 var oldAttrs = oldVnode.data.attrs || {};
6694 var attrs = vnode.data.attrs || {};
6695 // clone observed objects, as the user probably wants to mutate it
6696 if (isDef(attrs.__ob__)) {
6697 attrs = vnode.data.attrs = extend({}, attrs);
6698 }
6699
6700 for (key in attrs) {
6701 cur = attrs[key];
6702 old = oldAttrs[key];
6703 if (old !== cur) {
6704 setAttr(elm, key, cur);
6705 }
6706 }
6707 // #4391: in IE9, setting type can reset value for input[type=radio]
6708 // #6666: IE/Edge forces progress value down to 1 before setting a max
6709 /* istanbul ignore if */
6710 if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
6711 setAttr(elm, 'value', attrs.value);
6712 }
6713 for (key in oldAttrs) {
6714 if (isUndef(attrs[key])) {
6715 if (isXlink(key)) {
6716 elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
6717 } else if (!isEnumeratedAttr(key)) {
6718 elm.removeAttribute(key);
6719 }
6720 }
6721 }
6722}
6723
6724function setAttr (el, key, value) {
6725 if (el.tagName.indexOf('-') > -1) {
6726 baseSetAttr(el, key, value);
6727 } else if (isBooleanAttr(key)) {
6728 // set attribute for blank value
6729 // e.g. <option disabled>Select one</option>
6730 if (isFalsyAttrValue(value)) {
6731 el.removeAttribute(key);
6732 } else {
6733 // technically allowfullscreen is a boolean attribute for <iframe>,
6734 // but Flash expects a value of "true" when used on <embed> tag
6735 value = key === 'allowfullscreen' && el.tagName === 'EMBED'
6736 ? 'true'
6737 : key;
6738 el.setAttribute(key, value);
6739 }
6740 } else if (isEnumeratedAttr(key)) {
6741 el.setAttribute(key, convertEnumeratedValue(key, value));
6742 } else if (isXlink(key)) {
6743 if (isFalsyAttrValue(value)) {
6744 el.removeAttributeNS(xlinkNS, getXlinkProp(key));
6745 } else {
6746 el.setAttributeNS(xlinkNS, key, value);
6747 }
6748 } else {
6749 baseSetAttr(el, key, value);
6750 }
6751}
6752
6753function baseSetAttr (el, key, value) {
6754 if (isFalsyAttrValue(value)) {
6755 el.removeAttribute(key);
6756 } else {
6757 // #7138: IE10 & 11 fires input event when setting placeholder on
6758 // <textarea>... block the first input event and remove the blocker
6759 // immediately.
6760 /* istanbul ignore if */
6761 if (
6762 isIE && !isIE9 &&
6763 el.tagName === 'TEXTAREA' &&
6764 key === 'placeholder' && value !== '' && !el.__ieph
6765 ) {
6766 var blocker = function (e) {
6767 e.stopImmediatePropagation();
6768 el.removeEventListener('input', blocker);
6769 };
6770 el.addEventListener('input', blocker);
6771 // $flow-disable-line
6772 el.__ieph = true; /* IE placeholder patched */
6773 }
6774 el.setAttribute(key, value);
6775 }
6776}
6777
6778var attrs = {
6779 create: updateAttrs,
6780 update: updateAttrs
6781};
6782
6783/* */
6784
6785function updateClass (oldVnode, vnode) {
6786 var el = vnode.elm;
6787 var data = vnode.data;
6788 var oldData = oldVnode.data;
6789 if (
6790 isUndef(data.staticClass) &&
6791 isUndef(data.class) && (
6792 isUndef(oldData) || (
6793 isUndef(oldData.staticClass) &&
6794 isUndef(oldData.class)
6795 )
6796 )
6797 ) {
6798 return
6799 }
6800
6801 var cls = genClassForVnode(vnode);
6802
6803 // handle transition classes
6804 var transitionClass = el._transitionClasses;
6805 if (isDef(transitionClass)) {
6806 cls = concat(cls, stringifyClass(transitionClass));
6807 }
6808
6809 // set the class
6810 if (cls !== el._prevClass) {
6811 el.setAttribute('class', cls);
6812 el._prevClass = cls;
6813 }
6814}
6815
6816var klass = {
6817 create: updateClass,
6818 update: updateClass
6819};
6820
6821/* */
6822
6823var validDivisionCharRE = /[\w).+\-_$\]]/;
6824
6825function parseFilters (exp) {
6826 var inSingle = false;
6827 var inDouble = false;
6828 var inTemplateString = false;
6829 var inRegex = false;
6830 var curly = 0;
6831 var square = 0;
6832 var paren = 0;
6833 var lastFilterIndex = 0;
6834 var c, prev, i, expression, filters;
6835
6836 for (i = 0; i < exp.length; i++) {
6837 prev = c;
6838 c = exp.charCodeAt(i);
6839 if (inSingle) {
6840 if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
6841 } else if (inDouble) {
6842 if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
6843 } else if (inTemplateString) {
6844 if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
6845 } else if (inRegex) {
6846 if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
6847 } else if (
6848 c === 0x7C && // pipe
6849 exp.charCodeAt(i + 1) !== 0x7C &&
6850 exp.charCodeAt(i - 1) !== 0x7C &&
6851 !curly && !square && !paren
6852 ) {
6853 if (expression === undefined) {
6854 // first filter, end of expression
6855 lastFilterIndex = i + 1;
6856 expression = exp.slice(0, i).trim();
6857 } else {
6858 pushFilter();
6859 }
6860 } else {
6861 switch (c) {
6862 case 0x22: inDouble = true; break // "
6863 case 0x27: inSingle = true; break // '
6864 case 0x60: inTemplateString = true; break // `
6865 case 0x28: paren++; break // (
6866 case 0x29: paren--; break // )
6867 case 0x5B: square++; break // [
6868 case 0x5D: square--; break // ]
6869 case 0x7B: curly++; break // {
6870 case 0x7D: curly--; break // }
6871 }
6872 if (c === 0x2f) { // /
6873 var j = i - 1;
6874 var p = (void 0);
6875 // find first non-whitespace prev char
6876 for (; j >= 0; j--) {
6877 p = exp.charAt(j);
6878 if (p !== ' ') { break }
6879 }
6880 if (!p || !validDivisionCharRE.test(p)) {
6881 inRegex = true;
6882 }
6883 }
6884 }
6885 }
6886
6887 if (expression === undefined) {
6888 expression = exp.slice(0, i).trim();
6889 } else if (lastFilterIndex !== 0) {
6890 pushFilter();
6891 }
6892
6893 function pushFilter () {
6894 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
6895 lastFilterIndex = i + 1;
6896 }
6897
6898 if (filters) {
6899 for (i = 0; i < filters.length; i++) {
6900 expression = wrapFilter(expression, filters[i]);
6901 }
6902 }
6903
6904 return expression
6905}
6906
6907function wrapFilter (exp, filter) {
6908 var i = filter.indexOf('(');
6909 if (i < 0) {
6910 // _f: resolveFilter
6911 return ("_f(\"" + filter + "\")(" + exp + ")")
6912 } else {
6913 var name = filter.slice(0, i);
6914 var args = filter.slice(i + 1);
6915 return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
6916 }
6917}
6918
6919/* */
6920
6921
6922
6923/* eslint-disable no-unused-vars */
6924function baseWarn (msg, range) {
6925 console.error(("[Vue compiler]: " + msg));
6926}
6927/* eslint-enable no-unused-vars */
6928
6929function pluckModuleFunction (
6930 modules,
6931 key
6932) {
6933 return modules
6934 ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
6935 : []
6936}
6937
6938function addProp (el, name, value, range, dynamic) {
6939 (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
6940 el.plain = false;
6941}
6942
6943function addAttr (el, name, value, range, dynamic) {
6944 var attrs = dynamic
6945 ? (el.dynamicAttrs || (el.dynamicAttrs = []))
6946 : (el.attrs || (el.attrs = []));
6947 attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
6948 el.plain = false;
6949}
6950
6951// add a raw attr (use this in preTransforms)
6952function addRawAttr (el, name, value, range) {
6953 el.attrsMap[name] = value;
6954 el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
6955}
6956
6957function addDirective (
6958 el,
6959 name,
6960 rawName,
6961 value,
6962 arg,
6963 isDynamicArg,
6964 modifiers,
6965 range
6966) {
6967 (el.directives || (el.directives = [])).push(rangeSetItem({
6968 name: name,
6969 rawName: rawName,
6970 value: value,
6971 arg: arg,
6972 isDynamicArg: isDynamicArg,
6973 modifiers: modifiers
6974 }, range));
6975 el.plain = false;
6976}
6977
6978function prependModifierMarker (symbol, name, dynamic) {
6979 return dynamic
6980 ? ("_p(" + name + ",\"" + symbol + "\")")
6981 : symbol + name // mark the event as captured
6982}
6983
6984function addHandler (
6985 el,
6986 name,
6987 value,
6988 modifiers,
6989 important,
6990 warn,
6991 range,
6992 dynamic
6993) {
6994 modifiers = modifiers || emptyObject;
6995 // warn prevent and passive modifier
6996 /* istanbul ignore if */
6997 if (
6998 warn &&
6999 modifiers.prevent && modifiers.passive
7000 ) {
7001 warn(
7002 'passive and prevent can\'t be used together. ' +
7003 'Passive handler can\'t prevent default event.',
7004 range
7005 );
7006 }
7007
7008 // normalize click.right and click.middle since they don't actually fire
7009 // this is technically browser-specific, but at least for now browsers are
7010 // the only target envs that have right/middle clicks.
7011 if (modifiers.right) {
7012 if (dynamic) {
7013 name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
7014 } else if (name === 'click') {
7015 name = 'contextmenu';
7016 delete modifiers.right;
7017 }
7018 } else if (modifiers.middle) {
7019 if (dynamic) {
7020 name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
7021 } else if (name === 'click') {
7022 name = 'mouseup';
7023 }
7024 }
7025
7026 // check capture modifier
7027 if (modifiers.capture) {
7028 delete modifiers.capture;
7029 name = prependModifierMarker('!', name, dynamic);
7030 }
7031 if (modifiers.once) {
7032 delete modifiers.once;
7033 name = prependModifierMarker('~', name, dynamic);
7034 }
7035 /* istanbul ignore if */
7036 if (modifiers.passive) {
7037 delete modifiers.passive;
7038 name = prependModifierMarker('&', name, dynamic);
7039 }
7040
7041 var events;
7042 if (modifiers.native) {
7043 delete modifiers.native;
7044 events = el.nativeEvents || (el.nativeEvents = {});
7045 } else {
7046 events = el.events || (el.events = {});
7047 }
7048
7049 var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
7050 if (modifiers !== emptyObject) {
7051 newHandler.modifiers = modifiers;
7052 }
7053
7054 var handlers = events[name];
7055 /* istanbul ignore if */
7056 if (Array.isArray(handlers)) {
7057 important ? handlers.unshift(newHandler) : handlers.push(newHandler);
7058 } else if (handlers) {
7059 events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
7060 } else {
7061 events[name] = newHandler;
7062 }
7063
7064 el.plain = false;
7065}
7066
7067function getRawBindingAttr (
7068 el,
7069 name
7070) {
7071 return el.rawAttrsMap[':' + name] ||
7072 el.rawAttrsMap['v-bind:' + name] ||
7073 el.rawAttrsMap[name]
7074}
7075
7076function getBindingAttr (
7077 el,
7078 name,
7079 getStatic
7080) {
7081 var dynamicValue =
7082 getAndRemoveAttr(el, ':' + name) ||
7083 getAndRemoveAttr(el, 'v-bind:' + name);
7084 if (dynamicValue != null) {
7085 return parseFilters(dynamicValue)
7086 } else if (getStatic !== false) {
7087 var staticValue = getAndRemoveAttr(el, name);
7088 if (staticValue != null) {
7089 return JSON.stringify(staticValue)
7090 }
7091 }
7092}
7093
7094// note: this only removes the attr from the Array (attrsList) so that it
7095// doesn't get processed by processAttrs.
7096// By default it does NOT remove it from the map (attrsMap) because the map is
7097// needed during codegen.
7098function getAndRemoveAttr (
7099 el,
7100 name,
7101 removeFromMap
7102) {
7103 var val;
7104 if ((val = el.attrsMap[name]) != null) {
7105 var list = el.attrsList;
7106 for (var i = 0, l = list.length; i < l; i++) {
7107 if (list[i].name === name) {
7108 list.splice(i, 1);
7109 break
7110 }
7111 }
7112 }
7113 if (removeFromMap) {
7114 delete el.attrsMap[name];
7115 }
7116 return val
7117}
7118
7119function getAndRemoveAttrByRegex (
7120 el,
7121 name
7122) {
7123 var list = el.attrsList;
7124 for (var i = 0, l = list.length; i < l; i++) {
7125 var attr = list[i];
7126 if (name.test(attr.name)) {
7127 list.splice(i, 1);
7128 return attr
7129 }
7130 }
7131}
7132
7133function rangeSetItem (
7134 item,
7135 range
7136) {
7137 if (range) {
7138 if (range.start != null) {
7139 item.start = range.start;
7140 }
7141 if (range.end != null) {
7142 item.end = range.end;
7143 }
7144 }
7145 return item
7146}
7147
7148/* */
7149
7150/**
7151 * Cross-platform code generation for component v-model
7152 */
7153function genComponentModel (
7154 el,
7155 value,
7156 modifiers
7157) {
7158 var ref = modifiers || {};
7159 var number = ref.number;
7160 var trim = ref.trim;
7161
7162 var baseValueExpression = '$$v';
7163 var valueExpression = baseValueExpression;
7164 if (trim) {
7165 valueExpression =
7166 "(typeof " + baseValueExpression + " === 'string'" +
7167 "? " + baseValueExpression + ".trim()" +
7168 ": " + baseValueExpression + ")";
7169 }
7170 if (number) {
7171 valueExpression = "_n(" + valueExpression + ")";
7172 }
7173 var assignment = genAssignmentCode(value, valueExpression);
7174
7175 el.model = {
7176 value: ("(" + value + ")"),
7177 expression: JSON.stringify(value),
7178 callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
7179 };
7180}
7181
7182/**
7183 * Cross-platform codegen helper for generating v-model value assignment code.
7184 */
7185function genAssignmentCode (
7186 value,
7187 assignment
7188) {
7189 var res = parseModel(value);
7190 if (res.key === null) {
7191 return (value + "=" + assignment)
7192 } else {
7193 return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
7194 }
7195}
7196
7197/**
7198 * Parse a v-model expression into a base path and a final key segment.
7199 * Handles both dot-path and possible square brackets.
7200 *
7201 * Possible cases:
7202 *
7203 * - test
7204 * - test[key]
7205 * - test[test1[key]]
7206 * - test["a"][key]
7207 * - xxx.test[a[a].test1[key]]
7208 * - test.xxx.a["asa"][test1[key]]
7209 *
7210 */
7211
7212var len, str, chr, index$1, expressionPos, expressionEndPos;
7213
7214
7215
7216function parseModel (val) {
7217 // Fix https://github.com/vuejs/vue/pull/7730
7218 // allow v-model="obj.val " (trailing whitespace)
7219 val = val.trim();
7220 len = val.length;
7221
7222 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
7223 index$1 = val.lastIndexOf('.');
7224 if (index$1 > -1) {
7225 return {
7226 exp: val.slice(0, index$1),
7227 key: '"' + val.slice(index$1 + 1) + '"'
7228 }
7229 } else {
7230 return {
7231 exp: val,
7232 key: null
7233 }
7234 }
7235 }
7236
7237 str = val;
7238 index$1 = expressionPos = expressionEndPos = 0;
7239
7240 while (!eof()) {
7241 chr = next();
7242 /* istanbul ignore if */
7243 if (isStringStart(chr)) {
7244 parseString(chr);
7245 } else if (chr === 0x5B) {
7246 parseBracket(chr);
7247 }
7248 }
7249
7250 return {
7251 exp: val.slice(0, expressionPos),
7252 key: val.slice(expressionPos + 1, expressionEndPos)
7253 }
7254}
7255
7256function next () {
7257 return str.charCodeAt(++index$1)
7258}
7259
7260function eof () {
7261 return index$1 >= len
7262}
7263
7264function isStringStart (chr) {
7265 return chr === 0x22 || chr === 0x27
7266}
7267
7268function parseBracket (chr) {
7269 var inBracket = 1;
7270 expressionPos = index$1;
7271 while (!eof()) {
7272 chr = next();
7273 if (isStringStart(chr)) {
7274 parseString(chr);
7275 continue
7276 }
7277 if (chr === 0x5B) { inBracket++; }
7278 if (chr === 0x5D) { inBracket--; }
7279 if (inBracket === 0) {
7280 expressionEndPos = index$1;
7281 break
7282 }
7283 }
7284}
7285
7286function parseString (chr) {
7287 var stringQuote = chr;
7288 while (!eof()) {
7289 chr = next();
7290 if (chr === stringQuote) {
7291 break
7292 }
7293 }
7294}
7295
7296/* */
7297
7298var warn$1;
7299
7300// in some cases, the event used has to be determined at runtime
7301// so we used some reserved tokens during compile.
7302var RANGE_TOKEN = '__r';
7303var CHECKBOX_RADIO_TOKEN = '__c';
7304
7305function model (
7306 el,
7307 dir,
7308 _warn
7309) {
7310 warn$1 = _warn;
7311 var value = dir.value;
7312 var modifiers = dir.modifiers;
7313 var tag = el.tag;
7314 var type = el.attrsMap.type;
7315
7316 {
7317 // inputs with type="file" are read only and setting the input's
7318 // value will throw an error.
7319 if (tag === 'input' && type === 'file') {
7320 warn$1(
7321 "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
7322 "File inputs are read only. Use a v-on:change listener instead.",
7323 el.rawAttrsMap['v-model']
7324 );
7325 }
7326 }
7327
7328 if (el.component) {
7329 genComponentModel(el, value, modifiers);
7330 // component v-model doesn't need extra runtime
7331 return false
7332 } else if (tag === 'select') {
7333 genSelect(el, value, modifiers);
7334 } else if (tag === 'input' && type === 'checkbox') {
7335 genCheckboxModel(el, value, modifiers);
7336 } else if (tag === 'input' && type === 'radio') {
7337 genRadioModel(el, value, modifiers);
7338 } else if (tag === 'input' || tag === 'textarea') {
7339 genDefaultModel(el, value, modifiers);
7340 } else if (!config.isReservedTag(tag)) {
7341 genComponentModel(el, value, modifiers);
7342 // component v-model doesn't need extra runtime
7343 return false
7344 } else {
7345 warn$1(
7346 "<" + (el.tag) + " v-model=\"" + value + "\">: " +
7347 "v-model is not supported on this element type. " +
7348 'If you are working with contenteditable, it\'s recommended to ' +
7349 'wrap a library dedicated for that purpose inside a custom component.',
7350 el.rawAttrsMap['v-model']
7351 );
7352 }
7353
7354 // ensure runtime directive metadata
7355 return true
7356}
7357
7358function genCheckboxModel (
7359 el,
7360 value,
7361 modifiers
7362) {
7363 var number = modifiers && modifiers.number;
7364 var valueBinding = getBindingAttr(el, 'value') || 'null';
7365 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
7366 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
7367 addProp(el, 'checked',
7368 "Array.isArray(" + value + ")" +
7369 "?_i(" + value + "," + valueBinding + ")>-1" + (
7370 trueValueBinding === 'true'
7371 ? (":(" + value + ")")
7372 : (":_q(" + value + "," + trueValueBinding + ")")
7373 )
7374 );
7375 addHandler(el, 'change',
7376 "var $$a=" + value + "," +
7377 '$$el=$event.target,' +
7378 "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
7379 'if(Array.isArray($$a)){' +
7380 "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
7381 '$$i=_i($$a,$$v);' +
7382 "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
7383 "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
7384 "}else{" + (genAssignmentCode(value, '$$c')) + "}",
7385 null, true
7386 );
7387}
7388
7389function genRadioModel (
7390 el,
7391 value,
7392 modifiers
7393) {
7394 var number = modifiers && modifiers.number;
7395 var valueBinding = getBindingAttr(el, 'value') || 'null';
7396 valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
7397 addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
7398 addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
7399}
7400
7401function genSelect (
7402 el,
7403 value,
7404 modifiers
7405) {
7406 var number = modifiers && modifiers.number;
7407 var selectedVal = "Array.prototype.filter" +
7408 ".call($event.target.options,function(o){return o.selected})" +
7409 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
7410 "return " + (number ? '_n(val)' : 'val') + "})";
7411
7412 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
7413 var code = "var $$selectedVal = " + selectedVal + ";";
7414 code = code + " " + (genAssignmentCode(value, assignment));
7415 addHandler(el, 'change', code, null, true);
7416}
7417
7418function genDefaultModel (
7419 el,
7420 value,
7421 modifiers
7422) {
7423 var type = el.attrsMap.type;
7424
7425 // warn if v-bind:value conflicts with v-model
7426 // except for inputs with v-bind:type
7427 {
7428 var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
7429 var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
7430 if (value$1 && !typeBinding) {
7431 var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
7432 warn$1(
7433 binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
7434 'because the latter already expands to a value binding internally',
7435 el.rawAttrsMap[binding]
7436 );
7437 }
7438 }
7439
7440 var ref = modifiers || {};
7441 var lazy = ref.lazy;
7442 var number = ref.number;
7443 var trim = ref.trim;
7444 var needCompositionGuard = !lazy && type !== 'range';
7445 var event = lazy
7446 ? 'change'
7447 : type === 'range'
7448 ? RANGE_TOKEN
7449 : 'input';
7450
7451 var valueExpression = '$event.target.value';
7452 if (trim) {
7453 valueExpression = "$event.target.value.trim()";
7454 }
7455 if (number) {
7456 valueExpression = "_n(" + valueExpression + ")";
7457 }
7458
7459 var code = genAssignmentCode(value, valueExpression);
7460 if (needCompositionGuard) {
7461 code = "if($event.target.composing)return;" + code;
7462 }
7463
7464 addProp(el, 'value', ("(" + value + ")"));
7465 addHandler(el, event, code, null, true);
7466 if (trim || number) {
7467 addHandler(el, 'blur', '$forceUpdate()');
7468 }
7469}
7470
7471/* */
7472
7473// normalize v-model event tokens that can only be determined at runtime.
7474// it's important to place the event as the first in the array because
7475// the whole point is ensuring the v-model callback gets called before
7476// user-attached handlers.
7477function normalizeEvents (on) {
7478 /* istanbul ignore if */
7479 if (isDef(on[RANGE_TOKEN])) {
7480 // IE input[type=range] only supports `change` event
7481 var event = isIE ? 'change' : 'input';
7482 on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
7483 delete on[RANGE_TOKEN];
7484 }
7485 // This was originally intended to fix #4521 but no longer necessary
7486 // after 2.5. Keeping it for backwards compat with generated code from < 2.4
7487 /* istanbul ignore if */
7488 if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
7489 on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
7490 delete on[CHECKBOX_RADIO_TOKEN];
7491 }
7492}
7493
7494var target$1;
7495
7496function createOnceHandler$1 (event, handler, capture) {
7497 var _target = target$1; // save current target element in closure
7498 return function onceHandler () {
7499 var res = handler.apply(null, arguments);
7500 if (res !== null) {
7501 remove$2(event, onceHandler, capture, _target);
7502 }
7503 }
7504}
7505
7506// #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
7507// implementation and does not fire microtasks in between event propagation, so
7508// safe to exclude.
7509var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
7510
7511function add$1 (
7512 name,
7513 handler,
7514 capture,
7515 passive
7516) {
7517 // async edge case #6566: inner click event triggers patch, event handler
7518 // attached to outer element during patch, and triggered again. This
7519 // happens because browsers fire microtask ticks between event propagation.
7520 // the solution is simple: we save the timestamp when a handler is attached,
7521 // and the handler would only fire if the event passed to it was fired
7522 // AFTER it was attached.
7523 if (useMicrotaskFix) {
7524 var attachedTimestamp = currentFlushTimestamp;
7525 var original = handler;
7526 handler = original._wrapper = function (e) {
7527 if (
7528 // no bubbling, should always fire.
7529 // this is just a safety net in case event.timeStamp is unreliable in
7530 // certain weird environments...
7531 e.target === e.currentTarget ||
7532 // event is fired after handler attachment
7533 e.timeStamp >= attachedTimestamp ||
7534 // bail for environments that have buggy event.timeStamp implementations
7535 // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
7536 // #9681 QtWebEngine event.timeStamp is negative value
7537 e.timeStamp <= 0 ||
7538 // #9448 bail if event is fired in another document in a multi-page
7539 // electron/nw.js app, since event.timeStamp will be using a different
7540 // starting reference
7541 e.target.ownerDocument !== document
7542 ) {
7543 return original.apply(this, arguments)
7544 }
7545 };
7546 }
7547 target$1.addEventListener(
7548 name,
7549 handler,
7550 supportsPassive
7551 ? { capture: capture, passive: passive }
7552 : capture
7553 );
7554}
7555
7556function remove$2 (
7557 name,
7558 handler,
7559 capture,
7560 _target
7561) {
7562 (_target || target$1).removeEventListener(
7563 name,
7564 handler._wrapper || handler,
7565 capture
7566 );
7567}
7568
7569function updateDOMListeners (oldVnode, vnode) {
7570 if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
7571 return
7572 }
7573 var on = vnode.data.on || {};
7574 var oldOn = oldVnode.data.on || {};
7575 target$1 = vnode.elm;
7576 normalizeEvents(on);
7577 updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
7578 target$1 = undefined;
7579}
7580
7581var events = {
7582 create: updateDOMListeners,
7583 update: updateDOMListeners
7584};
7585
7586/* */
7587
7588var svgContainer;
7589
7590function updateDOMProps (oldVnode, vnode) {
7591 if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
7592 return
7593 }
7594 var key, cur;
7595 var elm = vnode.elm;
7596 var oldProps = oldVnode.data.domProps || {};
7597 var props = vnode.data.domProps || {};
7598 // clone observed objects, as the user probably wants to mutate it
7599 if (isDef(props.__ob__)) {
7600 props = vnode.data.domProps = extend({}, props);
7601 }
7602
7603 for (key in oldProps) {
7604 if (!(key in props)) {
7605 elm[key] = '';
7606 }
7607 }
7608
7609 for (key in props) {
7610 cur = props[key];
7611 // ignore children if the node has textContent or innerHTML,
7612 // as these will throw away existing DOM nodes and cause removal errors
7613 // on subsequent patches (#3360)
7614 if (key === 'textContent' || key === 'innerHTML') {
7615 if (vnode.children) { vnode.children.length = 0; }
7616 if (cur === oldProps[key]) { continue }
7617 // #6601 work around Chrome version <= 55 bug where single textNode
7618 // replaced by innerHTML/textContent retains its parentNode property
7619 if (elm.childNodes.length === 1) {
7620 elm.removeChild(elm.childNodes[0]);
7621 }
7622 }
7623
7624 if (key === 'value' && elm.tagName !== 'PROGRESS') {
7625 // store value as _value as well since
7626 // non-string values will be stringified
7627 elm._value = cur;
7628 // avoid resetting cursor position when value is the same
7629 var strCur = isUndef(cur) ? '' : String(cur);
7630 if (shouldUpdateValue(elm, strCur)) {
7631 elm.value = strCur;
7632 }
7633 } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
7634 // IE doesn't support innerHTML for SVG elements
7635 svgContainer = svgContainer || document.createElement('div');
7636 svgContainer.innerHTML = "<svg>" + cur + "</svg>";
7637 var svg = svgContainer.firstChild;
7638 while (elm.firstChild) {
7639 elm.removeChild(elm.firstChild);
7640 }
7641 while (svg.firstChild) {
7642 elm.appendChild(svg.firstChild);
7643 }
7644 } else if (
7645 // skip the update if old and new VDOM state is the same.
7646 // `value` is handled separately because the DOM value may be temporarily
7647 // out of sync with VDOM state due to focus, composition and modifiers.
7648 // This #4521 by skipping the unnecessary `checked` update.
7649 cur !== oldProps[key]
7650 ) {
7651 // some property updates can throw
7652 // e.g. `value` on <progress> w/ non-finite value
7653 try {
7654 elm[key] = cur;
7655 } catch (e) {}
7656 }
7657 }
7658}
7659
7660// check platforms/web/util/attrs.js acceptValue
7661
7662
7663function shouldUpdateValue (elm, checkVal) {
7664 return (!elm.composing && (
7665 elm.tagName === 'OPTION' ||
7666 isNotInFocusAndDirty(elm, checkVal) ||
7667 isDirtyWithModifiers(elm, checkVal)
7668 ))
7669}
7670
7671function isNotInFocusAndDirty (elm, checkVal) {
7672 // return true when textbox (.number and .trim) loses focus and its value is
7673 // not equal to the updated value
7674 var notInFocus = true;
7675 // #6157
7676 // work around IE bug when accessing document.activeElement in an iframe
7677 try { notInFocus = document.activeElement !== elm; } catch (e) {}
7678 return notInFocus && elm.value !== checkVal
7679}
7680
7681function isDirtyWithModifiers (elm, newVal) {
7682 var value = elm.value;
7683 var modifiers = elm._vModifiers; // injected by v-model runtime
7684 if (isDef(modifiers)) {
7685 if (modifiers.number) {
7686 return toNumber(value) !== toNumber(newVal)
7687 }
7688 if (modifiers.trim) {
7689 return value.trim() !== newVal.trim()
7690 }
7691 }
7692 return value !== newVal
7693}
7694
7695var domProps = {
7696 create: updateDOMProps,
7697 update: updateDOMProps
7698};
7699
7700/* */
7701
7702var parseStyleText = cached(function (cssText) {
7703 var res = {};
7704 var listDelimiter = /;(?![^(]*\))/g;
7705 var propertyDelimiter = /:(.+)/;
7706 cssText.split(listDelimiter).forEach(function (item) {
7707 if (item) {
7708 var tmp = item.split(propertyDelimiter);
7709 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
7710 }
7711 });
7712 return res
7713});
7714
7715// merge static and dynamic style data on the same vnode
7716function normalizeStyleData (data) {
7717 var style = normalizeStyleBinding(data.style);
7718 // static style is pre-processed into an object during compilation
7719 // and is always a fresh object, so it's safe to merge into it
7720 return data.staticStyle
7721 ? extend(data.staticStyle, style)
7722 : style
7723}
7724
7725// normalize possible array / string values into Object
7726function normalizeStyleBinding (bindingStyle) {
7727 if (Array.isArray(bindingStyle)) {
7728 return toObject(bindingStyle)
7729 }
7730 if (typeof bindingStyle === 'string') {
7731 return parseStyleText(bindingStyle)
7732 }
7733 return bindingStyle
7734}
7735
7736/**
7737 * parent component style should be after child's
7738 * so that parent component's style could override it
7739 */
7740function getStyle (vnode, checkChild) {
7741 var res = {};
7742 var styleData;
7743
7744 if (checkChild) {
7745 var childNode = vnode;
7746 while (childNode.componentInstance) {
7747 childNode = childNode.componentInstance._vnode;
7748 if (
7749 childNode && childNode.data &&
7750 (styleData = normalizeStyleData(childNode.data))
7751 ) {
7752 extend(res, styleData);
7753 }
7754 }
7755 }
7756
7757 if ((styleData = normalizeStyleData(vnode.data))) {
7758 extend(res, styleData);
7759 }
7760
7761 var parentNode = vnode;
7762 while ((parentNode = parentNode.parent)) {
7763 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
7764 extend(res, styleData);
7765 }
7766 }
7767 return res
7768}
7769
7770/* */
7771
7772var cssVarRE = /^--/;
7773var importantRE = /\s*!important$/;
7774var setProp = function (el, name, val) {
7775 /* istanbul ignore if */
7776 if (cssVarRE.test(name)) {
7777 el.style.setProperty(name, val);
7778 } else if (importantRE.test(val)) {
7779 el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
7780 } else {
7781 var normalizedName = normalize(name);
7782 if (Array.isArray(val)) {
7783 // Support values array created by autoprefixer, e.g.
7784 // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
7785 // Set them one by one, and the browser will only set those it can recognize
7786 for (var i = 0, len = val.length; i < len; i++) {
7787 el.style[normalizedName] = val[i];
7788 }
7789 } else {
7790 el.style[normalizedName] = val;
7791 }
7792 }
7793};
7794
7795var vendorNames = ['Webkit', 'Moz', 'ms'];
7796
7797var emptyStyle;
7798var normalize = cached(function (prop) {
7799 emptyStyle = emptyStyle || document.createElement('div').style;
7800 prop = camelize(prop);
7801 if (prop !== 'filter' && (prop in emptyStyle)) {
7802 return prop
7803 }
7804 var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
7805 for (var i = 0; i < vendorNames.length; i++) {
7806 var name = vendorNames[i] + capName;
7807 if (name in emptyStyle) {
7808 return name
7809 }
7810 }
7811});
7812
7813function updateStyle (oldVnode, vnode) {
7814 var data = vnode.data;
7815 var oldData = oldVnode.data;
7816
7817 if (isUndef(data.staticStyle) && isUndef(data.style) &&
7818 isUndef(oldData.staticStyle) && isUndef(oldData.style)
7819 ) {
7820 return
7821 }
7822
7823 var cur, name;
7824 var el = vnode.elm;
7825 var oldStaticStyle = oldData.staticStyle;
7826 var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
7827
7828 // if static style exists, stylebinding already merged into it when doing normalizeStyleData
7829 var oldStyle = oldStaticStyle || oldStyleBinding;
7830
7831 var style = normalizeStyleBinding(vnode.data.style) || {};
7832
7833 // store normalized style under a different key for next diff
7834 // make sure to clone it if it's reactive, since the user likely wants
7835 // to mutate it.
7836 vnode.data.normalizedStyle = isDef(style.__ob__)
7837 ? extend({}, style)
7838 : style;
7839
7840 var newStyle = getStyle(vnode, true);
7841
7842 for (name in oldStyle) {
7843 if (isUndef(newStyle[name])) {
7844 setProp(el, name, '');
7845 }
7846 }
7847 for (name in newStyle) {
7848 cur = newStyle[name];
7849 if (cur !== oldStyle[name]) {
7850 // ie9 setting to null has no effect, must use empty string
7851 setProp(el, name, cur == null ? '' : cur);
7852 }
7853 }
7854}
7855
7856var style = {
7857 create: updateStyle,
7858 update: updateStyle
7859};
7860
7861/* */
7862
7863var whitespaceRE = /\s+/;
7864
7865/**
7866 * Add class with compatibility for SVG since classList is not supported on
7867 * SVG elements in IE
7868 */
7869function addClass (el, cls) {
7870 /* istanbul ignore if */
7871 if (!cls || !(cls = cls.trim())) {
7872 return
7873 }
7874
7875 /* istanbul ignore else */
7876 if (el.classList) {
7877 if (cls.indexOf(' ') > -1) {
7878 cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
7879 } else {
7880 el.classList.add(cls);
7881 }
7882 } else {
7883 var cur = " " + (el.getAttribute('class') || '') + " ";
7884 if (cur.indexOf(' ' + cls + ' ') < 0) {
7885 el.setAttribute('class', (cur + cls).trim());
7886 }
7887 }
7888}
7889
7890/**
7891 * Remove class with compatibility for SVG since classList is not supported on
7892 * SVG elements in IE
7893 */
7894function removeClass (el, cls) {
7895 /* istanbul ignore if */
7896 if (!cls || !(cls = cls.trim())) {
7897 return
7898 }
7899
7900 /* istanbul ignore else */
7901 if (el.classList) {
7902 if (cls.indexOf(' ') > -1) {
7903 cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
7904 } else {
7905 el.classList.remove(cls);
7906 }
7907 if (!el.classList.length) {
7908 el.removeAttribute('class');
7909 }
7910 } else {
7911 var cur = " " + (el.getAttribute('class') || '') + " ";
7912 var tar = ' ' + cls + ' ';
7913 while (cur.indexOf(tar) >= 0) {
7914 cur = cur.replace(tar, ' ');
7915 }
7916 cur = cur.trim();
7917 if (cur) {
7918 el.setAttribute('class', cur);
7919 } else {
7920 el.removeAttribute('class');
7921 }
7922 }
7923}
7924
7925/* */
7926
7927function resolveTransition (def$$1) {
7928 if (!def$$1) {
7929 return
7930 }
7931 /* istanbul ignore else */
7932 if (typeof def$$1 === 'object') {
7933 var res = {};
7934 if (def$$1.css !== false) {
7935 extend(res, autoCssTransition(def$$1.name || 'v'));
7936 }
7937 extend(res, def$$1);
7938 return res
7939 } else if (typeof def$$1 === 'string') {
7940 return autoCssTransition(def$$1)
7941 }
7942}
7943
7944var autoCssTransition = cached(function (name) {
7945 return {
7946 enterClass: (name + "-enter"),
7947 enterToClass: (name + "-enter-to"),
7948 enterActiveClass: (name + "-enter-active"),
7949 leaveClass: (name + "-leave"),
7950 leaveToClass: (name + "-leave-to"),
7951 leaveActiveClass: (name + "-leave-active")
7952 }
7953});
7954
7955var hasTransition = inBrowser && !isIE9;
7956var TRANSITION = 'transition';
7957var ANIMATION = 'animation';
7958
7959// Transition property/event sniffing
7960var transitionProp = 'transition';
7961var transitionEndEvent = 'transitionend';
7962var animationProp = 'animation';
7963var animationEndEvent = 'animationend';
7964if (hasTransition) {
7965 /* istanbul ignore if */
7966 if (window.ontransitionend === undefined &&
7967 window.onwebkittransitionend !== undefined
7968 ) {
7969 transitionProp = 'WebkitTransition';
7970 transitionEndEvent = 'webkitTransitionEnd';
7971 }
7972 if (window.onanimationend === undefined &&
7973 window.onwebkitanimationend !== undefined
7974 ) {
7975 animationProp = 'WebkitAnimation';
7976 animationEndEvent = 'webkitAnimationEnd';
7977 }
7978}
7979
7980// binding to window is necessary to make hot reload work in IE in strict mode
7981var raf = inBrowser
7982 ? window.requestAnimationFrame
7983 ? window.requestAnimationFrame.bind(window)
7984 : setTimeout
7985 : /* istanbul ignore next */ function (fn) { return fn(); };
7986
7987function nextFrame (fn) {
7988 raf(function () {
7989 raf(fn);
7990 });
7991}
7992
7993function addTransitionClass (el, cls) {
7994 var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
7995 if (transitionClasses.indexOf(cls) < 0) {
7996 transitionClasses.push(cls);
7997 addClass(el, cls);
7998 }
7999}
8000
8001function removeTransitionClass (el, cls) {
8002 if (el._transitionClasses) {
8003 remove(el._transitionClasses, cls);
8004 }
8005 removeClass(el, cls);
8006}
8007
8008function whenTransitionEnds (
8009 el,
8010 expectedType,
8011 cb
8012) {
8013 var ref = getTransitionInfo(el, expectedType);
8014 var type = ref.type;
8015 var timeout = ref.timeout;
8016 var propCount = ref.propCount;
8017 if (!type) { return cb() }
8018 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
8019 var ended = 0;
8020 var end = function () {
8021 el.removeEventListener(event, onEnd);
8022 cb();
8023 };
8024 var onEnd = function (e) {
8025 if (e.target === el) {
8026 if (++ended >= propCount) {
8027 end();
8028 }
8029 }
8030 };
8031 setTimeout(function () {
8032 if (ended < propCount) {
8033 end();
8034 }
8035 }, timeout + 1);
8036 el.addEventListener(event, onEnd);
8037}
8038
8039var transformRE = /\b(transform|all)(,|$)/;
8040
8041function getTransitionInfo (el, expectedType) {
8042 var styles = window.getComputedStyle(el);
8043 // JSDOM may return undefined for transition properties
8044 var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
8045 var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
8046 var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
8047 var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
8048 var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
8049 var animationTimeout = getTimeout(animationDelays, animationDurations);
8050
8051 var type;
8052 var timeout = 0;
8053 var propCount = 0;
8054 /* istanbul ignore if */
8055 if (expectedType === TRANSITION) {
8056 if (transitionTimeout > 0) {
8057 type = TRANSITION;
8058 timeout = transitionTimeout;
8059 propCount = transitionDurations.length;
8060 }
8061 } else if (expectedType === ANIMATION) {
8062 if (animationTimeout > 0) {
8063 type = ANIMATION;
8064 timeout = animationTimeout;
8065 propCount = animationDurations.length;
8066 }
8067 } else {
8068 timeout = Math.max(transitionTimeout, animationTimeout);
8069 type = timeout > 0
8070 ? transitionTimeout > animationTimeout
8071 ? TRANSITION
8072 : ANIMATION
8073 : null;
8074 propCount = type
8075 ? type === TRANSITION
8076 ? transitionDurations.length
8077 : animationDurations.length
8078 : 0;
8079 }
8080 var hasTransform =
8081 type === TRANSITION &&
8082 transformRE.test(styles[transitionProp + 'Property']);
8083 return {
8084 type: type,
8085 timeout: timeout,
8086 propCount: propCount,
8087 hasTransform: hasTransform
8088 }
8089}
8090
8091function getTimeout (delays, durations) {
8092 /* istanbul ignore next */
8093 while (delays.length < durations.length) {
8094 delays = delays.concat(delays);
8095 }
8096
8097 return Math.max.apply(null, durations.map(function (d, i) {
8098 return toMs(d) + toMs(delays[i])
8099 }))
8100}
8101
8102// Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
8103// in a locale-dependent way, using a comma instead of a dot.
8104// If comma is not replaced with a dot, the input will be rounded down (i.e. acting
8105// as a floor function) causing unexpected behaviors
8106function toMs (s) {
8107 return Number(s.slice(0, -1).replace(',', '.')) * 1000
8108}
8109
8110/* */
8111
8112function enter (vnode, toggleDisplay) {
8113 var el = vnode.elm;
8114
8115 // call leave callback now
8116 if (isDef(el._leaveCb)) {
8117 el._leaveCb.cancelled = true;
8118 el._leaveCb();
8119 }
8120
8121 var data = resolveTransition(vnode.data.transition);
8122 if (isUndef(data)) {
8123 return
8124 }
8125
8126 /* istanbul ignore if */
8127 if (isDef(el._enterCb) || el.nodeType !== 1) {
8128 return
8129 }
8130
8131 var css = data.css;
8132 var type = data.type;
8133 var enterClass = data.enterClass;
8134 var enterToClass = data.enterToClass;
8135 var enterActiveClass = data.enterActiveClass;
8136 var appearClass = data.appearClass;
8137 var appearToClass = data.appearToClass;
8138 var appearActiveClass = data.appearActiveClass;
8139 var beforeEnter = data.beforeEnter;
8140 var enter = data.enter;
8141 var afterEnter = data.afterEnter;
8142 var enterCancelled = data.enterCancelled;
8143 var beforeAppear = data.beforeAppear;
8144 var appear = data.appear;
8145 var afterAppear = data.afterAppear;
8146 var appearCancelled = data.appearCancelled;
8147 var duration = data.duration;
8148
8149 // activeInstance will always be the <transition> component managing this
8150 // transition. One edge case to check is when the <transition> is placed
8151 // as the root node of a child component. In that case we need to check
8152 // <transition>'s parent for appear check.
8153 var context = activeInstance;
8154 var transitionNode = activeInstance.$vnode;
8155 while (transitionNode && transitionNode.parent) {
8156 context = transitionNode.context;
8157 transitionNode = transitionNode.parent;
8158 }
8159
8160 var isAppear = !context._isMounted || !vnode.isRootInsert;
8161
8162 if (isAppear && !appear && appear !== '') {
8163 return
8164 }
8165
8166 var startClass = isAppear && appearClass
8167 ? appearClass
8168 : enterClass;
8169 var activeClass = isAppear && appearActiveClass
8170 ? appearActiveClass
8171 : enterActiveClass;
8172 var toClass = isAppear && appearToClass
8173 ? appearToClass
8174 : enterToClass;
8175
8176 var beforeEnterHook = isAppear
8177 ? (beforeAppear || beforeEnter)
8178 : beforeEnter;
8179 var enterHook = isAppear
8180 ? (typeof appear === 'function' ? appear : enter)
8181 : enter;
8182 var afterEnterHook = isAppear
8183 ? (afterAppear || afterEnter)
8184 : afterEnter;
8185 var enterCancelledHook = isAppear
8186 ? (appearCancelled || enterCancelled)
8187 : enterCancelled;
8188
8189 var explicitEnterDuration = toNumber(
8190 isObject(duration)
8191 ? duration.enter
8192 : duration
8193 );
8194
8195 if (explicitEnterDuration != null) {
8196 checkDuration(explicitEnterDuration, 'enter', vnode);
8197 }
8198
8199 var expectsCSS = css !== false && !isIE9;
8200 var userWantsControl = getHookArgumentsLength(enterHook);
8201
8202 var cb = el._enterCb = once(function () {
8203 if (expectsCSS) {
8204 removeTransitionClass(el, toClass);
8205 removeTransitionClass(el, activeClass);
8206 }
8207 if (cb.cancelled) {
8208 if (expectsCSS) {
8209 removeTransitionClass(el, startClass);
8210 }
8211 enterCancelledHook && enterCancelledHook(el);
8212 } else {
8213 afterEnterHook && afterEnterHook(el);
8214 }
8215 el._enterCb = null;
8216 });
8217
8218 if (!vnode.data.show) {
8219 // remove pending leave element on enter by injecting an insert hook
8220 mergeVNodeHook(vnode, 'insert', function () {
8221 var parent = el.parentNode;
8222 var pendingNode = parent && parent._pending && parent._pending[vnode.key];
8223 if (pendingNode &&
8224 pendingNode.tag === vnode.tag &&
8225 pendingNode.elm._leaveCb
8226 ) {
8227 pendingNode.elm._leaveCb();
8228 }
8229 enterHook && enterHook(el, cb);
8230 });
8231 }
8232
8233 // start enter transition
8234 beforeEnterHook && beforeEnterHook(el);
8235 if (expectsCSS) {
8236 addTransitionClass(el, startClass);
8237 addTransitionClass(el, activeClass);
8238 nextFrame(function () {
8239 removeTransitionClass(el, startClass);
8240 if (!cb.cancelled) {
8241 addTransitionClass(el, toClass);
8242 if (!userWantsControl) {
8243 if (isValidDuration(explicitEnterDuration)) {
8244 setTimeout(cb, explicitEnterDuration);
8245 } else {
8246 whenTransitionEnds(el, type, cb);
8247 }
8248 }
8249 }
8250 });
8251 }
8252
8253 if (vnode.data.show) {
8254 toggleDisplay && toggleDisplay();
8255 enterHook && enterHook(el, cb);
8256 }
8257
8258 if (!expectsCSS && !userWantsControl) {
8259 cb();
8260 }
8261}
8262
8263function leave (vnode, rm) {
8264 var el = vnode.elm;
8265
8266 // call enter callback now
8267 if (isDef(el._enterCb)) {
8268 el._enterCb.cancelled = true;
8269 el._enterCb();
8270 }
8271
8272 var data = resolveTransition(vnode.data.transition);
8273 if (isUndef(data) || el.nodeType !== 1) {
8274 return rm()
8275 }
8276
8277 /* istanbul ignore if */
8278 if (isDef(el._leaveCb)) {
8279 return
8280 }
8281
8282 var css = data.css;
8283 var type = data.type;
8284 var leaveClass = data.leaveClass;
8285 var leaveToClass = data.leaveToClass;
8286 var leaveActiveClass = data.leaveActiveClass;
8287 var beforeLeave = data.beforeLeave;
8288 var leave = data.leave;
8289 var afterLeave = data.afterLeave;
8290 var leaveCancelled = data.leaveCancelled;
8291 var delayLeave = data.delayLeave;
8292 var duration = data.duration;
8293
8294 var expectsCSS = css !== false && !isIE9;
8295 var userWantsControl = getHookArgumentsLength(leave);
8296
8297 var explicitLeaveDuration = toNumber(
8298 isObject(duration)
8299 ? duration.leave
8300 : duration
8301 );
8302
8303 if (isDef(explicitLeaveDuration)) {
8304 checkDuration(explicitLeaveDuration, 'leave', vnode);
8305 }
8306
8307 var cb = el._leaveCb = once(function () {
8308 if (el.parentNode && el.parentNode._pending) {
8309 el.parentNode._pending[vnode.key] = null;
8310 }
8311 if (expectsCSS) {
8312 removeTransitionClass(el, leaveToClass);
8313 removeTransitionClass(el, leaveActiveClass);
8314 }
8315 if (cb.cancelled) {
8316 if (expectsCSS) {
8317 removeTransitionClass(el, leaveClass);
8318 }
8319 leaveCancelled && leaveCancelled(el);
8320 } else {
8321 rm();
8322 afterLeave && afterLeave(el);
8323 }
8324 el._leaveCb = null;
8325 });
8326
8327 if (delayLeave) {
8328 delayLeave(performLeave);
8329 } else {
8330 performLeave();
8331 }
8332
8333 function performLeave () {
8334 // the delayed leave may have already been cancelled
8335 if (cb.cancelled) {
8336 return
8337 }
8338 // record leaving element
8339 if (!vnode.data.show && el.parentNode) {
8340 (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
8341 }
8342 beforeLeave && beforeLeave(el);
8343 if (expectsCSS) {
8344 addTransitionClass(el, leaveClass);
8345 addTransitionClass(el, leaveActiveClass);
8346 nextFrame(function () {
8347 removeTransitionClass(el, leaveClass);
8348 if (!cb.cancelled) {
8349 addTransitionClass(el, leaveToClass);
8350 if (!userWantsControl) {
8351 if (isValidDuration(explicitLeaveDuration)) {
8352 setTimeout(cb, explicitLeaveDuration);
8353 } else {
8354 whenTransitionEnds(el, type, cb);
8355 }
8356 }
8357 }
8358 });
8359 }
8360 leave && leave(el, cb);
8361 if (!expectsCSS && !userWantsControl) {
8362 cb();
8363 }
8364 }
8365}
8366
8367// only used in dev mode
8368function checkDuration (val, name, vnode) {
8369 if (typeof val !== 'number') {
8370 warn(
8371 "<transition> explicit " + name + " duration is not a valid number - " +
8372 "got " + (JSON.stringify(val)) + ".",
8373 vnode.context
8374 );
8375 } else if (isNaN(val)) {
8376 warn(
8377 "<transition> explicit " + name + " duration is NaN - " +
8378 'the duration expression might be incorrect.',
8379 vnode.context
8380 );
8381 }
8382}
8383
8384function isValidDuration (val) {
8385 return typeof val === 'number' && !isNaN(val)
8386}
8387
8388/**
8389 * Normalize a transition hook's argument length. The hook may be:
8390 * - a merged hook (invoker) with the original in .fns
8391 * - a wrapped component method (check ._length)
8392 * - a plain function (.length)
8393 */
8394function getHookArgumentsLength (fn) {
8395 if (isUndef(fn)) {
8396 return false
8397 }
8398 var invokerFns = fn.fns;
8399 if (isDef(invokerFns)) {
8400 // invoker
8401 return getHookArgumentsLength(
8402 Array.isArray(invokerFns)
8403 ? invokerFns[0]
8404 : invokerFns
8405 )
8406 } else {
8407 return (fn._length || fn.length) > 1
8408 }
8409}
8410
8411function _enter (_, vnode) {
8412 if (vnode.data.show !== true) {
8413 enter(vnode);
8414 }
8415}
8416
8417var transition = inBrowser ? {
8418 create: _enter,
8419 activate: _enter,
8420 remove: function remove$$1 (vnode, rm) {
8421 /* istanbul ignore else */
8422 if (vnode.data.show !== true) {
8423 leave(vnode, rm);
8424 } else {
8425 rm();
8426 }
8427 }
8428} : {};
8429
8430var platformModules = [
8431 attrs,
8432 klass,
8433 events,
8434 domProps,
8435 style,
8436 transition
8437];
8438
8439/* */
8440
8441// the directive module should be applied last, after all
8442// built-in modules have been applied.
8443var modules = platformModules.concat(baseModules);
8444
8445var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
8446
8447/**
8448 * Not type checking this file because flow doesn't like attaching
8449 * properties to Elements.
8450 */
8451
8452/* istanbul ignore if */
8453if (isIE9) {
8454 // http://www.matts411.com/post/internet-explorer-9-oninput/
8455 document.addEventListener('selectionchange', function () {
8456 var el = document.activeElement;
8457 if (el && el.vmodel) {
8458 trigger(el, 'input');
8459 }
8460 });
8461}
8462
8463var directive = {
8464 inserted: function inserted (el, binding, vnode, oldVnode) {
8465 if (vnode.tag === 'select') {
8466 // #6903
8467 if (oldVnode.elm && !oldVnode.elm._vOptions) {
8468 mergeVNodeHook(vnode, 'postpatch', function () {
8469 directive.componentUpdated(el, binding, vnode);
8470 });
8471 } else {
8472 setSelected(el, binding, vnode.context);
8473 }
8474 el._vOptions = [].map.call(el.options, getValue);
8475 } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
8476 el._vModifiers = binding.modifiers;
8477 if (!binding.modifiers.lazy) {
8478 el.addEventListener('compositionstart', onCompositionStart);
8479 el.addEventListener('compositionend', onCompositionEnd);
8480 // Safari < 10.2 & UIWebView doesn't fire compositionend when
8481 // switching focus before confirming composition choice
8482 // this also fixes the issue where some browsers e.g. iOS Chrome
8483 // fires "change" instead of "input" on autocomplete.
8484 el.addEventListener('change', onCompositionEnd);
8485 /* istanbul ignore if */
8486 if (isIE9) {
8487 el.vmodel = true;
8488 }
8489 }
8490 }
8491 },
8492
8493 componentUpdated: function componentUpdated (el, binding, vnode) {
8494 if (vnode.tag === 'select') {
8495 setSelected(el, binding, vnode.context);
8496 // in case the options rendered by v-for have changed,
8497 // it's possible that the value is out-of-sync with the rendered options.
8498 // detect such cases and filter out values that no longer has a matching
8499 // option in the DOM.
8500 var prevOptions = el._vOptions;
8501 var curOptions = el._vOptions = [].map.call(el.options, getValue);
8502 if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
8503 // trigger change event if
8504 // no matching option found for at least one value
8505 var needReset = el.multiple
8506 ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
8507 : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
8508 if (needReset) {
8509 trigger(el, 'change');
8510 }
8511 }
8512 }
8513 }
8514};
8515
8516function setSelected (el, binding, vm) {
8517 actuallySetSelected(el, binding, vm);
8518 /* istanbul ignore if */
8519 if (isIE || isEdge) {
8520 setTimeout(function () {
8521 actuallySetSelected(el, binding, vm);
8522 }, 0);
8523 }
8524}
8525
8526function actuallySetSelected (el, binding, vm) {
8527 var value = binding.value;
8528 var isMultiple = el.multiple;
8529 if (isMultiple && !Array.isArray(value)) {
8530 warn(
8531 "<select multiple v-model=\"" + (binding.expression) + "\"> " +
8532 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
8533 vm
8534 );
8535 return
8536 }
8537 var selected, option;
8538 for (var i = 0, l = el.options.length; i < l; i++) {
8539 option = el.options[i];
8540 if (isMultiple) {
8541 selected = looseIndexOf(value, getValue(option)) > -1;
8542 if (option.selected !== selected) {
8543 option.selected = selected;
8544 }
8545 } else {
8546 if (looseEqual(getValue(option), value)) {
8547 if (el.selectedIndex !== i) {
8548 el.selectedIndex = i;
8549 }
8550 return
8551 }
8552 }
8553 }
8554 if (!isMultiple) {
8555 el.selectedIndex = -1;
8556 }
8557}
8558
8559function hasNoMatchingOption (value, options) {
8560 return options.every(function (o) { return !looseEqual(o, value); })
8561}
8562
8563function getValue (option) {
8564 return '_value' in option
8565 ? option._value
8566 : option.value
8567}
8568
8569function onCompositionStart (e) {
8570 e.target.composing = true;
8571}
8572
8573function onCompositionEnd (e) {
8574 // prevent triggering an input event for no reason
8575 if (!e.target.composing) { return }
8576 e.target.composing = false;
8577 trigger(e.target, 'input');
8578}
8579
8580function trigger (el, type) {
8581 var e = document.createEvent('HTMLEvents');
8582 e.initEvent(type, true, true);
8583 el.dispatchEvent(e);
8584}
8585
8586/* */
8587
8588// recursively search for possible transition defined inside the component root
8589function locateNode (vnode) {
8590 return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
8591 ? locateNode(vnode.componentInstance._vnode)
8592 : vnode
8593}
8594
8595var show = {
8596 bind: function bind (el, ref, vnode) {
8597 var value = ref.value;
8598
8599 vnode = locateNode(vnode);
8600 var transition$$1 = vnode.data && vnode.data.transition;
8601 var originalDisplay = el.__vOriginalDisplay =
8602 el.style.display === 'none' ? '' : el.style.display;
8603 if (value && transition$$1) {
8604 vnode.data.show = true;
8605 enter(vnode, function () {
8606 el.style.display = originalDisplay;
8607 });
8608 } else {
8609 el.style.display = value ? originalDisplay : 'none';
8610 }
8611 },
8612
8613 update: function update (el, ref, vnode) {
8614 var value = ref.value;
8615 var oldValue = ref.oldValue;
8616
8617 /* istanbul ignore if */
8618 if (!value === !oldValue) { return }
8619 vnode = locateNode(vnode);
8620 var transition$$1 = vnode.data && vnode.data.transition;
8621 if (transition$$1) {
8622 vnode.data.show = true;
8623 if (value) {
8624 enter(vnode, function () {
8625 el.style.display = el.__vOriginalDisplay;
8626 });
8627 } else {
8628 leave(vnode, function () {
8629 el.style.display = 'none';
8630 });
8631 }
8632 } else {
8633 el.style.display = value ? el.__vOriginalDisplay : 'none';
8634 }
8635 },
8636
8637 unbind: function unbind (
8638 el,
8639 binding,
8640 vnode,
8641 oldVnode,
8642 isDestroy
8643 ) {
8644 if (!isDestroy) {
8645 el.style.display = el.__vOriginalDisplay;
8646 }
8647 }
8648};
8649
8650var platformDirectives = {
8651 model: directive,
8652 show: show
8653};
8654
8655/* */
8656
8657var transitionProps = {
8658 name: String,
8659 appear: Boolean,
8660 css: Boolean,
8661 mode: String,
8662 type: String,
8663 enterClass: String,
8664 leaveClass: String,
8665 enterToClass: String,
8666 leaveToClass: String,
8667 enterActiveClass: String,
8668 leaveActiveClass: String,
8669 appearClass: String,
8670 appearActiveClass: String,
8671 appearToClass: String,
8672 duration: [Number, String, Object]
8673};
8674
8675// in case the child is also an abstract component, e.g. <keep-alive>
8676// we want to recursively retrieve the real component to be rendered
8677function getRealChild (vnode) {
8678 var compOptions = vnode && vnode.componentOptions;
8679 if (compOptions && compOptions.Ctor.options.abstract) {
8680 return getRealChild(getFirstComponentChild(compOptions.children))
8681 } else {
8682 return vnode
8683 }
8684}
8685
8686function extractTransitionData (comp) {
8687 var data = {};
8688 var options = comp.$options;
8689 // props
8690 for (var key in options.propsData) {
8691 data[key] = comp[key];
8692 }
8693 // events.
8694 // extract listeners and pass them directly to the transition methods
8695 var listeners = options._parentListeners;
8696 for (var key$1 in listeners) {
8697 data[camelize(key$1)] = listeners[key$1];
8698 }
8699 return data
8700}
8701
8702function placeholder (h, rawChild) {
8703 if (/\d-keep-alive$/.test(rawChild.tag)) {
8704 return h('keep-alive', {
8705 props: rawChild.componentOptions.propsData
8706 })
8707 }
8708}
8709
8710function hasParentTransition (vnode) {
8711 while ((vnode = vnode.parent)) {
8712 if (vnode.data.transition) {
8713 return true
8714 }
8715 }
8716}
8717
8718function isSameChild (child, oldChild) {
8719 return oldChild.key === child.key && oldChild.tag === child.tag
8720}
8721
8722var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
8723
8724var isVShowDirective = function (d) { return d.name === 'show'; };
8725
8726var Transition = {
8727 name: 'transition',
8728 props: transitionProps,
8729 abstract: true,
8730
8731 render: function render (h) {
8732 var this$1 = this;
8733
8734 var children = this.$slots.default;
8735 if (!children) {
8736 return
8737 }
8738
8739 // filter out text nodes (possible whitespaces)
8740 children = children.filter(isNotTextNode);
8741 /* istanbul ignore if */
8742 if (!children.length) {
8743 return
8744 }
8745
8746 // warn multiple elements
8747 if (children.length > 1) {
8748 warn(
8749 '<transition> can only be used on a single element. Use ' +
8750 '<transition-group> for lists.',
8751 this.$parent
8752 );
8753 }
8754
8755 var mode = this.mode;
8756
8757 // warn invalid mode
8758 if (mode && mode !== 'in-out' && mode !== 'out-in'
8759 ) {
8760 warn(
8761 'invalid <transition> mode: ' + mode,
8762 this.$parent
8763 );
8764 }
8765
8766 var rawChild = children[0];
8767
8768 // if this is a component root node and the component's
8769 // parent container node also has transition, skip.
8770 if (hasParentTransition(this.$vnode)) {
8771 return rawChild
8772 }
8773
8774 // apply transition data to child
8775 // use getRealChild() to ignore abstract components e.g. keep-alive
8776 var child = getRealChild(rawChild);
8777 /* istanbul ignore if */
8778 if (!child) {
8779 return rawChild
8780 }
8781
8782 if (this._leaving) {
8783 return placeholder(h, rawChild)
8784 }
8785
8786 // ensure a key that is unique to the vnode type and to this transition
8787 // component instance. This key will be used to remove pending leaving nodes
8788 // during entering.
8789 var id = "__transition-" + (this._uid) + "-";
8790 child.key = child.key == null
8791 ? child.isComment
8792 ? id + 'comment'
8793 : id + child.tag
8794 : isPrimitive(child.key)
8795 ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
8796 : child.key;
8797
8798 var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
8799 var oldRawChild = this._vnode;
8800 var oldChild = getRealChild(oldRawChild);
8801
8802 // mark v-show
8803 // so that the transition module can hand over the control to the directive
8804 if (child.data.directives && child.data.directives.some(isVShowDirective)) {
8805 child.data.show = true;
8806 }
8807
8808 if (
8809 oldChild &&
8810 oldChild.data &&
8811 !isSameChild(child, oldChild) &&
8812 !isAsyncPlaceholder(oldChild) &&
8813 // #6687 component root is a comment node
8814 !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
8815 ) {
8816 // replace old child transition data with fresh one
8817 // important for dynamic transitions!
8818 var oldData = oldChild.data.transition = extend({}, data);
8819 // handle transition mode
8820 if (mode === 'out-in') {
8821 // return placeholder node and queue update when leave finishes
8822 this._leaving = true;
8823 mergeVNodeHook(oldData, 'afterLeave', function () {
8824 this$1._leaving = false;
8825 this$1.$forceUpdate();
8826 });
8827 return placeholder(h, rawChild)
8828 } else if (mode === 'in-out') {
8829 if (isAsyncPlaceholder(child)) {
8830 return oldRawChild
8831 }
8832 var delayedLeave;
8833 var performLeave = function () { delayedLeave(); };
8834 mergeVNodeHook(data, 'afterEnter', performLeave);
8835 mergeVNodeHook(data, 'enterCancelled', performLeave);
8836 mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
8837 }
8838 }
8839
8840 return rawChild
8841 }
8842};
8843
8844/* */
8845
8846var props = extend({
8847 tag: String,
8848 moveClass: String
8849}, transitionProps);
8850
8851delete props.mode;
8852
8853var TransitionGroup = {
8854 props: props,
8855
8856 beforeMount: function beforeMount () {
8857 var this$1 = this;
8858
8859 var update = this._update;
8860 this._update = function (vnode, hydrating) {
8861 var restoreActiveInstance = setActiveInstance(this$1);
8862 // force removing pass
8863 this$1.__patch__(
8864 this$1._vnode,
8865 this$1.kept,
8866 false, // hydrating
8867 true // removeOnly (!important, avoids unnecessary moves)
8868 );
8869 this$1._vnode = this$1.kept;
8870 restoreActiveInstance();
8871 update.call(this$1, vnode, hydrating);
8872 };
8873 },
8874
8875 render: function render (h) {
8876 var tag = this.tag || this.$vnode.data.tag || 'span';
8877 var map = Object.create(null);
8878 var prevChildren = this.prevChildren = this.children;
8879 var rawChildren = this.$slots.default || [];
8880 var children = this.children = [];
8881 var transitionData = extractTransitionData(this);
8882
8883 for (var i = 0; i < rawChildren.length; i++) {
8884 var c = rawChildren[i];
8885 if (c.tag) {
8886 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
8887 children.push(c);
8888 map[c.key] = c
8889 ;(c.data || (c.data = {})).transition = transitionData;
8890 } else {
8891 var opts = c.componentOptions;
8892 var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
8893 warn(("<transition-group> children must be keyed: <" + name + ">"));
8894 }
8895 }
8896 }
8897
8898 if (prevChildren) {
8899 var kept = [];
8900 var removed = [];
8901 for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
8902 var c$1 = prevChildren[i$1];
8903 c$1.data.transition = transitionData;
8904 c$1.data.pos = c$1.elm.getBoundingClientRect();
8905 if (map[c$1.key]) {
8906 kept.push(c$1);
8907 } else {
8908 removed.push(c$1);
8909 }
8910 }
8911 this.kept = h(tag, null, kept);
8912 this.removed = removed;
8913 }
8914
8915 return h(tag, null, children)
8916 },
8917
8918 updated: function updated () {
8919 var children = this.prevChildren;
8920 var moveClass = this.moveClass || ((this.name || 'v') + '-move');
8921 if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
8922 return
8923 }
8924
8925 // we divide the work into three loops to avoid mixing DOM reads and writes
8926 // in each iteration - which helps prevent layout thrashing.
8927 children.forEach(callPendingCbs);
8928 children.forEach(recordPosition);
8929 children.forEach(applyTranslation);
8930
8931 // force reflow to put everything in position
8932 // assign to this to avoid being removed in tree-shaking
8933 // $flow-disable-line
8934 this._reflow = document.body.offsetHeight;
8935
8936 children.forEach(function (c) {
8937 if (c.data.moved) {
8938 var el = c.elm;
8939 var s = el.style;
8940 addTransitionClass(el, moveClass);
8941 s.transform = s.WebkitTransform = s.transitionDuration = '';
8942 el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
8943 if (e && e.target !== el) {
8944 return
8945 }
8946 if (!e || /transform$/.test(e.propertyName)) {
8947 el.removeEventListener(transitionEndEvent, cb);
8948 el._moveCb = null;
8949 removeTransitionClass(el, moveClass);
8950 }
8951 });
8952 }
8953 });
8954 },
8955
8956 methods: {
8957 hasMove: function hasMove (el, moveClass) {
8958 /* istanbul ignore if */
8959 if (!hasTransition) {
8960 return false
8961 }
8962 /* istanbul ignore if */
8963 if (this._hasMove) {
8964 return this._hasMove
8965 }
8966 // Detect whether an element with the move class applied has
8967 // CSS transitions. Since the element may be inside an entering
8968 // transition at this very moment, we make a clone of it and remove
8969 // all other transition classes applied to ensure only the move class
8970 // is applied.
8971 var clone = el.cloneNode();
8972 if (el._transitionClasses) {
8973 el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
8974 }
8975 addClass(clone, moveClass);
8976 clone.style.display = 'none';
8977 this.$el.appendChild(clone);
8978 var info = getTransitionInfo(clone);
8979 this.$el.removeChild(clone);
8980 return (this._hasMove = info.hasTransform)
8981 }
8982 }
8983};
8984
8985function callPendingCbs (c) {
8986 /* istanbul ignore if */
8987 if (c.elm._moveCb) {
8988 c.elm._moveCb();
8989 }
8990 /* istanbul ignore if */
8991 if (c.elm._enterCb) {
8992 c.elm._enterCb();
8993 }
8994}
8995
8996function recordPosition (c) {
8997 c.data.newPos = c.elm.getBoundingClientRect();
8998}
8999
9000function applyTranslation (c) {
9001 var oldPos = c.data.pos;
9002 var newPos = c.data.newPos;
9003 var dx = oldPos.left - newPos.left;
9004 var dy = oldPos.top - newPos.top;
9005 if (dx || dy) {
9006 c.data.moved = true;
9007 var s = c.elm.style;
9008 s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
9009 s.transitionDuration = '0s';
9010 }
9011}
9012
9013var platformComponents = {
9014 Transition: Transition,
9015 TransitionGroup: TransitionGroup
9016};
9017
9018/* */
9019
9020// install platform specific utils
9021Vue.config.mustUseProp = mustUseProp;
9022Vue.config.isReservedTag = isReservedTag;
9023Vue.config.isReservedAttr = isReservedAttr;
9024Vue.config.getTagNamespace = getTagNamespace;
9025Vue.config.isUnknownElement = isUnknownElement;
9026
9027// install platform runtime directives & components
9028extend(Vue.options.directives, platformDirectives);
9029extend(Vue.options.components, platformComponents);
9030
9031// install platform patch function
9032Vue.prototype.__patch__ = inBrowser ? patch : noop;
9033
9034// public mount method
9035Vue.prototype.$mount = function (
9036 el,
9037 hydrating
9038) {
9039 el = el && inBrowser ? query(el) : undefined;
9040 return mountComponent(this, el, hydrating)
9041};
9042
9043// devtools global hook
9044/* istanbul ignore next */
9045if (inBrowser) {
9046 setTimeout(function () {
9047 if (config.devtools) {
9048 if (devtools) {
9049 devtools.emit('init', Vue);
9050 } else {
9051 console[console.info ? 'info' : 'log'](
9052 'Download the Vue Devtools extension for a better development experience:\n' +
9053 'https://github.com/vuejs/vue-devtools'
9054 );
9055 }
9056 }
9057 if (config.productionTip !== false &&
9058 typeof console !== 'undefined'
9059 ) {
9060 console[console.info ? 'info' : 'log'](
9061 "You are running Vue in development mode.\n" +
9062 "Make sure to turn on production mode when deploying for production.\n" +
9063 "See more tips at https://vuejs.org/guide/deployment.html"
9064 );
9065 }
9066 }, 0);
9067}
9068
9069/* */
9070
9071var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
9072var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
9073
9074var buildRegex = cached(function (delimiters) {
9075 var open = delimiters[0].replace(regexEscapeRE, '\\$&');
9076 var close = delimiters[1].replace(regexEscapeRE, '\\$&');
9077 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
9078});
9079
9080
9081
9082function parseText (
9083 text,
9084 delimiters
9085) {
9086 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
9087 if (!tagRE.test(text)) {
9088 return
9089 }
9090 var tokens = [];
9091 var rawTokens = [];
9092 var lastIndex = tagRE.lastIndex = 0;
9093 var match, index, tokenValue;
9094 while ((match = tagRE.exec(text))) {
9095 index = match.index;
9096 // push text token
9097 if (index > lastIndex) {
9098 rawTokens.push(tokenValue = text.slice(lastIndex, index));
9099 tokens.push(JSON.stringify(tokenValue));
9100 }
9101 // tag token
9102 var exp = parseFilters(match[1].trim());
9103 tokens.push(("_s(" + exp + ")"));
9104 rawTokens.push({ '@binding': exp });
9105 lastIndex = index + match[0].length;
9106 }
9107 if (lastIndex < text.length) {
9108 rawTokens.push(tokenValue = text.slice(lastIndex));
9109 tokens.push(JSON.stringify(tokenValue));
9110 }
9111 return {
9112 expression: tokens.join('+'),
9113 tokens: rawTokens
9114 }
9115}
9116
9117/* */
9118
9119function transformNode (el, options) {
9120 var warn = options.warn || baseWarn;
9121 var staticClass = getAndRemoveAttr(el, 'class');
9122 if (staticClass) {
9123 var res = parseText(staticClass, options.delimiters);
9124 if (res) {
9125 warn(
9126 "class=\"" + staticClass + "\": " +
9127 'Interpolation inside attributes has been removed. ' +
9128 'Use v-bind or the colon shorthand instead. For example, ' +
9129 'instead of <div class="{{ val }}">, use <div :class="val">.',
9130 el.rawAttrsMap['class']
9131 );
9132 }
9133 }
9134 if (staticClass) {
9135 el.staticClass = JSON.stringify(staticClass);
9136 }
9137 var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
9138 if (classBinding) {
9139 el.classBinding = classBinding;
9140 }
9141}
9142
9143function genData (el) {
9144 var data = '';
9145 if (el.staticClass) {
9146 data += "staticClass:" + (el.staticClass) + ",";
9147 }
9148 if (el.classBinding) {
9149 data += "class:" + (el.classBinding) + ",";
9150 }
9151 return data
9152}
9153
9154var klass$1 = {
9155 staticKeys: ['staticClass'],
9156 transformNode: transformNode,
9157 genData: genData
9158};
9159
9160/* */
9161
9162function transformNode$1 (el, options) {
9163 var warn = options.warn || baseWarn;
9164 var staticStyle = getAndRemoveAttr(el, 'style');
9165 if (staticStyle) {
9166 /* istanbul ignore if */
9167 {
9168 var res = parseText(staticStyle, options.delimiters);
9169 if (res) {
9170 warn(
9171 "style=\"" + staticStyle + "\": " +
9172 'Interpolation inside attributes has been removed. ' +
9173 'Use v-bind or the colon shorthand instead. For example, ' +
9174 'instead of <div style="{{ val }}">, use <div :style="val">.',
9175 el.rawAttrsMap['style']
9176 );
9177 }
9178 }
9179 el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
9180 }
9181
9182 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
9183 if (styleBinding) {
9184 el.styleBinding = styleBinding;
9185 }
9186}
9187
9188function genData$1 (el) {
9189 var data = '';
9190 if (el.staticStyle) {
9191 data += "staticStyle:" + (el.staticStyle) + ",";
9192 }
9193 if (el.styleBinding) {
9194 data += "style:(" + (el.styleBinding) + "),";
9195 }
9196 return data
9197}
9198
9199var style$1 = {
9200 staticKeys: ['staticStyle'],
9201 transformNode: transformNode$1,
9202 genData: genData$1
9203};
9204
9205/* */
9206
9207var decoder;
9208
9209var he = {
9210 decode: function decode (html) {
9211 decoder = decoder || document.createElement('div');
9212 decoder.innerHTML = html;
9213 return decoder.textContent
9214 }
9215};
9216
9217/* */
9218
9219var isUnaryTag = makeMap(
9220 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
9221 'link,meta,param,source,track,wbr'
9222);
9223
9224// Elements that you can, intentionally, leave open
9225// (and which close themselves)
9226var canBeLeftOpenTag = makeMap(
9227 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
9228);
9229
9230// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
9231// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
9232var isNonPhrasingTag = makeMap(
9233 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
9234 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
9235 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
9236 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
9237 'title,tr,track'
9238);
9239
9240/**
9241 * Not type-checking this file because it's mostly vendor code.
9242 */
9243
9244// Regular Expressions for parsing tags and attributes
9245var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9246var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9247var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
9248var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
9249var startTagOpen = new RegExp(("^<" + qnameCapture));
9250var startTagClose = /^\s*(\/?)>/;
9251var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
9252var doctype = /^<!DOCTYPE [^>]+>/i;
9253// #7298: escape - to avoid being passed as HTML comment when inlined in page
9254var comment = /^<!\--/;
9255var conditionalComment = /^<!\[/;
9256
9257// Special Elements (can contain anything)
9258var isPlainTextElement = makeMap('script,style,textarea', true);
9259var reCache = {};
9260
9261var decodingMap = {
9262 '&lt;': '<',
9263 '&gt;': '>',
9264 '&quot;': '"',
9265 '&amp;': '&',
9266 '&#10;': '\n',
9267 '&#9;': '\t',
9268 '&#39;': "'"
9269};
9270var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
9271var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
9272
9273// #5992
9274var isIgnoreNewlineTag = makeMap('pre,textarea', true);
9275var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
9276
9277function decodeAttr (value, shouldDecodeNewlines) {
9278 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
9279 return value.replace(re, function (match) { return decodingMap[match]; })
9280}
9281
9282function parseHTML (html, options) {
9283 var stack = [];
9284 var expectHTML = options.expectHTML;
9285 var isUnaryTag$$1 = options.isUnaryTag || no;
9286 var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
9287 var index = 0;
9288 var last, lastTag;
9289 while (html) {
9290 last = html;
9291 // Make sure we're not in a plaintext content element like script/style
9292 if (!lastTag || !isPlainTextElement(lastTag)) {
9293 var textEnd = html.indexOf('<');
9294 if (textEnd === 0) {
9295 // Comment:
9296 if (comment.test(html)) {
9297 var commentEnd = html.indexOf('-->');
9298
9299 if (commentEnd >= 0) {
9300 if (options.shouldKeepComment) {
9301 options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
9302 }
9303 advance(commentEnd + 3);
9304 continue
9305 }
9306 }
9307
9308 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
9309 if (conditionalComment.test(html)) {
9310 var conditionalEnd = html.indexOf(']>');
9311
9312 if (conditionalEnd >= 0) {
9313 advance(conditionalEnd + 2);
9314 continue
9315 }
9316 }
9317
9318 // Doctype:
9319 var doctypeMatch = html.match(doctype);
9320 if (doctypeMatch) {
9321 advance(doctypeMatch[0].length);
9322 continue
9323 }
9324
9325 // End tag:
9326 var endTagMatch = html.match(endTag);
9327 if (endTagMatch) {
9328 var curIndex = index;
9329 advance(endTagMatch[0].length);
9330 parseEndTag(endTagMatch[1], curIndex, index);
9331 continue
9332 }
9333
9334 // Start tag:
9335 var startTagMatch = parseStartTag();
9336 if (startTagMatch) {
9337 handleStartTag(startTagMatch);
9338 if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
9339 advance(1);
9340 }
9341 continue
9342 }
9343 }
9344
9345 var text = (void 0), rest = (void 0), next = (void 0);
9346 if (textEnd >= 0) {
9347 rest = html.slice(textEnd);
9348 while (
9349 !endTag.test(rest) &&
9350 !startTagOpen.test(rest) &&
9351 !comment.test(rest) &&
9352 !conditionalComment.test(rest)
9353 ) {
9354 // < in plain text, be forgiving and treat it as text
9355 next = rest.indexOf('<', 1);
9356 if (next < 0) { break }
9357 textEnd += next;
9358 rest = html.slice(textEnd);
9359 }
9360 text = html.substring(0, textEnd);
9361 }
9362
9363 if (textEnd < 0) {
9364 text = html;
9365 }
9366
9367 if (text) {
9368 advance(text.length);
9369 }
9370
9371 if (options.chars && text) {
9372 options.chars(text, index - text.length, index);
9373 }
9374 } else {
9375 var endTagLength = 0;
9376 var stackedTag = lastTag.toLowerCase();
9377 var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
9378 var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
9379 endTagLength = endTag.length;
9380 if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
9381 text = text
9382 .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
9383 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
9384 }
9385 if (shouldIgnoreFirstNewline(stackedTag, text)) {
9386 text = text.slice(1);
9387 }
9388 if (options.chars) {
9389 options.chars(text);
9390 }
9391 return ''
9392 });
9393 index += html.length - rest$1.length;
9394 html = rest$1;
9395 parseEndTag(stackedTag, index - endTagLength, index);
9396 }
9397
9398 if (html === last) {
9399 options.chars && options.chars(html);
9400 if (!stack.length && options.warn) {
9401 options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
9402 }
9403 break
9404 }
9405 }
9406
9407 // Clean up any remaining tags
9408 parseEndTag();
9409
9410 function advance (n) {
9411 index += n;
9412 html = html.substring(n);
9413 }
9414
9415 function parseStartTag () {
9416 var start = html.match(startTagOpen);
9417 if (start) {
9418 var match = {
9419 tagName: start[1],
9420 attrs: [],
9421 start: index
9422 };
9423 advance(start[0].length);
9424 var end, attr;
9425 while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
9426 attr.start = index;
9427 advance(attr[0].length);
9428 attr.end = index;
9429 match.attrs.push(attr);
9430 }
9431 if (end) {
9432 match.unarySlash = end[1];
9433 advance(end[0].length);
9434 match.end = index;
9435 return match
9436 }
9437 }
9438 }
9439
9440 function handleStartTag (match) {
9441 var tagName = match.tagName;
9442 var unarySlash = match.unarySlash;
9443
9444 if (expectHTML) {
9445 if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
9446 parseEndTag(lastTag);
9447 }
9448 if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
9449 parseEndTag(tagName);
9450 }
9451 }
9452
9453 var unary = isUnaryTag$$1(tagName) || !!unarySlash;
9454
9455 var l = match.attrs.length;
9456 var attrs = new Array(l);
9457 for (var i = 0; i < l; i++) {
9458 var args = match.attrs[i];
9459 var value = args[3] || args[4] || args[5] || '';
9460 var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
9461 ? options.shouldDecodeNewlinesForHref
9462 : options.shouldDecodeNewlines;
9463 attrs[i] = {
9464 name: args[1],
9465 value: decodeAttr(value, shouldDecodeNewlines)
9466 };
9467 if (options.outputSourceRange) {
9468 attrs[i].start = args.start + args[0].match(/^\s*/).length;
9469 attrs[i].end = args.end;
9470 }
9471 }
9472
9473 if (!unary) {
9474 stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
9475 lastTag = tagName;
9476 }
9477
9478 if (options.start) {
9479 options.start(tagName, attrs, unary, match.start, match.end);
9480 }
9481 }
9482
9483 function parseEndTag (tagName, start, end) {
9484 var pos, lowerCasedTagName;
9485 if (start == null) { start = index; }
9486 if (end == null) { end = index; }
9487
9488 // Find the closest opened tag of the same type
9489 if (tagName) {
9490 lowerCasedTagName = tagName.toLowerCase();
9491 for (pos = stack.length - 1; pos >= 0; pos--) {
9492 if (stack[pos].lowerCasedTag === lowerCasedTagName) {
9493 break
9494 }
9495 }
9496 } else {
9497 // If no tag name is provided, clean shop
9498 pos = 0;
9499 }
9500
9501 if (pos >= 0) {
9502 // Close all the open elements, up the stack
9503 for (var i = stack.length - 1; i >= pos; i--) {
9504 if (i > pos || !tagName &&
9505 options.warn
9506 ) {
9507 options.warn(
9508 ("tag <" + (stack[i].tag) + "> has no matching end tag."),
9509 { start: stack[i].start, end: stack[i].end }
9510 );
9511 }
9512 if (options.end) {
9513 options.end(stack[i].tag, start, end);
9514 }
9515 }
9516
9517 // Remove the open elements from the stack
9518 stack.length = pos;
9519 lastTag = pos && stack[pos - 1].tag;
9520 } else if (lowerCasedTagName === 'br') {
9521 if (options.start) {
9522 options.start(tagName, [], true, start, end);
9523 }
9524 } else if (lowerCasedTagName === 'p') {
9525 if (options.start) {
9526 options.start(tagName, [], false, start, end);
9527 }
9528 if (options.end) {
9529 options.end(tagName, start, end);
9530 }
9531 }
9532 }
9533}
9534
9535/* */
9536
9537var onRE = /^@|^v-on:/;
9538var dirRE = /^v-|^@|^:|^#/;
9539var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
9540var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
9541var stripParensRE = /^\(|\)$/g;
9542var dynamicArgRE = /^\[.*\]$/;
9543
9544var argRE = /:(.*)$/;
9545var bindRE = /^:|^\.|^v-bind:/;
9546var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
9547
9548var slotRE = /^v-slot(:|$)|^#/;
9549
9550var lineBreakRE = /[\r\n]/;
9551var whitespaceRE$1 = /\s+/g;
9552
9553var invalidAttributeRE = /[\s"'<>\/=]/;
9554
9555var decodeHTMLCached = cached(he.decode);
9556
9557var emptySlotScopeToken = "_empty_";
9558
9559// configurable state
9560var warn$2;
9561var delimiters;
9562var transforms;
9563var preTransforms;
9564var postTransforms;
9565var platformIsPreTag;
9566var platformMustUseProp;
9567var platformGetTagNamespace;
9568var maybeComponent;
9569
9570function createASTElement (
9571 tag,
9572 attrs,
9573 parent
9574) {
9575 return {
9576 type: 1,
9577 tag: tag,
9578 attrsList: attrs,
9579 attrsMap: makeAttrsMap(attrs),
9580 rawAttrsMap: {},
9581 parent: parent,
9582 children: []
9583 }
9584}
9585
9586/**
9587 * Convert HTML string to AST.
9588 */
9589function parse (
9590 template,
9591 options
9592) {
9593 warn$2 = options.warn || baseWarn;
9594
9595 platformIsPreTag = options.isPreTag || no;
9596 platformMustUseProp = options.mustUseProp || no;
9597 platformGetTagNamespace = options.getTagNamespace || no;
9598 var isReservedTag = options.isReservedTag || no;
9599 maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
9600
9601 transforms = pluckModuleFunction(options.modules, 'transformNode');
9602 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
9603 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
9604
9605 delimiters = options.delimiters;
9606
9607 var stack = [];
9608 var preserveWhitespace = options.preserveWhitespace !== false;
9609 var whitespaceOption = options.whitespace;
9610 var root;
9611 var currentParent;
9612 var inVPre = false;
9613 var inPre = false;
9614 var warned = false;
9615
9616 function warnOnce (msg, range) {
9617 if (!warned) {
9618 warned = true;
9619 warn$2(msg, range);
9620 }
9621 }
9622
9623 function closeElement (element) {
9624 trimEndingWhitespace(element);
9625 if (!inVPre && !element.processed) {
9626 element = processElement(element, options);
9627 }
9628 // tree management
9629 if (!stack.length && element !== root) {
9630 // allow root elements with v-if, v-else-if and v-else
9631 if (root.if && (element.elseif || element.else)) {
9632 {
9633 checkRootConstraints(element);
9634 }
9635 addIfCondition(root, {
9636 exp: element.elseif,
9637 block: element
9638 });
9639 } else {
9640 warnOnce(
9641 "Component template should contain exactly one root element. " +
9642 "If you are using v-if on multiple elements, " +
9643 "use v-else-if to chain them instead.",
9644 { start: element.start }
9645 );
9646 }
9647 }
9648 if (currentParent && !element.forbidden) {
9649 if (element.elseif || element.else) {
9650 processIfConditions(element, currentParent);
9651 } else {
9652 if (element.slotScope) {
9653 // scoped slot
9654 // keep it in the children list so that v-else(-if) conditions can
9655 // find it as the prev node.
9656 var name = element.slotTarget || '"default"'
9657 ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
9658 }
9659 currentParent.children.push(element);
9660 element.parent = currentParent;
9661 }
9662 }
9663
9664 // final children cleanup
9665 // filter out scoped slots
9666 element.children = element.children.filter(function (c) { return !(c).slotScope; });
9667 // remove trailing whitespace node again
9668 trimEndingWhitespace(element);
9669
9670 // check pre state
9671 if (element.pre) {
9672 inVPre = false;
9673 }
9674 if (platformIsPreTag(element.tag)) {
9675 inPre = false;
9676 }
9677 // apply post-transforms
9678 for (var i = 0; i < postTransforms.length; i++) {
9679 postTransforms[i](element, options);
9680 }
9681 }
9682
9683 function trimEndingWhitespace (el) {
9684 // remove trailing whitespace node
9685 if (!inPre) {
9686 var lastNode;
9687 while (
9688 (lastNode = el.children[el.children.length - 1]) &&
9689 lastNode.type === 3 &&
9690 lastNode.text === ' '
9691 ) {
9692 el.children.pop();
9693 }
9694 }
9695 }
9696
9697 function checkRootConstraints (el) {
9698 if (el.tag === 'slot' || el.tag === 'template') {
9699 warnOnce(
9700 "Cannot use <" + (el.tag) + "> as component root element because it may " +
9701 'contain multiple nodes.',
9702 { start: el.start }
9703 );
9704 }
9705 if (el.attrsMap.hasOwnProperty('v-for')) {
9706 warnOnce(
9707 'Cannot use v-for on stateful component root element because ' +
9708 'it renders multiple elements.',
9709 el.rawAttrsMap['v-for']
9710 );
9711 }
9712 }
9713
9714 parseHTML(template, {
9715 warn: warn$2,
9716 expectHTML: options.expectHTML,
9717 isUnaryTag: options.isUnaryTag,
9718 canBeLeftOpenTag: options.canBeLeftOpenTag,
9719 shouldDecodeNewlines: options.shouldDecodeNewlines,
9720 shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
9721 shouldKeepComment: options.comments,
9722 outputSourceRange: options.outputSourceRange,
9723 start: function start (tag, attrs, unary, start$1, end) {
9724 // check namespace.
9725 // inherit parent ns if there is one
9726 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
9727
9728 // handle IE svg bug
9729 /* istanbul ignore if */
9730 if (isIE && ns === 'svg') {
9731 attrs = guardIESVGBug(attrs);
9732 }
9733
9734 var element = createASTElement(tag, attrs, currentParent);
9735 if (ns) {
9736 element.ns = ns;
9737 }
9738
9739 {
9740 if (options.outputSourceRange) {
9741 element.start = start$1;
9742 element.end = end;
9743 element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
9744 cumulated[attr.name] = attr;
9745 return cumulated
9746 }, {});
9747 }
9748 attrs.forEach(function (attr) {
9749 if (invalidAttributeRE.test(attr.name)) {
9750 warn$2(
9751 "Invalid dynamic argument expression: attribute names cannot contain " +
9752 "spaces, quotes, <, >, / or =.",
9753 {
9754 start: attr.start + attr.name.indexOf("["),
9755 end: attr.start + attr.name.length
9756 }
9757 );
9758 }
9759 });
9760 }
9761
9762 if (isForbiddenTag(element) && !isServerRendering()) {
9763 element.forbidden = true;
9764 warn$2(
9765 'Templates should only be responsible for mapping the state to the ' +
9766 'UI. Avoid placing tags with side-effects in your templates, such as ' +
9767 "<" + tag + ">" + ', as they will not be parsed.',
9768 { start: element.start }
9769 );
9770 }
9771
9772 // apply pre-transforms
9773 for (var i = 0; i < preTransforms.length; i++) {
9774 element = preTransforms[i](element, options) || element;
9775 }
9776
9777 if (!inVPre) {
9778 processPre(element);
9779 if (element.pre) {
9780 inVPre = true;
9781 }
9782 }
9783 if (platformIsPreTag(element.tag)) {
9784 inPre = true;
9785 }
9786 if (inVPre) {
9787 processRawAttrs(element);
9788 } else if (!element.processed) {
9789 // structural directives
9790 processFor(element);
9791 processIf(element);
9792 processOnce(element);
9793 }
9794
9795 if (!root) {
9796 root = element;
9797 {
9798 checkRootConstraints(root);
9799 }
9800 }
9801
9802 if (!unary) {
9803 currentParent = element;
9804 stack.push(element);
9805 } else {
9806 closeElement(element);
9807 }
9808 },
9809
9810 end: function end (tag, start, end$1) {
9811 var element = stack[stack.length - 1];
9812 // pop stack
9813 stack.length -= 1;
9814 currentParent = stack[stack.length - 1];
9815 if (options.outputSourceRange) {
9816 element.end = end$1;
9817 }
9818 closeElement(element);
9819 },
9820
9821 chars: function chars (text, start, end) {
9822 if (!currentParent) {
9823 {
9824 if (text === template) {
9825 warnOnce(
9826 'Component template requires a root element, rather than just text.',
9827 { start: start }
9828 );
9829 } else if ((text = text.trim())) {
9830 warnOnce(
9831 ("text \"" + text + "\" outside root element will be ignored."),
9832 { start: start }
9833 );
9834 }
9835 }
9836 return
9837 }
9838 // IE textarea placeholder bug
9839 /* istanbul ignore if */
9840 if (isIE &&
9841 currentParent.tag === 'textarea' &&
9842 currentParent.attrsMap.placeholder === text
9843 ) {
9844 return
9845 }
9846 var children = currentParent.children;
9847 if (inPre || text.trim()) {
9848 text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
9849 } else if (!children.length) {
9850 // remove the whitespace-only node right after an opening tag
9851 text = '';
9852 } else if (whitespaceOption) {
9853 if (whitespaceOption === 'condense') {
9854 // in condense mode, remove the whitespace node if it contains
9855 // line break, otherwise condense to a single space
9856 text = lineBreakRE.test(text) ? '' : ' ';
9857 } else {
9858 text = ' ';
9859 }
9860 } else {
9861 text = preserveWhitespace ? ' ' : '';
9862 }
9863 if (text) {
9864 if (!inPre && whitespaceOption === 'condense') {
9865 // condense consecutive whitespaces into single space
9866 text = text.replace(whitespaceRE$1, ' ');
9867 }
9868 var res;
9869 var child;
9870 if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
9871 child = {
9872 type: 2,
9873 expression: res.expression,
9874 tokens: res.tokens,
9875 text: text
9876 };
9877 } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
9878 child = {
9879 type: 3,
9880 text: text
9881 };
9882 }
9883 if (child) {
9884 if (options.outputSourceRange) {
9885 child.start = start;
9886 child.end = end;
9887 }
9888 children.push(child);
9889 }
9890 }
9891 },
9892 comment: function comment (text, start, end) {
9893 // adding anything as a sibling to the root node is forbidden
9894 // comments should still be allowed, but ignored
9895 if (currentParent) {
9896 var child = {
9897 type: 3,
9898 text: text,
9899 isComment: true
9900 };
9901 if (options.outputSourceRange) {
9902 child.start = start;
9903 child.end = end;
9904 }
9905 currentParent.children.push(child);
9906 }
9907 }
9908 });
9909 return root
9910}
9911
9912function processPre (el) {
9913 if (getAndRemoveAttr(el, 'v-pre') != null) {
9914 el.pre = true;
9915 }
9916}
9917
9918function processRawAttrs (el) {
9919 var list = el.attrsList;
9920 var len = list.length;
9921 if (len) {
9922 var attrs = el.attrs = new Array(len);
9923 for (var i = 0; i < len; i++) {
9924 attrs[i] = {
9925 name: list[i].name,
9926 value: JSON.stringify(list[i].value)
9927 };
9928 if (list[i].start != null) {
9929 attrs[i].start = list[i].start;
9930 attrs[i].end = list[i].end;
9931 }
9932 }
9933 } else if (!el.pre) {
9934 // non root node in pre blocks with no attributes
9935 el.plain = true;
9936 }
9937}
9938
9939function processElement (
9940 element,
9941 options
9942) {
9943 processKey(element);
9944
9945 // determine whether this is a plain element after
9946 // removing structural attributes
9947 element.plain = (
9948 !element.key &&
9949 !element.scopedSlots &&
9950 !element.attrsList.length
9951 );
9952
9953 processRef(element);
9954 processSlotContent(element);
9955 processSlotOutlet(element);
9956 processComponent(element);
9957 for (var i = 0; i < transforms.length; i++) {
9958 element = transforms[i](element, options) || element;
9959 }
9960 processAttrs(element);
9961 return element
9962}
9963
9964function processKey (el) {
9965 var exp = getBindingAttr(el, 'key');
9966 if (exp) {
9967 {
9968 if (el.tag === 'template') {
9969 warn$2(
9970 "<template> cannot be keyed. Place the key on real elements instead.",
9971 getRawBindingAttr(el, 'key')
9972 );
9973 }
9974 if (el.for) {
9975 var iterator = el.iterator2 || el.iterator1;
9976 var parent = el.parent;
9977 if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
9978 warn$2(
9979 "Do not use v-for index as key on <transition-group> children, " +
9980 "this is the same as not using keys.",
9981 getRawBindingAttr(el, 'key'),
9982 true /* tip */
9983 );
9984 }
9985 }
9986 }
9987 el.key = exp;
9988 }
9989}
9990
9991function processRef (el) {
9992 var ref = getBindingAttr(el, 'ref');
9993 if (ref) {
9994 el.ref = ref;
9995 el.refInFor = checkInFor(el);
9996 }
9997}
9998
9999function processFor (el) {
10000 var exp;
10001 if ((exp = getAndRemoveAttr(el, 'v-for'))) {
10002 var res = parseFor(exp);
10003 if (res) {
10004 extend(el, res);
10005 } else {
10006 warn$2(
10007 ("Invalid v-for expression: " + exp),
10008 el.rawAttrsMap['v-for']
10009 );
10010 }
10011 }
10012}
10013
10014
10015
10016function parseFor (exp) {
10017 var inMatch = exp.match(forAliasRE);
10018 if (!inMatch) { return }
10019 var res = {};
10020 res.for = inMatch[2].trim();
10021 var alias = inMatch[1].trim().replace(stripParensRE, '');
10022 var iteratorMatch = alias.match(forIteratorRE);
10023 if (iteratorMatch) {
10024 res.alias = alias.replace(forIteratorRE, '').trim();
10025 res.iterator1 = iteratorMatch[1].trim();
10026 if (iteratorMatch[2]) {
10027 res.iterator2 = iteratorMatch[2].trim();
10028 }
10029 } else {
10030 res.alias = alias;
10031 }
10032 return res
10033}
10034
10035function processIf (el) {
10036 var exp = getAndRemoveAttr(el, 'v-if');
10037 if (exp) {
10038 el.if = exp;
10039 addIfCondition(el, {
10040 exp: exp,
10041 block: el
10042 });
10043 } else {
10044 if (getAndRemoveAttr(el, 'v-else') != null) {
10045 el.else = true;
10046 }
10047 var elseif = getAndRemoveAttr(el, 'v-else-if');
10048 if (elseif) {
10049 el.elseif = elseif;
10050 }
10051 }
10052}
10053
10054function processIfConditions (el, parent) {
10055 var prev = findPrevElement(parent.children);
10056 if (prev && prev.if) {
10057 addIfCondition(prev, {
10058 exp: el.elseif,
10059 block: el
10060 });
10061 } else {
10062 warn$2(
10063 "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
10064 "used on element <" + (el.tag) + "> without corresponding v-if.",
10065 el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
10066 );
10067 }
10068}
10069
10070function findPrevElement (children) {
10071 var i = children.length;
10072 while (i--) {
10073 if (children[i].type === 1) {
10074 return children[i]
10075 } else {
10076 if (children[i].text !== ' ') {
10077 warn$2(
10078 "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
10079 "will be ignored.",
10080 children[i]
10081 );
10082 }
10083 children.pop();
10084 }
10085 }
10086}
10087
10088function addIfCondition (el, condition) {
10089 if (!el.ifConditions) {
10090 el.ifConditions = [];
10091 }
10092 el.ifConditions.push(condition);
10093}
10094
10095function processOnce (el) {
10096 var once$$1 = getAndRemoveAttr(el, 'v-once');
10097 if (once$$1 != null) {
10098 el.once = true;
10099 }
10100}
10101
10102// handle content being passed to a component as slot,
10103// e.g. <template slot="xxx">, <div slot-scope="xxx">
10104function processSlotContent (el) {
10105 var slotScope;
10106 if (el.tag === 'template') {
10107 slotScope = getAndRemoveAttr(el, 'scope');
10108 /* istanbul ignore if */
10109 if (slotScope) {
10110 warn$2(
10111 "the \"scope\" attribute for scoped slots have been deprecated and " +
10112 "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
10113 "can also be used on plain elements in addition to <template> to " +
10114 "denote scoped slots.",
10115 el.rawAttrsMap['scope'],
10116 true
10117 );
10118 }
10119 el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
10120 } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
10121 /* istanbul ignore if */
10122 if (el.attrsMap['v-for']) {
10123 warn$2(
10124 "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
10125 "(v-for takes higher priority). Use a wrapper <template> for the " +
10126 "scoped slot to make it clearer.",
10127 el.rawAttrsMap['slot-scope'],
10128 true
10129 );
10130 }
10131 el.slotScope = slotScope;
10132 }
10133
10134 // slot="xxx"
10135 var slotTarget = getBindingAttr(el, 'slot');
10136 if (slotTarget) {
10137 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
10138 el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
10139 // preserve slot as an attribute for native shadow DOM compat
10140 // only for non-scoped slots.
10141 if (el.tag !== 'template' && !el.slotScope) {
10142 addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
10143 }
10144 }
10145
10146 // 2.6 v-slot syntax
10147 {
10148 if (el.tag === 'template') {
10149 // v-slot on <template>
10150 var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
10151 if (slotBinding) {
10152 {
10153 if (el.slotTarget || el.slotScope) {
10154 warn$2(
10155 "Unexpected mixed usage of different slot syntaxes.",
10156 el
10157 );
10158 }
10159 if (el.parent && !maybeComponent(el.parent)) {
10160 warn$2(
10161 "<template v-slot> can only appear at the root level inside " +
10162 "the receiving component",
10163 el
10164 );
10165 }
10166 }
10167 var ref = getSlotName(slotBinding);
10168 var name = ref.name;
10169 var dynamic = ref.dynamic;
10170 el.slotTarget = name;
10171 el.slotTargetDynamic = dynamic;
10172 el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
10173 }
10174 } else {
10175 // v-slot on component, denotes default slot
10176 var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
10177 if (slotBinding$1) {
10178 {
10179 if (!maybeComponent(el)) {
10180 warn$2(
10181 "v-slot can only be used on components or <template>.",
10182 slotBinding$1
10183 );
10184 }
10185 if (el.slotScope || el.slotTarget) {
10186 warn$2(
10187 "Unexpected mixed usage of different slot syntaxes.",
10188 el
10189 );
10190 }
10191 if (el.scopedSlots) {
10192 warn$2(
10193 "To avoid scope ambiguity, the default slot should also use " +
10194 "<template> syntax when there are other named slots.",
10195 slotBinding$1
10196 );
10197 }
10198 }
10199 // add the component's children to its default slot
10200 var slots = el.scopedSlots || (el.scopedSlots = {});
10201 var ref$1 = getSlotName(slotBinding$1);
10202 var name$1 = ref$1.name;
10203 var dynamic$1 = ref$1.dynamic;
10204 var slotContainer = slots[name$1] = createASTElement('template', [], el);
10205 slotContainer.slotTarget = name$1;
10206 slotContainer.slotTargetDynamic = dynamic$1;
10207 slotContainer.children = el.children.filter(function (c) {
10208 if (!c.slotScope) {
10209 c.parent = slotContainer;
10210 return true
10211 }
10212 });
10213 slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
10214 // remove children as they are returned from scopedSlots now
10215 el.children = [];
10216 // mark el non-plain so data gets generated
10217 el.plain = false;
10218 }
10219 }
10220 }
10221}
10222
10223function getSlotName (binding) {
10224 var name = binding.name.replace(slotRE, '');
10225 if (!name) {
10226 if (binding.name[0] !== '#') {
10227 name = 'default';
10228 } else {
10229 warn$2(
10230 "v-slot shorthand syntax requires a slot name.",
10231 binding
10232 );
10233 }
10234 }
10235 return dynamicArgRE.test(name)
10236 // dynamic [name]
10237 ? { name: name.slice(1, -1), dynamic: true }
10238 // static name
10239 : { name: ("\"" + name + "\""), dynamic: false }
10240}
10241
10242// handle <slot/> outlets
10243function processSlotOutlet (el) {
10244 if (el.tag === 'slot') {
10245 el.slotName = getBindingAttr(el, 'name');
10246 if (el.key) {
10247 warn$2(
10248 "`key` does not work on <slot> because slots are abstract outlets " +
10249 "and can possibly expand into multiple elements. " +
10250 "Use the key on a wrapping element instead.",
10251 getRawBindingAttr(el, 'key')
10252 );
10253 }
10254 }
10255}
10256
10257function processComponent (el) {
10258 var binding;
10259 if ((binding = getBindingAttr(el, 'is'))) {
10260 el.component = binding;
10261 }
10262 if (getAndRemoveAttr(el, 'inline-template') != null) {
10263 el.inlineTemplate = true;
10264 }
10265}
10266
10267function processAttrs (el) {
10268 var list = el.attrsList;
10269 var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
10270 for (i = 0, l = list.length; i < l; i++) {
10271 name = rawName = list[i].name;
10272 value = list[i].value;
10273 if (dirRE.test(name)) {
10274 // mark element as dynamic
10275 el.hasBindings = true;
10276 // modifiers
10277 modifiers = parseModifiers(name.replace(dirRE, ''));
10278 // support .foo shorthand syntax for the .prop modifier
10279 if (modifiers) {
10280 name = name.replace(modifierRE, '');
10281 }
10282 if (bindRE.test(name)) { // v-bind
10283 name = name.replace(bindRE, '');
10284 value = parseFilters(value);
10285 isDynamic = dynamicArgRE.test(name);
10286 if (isDynamic) {
10287 name = name.slice(1, -1);
10288 }
10289 if (
10290 value.trim().length === 0
10291 ) {
10292 warn$2(
10293 ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
10294 );
10295 }
10296 if (modifiers) {
10297 if (modifiers.prop && !isDynamic) {
10298 name = camelize(name);
10299 if (name === 'innerHtml') { name = 'innerHTML'; }
10300 }
10301 if (modifiers.camel && !isDynamic) {
10302 name = camelize(name);
10303 }
10304 if (modifiers.sync) {
10305 syncGen = genAssignmentCode(value, "$event");
10306 if (!isDynamic) {
10307 addHandler(
10308 el,
10309 ("update:" + (camelize(name))),
10310 syncGen,
10311 null,
10312 false,
10313 warn$2,
10314 list[i]
10315 );
10316 if (hyphenate(name) !== camelize(name)) {
10317 addHandler(
10318 el,
10319 ("update:" + (hyphenate(name))),
10320 syncGen,
10321 null,
10322 false,
10323 warn$2,
10324 list[i]
10325 );
10326 }
10327 } else {
10328 // handler w/ dynamic event name
10329 addHandler(
10330 el,
10331 ("\"update:\"+(" + name + ")"),
10332 syncGen,
10333 null,
10334 false,
10335 warn$2,
10336 list[i],
10337 true // dynamic
10338 );
10339 }
10340 }
10341 }
10342 if ((modifiers && modifiers.prop) || (
10343 !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
10344 )) {
10345 addProp(el, name, value, list[i], isDynamic);
10346 } else {
10347 addAttr(el, name, value, list[i], isDynamic);
10348 }
10349 } else if (onRE.test(name)) { // v-on
10350 name = name.replace(onRE, '');
10351 isDynamic = dynamicArgRE.test(name);
10352 if (isDynamic) {
10353 name = name.slice(1, -1);
10354 }
10355 addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
10356 } else { // normal directives
10357 name = name.replace(dirRE, '');
10358 // parse arg
10359 var argMatch = name.match(argRE);
10360 var arg = argMatch && argMatch[1];
10361 isDynamic = false;
10362 if (arg) {
10363 name = name.slice(0, -(arg.length + 1));
10364 if (dynamicArgRE.test(arg)) {
10365 arg = arg.slice(1, -1);
10366 isDynamic = true;
10367 }
10368 }
10369 addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
10370 if (name === 'model') {
10371 checkForAliasModel(el, value);
10372 }
10373 }
10374 } else {
10375 // literal attribute
10376 {
10377 var res = parseText(value, delimiters);
10378 if (res) {
10379 warn$2(
10380 name + "=\"" + value + "\": " +
10381 'Interpolation inside attributes has been removed. ' +
10382 'Use v-bind or the colon shorthand instead. For example, ' +
10383 'instead of <div id="{{ val }}">, use <div :id="val">.',
10384 list[i]
10385 );
10386 }
10387 }
10388 addAttr(el, name, JSON.stringify(value), list[i]);
10389 // #6887 firefox doesn't update muted state if set via attribute
10390 // even immediately after element creation
10391 if (!el.component &&
10392 name === 'muted' &&
10393 platformMustUseProp(el.tag, el.attrsMap.type, name)) {
10394 addProp(el, name, 'true', list[i]);
10395 }
10396 }
10397 }
10398}
10399
10400function checkInFor (el) {
10401 var parent = el;
10402 while (parent) {
10403 if (parent.for !== undefined) {
10404 return true
10405 }
10406 parent = parent.parent;
10407 }
10408 return false
10409}
10410
10411function parseModifiers (name) {
10412 var match = name.match(modifierRE);
10413 if (match) {
10414 var ret = {};
10415 match.forEach(function (m) { ret[m.slice(1)] = true; });
10416 return ret
10417 }
10418}
10419
10420function makeAttrsMap (attrs) {
10421 var map = {};
10422 for (var i = 0, l = attrs.length; i < l; i++) {
10423 if (
10424 map[attrs[i].name] && !isIE && !isEdge
10425 ) {
10426 warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
10427 }
10428 map[attrs[i].name] = attrs[i].value;
10429 }
10430 return map
10431}
10432
10433// for script (e.g. type="x/template") or style, do not decode content
10434function isTextTag (el) {
10435 return el.tag === 'script' || el.tag === 'style'
10436}
10437
10438function isForbiddenTag (el) {
10439 return (
10440 el.tag === 'style' ||
10441 (el.tag === 'script' && (
10442 !el.attrsMap.type ||
10443 el.attrsMap.type === 'text/javascript'
10444 ))
10445 )
10446}
10447
10448var ieNSBug = /^xmlns:NS\d+/;
10449var ieNSPrefix = /^NS\d+:/;
10450
10451/* istanbul ignore next */
10452function guardIESVGBug (attrs) {
10453 var res = [];
10454 for (var i = 0; i < attrs.length; i++) {
10455 var attr = attrs[i];
10456 if (!ieNSBug.test(attr.name)) {
10457 attr.name = attr.name.replace(ieNSPrefix, '');
10458 res.push(attr);
10459 }
10460 }
10461 return res
10462}
10463
10464function checkForAliasModel (el, value) {
10465 var _el = el;
10466 while (_el) {
10467 if (_el.for && _el.alias === value) {
10468 warn$2(
10469 "<" + (el.tag) + " v-model=\"" + value + "\">: " +
10470 "You are binding v-model directly to a v-for iteration alias. " +
10471 "This will not be able to modify the v-for source array because " +
10472 "writing to the alias is like modifying a function local variable. " +
10473 "Consider using an array of objects and use v-model on an object property instead.",
10474 el.rawAttrsMap['v-model']
10475 );
10476 }
10477 _el = _el.parent;
10478 }
10479}
10480
10481/* */
10482
10483function preTransformNode (el, options) {
10484 if (el.tag === 'input') {
10485 var map = el.attrsMap;
10486 if (!map['v-model']) {
10487 return
10488 }
10489
10490 var typeBinding;
10491 if (map[':type'] || map['v-bind:type']) {
10492 typeBinding = getBindingAttr(el, 'type');
10493 }
10494 if (!map.type && !typeBinding && map['v-bind']) {
10495 typeBinding = "(" + (map['v-bind']) + ").type";
10496 }
10497
10498 if (typeBinding) {
10499 var ifCondition = getAndRemoveAttr(el, 'v-if', true);
10500 var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
10501 var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
10502 var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
10503 // 1. checkbox
10504 var branch0 = cloneASTElement(el);
10505 // process for on the main node
10506 processFor(branch0);
10507 addRawAttr(branch0, 'type', 'checkbox');
10508 processElement(branch0, options);
10509 branch0.processed = true; // prevent it from double-processed
10510 branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
10511 addIfCondition(branch0, {
10512 exp: branch0.if,
10513 block: branch0
10514 });
10515 // 2. add radio else-if condition
10516 var branch1 = cloneASTElement(el);
10517 getAndRemoveAttr(branch1, 'v-for', true);
10518 addRawAttr(branch1, 'type', 'radio');
10519 processElement(branch1, options);
10520 addIfCondition(branch0, {
10521 exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
10522 block: branch1
10523 });
10524 // 3. other
10525 var branch2 = cloneASTElement(el);
10526 getAndRemoveAttr(branch2, 'v-for', true);
10527 addRawAttr(branch2, ':type', typeBinding);
10528 processElement(branch2, options);
10529 addIfCondition(branch0, {
10530 exp: ifCondition,
10531 block: branch2
10532 });
10533
10534 if (hasElse) {
10535 branch0.else = true;
10536 } else if (elseIfCondition) {
10537 branch0.elseif = elseIfCondition;
10538 }
10539
10540 return branch0
10541 }
10542 }
10543}
10544
10545function cloneASTElement (el) {
10546 return createASTElement(el.tag, el.attrsList.slice(), el.parent)
10547}
10548
10549var model$1 = {
10550 preTransformNode: preTransformNode
10551};
10552
10553var modules$1 = [
10554 klass$1,
10555 style$1,
10556 model$1
10557];
10558
10559/* */
10560
10561function text (el, dir) {
10562 if (dir.value) {
10563 addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
10564 }
10565}
10566
10567/* */
10568
10569function html (el, dir) {
10570 if (dir.value) {
10571 addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
10572 }
10573}
10574
10575var directives$1 = {
10576 model: model,
10577 text: text,
10578 html: html
10579};
10580
10581/* */
10582
10583var baseOptions = {
10584 expectHTML: true,
10585 modules: modules$1,
10586 directives: directives$1,
10587 isPreTag: isPreTag,
10588 isUnaryTag: isUnaryTag,
10589 mustUseProp: mustUseProp,
10590 canBeLeftOpenTag: canBeLeftOpenTag,
10591 isReservedTag: isReservedTag,
10592 getTagNamespace: getTagNamespace,
10593 staticKeys: genStaticKeys(modules$1)
10594};
10595
10596/* */
10597
10598var isStaticKey;
10599var isPlatformReservedTag;
10600
10601var genStaticKeysCached = cached(genStaticKeys$1);
10602
10603/**
10604 * Goal of the optimizer: walk the generated template AST tree
10605 * and detect sub-trees that are purely static, i.e. parts of
10606 * the DOM that never needs to change.
10607 *
10608 * Once we detect these sub-trees, we can:
10609 *
10610 * 1. Hoist them into constants, so that we no longer need to
10611 * create fresh nodes for them on each re-render;
10612 * 2. Completely skip them in the patching process.
10613 */
10614function optimize (root, options) {
10615 if (!root) { return }
10616 isStaticKey = genStaticKeysCached(options.staticKeys || '');
10617 isPlatformReservedTag = options.isReservedTag || no;
10618 // first pass: mark all non-static nodes.
10619 markStatic$1(root);
10620 // second pass: mark static roots.
10621 markStaticRoots(root, false);
10622}
10623
10624function genStaticKeys$1 (keys) {
10625 return makeMap(
10626 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
10627 (keys ? ',' + keys : '')
10628 )
10629}
10630
10631function markStatic$1 (node) {
10632 node.static = isStatic(node);
10633 if (node.type === 1) {
10634 // do not make component slot content static. this avoids
10635 // 1. components not able to mutate slot nodes
10636 // 2. static slot content fails for hot-reloading
10637 if (
10638 !isPlatformReservedTag(node.tag) &&
10639 node.tag !== 'slot' &&
10640 node.attrsMap['inline-template'] == null
10641 ) {
10642 return
10643 }
10644 for (var i = 0, l = node.children.length; i < l; i++) {
10645 var child = node.children[i];
10646 markStatic$1(child);
10647 if (!child.static) {
10648 node.static = false;
10649 }
10650 }
10651 if (node.ifConditions) {
10652 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
10653 var block = node.ifConditions[i$1].block;
10654 markStatic$1(block);
10655 if (!block.static) {
10656 node.static = false;
10657 }
10658 }
10659 }
10660 }
10661}
10662
10663function markStaticRoots (node, isInFor) {
10664 if (node.type === 1) {
10665 if (node.static || node.once) {
10666 node.staticInFor = isInFor;
10667 }
10668 // For a node to qualify as a static root, it should have children that
10669 // are not just static text. Otherwise the cost of hoisting out will
10670 // outweigh the benefits and it's better off to just always render it fresh.
10671 if (node.static && node.children.length && !(
10672 node.children.length === 1 &&
10673 node.children[0].type === 3
10674 )) {
10675 node.staticRoot = true;
10676 return
10677 } else {
10678 node.staticRoot = false;
10679 }
10680 if (node.children) {
10681 for (var i = 0, l = node.children.length; i < l; i++) {
10682 markStaticRoots(node.children[i], isInFor || !!node.for);
10683 }
10684 }
10685 if (node.ifConditions) {
10686 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
10687 markStaticRoots(node.ifConditions[i$1].block, isInFor);
10688 }
10689 }
10690 }
10691}
10692
10693function isStatic (node) {
10694 if (node.type === 2) { // expression
10695 return false
10696 }
10697 if (node.type === 3) { // text
10698 return true
10699 }
10700 return !!(node.pre || (
10701 !node.hasBindings && // no dynamic bindings
10702 !node.if && !node.for && // not v-if or v-for or v-else
10703 !isBuiltInTag(node.tag) && // not a built-in
10704 isPlatformReservedTag(node.tag) && // not a component
10705 !isDirectChildOfTemplateFor(node) &&
10706 Object.keys(node).every(isStaticKey)
10707 ))
10708}
10709
10710function isDirectChildOfTemplateFor (node) {
10711 while (node.parent) {
10712 node = node.parent;
10713 if (node.tag !== 'template') {
10714 return false
10715 }
10716 if (node.for) {
10717 return true
10718 }
10719 }
10720 return false
10721}
10722
10723/* */
10724
10725var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
10726var fnInvokeRE = /\([^)]*?\);*$/;
10727var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
10728
10729// KeyboardEvent.keyCode aliases
10730var keyCodes = {
10731 esc: 27,
10732 tab: 9,
10733 enter: 13,
10734 space: 32,
10735 up: 38,
10736 left: 37,
10737 right: 39,
10738 down: 40,
10739 'delete': [8, 46]
10740};
10741
10742// KeyboardEvent.key aliases
10743var keyNames = {
10744 // #7880: IE11 and Edge use `Esc` for Escape key name.
10745 esc: ['Esc', 'Escape'],
10746 tab: 'Tab',
10747 enter: 'Enter',
10748 // #9112: IE11 uses `Spacebar` for Space key name.
10749 space: [' ', 'Spacebar'],
10750 // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
10751 up: ['Up', 'ArrowUp'],
10752 left: ['Left', 'ArrowLeft'],
10753 right: ['Right', 'ArrowRight'],
10754 down: ['Down', 'ArrowDown'],
10755 // #9112: IE11 uses `Del` for Delete key name.
10756 'delete': ['Backspace', 'Delete', 'Del']
10757};
10758
10759// #4868: modifiers that prevent the execution of the listener
10760// need to explicitly return null so that we can determine whether to remove
10761// the listener for .once
10762var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
10763
10764var modifierCode = {
10765 stop: '$event.stopPropagation();',
10766 prevent: '$event.preventDefault();',
10767 self: genGuard("$event.target !== $event.currentTarget"),
10768 ctrl: genGuard("!$event.ctrlKey"),
10769 shift: genGuard("!$event.shiftKey"),
10770 alt: genGuard("!$event.altKey"),
10771 meta: genGuard("!$event.metaKey"),
10772 left: genGuard("'button' in $event && $event.button !== 0"),
10773 middle: genGuard("'button' in $event && $event.button !== 1"),
10774 right: genGuard("'button' in $event && $event.button !== 2")
10775};
10776
10777function genHandlers (
10778 events,
10779 isNative
10780) {
10781 var prefix = isNative ? 'nativeOn:' : 'on:';
10782 var staticHandlers = "";
10783 var dynamicHandlers = "";
10784 for (var name in events) {
10785 var handlerCode = genHandler(events[name]);
10786 if (events[name] && events[name].dynamic) {
10787 dynamicHandlers += name + "," + handlerCode + ",";
10788 } else {
10789 staticHandlers += "\"" + name + "\":" + handlerCode + ",";
10790 }
10791 }
10792 staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
10793 if (dynamicHandlers) {
10794 return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
10795 } else {
10796 return prefix + staticHandlers
10797 }
10798}
10799
10800function genHandler (handler) {
10801 if (!handler) {
10802 return 'function(){}'
10803 }
10804
10805 if (Array.isArray(handler)) {
10806 return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
10807 }
10808
10809 var isMethodPath = simplePathRE.test(handler.value);
10810 var isFunctionExpression = fnExpRE.test(handler.value);
10811 var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
10812
10813 if (!handler.modifiers) {
10814 if (isMethodPath || isFunctionExpression) {
10815 return handler.value
10816 }
10817 return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
10818 } else {
10819 var code = '';
10820 var genModifierCode = '';
10821 var keys = [];
10822 for (var key in handler.modifiers) {
10823 if (modifierCode[key]) {
10824 genModifierCode += modifierCode[key];
10825 // left/right
10826 if (keyCodes[key]) {
10827 keys.push(key);
10828 }
10829 } else if (key === 'exact') {
10830 var modifiers = (handler.modifiers);
10831 genModifierCode += genGuard(
10832 ['ctrl', 'shift', 'alt', 'meta']
10833 .filter(function (keyModifier) { return !modifiers[keyModifier]; })
10834 .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
10835 .join('||')
10836 );
10837 } else {
10838 keys.push(key);
10839 }
10840 }
10841 if (keys.length) {
10842 code += genKeyFilter(keys);
10843 }
10844 // Make sure modifiers like prevent and stop get executed after key filtering
10845 if (genModifierCode) {
10846 code += genModifierCode;
10847 }
10848 var handlerCode = isMethodPath
10849 ? ("return " + (handler.value) + "($event)")
10850 : isFunctionExpression
10851 ? ("return (" + (handler.value) + ")($event)")
10852 : isFunctionInvocation
10853 ? ("return " + (handler.value))
10854 : handler.value;
10855 return ("function($event){" + code + handlerCode + "}")
10856 }
10857}
10858
10859function genKeyFilter (keys) {
10860 return (
10861 // make sure the key filters only apply to KeyboardEvents
10862 // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
10863 // key events that do not have keyCode property...
10864 "if(!$event.type.indexOf('key')&&" +
10865 (keys.map(genFilterCode).join('&&')) + ")return null;"
10866 )
10867}
10868
10869function genFilterCode (key) {
10870 var keyVal = parseInt(key, 10);
10871 if (keyVal) {
10872 return ("$event.keyCode!==" + keyVal)
10873 }
10874 var keyCode = keyCodes[key];
10875 var keyName = keyNames[key];
10876 return (
10877 "_k($event.keyCode," +
10878 (JSON.stringify(key)) + "," +
10879 (JSON.stringify(keyCode)) + "," +
10880 "$event.key," +
10881 "" + (JSON.stringify(keyName)) +
10882 ")"
10883 )
10884}
10885
10886/* */
10887
10888function on (el, dir) {
10889 if (dir.modifiers) {
10890 warn("v-on without argument does not support modifiers.");
10891 }
10892 el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
10893}
10894
10895/* */
10896
10897function bind$1 (el, dir) {
10898 el.wrapData = function (code) {
10899 return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
10900 };
10901}
10902
10903/* */
10904
10905var baseDirectives = {
10906 on: on,
10907 bind: bind$1,
10908 cloak: noop
10909};
10910
10911/* */
10912
10913
10914
10915
10916
10917var CodegenState = function CodegenState (options) {
10918 this.options = options;
10919 this.warn = options.warn || baseWarn;
10920 this.transforms = pluckModuleFunction(options.modules, 'transformCode');
10921 this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
10922 this.directives = extend(extend({}, baseDirectives), options.directives);
10923 var isReservedTag = options.isReservedTag || no;
10924 this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
10925 this.onceId = 0;
10926 this.staticRenderFns = [];
10927 this.pre = false;
10928};
10929
10930
10931
10932function generate (
10933 ast,
10934 options
10935) {
10936 var state = new CodegenState(options);
10937 var code = ast ? genElement(ast, state) : '_c("div")';
10938 return {
10939 render: ("with(this){return " + code + "}"),
10940 staticRenderFns: state.staticRenderFns
10941 }
10942}
10943
10944function genElement (el, state) {
10945 if (el.parent) {
10946 el.pre = el.pre || el.parent.pre;
10947 }
10948
10949 if (el.staticRoot && !el.staticProcessed) {
10950 return genStatic(el, state)
10951 } else if (el.once && !el.onceProcessed) {
10952 return genOnce(el, state)
10953 } else if (el.for && !el.forProcessed) {
10954 return genFor(el, state)
10955 } else if (el.if && !el.ifProcessed) {
10956 return genIf(el, state)
10957 } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
10958 return genChildren(el, state) || 'void 0'
10959 } else if (el.tag === 'slot') {
10960 return genSlot(el, state)
10961 } else {
10962 // component or element
10963 var code;
10964 if (el.component) {
10965 code = genComponent(el.component, el, state);
10966 } else {
10967 var data;
10968 if (!el.plain || (el.pre && state.maybeComponent(el))) {
10969 data = genData$2(el, state);
10970 }
10971
10972 var children = el.inlineTemplate ? null : genChildren(el, state, true);
10973 code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
10974 }
10975 // module transforms
10976 for (var i = 0; i < state.transforms.length; i++) {
10977 code = state.transforms[i](el, code);
10978 }
10979 return code
10980 }
10981}
10982
10983// hoist static sub-trees out
10984function genStatic (el, state) {
10985 el.staticProcessed = true;
10986 // Some elements (templates) need to behave differently inside of a v-pre
10987 // node. All pre nodes are static roots, so we can use this as a location to
10988 // wrap a state change and reset it upon exiting the pre node.
10989 var originalPreState = state.pre;
10990 if (el.pre) {
10991 state.pre = el.pre;
10992 }
10993 state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
10994 state.pre = originalPreState;
10995 return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
10996}
10997
10998// v-once
10999function genOnce (el, state) {
11000 el.onceProcessed = true;
11001 if (el.if && !el.ifProcessed) {
11002 return genIf(el, state)
11003 } else if (el.staticInFor) {
11004 var key = '';
11005 var parent = el.parent;
11006 while (parent) {
11007 if (parent.for) {
11008 key = parent.key;
11009 break
11010 }
11011 parent = parent.parent;
11012 }
11013 if (!key) {
11014 state.warn(
11015 "v-once can only be used inside v-for that is keyed. ",
11016 el.rawAttrsMap['v-once']
11017 );
11018 return genElement(el, state)
11019 }
11020 return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
11021 } else {
11022 return genStatic(el, state)
11023 }
11024}
11025
11026function genIf (
11027 el,
11028 state,
11029 altGen,
11030 altEmpty
11031) {
11032 el.ifProcessed = true; // avoid recursion
11033 return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
11034}
11035
11036function genIfConditions (
11037 conditions,
11038 state,
11039 altGen,
11040 altEmpty
11041) {
11042 if (!conditions.length) {
11043 return altEmpty || '_e()'
11044 }
11045
11046 var condition = conditions.shift();
11047 if (condition.exp) {
11048 return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
11049 } else {
11050 return ("" + (genTernaryExp(condition.block)))
11051 }
11052
11053 // v-if with v-once should generate code like (a)?_m(0):_m(1)
11054 function genTernaryExp (el) {
11055 return altGen
11056 ? altGen(el, state)
11057 : el.once
11058 ? genOnce(el, state)
11059 : genElement(el, state)
11060 }
11061}
11062
11063function genFor (
11064 el,
11065 state,
11066 altGen,
11067 altHelper
11068) {
11069 var exp = el.for;
11070 var alias = el.alias;
11071 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
11072 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
11073
11074 if (state.maybeComponent(el) &&
11075 el.tag !== 'slot' &&
11076 el.tag !== 'template' &&
11077 !el.key
11078 ) {
11079 state.warn(
11080 "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
11081 "v-for should have explicit keys. " +
11082 "See https://vuejs.org/guide/list.html#key for more info.",
11083 el.rawAttrsMap['v-for'],
11084 true /* tip */
11085 );
11086 }
11087
11088 el.forProcessed = true; // avoid recursion
11089 return (altHelper || '_l') + "((" + exp + ")," +
11090 "function(" + alias + iterator1 + iterator2 + "){" +
11091 "return " + ((altGen || genElement)(el, state)) +
11092 '})'
11093}
11094
11095function genData$2 (el, state) {
11096 var data = '{';
11097
11098 // directives first.
11099 // directives may mutate the el's other properties before they are generated.
11100 var dirs = genDirectives(el, state);
11101 if (dirs) { data += dirs + ','; }
11102
11103 // key
11104 if (el.key) {
11105 data += "key:" + (el.key) + ",";
11106 }
11107 // ref
11108 if (el.ref) {
11109 data += "ref:" + (el.ref) + ",";
11110 }
11111 if (el.refInFor) {
11112 data += "refInFor:true,";
11113 }
11114 // pre
11115 if (el.pre) {
11116 data += "pre:true,";
11117 }
11118 // record original tag name for components using "is" attribute
11119 if (el.component) {
11120 data += "tag:\"" + (el.tag) + "\",";
11121 }
11122 // module data generation functions
11123 for (var i = 0; i < state.dataGenFns.length; i++) {
11124 data += state.dataGenFns[i](el);
11125 }
11126 // attributes
11127 if (el.attrs) {
11128 data += "attrs:" + (genProps(el.attrs)) + ",";
11129 }
11130 // DOM props
11131 if (el.props) {
11132 data += "domProps:" + (genProps(el.props)) + ",";
11133 }
11134 // event handlers
11135 if (el.events) {
11136 data += (genHandlers(el.events, false)) + ",";
11137 }
11138 if (el.nativeEvents) {
11139 data += (genHandlers(el.nativeEvents, true)) + ",";
11140 }
11141 // slot target
11142 // only for non-scoped slots
11143 if (el.slotTarget && !el.slotScope) {
11144 data += "slot:" + (el.slotTarget) + ",";
11145 }
11146 // scoped slots
11147 if (el.scopedSlots) {
11148 data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
11149 }
11150 // component v-model
11151 if (el.model) {
11152 data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
11153 }
11154 // inline-template
11155 if (el.inlineTemplate) {
11156 var inlineTemplate = genInlineTemplate(el, state);
11157 if (inlineTemplate) {
11158 data += inlineTemplate + ",";
11159 }
11160 }
11161 data = data.replace(/,$/, '') + '}';
11162 // v-bind dynamic argument wrap
11163 // v-bind with dynamic arguments must be applied using the same v-bind object
11164 // merge helper so that class/style/mustUseProp attrs are handled correctly.
11165 if (el.dynamicAttrs) {
11166 data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
11167 }
11168 // v-bind data wrap
11169 if (el.wrapData) {
11170 data = el.wrapData(data);
11171 }
11172 // v-on data wrap
11173 if (el.wrapListeners) {
11174 data = el.wrapListeners(data);
11175 }
11176 return data
11177}
11178
11179function genDirectives (el, state) {
11180 var dirs = el.directives;
11181 if (!dirs) { return }
11182 var res = 'directives:[';
11183 var hasRuntime = false;
11184 var i, l, dir, needRuntime;
11185 for (i = 0, l = dirs.length; i < l; i++) {
11186 dir = dirs[i];
11187 needRuntime = true;
11188 var gen = state.directives[dir.name];
11189 if (gen) {
11190 // compile-time directive that manipulates AST.
11191 // returns true if it also needs a runtime counterpart.
11192 needRuntime = !!gen(el, dir, state.warn);
11193 }
11194 if (needRuntime) {
11195 hasRuntime = true;
11196 res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
11197 }
11198 }
11199 if (hasRuntime) {
11200 return res.slice(0, -1) + ']'
11201 }
11202}
11203
11204function genInlineTemplate (el, state) {
11205 var ast = el.children[0];
11206 if (el.children.length !== 1 || ast.type !== 1) {
11207 state.warn(
11208 'Inline-template components must have exactly one child element.',
11209 { start: el.start }
11210 );
11211 }
11212 if (ast && ast.type === 1) {
11213 var inlineRenderFns = generate(ast, state.options);
11214 return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
11215 }
11216}
11217
11218function genScopedSlots (
11219 el,
11220 slots,
11221 state
11222) {
11223 // by default scoped slots are considered "stable", this allows child
11224 // components with only scoped slots to skip forced updates from parent.
11225 // but in some cases we have to bail-out of this optimization
11226 // for example if the slot contains dynamic names, has v-if or v-for on them...
11227 var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
11228 var slot = slots[key];
11229 return (
11230 slot.slotTargetDynamic ||
11231 slot.if ||
11232 slot.for ||
11233 containsSlotChild(slot) // is passing down slot from parent which may be dynamic
11234 )
11235 });
11236
11237 // #9534: if a component with scoped slots is inside a conditional branch,
11238 // it's possible for the same component to be reused but with different
11239 // compiled slot content. To avoid that, we generate a unique key based on
11240 // the generated code of all the slot contents.
11241 var needsKey = !!el.if;
11242
11243 // OR when it is inside another scoped slot or v-for (the reactivity may be
11244 // disconnected due to the intermediate scope variable)
11245 // #9438, #9506
11246 // TODO: this can be further optimized by properly analyzing in-scope bindings
11247 // and skip force updating ones that do not actually use scope variables.
11248 if (!needsForceUpdate) {
11249 var parent = el.parent;
11250 while (parent) {
11251 if (
11252 (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
11253 parent.for
11254 ) {
11255 needsForceUpdate = true;
11256 break
11257 }
11258 if (parent.if) {
11259 needsKey = true;
11260 }
11261 parent = parent.parent;
11262 }
11263 }
11264
11265 var generatedSlots = Object.keys(slots)
11266 .map(function (key) { return genScopedSlot(slots[key], state); })
11267 .join(',');
11268
11269 return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
11270}
11271
11272function hash(str) {
11273 var hash = 5381;
11274 var i = str.length;
11275 while(i) {
11276 hash = (hash * 33) ^ str.charCodeAt(--i);
11277 }
11278 return hash >>> 0
11279}
11280
11281function containsSlotChild (el) {
11282 if (el.type === 1) {
11283 if (el.tag === 'slot') {
11284 return true
11285 }
11286 return el.children.some(containsSlotChild)
11287 }
11288 return false
11289}
11290
11291function genScopedSlot (
11292 el,
11293 state
11294) {
11295 var isLegacySyntax = el.attrsMap['slot-scope'];
11296 if (el.if && !el.ifProcessed && !isLegacySyntax) {
11297 return genIf(el, state, genScopedSlot, "null")
11298 }
11299 if (el.for && !el.forProcessed) {
11300 return genFor(el, state, genScopedSlot)
11301 }
11302 var slotScope = el.slotScope === emptySlotScopeToken
11303 ? ""
11304 : String(el.slotScope);
11305 var fn = "function(" + slotScope + "){" +
11306 "return " + (el.tag === 'template'
11307 ? el.if && isLegacySyntax
11308 ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
11309 : genChildren(el, state) || 'undefined'
11310 : genElement(el, state)) + "}";
11311 // reverse proxy v-slot without scope on this.$slots
11312 var reverseProxy = slotScope ? "" : ",proxy:true";
11313 return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
11314}
11315
11316function genChildren (
11317 el,
11318 state,
11319 checkSkip,
11320 altGenElement,
11321 altGenNode
11322) {
11323 var children = el.children;
11324 if (children.length) {
11325 var el$1 = children[0];
11326 // optimize single v-for
11327 if (children.length === 1 &&
11328 el$1.for &&
11329 el$1.tag !== 'template' &&
11330 el$1.tag !== 'slot'
11331 ) {
11332 var normalizationType = checkSkip
11333 ? state.maybeComponent(el$1) ? ",1" : ",0"
11334 : "";
11335 return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
11336 }
11337 var normalizationType$1 = checkSkip
11338 ? getNormalizationType(children, state.maybeComponent)
11339 : 0;
11340 var gen = altGenNode || genNode;
11341 return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
11342 }
11343}
11344
11345// determine the normalization needed for the children array.
11346// 0: no normalization needed
11347// 1: simple normalization needed (possible 1-level deep nested array)
11348// 2: full normalization needed
11349function getNormalizationType (
11350 children,
11351 maybeComponent
11352) {
11353 var res = 0;
11354 for (var i = 0; i < children.length; i++) {
11355 var el = children[i];
11356 if (el.type !== 1) {
11357 continue
11358 }
11359 if (needsNormalization(el) ||
11360 (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
11361 res = 2;
11362 break
11363 }
11364 if (maybeComponent(el) ||
11365 (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
11366 res = 1;
11367 }
11368 }
11369 return res
11370}
11371
11372function needsNormalization (el) {
11373 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
11374}
11375
11376function genNode (node, state) {
11377 if (node.type === 1) {
11378 return genElement(node, state)
11379 } else if (node.type === 3 && node.isComment) {
11380 return genComment(node)
11381 } else {
11382 return genText(node)
11383 }
11384}
11385
11386function genText (text) {
11387 return ("_v(" + (text.type === 2
11388 ? text.expression // no need for () because already wrapped in _s()
11389 : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
11390}
11391
11392function genComment (comment) {
11393 return ("_e(" + (JSON.stringify(comment.text)) + ")")
11394}
11395
11396function genSlot (el, state) {
11397 var slotName = el.slotName || '"default"';
11398 var children = genChildren(el, state);
11399 var res = "_t(" + slotName + (children ? ("," + children) : '');
11400 var attrs = el.attrs || el.dynamicAttrs
11401 ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
11402 // slot props are camelized
11403 name: camelize(attr.name),
11404 value: attr.value,
11405 dynamic: attr.dynamic
11406 }); }))
11407 : null;
11408 var bind$$1 = el.attrsMap['v-bind'];
11409 if ((attrs || bind$$1) && !children) {
11410 res += ",null";
11411 }
11412 if (attrs) {
11413 res += "," + attrs;
11414 }
11415 if (bind$$1) {
11416 res += (attrs ? '' : ',null') + "," + bind$$1;
11417 }
11418 return res + ')'
11419}
11420
11421// componentName is el.component, take it as argument to shun flow's pessimistic refinement
11422function genComponent (
11423 componentName,
11424 el,
11425 state
11426) {
11427 var children = el.inlineTemplate ? null : genChildren(el, state, true);
11428 return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
11429}
11430
11431function genProps (props) {
11432 var staticProps = "";
11433 var dynamicProps = "";
11434 for (var i = 0; i < props.length; i++) {
11435 var prop = props[i];
11436 var value = transformSpecialNewlines(prop.value);
11437 if (prop.dynamic) {
11438 dynamicProps += (prop.name) + "," + value + ",";
11439 } else {
11440 staticProps += "\"" + (prop.name) + "\":" + value + ",";
11441 }
11442 }
11443 staticProps = "{" + (staticProps.slice(0, -1)) + "}";
11444 if (dynamicProps) {
11445 return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
11446 } else {
11447 return staticProps
11448 }
11449}
11450
11451// #3895, #4268
11452function transformSpecialNewlines (text) {
11453 return text
11454 .replace(/\u2028/g, '\\u2028')
11455 .replace(/\u2029/g, '\\u2029')
11456}
11457
11458/* */
11459
11460
11461
11462// these keywords should not appear inside expressions, but operators like
11463// typeof, instanceof and in are allowed
11464var prohibitedKeywordRE = new RegExp('\\b' + (
11465 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
11466 'super,throw,while,yield,delete,export,import,return,switch,default,' +
11467 'extends,finally,continue,debugger,function,arguments'
11468).split(',').join('\\b|\\b') + '\\b');
11469
11470// these unary operators should not be used as property/method names
11471var unaryOperatorsRE = new RegExp('\\b' + (
11472 'delete,typeof,void'
11473).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
11474
11475// strip strings in expressions
11476var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
11477
11478// detect problematic expressions in a template
11479function detectErrors (ast, warn) {
11480 if (ast) {
11481 checkNode(ast, warn);
11482 }
11483}
11484
11485function checkNode (node, warn) {
11486 if (node.type === 1) {
11487 for (var name in node.attrsMap) {
11488 if (dirRE.test(name)) {
11489 var value = node.attrsMap[name];
11490 if (value) {
11491 var range = node.rawAttrsMap[name];
11492 if (name === 'v-for') {
11493 checkFor(node, ("v-for=\"" + value + "\""), warn, range);
11494 } else if (name === 'v-slot' || name[0] === '#') {
11495 checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
11496 } else if (onRE.test(name)) {
11497 checkEvent(value, (name + "=\"" + value + "\""), warn, range);
11498 } else {
11499 checkExpression(value, (name + "=\"" + value + "\""), warn, range);
11500 }
11501 }
11502 }
11503 }
11504 if (node.children) {
11505 for (var i = 0; i < node.children.length; i++) {
11506 checkNode(node.children[i], warn);
11507 }
11508 }
11509 } else if (node.type === 2) {
11510 checkExpression(node.expression, node.text, warn, node);
11511 }
11512}
11513
11514function checkEvent (exp, text, warn, range) {
11515 var stripped = exp.replace(stripStringRE, '');
11516 var keywordMatch = stripped.match(unaryOperatorsRE);
11517 if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
11518 warn(
11519 "avoid using JavaScript unary operator as property name: " +
11520 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
11521 range
11522 );
11523 }
11524 checkExpression(exp, text, warn, range);
11525}
11526
11527function checkFor (node, text, warn, range) {
11528 checkExpression(node.for || '', text, warn, range);
11529 checkIdentifier(node.alias, 'v-for alias', text, warn, range);
11530 checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
11531 checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
11532}
11533
11534function checkIdentifier (
11535 ident,
11536 type,
11537 text,
11538 warn,
11539 range
11540) {
11541 if (typeof ident === 'string') {
11542 try {
11543 new Function(("var " + ident + "=_"));
11544 } catch (e) {
11545 warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
11546 }
11547 }
11548}
11549
11550function checkExpression (exp, text, warn, range) {
11551 try {
11552 new Function(("return " + exp));
11553 } catch (e) {
11554 var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
11555 if (keywordMatch) {
11556 warn(
11557 "avoid using JavaScript keyword as property name: " +
11558 "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
11559 range
11560 );
11561 } else {
11562 warn(
11563 "invalid expression: " + (e.message) + " in\n\n" +
11564 " " + exp + "\n\n" +
11565 " Raw expression: " + (text.trim()) + "\n",
11566 range
11567 );
11568 }
11569 }
11570}
11571
11572function checkFunctionParameterExpression (exp, text, warn, range) {
11573 try {
11574 new Function(exp, '');
11575 } catch (e) {
11576 warn(
11577 "invalid function parameter expression: " + (e.message) + " in\n\n" +
11578 " " + exp + "\n\n" +
11579 " Raw expression: " + (text.trim()) + "\n",
11580 range
11581 );
11582 }
11583}
11584
11585/* */
11586
11587var range = 2;
11588
11589function generateCodeFrame (
11590 source,
11591 start,
11592 end
11593) {
11594 if ( start === void 0 ) start = 0;
11595 if ( end === void 0 ) end = source.length;
11596
11597 var lines = source.split(/\r?\n/);
11598 var count = 0;
11599 var res = [];
11600 for (var i = 0; i < lines.length; i++) {
11601 count += lines[i].length + 1;
11602 if (count >= start) {
11603 for (var j = i - range; j <= i + range || end > count; j++) {
11604 if (j < 0 || j >= lines.length) { continue }
11605 res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
11606 var lineLength = lines[j].length;
11607 if (j === i) {
11608 // push underline
11609 var pad = start - (count - lineLength) + 1;
11610 var length = end > count ? lineLength - pad : end - start;
11611 res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
11612 } else if (j > i) {
11613 if (end > count) {
11614 var length$1 = Math.min(end - count, lineLength);
11615 res.push(" | " + repeat$1("^", length$1));
11616 }
11617 count += lineLength + 1;
11618 }
11619 }
11620 break
11621 }
11622 }
11623 return res.join('\n')
11624}
11625
11626function repeat$1 (str, n) {
11627 var result = '';
11628 if (n > 0) {
11629 while (true) { // eslint-disable-line
11630 if (n & 1) { result += str; }
11631 n >>>= 1;
11632 if (n <= 0) { break }
11633 str += str;
11634 }
11635 }
11636 return result
11637}
11638
11639/* */
11640
11641
11642
11643function createFunction (code, errors) {
11644 try {
11645 return new Function(code)
11646 } catch (err) {
11647 errors.push({ err: err, code: code });
11648 return noop
11649 }
11650}
11651
11652function createCompileToFunctionFn (compile) {
11653 var cache = Object.create(null);
11654
11655 return function compileToFunctions (
11656 template,
11657 options,
11658 vm
11659 ) {
11660 options = extend({}, options);
11661 var warn$$1 = options.warn || warn;
11662 delete options.warn;
11663
11664 /* istanbul ignore if */
11665 {
11666 // detect possible CSP restriction
11667 try {
11668 new Function('return 1');
11669 } catch (e) {
11670 if (e.toString().match(/unsafe-eval|CSP/)) {
11671 warn$$1(
11672 'It seems you are using the standalone build of Vue.js in an ' +
11673 'environment with Content Security Policy that prohibits unsafe-eval. ' +
11674 'The template compiler cannot work in this environment. Consider ' +
11675 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
11676 'templates into render functions.'
11677 );
11678 }
11679 }
11680 }
11681
11682 // check cache
11683 var key = options.delimiters
11684 ? String(options.delimiters) + template
11685 : template;
11686 if (cache[key]) {
11687 return cache[key]
11688 }
11689
11690 // compile
11691 var compiled = compile(template, options);
11692
11693 // check compilation errors/tips
11694 {
11695 if (compiled.errors && compiled.errors.length) {
11696 if (options.outputSourceRange) {
11697 compiled.errors.forEach(function (e) {
11698 warn$$1(
11699 "Error compiling template:\n\n" + (e.msg) + "\n\n" +
11700 generateCodeFrame(template, e.start, e.end),
11701 vm
11702 );
11703 });
11704 } else {
11705 warn$$1(
11706 "Error compiling template:\n\n" + template + "\n\n" +
11707 compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
11708 vm
11709 );
11710 }
11711 }
11712 if (compiled.tips && compiled.tips.length) {
11713 if (options.outputSourceRange) {
11714 compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
11715 } else {
11716 compiled.tips.forEach(function (msg) { return tip(msg, vm); });
11717 }
11718 }
11719 }
11720
11721 // turn code into functions
11722 var res = {};
11723 var fnGenErrors = [];
11724 res.render = createFunction(compiled.render, fnGenErrors);
11725 res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
11726 return createFunction(code, fnGenErrors)
11727 });
11728
11729 // check function generation errors.
11730 // this should only happen if there is a bug in the compiler itself.
11731 // mostly for codegen development use
11732 /* istanbul ignore if */
11733 {
11734 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
11735 warn$$1(
11736 "Failed to generate render function:\n\n" +
11737 fnGenErrors.map(function (ref) {
11738 var err = ref.err;
11739 var code = ref.code;
11740
11741 return ((err.toString()) + " in\n\n" + code + "\n");
11742 }).join('\n'),
11743 vm
11744 );
11745 }
11746 }
11747
11748 return (cache[key] = res)
11749 }
11750}
11751
11752/* */
11753
11754function createCompilerCreator (baseCompile) {
11755 return function createCompiler (baseOptions) {
11756 function compile (
11757 template,
11758 options
11759 ) {
11760 var finalOptions = Object.create(baseOptions);
11761 var errors = [];
11762 var tips = [];
11763
11764 var warn = function (msg, range, tip) {
11765 (tip ? tips : errors).push(msg);
11766 };
11767
11768 if (options) {
11769 if (options.outputSourceRange) {
11770 // $flow-disable-line
11771 var leadingSpaceLength = template.match(/^\s*/)[0].length;
11772
11773 warn = function (msg, range, tip) {
11774 var data = { msg: msg };
11775 if (range) {
11776 if (range.start != null) {
11777 data.start = range.start + leadingSpaceLength;
11778 }
11779 if (range.end != null) {
11780 data.end = range.end + leadingSpaceLength;
11781 }
11782 }
11783 (tip ? tips : errors).push(data);
11784 };
11785 }
11786 // merge custom modules
11787 if (options.modules) {
11788 finalOptions.modules =
11789 (baseOptions.modules || []).concat(options.modules);
11790 }
11791 // merge custom directives
11792 if (options.directives) {
11793 finalOptions.directives = extend(
11794 Object.create(baseOptions.directives || null),
11795 options.directives
11796 );
11797 }
11798 // copy other options
11799 for (var key in options) {
11800 if (key !== 'modules' && key !== 'directives') {
11801 finalOptions[key] = options[key];
11802 }
11803 }
11804 }
11805
11806 finalOptions.warn = warn;
11807
11808 var compiled = baseCompile(template.trim(), finalOptions);
11809 {
11810 detectErrors(compiled.ast, warn);
11811 }
11812 compiled.errors = errors;
11813 compiled.tips = tips;
11814 return compiled
11815 }
11816
11817 return {
11818 compile: compile,
11819 compileToFunctions: createCompileToFunctionFn(compile)
11820 }
11821 }
11822}
11823
11824/* */
11825
11826// `createCompilerCreator` allows creating compilers that use alternative
11827// parser/optimizer/codegen, e.g the SSR optimizing compiler.
11828// Here we just export a default compiler using the default parts.
11829var createCompiler = createCompilerCreator(function baseCompile (
11830 template,
11831 options
11832) {
11833 var ast = parse(template.trim(), options);
11834 if (options.optimize !== false) {
11835 optimize(ast, options);
11836 }
11837 var code = generate(ast, options);
11838 return {
11839 ast: ast,
11840 render: code.render,
11841 staticRenderFns: code.staticRenderFns
11842 }
11843});
11844
11845/* */
11846
11847var ref$1 = createCompiler(baseOptions);
11848var compile = ref$1.compile;
11849var compileToFunctions = ref$1.compileToFunctions;
11850
11851/* */
11852
11853// check whether current browser encodes a char inside attribute values
11854var div;
11855function getShouldDecode (href) {
11856 div = div || document.createElement('div');
11857 div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
11858 return div.innerHTML.indexOf('&#10;') > 0
11859}
11860
11861// #3663: IE encodes newlines inside attribute values while other browsers don't
11862var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
11863// #6828: chrome encodes content in a[href]
11864var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
11865
11866/* */
11867
11868var idToTemplate = cached(function (id) {
11869 var el = query(id);
11870 return el && el.innerHTML
11871});
11872
11873var mount = Vue.prototype.$mount;
11874Vue.prototype.$mount = function (
11875 el,
11876 hydrating
11877) {
11878 el = el && query(el);
11879
11880 /* istanbul ignore if */
11881 if (el === document.body || el === document.documentElement) {
11882 warn(
11883 "Do not mount Vue to <html> or <body> - mount to normal elements instead."
11884 );
11885 return this
11886 }
11887
11888 var options = this.$options;
11889 // resolve template/el and convert to render function
11890 if (!options.render) {
11891 var template = options.template;
11892 if (template) {
11893 if (typeof template === 'string') {
11894 if (template.charAt(0) === '#') {
11895 template = idToTemplate(template);
11896 /* istanbul ignore if */
11897 if (!template) {
11898 warn(
11899 ("Template element not found or is empty: " + (options.template)),
11900 this
11901 );
11902 }
11903 }
11904 } else if (template.nodeType) {
11905 template = template.innerHTML;
11906 } else {
11907 {
11908 warn('invalid template option:' + template, this);
11909 }
11910 return this
11911 }
11912 } else if (el) {
11913 template = getOuterHTML(el);
11914 }
11915 if (template) {
11916 /* istanbul ignore if */
11917 if (config.performance && mark) {
11918 mark('compile');
11919 }
11920
11921 var ref = compileToFunctions(template, {
11922 outputSourceRange: "development" !== 'production',
11923 shouldDecodeNewlines: shouldDecodeNewlines,
11924 shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
11925 delimiters: options.delimiters,
11926 comments: options.comments
11927 }, this);
11928 var render = ref.render;
11929 var staticRenderFns = ref.staticRenderFns;
11930 options.render = render;
11931 options.staticRenderFns = staticRenderFns;
11932
11933 /* istanbul ignore if */
11934 if (config.performance && mark) {
11935 mark('compile end');
11936 measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
11937 }
11938 }
11939 }
11940 return mount.call(this, el, hydrating)
11941};
11942
11943/**
11944 * Get outerHTML of elements, taking care
11945 * of SVG elements in IE as well.
11946 */
11947function getOuterHTML (el) {
11948 if (el.outerHTML) {
11949 return el.outerHTML
11950 } else {
11951 var container = document.createElement('div');
11952 container.appendChild(el.cloneNode(true));
11953 return container.innerHTML
11954 }
11955}
11956
11957Vue.compile = compileToFunctions;
11958
11959module.exports = Vue;