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