UNPKG

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