UNPKG

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