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