UNPKG

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