1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict';
|
7 |
|
8 |
|
9 |
|
10 | var emptyObject = Object.freeze({});
|
11 |
|
12 |
|
13 |
|
14 | function isUndef (v) {
|
15 | return v === undefined || v === null
|
16 | }
|
17 |
|
18 | function isDef (v) {
|
19 | return v !== undefined && v !== null
|
20 | }
|
21 |
|
22 | function isTrue (v) {
|
23 | return v === true
|
24 | }
|
25 |
|
26 | function isFalse (v) {
|
27 | return v === false
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | function isPrimitive (value) {
|
34 | return (
|
35 | typeof value === 'string' ||
|
36 | typeof value === 'number' ||
|
37 |
|
38 | typeof value === 'symbol' ||
|
39 | typeof value === 'boolean'
|
40 | )
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | function isObject (obj) {
|
49 | return obj !== null && typeof obj === 'object'
|
50 | }
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | var _toString = Object.prototype.toString;
|
56 |
|
57 | function toRawType (value) {
|
58 | return _toString.call(value).slice(8, -1)
|
59 | }
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | function isPlainObject (obj) {
|
66 | return _toString.call(obj) === '[object Object]'
|
67 | }
|
68 |
|
69 | function isRegExp (v) {
|
70 | return _toString.call(v) === '[object RegExp]'
|
71 | }
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | function isValidArrayIndex (val) {
|
77 | var n = parseFloat(String(val));
|
78 | return n >= 0 && Math.floor(n) === n && isFinite(val)
|
79 | }
|
80 |
|
81 | function isPromise (val) {
|
82 | return (
|
83 | isDef(val) &&
|
84 | typeof val.then === 'function' &&
|
85 | typeof val.catch === 'function'
|
86 | )
|
87 | }
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | function toString (val) {
|
93 | return val == null
|
94 | ? ''
|
95 | : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
|
96 | ? JSON.stringify(val, null, 2)
|
97 | : String(val)
|
98 | }
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | function toNumber (val) {
|
105 | var n = parseFloat(val);
|
106 | return isNaN(n) ? val : n
|
107 | }
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | function makeMap (
|
114 | str,
|
115 | expectsLowerCase
|
116 | ) {
|
117 | var map = Object.create(null);
|
118 | var list = str.split(',');
|
119 | for (var i = 0; i < list.length; i++) {
|
120 | map[list[i]] = true;
|
121 | }
|
122 | return expectsLowerCase
|
123 | ? function (val) { return map[val.toLowerCase()]; }
|
124 | : function (val) { return map[val]; }
|
125 | }
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | var isBuiltInTag = makeMap('slot,component', true);
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
|
136 |
|
137 |
|
138 |
|
139 |
|
140 | function remove (arr, item) {
|
141 | if (arr.length) {
|
142 | var index = arr.indexOf(item);
|
143 | if (index > -1) {
|
144 | return arr.splice(index, 1)
|
145 | }
|
146 | }
|
147 | }
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
153 | function hasOwn (obj, key) {
|
154 | return hasOwnProperty.call(obj, key)
|
155 | }
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | function cached (fn) {
|
161 | var cache = Object.create(null);
|
162 | return (function cachedFn (str) {
|
163 | var hit = cache[str];
|
164 | return hit || (cache[str] = fn(str))
|
165 | })
|
166 | }
|
167 |
|
168 |
|
169 |
|
170 |
|
171 | var camelizeRE = /-(\w)/g;
|
172 | var camelize = cached(function (str) {
|
173 | return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
|
174 | });
|
175 |
|
176 |
|
177 |
|
178 |
|
179 | var capitalize = cached(function (str) {
|
180 | return str.charAt(0).toUpperCase() + str.slice(1)
|
181 | });
|
182 |
|
183 |
|
184 |
|
185 |
|
186 | var hyphenateRE = /\B([A-Z])/g;
|
187 | var hyphenate = cached(function (str) {
|
188 | return str.replace(hyphenateRE, '-$1').toLowerCase()
|
189 | });
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 | function polyfillBind (fn, ctx) {
|
201 | function boundFn (a) {
|
202 | var l = arguments.length;
|
203 | return l
|
204 | ? l > 1
|
205 | ? fn.apply(ctx, arguments)
|
206 | : fn.call(ctx, a)
|
207 | : fn.call(ctx)
|
208 | }
|
209 |
|
210 | boundFn._length = fn.length;
|
211 | return boundFn
|
212 | }
|
213 |
|
214 | function nativeBind (fn, ctx) {
|
215 | return fn.bind(ctx)
|
216 | }
|
217 |
|
218 | var bind = Function.prototype.bind
|
219 | ? nativeBind
|
220 | : polyfillBind;
|
221 |
|
222 |
|
223 |
|
224 |
|
225 | function toArray (list, start) {
|
226 | start = start || 0;
|
227 | var i = list.length - start;
|
228 | var ret = new Array(i);
|
229 | while (i--) {
|
230 | ret[i] = list[i + start];
|
231 | }
|
232 | return ret
|
233 | }
|
234 |
|
235 |
|
236 |
|
237 |
|
238 | function extend (to, _from) {
|
239 | for (var key in _from) {
|
240 | to[key] = _from[key];
|
241 | }
|
242 | return to
|
243 | }
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | function toObject (arr) {
|
249 | var res = {};
|
250 | for (var i = 0; i < arr.length; i++) {
|
251 | if (arr[i]) {
|
252 | extend(res, arr[i]);
|
253 | }
|
254 | }
|
255 | return res
|
256 | }
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | function noop (a, b, c) {}
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | var no = function (a, b, c) { return false; };
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 | var identity = function (_) { return _; };
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | function genStaticKeys (modules) {
|
283 | return modules.reduce(function (keys, m) {
|
284 | return keys.concat(m.staticKeys || [])
|
285 | }, []).join(',')
|
286 | }
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | function looseEqual (a, b) {
|
293 | if (a === b) { return true }
|
294 | var isObjectA = isObject(a);
|
295 | var isObjectB = isObject(b);
|
296 | if (isObjectA && isObjectB) {
|
297 | try {
|
298 | var isArrayA = Array.isArray(a);
|
299 | var isArrayB = Array.isArray(b);
|
300 | if (isArrayA && isArrayB) {
|
301 | return a.length === b.length && a.every(function (e, i) {
|
302 | return looseEqual(e, b[i])
|
303 | })
|
304 | } else if (a instanceof Date && b instanceof Date) {
|
305 | return a.getTime() === b.getTime()
|
306 | } else if (!isArrayA && !isArrayB) {
|
307 | var keysA = Object.keys(a);
|
308 | var keysB = Object.keys(b);
|
309 | return keysA.length === keysB.length && keysA.every(function (key) {
|
310 | return looseEqual(a[key], b[key])
|
311 | })
|
312 | } else {
|
313 |
|
314 | return false
|
315 | }
|
316 | } catch (e) {
|
317 |
|
318 | return false
|
319 | }
|
320 | } else if (!isObjectA && !isObjectB) {
|
321 | return String(a) === String(b)
|
322 | } else {
|
323 | return false
|
324 | }
|
325 | }
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 | function looseIndexOf (arr, val) {
|
333 | for (var i = 0; i < arr.length; i++) {
|
334 | if (looseEqual(arr[i], val)) { return i }
|
335 | }
|
336 | return -1
|
337 | }
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | function once (fn) {
|
343 | var called = false;
|
344 | return function () {
|
345 | if (!called) {
|
346 | called = true;
|
347 | fn.apply(this, arguments);
|
348 | }
|
349 | }
|
350 | }
|
351 |
|
352 | var SSR_ATTR = 'data-server-rendered';
|
353 |
|
354 | var ASSET_TYPES = [
|
355 | 'component',
|
356 | 'directive',
|
357 | 'filter'
|
358 | ];
|
359 |
|
360 | var LIFECYCLE_HOOKS = [
|
361 | 'beforeCreate',
|
362 | 'created',
|
363 | 'beforeMount',
|
364 | 'mounted',
|
365 | 'beforeUpdate',
|
366 | 'updated',
|
367 | 'beforeDestroy',
|
368 | 'destroyed',
|
369 | 'activated',
|
370 | 'deactivated',
|
371 | 'errorCaptured',
|
372 | 'serverPrefetch'
|
373 | ];
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 | var config = ({
|
380 | |
381 |
|
382 |
|
383 |
|
384 | optionMergeStrategies: Object.create(null),
|
385 |
|
386 | |
387 |
|
388 |
|
389 | silent: false,
|
390 |
|
391 | |
392 |
|
393 |
|
394 | productionTip: "development" !== 'production',
|
395 |
|
396 | |
397 |
|
398 |
|
399 | devtools: "development" !== 'production',
|
400 |
|
401 | |
402 |
|
403 |
|
404 | performance: false,
|
405 |
|
406 | |
407 |
|
408 |
|
409 | errorHandler: null,
|
410 |
|
411 | |
412 |
|
413 |
|
414 | warnHandler: null,
|
415 |
|
416 | |
417 |
|
418 |
|
419 | ignoredElements: [],
|
420 |
|
421 | |
422 |
|
423 |
|
424 |
|
425 | keyCodes: Object.create(null),
|
426 |
|
427 | |
428 |
|
429 |
|
430 |
|
431 | isReservedTag: no,
|
432 |
|
433 | |
434 |
|
435 |
|
436 |
|
437 | isReservedAttr: no,
|
438 |
|
439 | |
440 |
|
441 |
|
442 |
|
443 | isUnknownElement: no,
|
444 |
|
445 | |
446 |
|
447 |
|
448 | getTagNamespace: noop,
|
449 |
|
450 | |
451 |
|
452 |
|
453 | parsePlatformTagName: identity,
|
454 |
|
455 | |
456 |
|
457 |
|
458 |
|
459 | mustUseProp: no,
|
460 |
|
461 | |
462 |
|
463 |
|
464 |
|
465 | async: true,
|
466 |
|
467 | |
468 |
|
469 |
|
470 | _lifecycleHooks: LIFECYCLE_HOOKS
|
471 | });
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 | var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | function isReserved (str) {
|
486 | var c = (str + '').charCodeAt(0);
|
487 | return c === 0x24 || c === 0x5F
|
488 | }
|
489 |
|
490 |
|
491 |
|
492 |
|
493 | function def (obj, key, val, enumerable) {
|
494 | Object.defineProperty(obj, key, {
|
495 | value: val,
|
496 | enumerable: !!enumerable,
|
497 | writable: true,
|
498 | configurable: true
|
499 | });
|
500 | }
|
501 |
|
502 |
|
503 |
|
504 |
|
505 | var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
|
506 | function parsePath (path) {
|
507 | if (bailRE.test(path)) {
|
508 | return
|
509 | }
|
510 | var segments = path.split('.');
|
511 | return function (obj) {
|
512 | for (var i = 0; i < segments.length; i++) {
|
513 | if (!obj) { return }
|
514 | obj = obj[segments[i]];
|
515 | }
|
516 | return obj
|
517 | }
|
518 | }
|
519 |
|
520 |
|
521 |
|
522 |
|
523 | var hasProto = '__proto__' in {};
|
524 |
|
525 |
|
526 | var inBrowser = typeof window !== 'undefined';
|
527 | var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
|
528 | var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
|
529 | var UA = inBrowser && window.navigator.userAgent.toLowerCase();
|
530 | var isIE = UA && /msie|trident/.test(UA);
|
531 | var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
|
532 | var isEdge = UA && UA.indexOf('edge/') > 0;
|
533 | var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
|
534 | var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
|
535 | var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
536 | var isPhantomJS = UA && /phantomjs/.test(UA);
|
537 | var isFF = UA && UA.match(/firefox\/(\d+)/);
|
538 |
|
539 |
|
540 | var nativeWatch = ({}).watch;
|
541 |
|
542 | var supportsPassive = false;
|
543 | if (inBrowser) {
|
544 | try {
|
545 | var opts = {};
|
546 | Object.defineProperty(opts, 'passive', ({
|
547 | get: function get () {
|
548 |
|
549 | supportsPassive = true;
|
550 | }
|
551 | }));
|
552 | window.addEventListener('test-passive', null, opts);
|
553 | } catch (e) {}
|
554 | }
|
555 |
|
556 |
|
557 |
|
558 | var _isServer;
|
559 | var isServerRendering = function () {
|
560 | if (_isServer === undefined) {
|
561 |
|
562 | if (!inBrowser && !inWeex && typeof global !== 'undefined') {
|
563 |
|
564 |
|
565 | _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
|
566 | } else {
|
567 | _isServer = false;
|
568 | }
|
569 | }
|
570 | return _isServer
|
571 | };
|
572 |
|
573 |
|
574 | var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
575 |
|
576 |
|
577 | function isNative (Ctor) {
|
578 | return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
|
579 | }
|
580 |
|
581 | var hasSymbol =
|
582 | typeof Symbol !== 'undefined' && isNative(Symbol) &&
|
583 | typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
|
584 |
|
585 | var _Set;
|
586 |
|
587 | if (typeof Set !== 'undefined' && isNative(Set)) {
|
588 |
|
589 | _Set = Set;
|
590 | } else {
|
591 |
|
592 | _Set = (function () {
|
593 | function Set () {
|
594 | this.set = Object.create(null);
|
595 | }
|
596 | Set.prototype.has = function has (key) {
|
597 | return this.set[key] === true
|
598 | };
|
599 | Set.prototype.add = function add (key) {
|
600 | this.set[key] = true;
|
601 | };
|
602 | Set.prototype.clear = function clear () {
|
603 | this.set = Object.create(null);
|
604 | };
|
605 |
|
606 | return Set;
|
607 | }());
|
608 | }
|
609 |
|
610 |
|
611 |
|
612 | var warn = noop;
|
613 | var tip = noop;
|
614 | var generateComponentTrace = (noop);
|
615 | var formatComponentName = (noop);
|
616 |
|
617 | {
|
618 | var hasConsole = typeof console !== 'undefined';
|
619 | var classifyRE = /(?:^|[-_])(\w)/g;
|
620 | var classify = function (str) { return str
|
621 | .replace(classifyRE, function (c) { return c.toUpperCase(); })
|
622 | .replace(/[-_]/g, ''); };
|
623 |
|
624 | warn = function (msg, vm) {
|
625 | var trace = vm ? generateComponentTrace(vm) : '';
|
626 |
|
627 | if (config.warnHandler) {
|
628 | config.warnHandler.call(null, msg, vm, trace);
|
629 | } else if (hasConsole && (!config.silent)) {
|
630 | console.error(("[Vue warn]: " + msg + trace));
|
631 | }
|
632 | };
|
633 |
|
634 | tip = function (msg, vm) {
|
635 | if (hasConsole && (!config.silent)) {
|
636 | console.warn("[Vue tip]: " + msg + (
|
637 | vm ? generateComponentTrace(vm) : ''
|
638 | ));
|
639 | }
|
640 | };
|
641 |
|
642 | formatComponentName = function (vm, includeFile) {
|
643 | if (vm.$root === vm) {
|
644 | return '<Root>'
|
645 | }
|
646 | var options = typeof vm === 'function' && vm.cid != null
|
647 | ? vm.options
|
648 | : vm._isVue
|
649 | ? vm.$options || vm.constructor.options
|
650 | : vm;
|
651 | var name = options.name || options._componentTag;
|
652 | var file = options.__file;
|
653 | if (!name && file) {
|
654 | var match = file.match(/([^/\\]+)\.vue$/);
|
655 | name = match && match[1];
|
656 | }
|
657 |
|
658 | return (
|
659 | (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
|
660 | (file && includeFile !== false ? (" at " + file) : '')
|
661 | )
|
662 | };
|
663 |
|
664 | var repeat = function (str, n) {
|
665 | var res = '';
|
666 | while (n) {
|
667 | if (n % 2 === 1) { res += str; }
|
668 | if (n > 1) { str += str; }
|
669 | n >>= 1;
|
670 | }
|
671 | return res
|
672 | };
|
673 |
|
674 | generateComponentTrace = function (vm) {
|
675 | if (vm._isVue && vm.$parent) {
|
676 | var tree = [];
|
677 | var currentRecursiveSequence = 0;
|
678 | while (vm) {
|
679 | if (tree.length > 0) {
|
680 | var last = tree[tree.length - 1];
|
681 | if (last.constructor === vm.constructor) {
|
682 | currentRecursiveSequence++;
|
683 | vm = vm.$parent;
|
684 | continue
|
685 | } else if (currentRecursiveSequence > 0) {
|
686 | tree[tree.length - 1] = [last, currentRecursiveSequence];
|
687 | currentRecursiveSequence = 0;
|
688 | }
|
689 | }
|
690 | tree.push(vm);
|
691 | vm = vm.$parent;
|
692 | }
|
693 | return '\n\nfound in\n\n' + tree
|
694 | .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
|
695 | ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
|
696 | : formatComponentName(vm))); })
|
697 | .join('\n')
|
698 | } else {
|
699 | return ("\n\n(found in " + (formatComponentName(vm)) + ")")
|
700 | }
|
701 | };
|
702 | }
|
703 |
|
704 |
|
705 |
|
706 | var uid = 0;
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 | var Dep = function Dep () {
|
713 | this.id = uid++;
|
714 | this.subs = [];
|
715 | };
|
716 |
|
717 | Dep.prototype.addSub = function addSub (sub) {
|
718 | this.subs.push(sub);
|
719 | };
|
720 |
|
721 | Dep.prototype.removeSub = function removeSub (sub) {
|
722 | remove(this.subs, sub);
|
723 | };
|
724 |
|
725 | Dep.prototype.depend = function depend () {
|
726 | if (Dep.target) {
|
727 | Dep.target.addDep(this);
|
728 | }
|
729 | };
|
730 |
|
731 | Dep.prototype.notify = function notify () {
|
732 |
|
733 | var subs = this.subs.slice();
|
734 | if (!config.async) {
|
735 |
|
736 |
|
737 |
|
738 | subs.sort(function (a, b) { return a.id - b.id; });
|
739 | }
|
740 | for (var i = 0, l = subs.length; i < l; i++) {
|
741 | subs[i].update();
|
742 | }
|
743 | };
|
744 |
|
745 |
|
746 |
|
747 |
|
748 | Dep.target = null;
|
749 | var targetStack = [];
|
750 |
|
751 | function pushTarget (target) {
|
752 | targetStack.push(target);
|
753 | Dep.target = target;
|
754 | }
|
755 |
|
756 | function popTarget () {
|
757 | targetStack.pop();
|
758 | Dep.target = targetStack[targetStack.length - 1];
|
759 | }
|
760 |
|
761 |
|
762 |
|
763 | var VNode = function VNode (
|
764 | tag,
|
765 | data,
|
766 | children,
|
767 | text,
|
768 | elm,
|
769 | context,
|
770 | componentOptions,
|
771 | asyncFactory
|
772 | ) {
|
773 | this.tag = tag;
|
774 | this.data = data;
|
775 | this.children = children;
|
776 | this.text = text;
|
777 | this.elm = elm;
|
778 | this.ns = undefined;
|
779 | this.context = context;
|
780 | this.fnContext = undefined;
|
781 | this.fnOptions = undefined;
|
782 | this.fnScopeId = undefined;
|
783 | this.key = data && data.key;
|
784 | this.componentOptions = componentOptions;
|
785 | this.componentInstance = undefined;
|
786 | this.parent = undefined;
|
787 | this.raw = false;
|
788 | this.isStatic = false;
|
789 | this.isRootInsert = true;
|
790 | this.isComment = false;
|
791 | this.isCloned = false;
|
792 | this.isOnce = false;
|
793 | this.asyncFactory = asyncFactory;
|
794 | this.asyncMeta = undefined;
|
795 | this.isAsyncPlaceholder = false;
|
796 | };
|
797 |
|
798 | var prototypeAccessors = { child: { configurable: true } };
|
799 |
|
800 |
|
801 |
|
802 | prototypeAccessors.child.get = function () {
|
803 | return this.componentInstance
|
804 | };
|
805 |
|
806 | Object.defineProperties( VNode.prototype, prototypeAccessors );
|
807 |
|
808 | var createEmptyVNode = function (text) {
|
809 | if ( text === void 0 ) text = '';
|
810 |
|
811 | var node = new VNode();
|
812 | node.text = text;
|
813 | node.isComment = true;
|
814 | return node
|
815 | };
|
816 |
|
817 | function createTextVNode (val) {
|
818 | return new VNode(undefined, undefined, undefined, String(val))
|
819 | }
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 | function cloneVNode (vnode) {
|
826 | var cloned = new VNode(
|
827 | vnode.tag,
|
828 | vnode.data,
|
829 |
|
830 |
|
831 |
|
832 | vnode.children && vnode.children.slice(),
|
833 | vnode.text,
|
834 | vnode.elm,
|
835 | vnode.context,
|
836 | vnode.componentOptions,
|
837 | vnode.asyncFactory
|
838 | );
|
839 | cloned.ns = vnode.ns;
|
840 | cloned.isStatic = vnode.isStatic;
|
841 | cloned.key = vnode.key;
|
842 | cloned.isComment = vnode.isComment;
|
843 | cloned.fnContext = vnode.fnContext;
|
844 | cloned.fnOptions = vnode.fnOptions;
|
845 | cloned.fnScopeId = vnode.fnScopeId;
|
846 | cloned.asyncMeta = vnode.asyncMeta;
|
847 | cloned.isCloned = true;
|
848 | return cloned
|
849 | }
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 | var arrayProto = Array.prototype;
|
857 | var arrayMethods = Object.create(arrayProto);
|
858 |
|
859 | var methodsToPatch = [
|
860 | 'push',
|
861 | 'pop',
|
862 | 'shift',
|
863 | 'unshift',
|
864 | 'splice',
|
865 | 'sort',
|
866 | 'reverse'
|
867 | ];
|
868 |
|
869 |
|
870 |
|
871 |
|
872 | methodsToPatch.forEach(function (method) {
|
873 |
|
874 | var original = arrayProto[method];
|
875 | def(arrayMethods, method, function mutator () {
|
876 | var args = [], len = arguments.length;
|
877 | while ( len-- ) args[ len ] = arguments[ len ];
|
878 |
|
879 | var result = original.apply(this, args);
|
880 | var ob = this.__ob__;
|
881 | var inserted;
|
882 | switch (method) {
|
883 | case 'push':
|
884 | case 'unshift':
|
885 | inserted = args;
|
886 | break
|
887 | case 'splice':
|
888 | inserted = args.slice(2);
|
889 | break
|
890 | }
|
891 | if (inserted) { ob.observeArray(inserted); }
|
892 |
|
893 | ob.dep.notify();
|
894 | return result
|
895 | });
|
896 | });
|
897 |
|
898 |
|
899 |
|
900 | var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 | var shouldObserve = true;
|
907 |
|
908 | function toggleObserving (value) {
|
909 | shouldObserve = value;
|
910 | }
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 | var Observer = function Observer (value) {
|
919 | this.value = value;
|
920 | this.dep = new Dep();
|
921 | this.vmCount = 0;
|
922 | def(value, '__ob__', this);
|
923 | if (Array.isArray(value)) {
|
924 | if (hasProto) {
|
925 | protoAugment(value, arrayMethods);
|
926 | } else {
|
927 | copyAugment(value, arrayMethods, arrayKeys);
|
928 | }
|
929 | this.observeArray(value);
|
930 | } else {
|
931 | this.walk(value);
|
932 | }
|
933 | };
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 | Observer.prototype.walk = function walk (obj) {
|
941 | var keys = Object.keys(obj);
|
942 | for (var i = 0; i < keys.length; i++) {
|
943 | defineReactive$$1(obj, keys[i]);
|
944 | }
|
945 | };
|
946 |
|
947 |
|
948 |
|
949 |
|
950 | Observer.prototype.observeArray = function observeArray (items) {
|
951 | for (var i = 0, l = items.length; i < l; i++) {
|
952 | observe(items[i]);
|
953 | }
|
954 | };
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 | function protoAugment (target, src) {
|
963 |
|
964 | target.__proto__ = src;
|
965 |
|
966 | }
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | function copyAugment (target, src, keys) {
|
974 | for (var i = 0, l = keys.length; i < l; i++) {
|
975 | var key = keys[i];
|
976 | def(target, key, src[key]);
|
977 | }
|
978 | }
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 | function observe (value, asRootData) {
|
986 | if (!isObject(value) || value instanceof VNode) {
|
987 | return
|
988 | }
|
989 | var ob;
|
990 | if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
991 | ob = value.__ob__;
|
992 | } else if (
|
993 | shouldObserve &&
|
994 | !isServerRendering() &&
|
995 | (Array.isArray(value) || isPlainObject(value)) &&
|
996 | Object.isExtensible(value) &&
|
997 | !value._isVue
|
998 | ) {
|
999 | ob = new Observer(value);
|
1000 | }
|
1001 | if (asRootData && ob) {
|
1002 | ob.vmCount++;
|
1003 | }
|
1004 | return ob
|
1005 | }
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 | function defineReactive$$1 (
|
1011 | obj,
|
1012 | key,
|
1013 | val,
|
1014 | customSetter,
|
1015 | shallow
|
1016 | ) {
|
1017 | var dep = new Dep();
|
1018 |
|
1019 | var property = Object.getOwnPropertyDescriptor(obj, key);
|
1020 | if (property && property.configurable === false) {
|
1021 | return
|
1022 | }
|
1023 |
|
1024 |
|
1025 | var getter = property && property.get;
|
1026 | var setter = property && property.set;
|
1027 | if ((!getter || setter) && arguments.length === 2) {
|
1028 | val = obj[key];
|
1029 | }
|
1030 |
|
1031 | var childOb = !shallow && observe(val);
|
1032 | Object.defineProperty(obj, key, {
|
1033 | enumerable: true,
|
1034 | configurable: true,
|
1035 | get: function reactiveGetter () {
|
1036 | var value = getter ? getter.call(obj) : val;
|
1037 | if (Dep.target) {
|
1038 | dep.depend();
|
1039 | if (childOb) {
|
1040 | childOb.dep.depend();
|
1041 | if (Array.isArray(value)) {
|
1042 | dependArray(value);
|
1043 | }
|
1044 | }
|
1045 | }
|
1046 | return value
|
1047 | },
|
1048 | set: function reactiveSetter (newVal) {
|
1049 | var value = getter ? getter.call(obj) : val;
|
1050 |
|
1051 | if (newVal === value || (newVal !== newVal && value !== value)) {
|
1052 | return
|
1053 | }
|
1054 |
|
1055 | if (customSetter) {
|
1056 | customSetter();
|
1057 | }
|
1058 |
|
1059 | if (getter && !setter) { return }
|
1060 | if (setter) {
|
1061 | setter.call(obj, newVal);
|
1062 | } else {
|
1063 | val = newVal;
|
1064 | }
|
1065 | childOb = !shallow && observe(newVal);
|
1066 | dep.notify();
|
1067 | }
|
1068 | });
|
1069 | }
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 | function set (target, key, val) {
|
1077 | if (isUndef(target) || isPrimitive(target)
|
1078 | ) {
|
1079 | warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
|
1080 | }
|
1081 | if (Array.isArray(target) && isValidArrayIndex(key)) {
|
1082 | target.length = Math.max(target.length, key);
|
1083 | target.splice(key, 1, val);
|
1084 | return val
|
1085 | }
|
1086 | if (key in target && !(key in Object.prototype)) {
|
1087 | target[key] = val;
|
1088 | return val
|
1089 | }
|
1090 | var ob = (target).__ob__;
|
1091 | if (target._isVue || (ob && ob.vmCount)) {
|
1092 | warn(
|
1093 | 'Avoid adding reactive properties to a Vue instance or its root $data ' +
|
1094 | 'at runtime - declare it upfront in the data option.'
|
1095 | );
|
1096 | return val
|
1097 | }
|
1098 | if (!ob) {
|
1099 | target[key] = val;
|
1100 | return val
|
1101 | }
|
1102 | defineReactive$$1(ob.value, key, val);
|
1103 | ob.dep.notify();
|
1104 | return val
|
1105 | }
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 | function del (target, key) {
|
1111 | if (isUndef(target) || isPrimitive(target)
|
1112 | ) {
|
1113 | warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
|
1114 | }
|
1115 | if (Array.isArray(target) && isValidArrayIndex(key)) {
|
1116 | target.splice(key, 1);
|
1117 | return
|
1118 | }
|
1119 | var ob = (target).__ob__;
|
1120 | if (target._isVue || (ob && ob.vmCount)) {
|
1121 | warn(
|
1122 | 'Avoid deleting properties on a Vue instance or its root $data ' +
|
1123 | '- just set it to null.'
|
1124 | );
|
1125 | return
|
1126 | }
|
1127 | if (!hasOwn(target, key)) {
|
1128 | return
|
1129 | }
|
1130 | delete target[key];
|
1131 | if (!ob) {
|
1132 | return
|
1133 | }
|
1134 | ob.dep.notify();
|
1135 | }
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 | function dependArray (value) {
|
1142 | for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
|
1143 | e = value[i];
|
1144 | e && e.__ob__ && e.__ob__.dep.depend();
|
1145 | if (Array.isArray(e)) {
|
1146 | dependArray(e);
|
1147 | }
|
1148 | }
|
1149 | }
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 | var strats = config.optionMergeStrategies;
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 | {
|
1164 | strats.el = strats.propsData = function (parent, child, vm, key) {
|
1165 | if (!vm) {
|
1166 | warn(
|
1167 | "option \"" + key + "\" can only be used during instance " +
|
1168 | 'creation with the `new` keyword.'
|
1169 | );
|
1170 | }
|
1171 | return defaultStrat(parent, child)
|
1172 | };
|
1173 | }
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 | function mergeData (to, from) {
|
1179 | if (!from) { return to }
|
1180 | var key, toVal, fromVal;
|
1181 |
|
1182 | var keys = hasSymbol
|
1183 | ? Reflect.ownKeys(from)
|
1184 | : Object.keys(from);
|
1185 |
|
1186 | for (var i = 0; i < keys.length; i++) {
|
1187 | key = keys[i];
|
1188 |
|
1189 | if (key === '__ob__') { continue }
|
1190 | toVal = to[key];
|
1191 | fromVal = from[key];
|
1192 | if (!hasOwn(to, key)) {
|
1193 | set(to, key, fromVal);
|
1194 | } else if (
|
1195 | toVal !== fromVal &&
|
1196 | isPlainObject(toVal) &&
|
1197 | isPlainObject(fromVal)
|
1198 | ) {
|
1199 | mergeData(toVal, fromVal);
|
1200 | }
|
1201 | }
|
1202 | return to
|
1203 | }
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 | function mergeDataOrFn (
|
1209 | parentVal,
|
1210 | childVal,
|
1211 | vm
|
1212 | ) {
|
1213 | if (!vm) {
|
1214 |
|
1215 | if (!childVal) {
|
1216 | return parentVal
|
1217 | }
|
1218 | if (!parentVal) {
|
1219 | return childVal
|
1220 | }
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 | return function mergedDataFn () {
|
1227 | return mergeData(
|
1228 | typeof childVal === 'function' ? childVal.call(this, this) : childVal,
|
1229 | typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
|
1230 | )
|
1231 | }
|
1232 | } else {
|
1233 | return function mergedInstanceDataFn () {
|
1234 |
|
1235 | var instanceData = typeof childVal === 'function'
|
1236 | ? childVal.call(vm, vm)
|
1237 | : childVal;
|
1238 | var defaultData = typeof parentVal === 'function'
|
1239 | ? parentVal.call(vm, vm)
|
1240 | : parentVal;
|
1241 | if (instanceData) {
|
1242 | return mergeData(instanceData, defaultData)
|
1243 | } else {
|
1244 | return defaultData
|
1245 | }
|
1246 | }
|
1247 | }
|
1248 | }
|
1249 |
|
1250 | strats.data = function (
|
1251 | parentVal,
|
1252 | childVal,
|
1253 | vm
|
1254 | ) {
|
1255 | if (!vm) {
|
1256 | if (childVal && typeof childVal !== 'function') {
|
1257 | warn(
|
1258 | 'The "data" option should be a function ' +
|
1259 | 'that returns a per-instance value in component ' +
|
1260 | 'definitions.',
|
1261 | vm
|
1262 | );
|
1263 |
|
1264 | return parentVal
|
1265 | }
|
1266 | return mergeDataOrFn(parentVal, childVal)
|
1267 | }
|
1268 |
|
1269 | return mergeDataOrFn(parentVal, childVal, vm)
|
1270 | };
|
1271 |
|
1272 |
|
1273 |
|
1274 |
|
1275 | function mergeHook (
|
1276 | parentVal,
|
1277 | childVal
|
1278 | ) {
|
1279 | var res = childVal
|
1280 | ? parentVal
|
1281 | ? parentVal.concat(childVal)
|
1282 | : Array.isArray(childVal)
|
1283 | ? childVal
|
1284 | : [childVal]
|
1285 | : parentVal;
|
1286 | return res
|
1287 | ? dedupeHooks(res)
|
1288 | : res
|
1289 | }
|
1290 |
|
1291 | function dedupeHooks (hooks) {
|
1292 | var res = [];
|
1293 | for (var i = 0; i < hooks.length; i++) {
|
1294 | if (res.indexOf(hooks[i]) === -1) {
|
1295 | res.push(hooks[i]);
|
1296 | }
|
1297 | }
|
1298 | return res
|
1299 | }
|
1300 |
|
1301 | LIFECYCLE_HOOKS.forEach(function (hook) {
|
1302 | strats[hook] = mergeHook;
|
1303 | });
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 | function mergeAssets (
|
1313 | parentVal,
|
1314 | childVal,
|
1315 | vm,
|
1316 | key
|
1317 | ) {
|
1318 | var res = Object.create(parentVal || null);
|
1319 | if (childVal) {
|
1320 | assertObjectType(key, childVal, vm);
|
1321 | return extend(res, childVal)
|
1322 | } else {
|
1323 | return res
|
1324 | }
|
1325 | }
|
1326 |
|
1327 | ASSET_TYPES.forEach(function (type) {
|
1328 | strats[type + 's'] = mergeAssets;
|
1329 | });
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 | strats.watch = function (
|
1338 | parentVal,
|
1339 | childVal,
|
1340 | vm,
|
1341 | key
|
1342 | ) {
|
1343 |
|
1344 | if (parentVal === nativeWatch) { parentVal = undefined; }
|
1345 | if (childVal === nativeWatch) { childVal = undefined; }
|
1346 |
|
1347 | if (!childVal) { return Object.create(parentVal || null) }
|
1348 | {
|
1349 | assertObjectType(key, childVal, vm);
|
1350 | }
|
1351 | if (!parentVal) { return childVal }
|
1352 | var ret = {};
|
1353 | extend(ret, parentVal);
|
1354 | for (var key$1 in childVal) {
|
1355 | var parent = ret[key$1];
|
1356 | var child = childVal[key$1];
|
1357 | if (parent && !Array.isArray(parent)) {
|
1358 | parent = [parent];
|
1359 | }
|
1360 | ret[key$1] = parent
|
1361 | ? parent.concat(child)
|
1362 | : Array.isArray(child) ? child : [child];
|
1363 | }
|
1364 | return ret
|
1365 | };
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 | strats.props =
|
1371 | strats.methods =
|
1372 | strats.inject =
|
1373 | strats.computed = function (
|
1374 | parentVal,
|
1375 | childVal,
|
1376 | vm,
|
1377 | key
|
1378 | ) {
|
1379 | if (childVal && "development" !== 'production') {
|
1380 | assertObjectType(key, childVal, vm);
|
1381 | }
|
1382 | if (!parentVal) { return childVal }
|
1383 | var ret = Object.create(null);
|
1384 | extend(ret, parentVal);
|
1385 | if (childVal) { extend(ret, childVal); }
|
1386 | return ret
|
1387 | };
|
1388 | strats.provide = mergeDataOrFn;
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 | var defaultStrat = function (parentVal, childVal) {
|
1394 | return childVal === undefined
|
1395 | ? parentVal
|
1396 | : childVal
|
1397 | };
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 | function checkComponents (options) {
|
1403 | for (var key in options.components) {
|
1404 | validateComponentName(key);
|
1405 | }
|
1406 | }
|
1407 |
|
1408 | function validateComponentName (name) {
|
1409 | if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
|
1410 | warn(
|
1411 | 'Invalid component name: "' + name + '". Component names ' +
|
1412 | 'should conform to valid custom element name in html5 specification.'
|
1413 | );
|
1414 | }
|
1415 | if (isBuiltInTag(name) || config.isReservedTag(name)) {
|
1416 | warn(
|
1417 | 'Do not use built-in or reserved HTML elements as component ' +
|
1418 | 'id: ' + name
|
1419 | );
|
1420 | }
|
1421 | }
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 | function normalizeProps (options, vm) {
|
1428 | var props = options.props;
|
1429 | if (!props) { return }
|
1430 | var res = {};
|
1431 | var i, val, name;
|
1432 | if (Array.isArray(props)) {
|
1433 | i = props.length;
|
1434 | while (i--) {
|
1435 | val = props[i];
|
1436 | if (typeof val === 'string') {
|
1437 | name = camelize(val);
|
1438 | res[name] = { type: null };
|
1439 | } else {
|
1440 | warn('props must be strings when using array syntax.');
|
1441 | }
|
1442 | }
|
1443 | } else if (isPlainObject(props)) {
|
1444 | for (var key in props) {
|
1445 | val = props[key];
|
1446 | name = camelize(key);
|
1447 | res[name] = isPlainObject(val)
|
1448 | ? val
|
1449 | : { type: val };
|
1450 | }
|
1451 | } else {
|
1452 | warn(
|
1453 | "Invalid value for option \"props\": expected an Array or an Object, " +
|
1454 | "but got " + (toRawType(props)) + ".",
|
1455 | vm
|
1456 | );
|
1457 | }
|
1458 | options.props = res;
|
1459 | }
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 | function normalizeInject (options, vm) {
|
1465 | var inject = options.inject;
|
1466 | if (!inject) { return }
|
1467 | var normalized = options.inject = {};
|
1468 | if (Array.isArray(inject)) {
|
1469 | for (var i = 0; i < inject.length; i++) {
|
1470 | normalized[inject[i]] = { from: inject[i] };
|
1471 | }
|
1472 | } else if (isPlainObject(inject)) {
|
1473 | for (var key in inject) {
|
1474 | var val = inject[key];
|
1475 | normalized[key] = isPlainObject(val)
|
1476 | ? extend({ from: key }, val)
|
1477 | : { from: val };
|
1478 | }
|
1479 | } else {
|
1480 | warn(
|
1481 | "Invalid value for option \"inject\": expected an Array or an Object, " +
|
1482 | "but got " + (toRawType(inject)) + ".",
|
1483 | vm
|
1484 | );
|
1485 | }
|
1486 | }
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 | function normalizeDirectives (options) {
|
1492 | var dirs = options.directives;
|
1493 | if (dirs) {
|
1494 | for (var key in dirs) {
|
1495 | var def$$1 = dirs[key];
|
1496 | if (typeof def$$1 === 'function') {
|
1497 | dirs[key] = { bind: def$$1, update: def$$1 };
|
1498 | }
|
1499 | }
|
1500 | }
|
1501 | }
|
1502 |
|
1503 | function assertObjectType (name, value, vm) {
|
1504 | if (!isPlainObject(value)) {
|
1505 | warn(
|
1506 | "Invalid value for option \"" + name + "\": expected an Object, " +
|
1507 | "but got " + (toRawType(value)) + ".",
|
1508 | vm
|
1509 | );
|
1510 | }
|
1511 | }
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 | function mergeOptions (
|
1518 | parent,
|
1519 | child,
|
1520 | vm
|
1521 | ) {
|
1522 | {
|
1523 | checkComponents(child);
|
1524 | }
|
1525 |
|
1526 | if (typeof child === 'function') {
|
1527 | child = child.options;
|
1528 | }
|
1529 |
|
1530 | normalizeProps(child, vm);
|
1531 | normalizeInject(child, vm);
|
1532 | normalizeDirectives(child);
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 | if (!child._base) {
|
1539 | if (child.extends) {
|
1540 | parent = mergeOptions(parent, child.extends, vm);
|
1541 | }
|
1542 | if (child.mixins) {
|
1543 | for (var i = 0, l = child.mixins.length; i < l; i++) {
|
1544 | parent = mergeOptions(parent, child.mixins[i], vm);
|
1545 | }
|
1546 | }
|
1547 | }
|
1548 |
|
1549 | var options = {};
|
1550 | var key;
|
1551 | for (key in parent) {
|
1552 | mergeField(key);
|
1553 | }
|
1554 | for (key in child) {
|
1555 | if (!hasOwn(parent, key)) {
|
1556 | mergeField(key);
|
1557 | }
|
1558 | }
|
1559 | function mergeField (key) {
|
1560 | var strat = strats[key] || defaultStrat;
|
1561 | options[key] = strat(parent[key], child[key], vm, key);
|
1562 | }
|
1563 | return options
|
1564 | }
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 | function resolveAsset (
|
1572 | options,
|
1573 | type,
|
1574 | id,
|
1575 | warnMissing
|
1576 | ) {
|
1577 |
|
1578 | if (typeof id !== 'string') {
|
1579 | return
|
1580 | }
|
1581 | var assets = options[type];
|
1582 |
|
1583 | if (hasOwn(assets, id)) { return assets[id] }
|
1584 | var camelizedId = camelize(id);
|
1585 | if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
|
1586 | var PascalCaseId = capitalize(camelizedId);
|
1587 | if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
|
1588 |
|
1589 | var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
|
1590 | if (warnMissing && !res) {
|
1591 | warn(
|
1592 | 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
|
1593 | options
|
1594 | );
|
1595 | }
|
1596 | return res
|
1597 | }
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 | function validateProp (
|
1604 | key,
|
1605 | propOptions,
|
1606 | propsData,
|
1607 | vm
|
1608 | ) {
|
1609 | var prop = propOptions[key];
|
1610 | var absent = !hasOwn(propsData, key);
|
1611 | var value = propsData[key];
|
1612 |
|
1613 | var booleanIndex = getTypeIndex(Boolean, prop.type);
|
1614 | if (booleanIndex > -1) {
|
1615 | if (absent && !hasOwn(prop, 'default')) {
|
1616 | value = false;
|
1617 | } else if (value === '' || value === hyphenate(key)) {
|
1618 |
|
1619 |
|
1620 | var stringIndex = getTypeIndex(String, prop.type);
|
1621 | if (stringIndex < 0 || booleanIndex < stringIndex) {
|
1622 | value = true;
|
1623 | }
|
1624 | }
|
1625 | }
|
1626 |
|
1627 | if (value === undefined) {
|
1628 | value = getPropDefaultValue(vm, prop, key);
|
1629 |
|
1630 |
|
1631 | var prevShouldObserve = shouldObserve;
|
1632 | toggleObserving(true);
|
1633 | observe(value);
|
1634 | toggleObserving(prevShouldObserve);
|
1635 | }
|
1636 | {
|
1637 | assertProp(prop, key, value, vm, absent);
|
1638 | }
|
1639 | return value
|
1640 | }
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 | function getPropDefaultValue (vm, prop, key) {
|
1646 |
|
1647 | if (!hasOwn(prop, 'default')) {
|
1648 | return undefined
|
1649 | }
|
1650 | var def = prop.default;
|
1651 |
|
1652 | if (isObject(def)) {
|
1653 | warn(
|
1654 | 'Invalid default value for prop "' + key + '": ' +
|
1655 | 'Props with type Object/Array must use a factory function ' +
|
1656 | 'to return the default value.',
|
1657 | vm
|
1658 | );
|
1659 | }
|
1660 |
|
1661 |
|
1662 | if (vm && vm.$options.propsData &&
|
1663 | vm.$options.propsData[key] === undefined &&
|
1664 | vm._props[key] !== undefined
|
1665 | ) {
|
1666 | return vm._props[key]
|
1667 | }
|
1668 |
|
1669 |
|
1670 | return typeof def === 'function' && getType(prop.type) !== 'Function'
|
1671 | ? def.call(vm)
|
1672 | : def
|
1673 | }
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 | function assertProp (
|
1679 | prop,
|
1680 | name,
|
1681 | value,
|
1682 | vm,
|
1683 | absent
|
1684 | ) {
|
1685 | if (prop.required && absent) {
|
1686 | warn(
|
1687 | 'Missing required prop: "' + name + '"',
|
1688 | vm
|
1689 | );
|
1690 | return
|
1691 | }
|
1692 | if (value == null && !prop.required) {
|
1693 | return
|
1694 | }
|
1695 | var type = prop.type;
|
1696 | var valid = !type || type === true;
|
1697 | var expectedTypes = [];
|
1698 | if (type) {
|
1699 | if (!Array.isArray(type)) {
|
1700 | type = [type];
|
1701 | }
|
1702 | for (var i = 0; i < type.length && !valid; i++) {
|
1703 | var assertedType = assertType(value, type[i], vm);
|
1704 | expectedTypes.push(assertedType.expectedType || '');
|
1705 | valid = assertedType.valid;
|
1706 | }
|
1707 | }
|
1708 |
|
1709 | var haveExpectedTypes = expectedTypes.some(function (t) { return t; });
|
1710 | if (!valid && haveExpectedTypes) {
|
1711 | warn(
|
1712 | getInvalidTypeMessage(name, value, expectedTypes),
|
1713 | vm
|
1714 | );
|
1715 | return
|
1716 | }
|
1717 | var validator = prop.validator;
|
1718 | if (validator) {
|
1719 | if (!validator(value)) {
|
1720 | warn(
|
1721 | 'Invalid prop: custom validator check failed for prop "' + name + '".',
|
1722 | vm
|
1723 | );
|
1724 | }
|
1725 | }
|
1726 | }
|
1727 |
|
1728 | var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
|
1729 |
|
1730 | function assertType (value, type, vm) {
|
1731 | var valid;
|
1732 | var expectedType = getType(type);
|
1733 | if (simpleCheckRE.test(expectedType)) {
|
1734 | var t = typeof value;
|
1735 | valid = t === expectedType.toLowerCase();
|
1736 |
|
1737 | if (!valid && t === 'object') {
|
1738 | valid = value instanceof type;
|
1739 | }
|
1740 | } else if (expectedType === 'Object') {
|
1741 | valid = isPlainObject(value);
|
1742 | } else if (expectedType === 'Array') {
|
1743 | valid = Array.isArray(value);
|
1744 | } else {
|
1745 | try {
|
1746 | valid = value instanceof type;
|
1747 | } catch (e) {
|
1748 | warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
|
1749 | valid = false;
|
1750 | }
|
1751 | }
|
1752 | return {
|
1753 | valid: valid,
|
1754 | expectedType: expectedType
|
1755 | }
|
1756 | }
|
1757 |
|
1758 | var functionTypeCheckRE = /^\s*function (\w+)/;
|
1759 |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 | function getType (fn) {
|
1766 | var match = fn && fn.toString().match(functionTypeCheckRE);
|
1767 | return match ? match[1] : ''
|
1768 | }
|
1769 |
|
1770 | function isSameType (a, b) {
|
1771 | return getType(a) === getType(b)
|
1772 | }
|
1773 |
|
1774 | function getTypeIndex (type, expectedTypes) {
|
1775 | if (!Array.isArray(expectedTypes)) {
|
1776 | return isSameType(expectedTypes, type) ? 0 : -1
|
1777 | }
|
1778 | for (var i = 0, len = expectedTypes.length; i < len; i++) {
|
1779 | if (isSameType(expectedTypes[i], type)) {
|
1780 | return i
|
1781 | }
|
1782 | }
|
1783 | return -1
|
1784 | }
|
1785 |
|
1786 | function getInvalidTypeMessage (name, value, expectedTypes) {
|
1787 | var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
|
1788 | " Expected " + (expectedTypes.map(capitalize).join(', '));
|
1789 | var expectedType = expectedTypes[0];
|
1790 | var receivedType = toRawType(value);
|
1791 |
|
1792 | if (
|
1793 | expectedTypes.length === 1 &&
|
1794 | isExplicable(expectedType) &&
|
1795 | isExplicable(typeof value) &&
|
1796 | !isBoolean(expectedType, receivedType)
|
1797 | ) {
|
1798 | message += " with value " + (styleValue(value, expectedType));
|
1799 | }
|
1800 | message += ", got " + receivedType + " ";
|
1801 |
|
1802 | if (isExplicable(receivedType)) {
|
1803 | message += "with value " + (styleValue(value, receivedType)) + ".";
|
1804 | }
|
1805 | return message
|
1806 | }
|
1807 |
|
1808 | function styleValue (value, type) {
|
1809 | if (type === 'String') {
|
1810 | return ("\"" + value + "\"")
|
1811 | } else if (type === 'Number') {
|
1812 | return ("" + (Number(value)))
|
1813 | } else {
|
1814 | return ("" + value)
|
1815 | }
|
1816 | }
|
1817 |
|
1818 | var EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
|
1819 | function isExplicable (value) {
|
1820 | return EXPLICABLE_TYPES.some(function (elem) { return value.toLowerCase() === elem; })
|
1821 | }
|
1822 |
|
1823 | function isBoolean () {
|
1824 | var args = [], len = arguments.length;
|
1825 | while ( len-- ) args[ len ] = arguments[ len ];
|
1826 |
|
1827 | return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
|
1828 | }
|
1829 |
|
1830 |
|
1831 |
|
1832 | function handleError (err, vm, info) {
|
1833 |
|
1834 |
|
1835 | pushTarget();
|
1836 | try {
|
1837 | if (vm) {
|
1838 | var cur = vm;
|
1839 | while ((cur = cur.$parent)) {
|
1840 | var hooks = cur.$options.errorCaptured;
|
1841 | if (hooks) {
|
1842 | for (var i = 0; i < hooks.length; i++) {
|
1843 | try {
|
1844 | var capture = hooks[i].call(cur, err, vm, info) === false;
|
1845 | if (capture) { return }
|
1846 | } catch (e) {
|
1847 | globalHandleError(e, cur, 'errorCaptured hook');
|
1848 | }
|
1849 | }
|
1850 | }
|
1851 | }
|
1852 | }
|
1853 | globalHandleError(err, vm, info);
|
1854 | } finally {
|
1855 | popTarget();
|
1856 | }
|
1857 | }
|
1858 |
|
1859 | function invokeWithErrorHandling (
|
1860 | handler,
|
1861 | context,
|
1862 | args,
|
1863 | vm,
|
1864 | info
|
1865 | ) {
|
1866 | var res;
|
1867 | try {
|
1868 | res = args ? handler.apply(context, args) : handler.call(context);
|
1869 | if (res && !res._isVue && isPromise(res) && !res._handled) {
|
1870 | res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
|
1871 |
|
1872 |
|
1873 | res._handled = true;
|
1874 | }
|
1875 | } catch (e) {
|
1876 | handleError(e, vm, info);
|
1877 | }
|
1878 | return res
|
1879 | }
|
1880 |
|
1881 | function globalHandleError (err, vm, info) {
|
1882 | if (config.errorHandler) {
|
1883 | try {
|
1884 | return config.errorHandler.call(null, err, vm, info)
|
1885 | } catch (e) {
|
1886 |
|
1887 |
|
1888 | if (e !== err) {
|
1889 | logError(e, null, 'config.errorHandler');
|
1890 | }
|
1891 | }
|
1892 | }
|
1893 | logError(err, vm, info);
|
1894 | }
|
1895 |
|
1896 | function logError (err, vm, info) {
|
1897 | {
|
1898 | warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
|
1899 | }
|
1900 |
|
1901 | if ((inBrowser || inWeex) && typeof console !== 'undefined') {
|
1902 | console.error(err);
|
1903 | } else {
|
1904 | throw err
|
1905 | }
|
1906 | }
|
1907 |
|
1908 |
|
1909 |
|
1910 | var isUsingMicroTask = false;
|
1911 |
|
1912 | var callbacks = [];
|
1913 | var pending = false;
|
1914 |
|
1915 | function flushCallbacks () {
|
1916 | pending = false;
|
1917 | var copies = callbacks.slice(0);
|
1918 | callbacks.length = 0;
|
1919 | for (var i = 0; i < copies.length; i++) {
|
1920 | copies[i]();
|
1921 | }
|
1922 | }
|
1923 |
|
1924 |
|
1925 |
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 |
|
1934 |
|
1935 | var timerFunc;
|
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 | if (typeof Promise !== 'undefined' && isNative(Promise)) {
|
1945 | var p = Promise.resolve();
|
1946 | timerFunc = function () {
|
1947 | p.then(flushCallbacks);
|
1948 |
|
1949 |
|
1950 |
|
1951 |
|
1952 |
|
1953 | if (isIOS) { setTimeout(noop); }
|
1954 | };
|
1955 | isUsingMicroTask = true;
|
1956 | } else if (!isIE && typeof MutationObserver !== 'undefined' && (
|
1957 | isNative(MutationObserver) ||
|
1958 |
|
1959 | MutationObserver.toString() === '[object MutationObserverConstructor]'
|
1960 | )) {
|
1961 |
|
1962 |
|
1963 |
|
1964 | var counter = 1;
|
1965 | var observer = new MutationObserver(flushCallbacks);
|
1966 | var textNode = document.createTextNode(String(counter));
|
1967 | observer.observe(textNode, {
|
1968 | characterData: true
|
1969 | });
|
1970 | timerFunc = function () {
|
1971 | counter = (counter + 1) % 2;
|
1972 | textNode.data = String(counter);
|
1973 | };
|
1974 | isUsingMicroTask = true;
|
1975 | } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
|
1976 |
|
1977 |
|
1978 |
|
1979 | timerFunc = function () {
|
1980 | setImmediate(flushCallbacks);
|
1981 | };
|
1982 | } else {
|
1983 |
|
1984 | timerFunc = function () {
|
1985 | setTimeout(flushCallbacks, 0);
|
1986 | };
|
1987 | }
|
1988 |
|
1989 | function nextTick (cb, ctx) {
|
1990 | var _resolve;
|
1991 | callbacks.push(function () {
|
1992 | if (cb) {
|
1993 | try {
|
1994 | cb.call(ctx);
|
1995 | } catch (e) {
|
1996 | handleError(e, ctx, 'nextTick');
|
1997 | }
|
1998 | } else if (_resolve) {
|
1999 | _resolve(ctx);
|
2000 | }
|
2001 | });
|
2002 | if (!pending) {
|
2003 | pending = true;
|
2004 | timerFunc();
|
2005 | }
|
2006 |
|
2007 | if (!cb && typeof Promise !== 'undefined') {
|
2008 | return new Promise(function (resolve) {
|
2009 | _resolve = resolve;
|
2010 | })
|
2011 | }
|
2012 | }
|
2013 |
|
2014 |
|
2015 |
|
2016 | var mark;
|
2017 | var measure;
|
2018 |
|
2019 | {
|
2020 | var perf = inBrowser && window.performance;
|
2021 |
|
2022 | if (
|
2023 | perf &&
|
2024 | perf.mark &&
|
2025 | perf.measure &&
|
2026 | perf.clearMarks &&
|
2027 | perf.clearMeasures
|
2028 | ) {
|
2029 | mark = function (tag) { return perf.mark(tag); };
|
2030 | measure = function (name, startTag, endTag) {
|
2031 | perf.measure(name, startTag, endTag);
|
2032 | perf.clearMarks(startTag);
|
2033 | perf.clearMarks(endTag);
|
2034 |
|
2035 | };
|
2036 | }
|
2037 | }
|
2038 |
|
2039 |
|
2040 |
|
2041 | var initProxy;
|
2042 |
|
2043 | {
|
2044 | var allowedGlobals = makeMap(
|
2045 | 'Infinity,undefined,NaN,isFinite,isNaN,' +
|
2046 | 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
2047 | 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
|
2048 | 'require'
|
2049 | );
|
2050 |
|
2051 | var warnNonPresent = function (target, key) {
|
2052 | warn(
|
2053 | "Property or method \"" + key + "\" is not defined on the instance but " +
|
2054 | 'referenced during render. Make sure that this property is reactive, ' +
|
2055 | 'either in the data option, or for class-based components, by ' +
|
2056 | 'initializing the property. ' +
|
2057 | 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
|
2058 | target
|
2059 | );
|
2060 | };
|
2061 |
|
2062 | var warnReservedPrefix = function (target, key) {
|
2063 | warn(
|
2064 | "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
|
2065 | 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
|
2066 | 'prevent conflicts with Vue internals. ' +
|
2067 | 'See: https://vuejs.org/v2/api/#data',
|
2068 | target
|
2069 | );
|
2070 | };
|
2071 |
|
2072 | var hasProxy =
|
2073 | typeof Proxy !== 'undefined' && isNative(Proxy);
|
2074 |
|
2075 | if (hasProxy) {
|
2076 | var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
|
2077 | config.keyCodes = new Proxy(config.keyCodes, {
|
2078 | set: function set (target, key, value) {
|
2079 | if (isBuiltInModifier(key)) {
|
2080 | warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
|
2081 | return false
|
2082 | } else {
|
2083 | target[key] = value;
|
2084 | return true
|
2085 | }
|
2086 | }
|
2087 | });
|
2088 | }
|
2089 |
|
2090 | var hasHandler = {
|
2091 | has: function has (target, key) {
|
2092 | var has = key in target;
|
2093 | var isAllowed = allowedGlobals(key) ||
|
2094 | (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
|
2095 | if (!has && !isAllowed) {
|
2096 | if (key in target.$data) { warnReservedPrefix(target, key); }
|
2097 | else { warnNonPresent(target, key); }
|
2098 | }
|
2099 | return has || !isAllowed
|
2100 | }
|
2101 | };
|
2102 |
|
2103 | var getHandler = {
|
2104 | get: function get (target, key) {
|
2105 | if (typeof key === 'string' && !(key in target)) {
|
2106 | if (key in target.$data) { warnReservedPrefix(target, key); }
|
2107 | else { warnNonPresent(target, key); }
|
2108 | }
|
2109 | return target[key]
|
2110 | }
|
2111 | };
|
2112 |
|
2113 | initProxy = function initProxy (vm) {
|
2114 | if (hasProxy) {
|
2115 |
|
2116 | var options = vm.$options;
|
2117 | var handlers = options.render && options.render._withStripped
|
2118 | ? getHandler
|
2119 | : hasHandler;
|
2120 | vm._renderProxy = new Proxy(vm, handlers);
|
2121 | } else {
|
2122 | vm._renderProxy = vm;
|
2123 | }
|
2124 | };
|
2125 | }
|
2126 |
|
2127 |
|
2128 |
|
2129 | var seenObjects = new _Set();
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 |
|
2135 |
|
2136 | function traverse (val) {
|
2137 | _traverse(val, seenObjects);
|
2138 | seenObjects.clear();
|
2139 | }
|
2140 |
|
2141 | function _traverse (val, seen) {
|
2142 | var i, keys;
|
2143 | var isA = Array.isArray(val);
|
2144 | if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
|
2145 | return
|
2146 | }
|
2147 | if (val.__ob__) {
|
2148 | var depId = val.__ob__.dep.id;
|
2149 | if (seen.has(depId)) {
|
2150 | return
|
2151 | }
|
2152 | seen.add(depId);
|
2153 | }
|
2154 | if (isA) {
|
2155 | i = val.length;
|
2156 | while (i--) { _traverse(val[i], seen); }
|
2157 | } else {
|
2158 | keys = Object.keys(val);
|
2159 | i = keys.length;
|
2160 | while (i--) { _traverse(val[keys[i]], seen); }
|
2161 | }
|
2162 | }
|
2163 |
|
2164 |
|
2165 |
|
2166 | var normalizeEvent = cached(function (name) {
|
2167 | var passive = name.charAt(0) === '&';
|
2168 | name = passive ? name.slice(1) : name;
|
2169 | var once$$1 = name.charAt(0) === '~';
|
2170 | name = once$$1 ? name.slice(1) : name;
|
2171 | var capture = name.charAt(0) === '!';
|
2172 | name = capture ? name.slice(1) : name;
|
2173 | return {
|
2174 | name: name,
|
2175 | once: once$$1,
|
2176 | capture: capture,
|
2177 | passive: passive
|
2178 | }
|
2179 | });
|
2180 |
|
2181 | function createFnInvoker (fns, vm) {
|
2182 | function invoker () {
|
2183 | var arguments$1 = arguments;
|
2184 |
|
2185 | var fns = invoker.fns;
|
2186 | if (Array.isArray(fns)) {
|
2187 | var cloned = fns.slice();
|
2188 | for (var i = 0; i < cloned.length; i++) {
|
2189 | invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
|
2190 | }
|
2191 | } else {
|
2192 |
|
2193 | return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
|
2194 | }
|
2195 | }
|
2196 | invoker.fns = fns;
|
2197 | return invoker
|
2198 | }
|
2199 |
|
2200 | function updateListeners (
|
2201 | on,
|
2202 | oldOn,
|
2203 | add,
|
2204 | remove$$1,
|
2205 | createOnceHandler,
|
2206 | vm
|
2207 | ) {
|
2208 | var name, def$$1, cur, old, event;
|
2209 | for (name in on) {
|
2210 | def$$1 = cur = on[name];
|
2211 | old = oldOn[name];
|
2212 | event = normalizeEvent(name);
|
2213 | if (isUndef(cur)) {
|
2214 | warn(
|
2215 | "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
|
2216 | vm
|
2217 | );
|
2218 | } else if (isUndef(old)) {
|
2219 | if (isUndef(cur.fns)) {
|
2220 | cur = on[name] = createFnInvoker(cur, vm);
|
2221 | }
|
2222 | if (isTrue(event.once)) {
|
2223 | cur = on[name] = createOnceHandler(event.name, cur, event.capture);
|
2224 | }
|
2225 | add(event.name, cur, event.capture, event.passive, event.params);
|
2226 | } else if (cur !== old) {
|
2227 | old.fns = cur;
|
2228 | on[name] = old;
|
2229 | }
|
2230 | }
|
2231 | for (name in oldOn) {
|
2232 | if (isUndef(on[name])) {
|
2233 | event = normalizeEvent(name);
|
2234 | remove$$1(event.name, oldOn[name], event.capture);
|
2235 | }
|
2236 | }
|
2237 | }
|
2238 |
|
2239 |
|
2240 |
|
2241 | function mergeVNodeHook (def, hookKey, hook) {
|
2242 | if (def instanceof VNode) {
|
2243 | def = def.data.hook || (def.data.hook = {});
|
2244 | }
|
2245 | var invoker;
|
2246 | var oldHook = def[hookKey];
|
2247 |
|
2248 | function wrappedHook () {
|
2249 | hook.apply(this, arguments);
|
2250 |
|
2251 |
|
2252 | remove(invoker.fns, wrappedHook);
|
2253 | }
|
2254 |
|
2255 | if (isUndef(oldHook)) {
|
2256 |
|
2257 | invoker = createFnInvoker([wrappedHook]);
|
2258 | } else {
|
2259 |
|
2260 | if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
|
2261 |
|
2262 | invoker = oldHook;
|
2263 | invoker.fns.push(wrappedHook);
|
2264 | } else {
|
2265 |
|
2266 | invoker = createFnInvoker([oldHook, wrappedHook]);
|
2267 | }
|
2268 | }
|
2269 |
|
2270 | invoker.merged = true;
|
2271 | def[hookKey] = invoker;
|
2272 | }
|
2273 |
|
2274 |
|
2275 |
|
2276 | function extractPropsFromVNodeData (
|
2277 | data,
|
2278 | Ctor,
|
2279 | tag
|
2280 | ) {
|
2281 |
|
2282 |
|
2283 |
|
2284 | var propOptions = Ctor.options.props;
|
2285 | if (isUndef(propOptions)) {
|
2286 | return
|
2287 | }
|
2288 | var res = {};
|
2289 | var attrs = data.attrs;
|
2290 | var props = data.props;
|
2291 | if (isDef(attrs) || isDef(props)) {
|
2292 | for (var key in propOptions) {
|
2293 | var altKey = hyphenate(key);
|
2294 | {
|
2295 | var keyInLowerCase = key.toLowerCase();
|
2296 | if (
|
2297 | key !== keyInLowerCase &&
|
2298 | attrs && hasOwn(attrs, keyInLowerCase)
|
2299 | ) {
|
2300 | tip(
|
2301 | "Prop \"" + keyInLowerCase + "\" is passed to component " +
|
2302 | (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
|
2303 | " \"" + key + "\". " +
|
2304 | "Note that HTML attributes are case-insensitive and camelCased " +
|
2305 | "props need to use their kebab-case equivalents when using in-DOM " +
|
2306 | "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
|
2307 | );
|
2308 | }
|
2309 | }
|
2310 | checkProp(res, props, key, altKey, true) ||
|
2311 | checkProp(res, attrs, key, altKey, false);
|
2312 | }
|
2313 | }
|
2314 | return res
|
2315 | }
|
2316 |
|
2317 | function checkProp (
|
2318 | res,
|
2319 | hash,
|
2320 | key,
|
2321 | altKey,
|
2322 | preserve
|
2323 | ) {
|
2324 | if (isDef(hash)) {
|
2325 | if (hasOwn(hash, key)) {
|
2326 | res[key] = hash[key];
|
2327 | if (!preserve) {
|
2328 | delete hash[key];
|
2329 | }
|
2330 | return true
|
2331 | } else if (hasOwn(hash, altKey)) {
|
2332 | res[key] = hash[altKey];
|
2333 | if (!preserve) {
|
2334 | delete hash[altKey];
|
2335 | }
|
2336 | return true
|
2337 | }
|
2338 | }
|
2339 | return false
|
2340 | }
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 |
|
2355 |
|
2356 | function simpleNormalizeChildren (children) {
|
2357 | for (var i = 0; i < children.length; i++) {
|
2358 | if (Array.isArray(children[i])) {
|
2359 | return Array.prototype.concat.apply([], children)
|
2360 | }
|
2361 | }
|
2362 | return children
|
2363 | }
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 | function normalizeChildren (children) {
|
2370 | return isPrimitive(children)
|
2371 | ? [createTextVNode(children)]
|
2372 | : Array.isArray(children)
|
2373 | ? normalizeArrayChildren(children)
|
2374 | : undefined
|
2375 | }
|
2376 |
|
2377 | function isTextNode (node) {
|
2378 | return isDef(node) && isDef(node.text) && isFalse(node.isComment)
|
2379 | }
|
2380 |
|
2381 | function normalizeArrayChildren (children, nestedIndex) {
|
2382 | var res = [];
|
2383 | var i, c, lastIndex, last;
|
2384 | for (i = 0; i < children.length; i++) {
|
2385 | c = children[i];
|
2386 | if (isUndef(c) || typeof c === 'boolean') { continue }
|
2387 | lastIndex = res.length - 1;
|
2388 | last = res[lastIndex];
|
2389 |
|
2390 | if (Array.isArray(c)) {
|
2391 | if (c.length > 0) {
|
2392 | c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
|
2393 |
|
2394 | if (isTextNode(c[0]) && isTextNode(last)) {
|
2395 | res[lastIndex] = createTextVNode(last.text + (c[0]).text);
|
2396 | c.shift();
|
2397 | }
|
2398 | res.push.apply(res, c);
|
2399 | }
|
2400 | } else if (isPrimitive(c)) {
|
2401 | if (isTextNode(last)) {
|
2402 |
|
2403 |
|
2404 |
|
2405 | res[lastIndex] = createTextVNode(last.text + c);
|
2406 | } else if (c !== '') {
|
2407 |
|
2408 | res.push(createTextVNode(c));
|
2409 | }
|
2410 | } else {
|
2411 | if (isTextNode(c) && isTextNode(last)) {
|
2412 |
|
2413 | res[lastIndex] = createTextVNode(last.text + c.text);
|
2414 | } else {
|
2415 |
|
2416 | if (isTrue(children._isVList) &&
|
2417 | isDef(c.tag) &&
|
2418 | isUndef(c.key) &&
|
2419 | isDef(nestedIndex)) {
|
2420 | c.key = "__vlist" + nestedIndex + "_" + i + "__";
|
2421 | }
|
2422 | res.push(c);
|
2423 | }
|
2424 | }
|
2425 | }
|
2426 | return res
|
2427 | }
|
2428 |
|
2429 |
|
2430 |
|
2431 | function initProvide (vm) {
|
2432 | var provide = vm.$options.provide;
|
2433 | if (provide) {
|
2434 | vm._provided = typeof provide === 'function'
|
2435 | ? provide.call(vm)
|
2436 | : provide;
|
2437 | }
|
2438 | }
|
2439 |
|
2440 | function initInjections (vm) {
|
2441 | var result = resolveInject(vm.$options.inject, vm);
|
2442 | if (result) {
|
2443 | toggleObserving(false);
|
2444 | Object.keys(result).forEach(function (key) {
|
2445 |
|
2446 | {
|
2447 | defineReactive$$1(vm, key, result[key], function () {
|
2448 | warn(
|
2449 | "Avoid mutating an injected value directly since the changes will be " +
|
2450 | "overwritten whenever the provided component re-renders. " +
|
2451 | "injection being mutated: \"" + key + "\"",
|
2452 | vm
|
2453 | );
|
2454 | });
|
2455 | }
|
2456 | });
|
2457 | toggleObserving(true);
|
2458 | }
|
2459 | }
|
2460 |
|
2461 | function resolveInject (inject, vm) {
|
2462 | if (inject) {
|
2463 |
|
2464 | var result = Object.create(null);
|
2465 | var keys = hasSymbol
|
2466 | ? Reflect.ownKeys(inject)
|
2467 | : Object.keys(inject);
|
2468 |
|
2469 | for (var i = 0; i < keys.length; i++) {
|
2470 | var key = keys[i];
|
2471 |
|
2472 | if (key === '__ob__') { continue }
|
2473 | var provideKey = inject[key].from;
|
2474 | var source = vm;
|
2475 | while (source) {
|
2476 | if (source._provided && hasOwn(source._provided, provideKey)) {
|
2477 | result[key] = source._provided[provideKey];
|
2478 | break
|
2479 | }
|
2480 | source = source.$parent;
|
2481 | }
|
2482 | if (!source) {
|
2483 | if ('default' in inject[key]) {
|
2484 | var provideDefault = inject[key].default;
|
2485 | result[key] = typeof provideDefault === 'function'
|
2486 | ? provideDefault.call(vm)
|
2487 | : provideDefault;
|
2488 | } else {
|
2489 | warn(("Injection \"" + key + "\" not found"), vm);
|
2490 | }
|
2491 | }
|
2492 | }
|
2493 | return result
|
2494 | }
|
2495 | }
|
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
|
2504 | function resolveSlots (
|
2505 | children,
|
2506 | context
|
2507 | ) {
|
2508 | if (!children || !children.length) {
|
2509 | return {}
|
2510 | }
|
2511 | var slots = {};
|
2512 | for (var i = 0, l = children.length; i < l; i++) {
|
2513 | var child = children[i];
|
2514 | var data = child.data;
|
2515 |
|
2516 | if (data && data.attrs && data.attrs.slot) {
|
2517 | delete data.attrs.slot;
|
2518 | }
|
2519 |
|
2520 |
|
2521 | if ((child.context === context || child.fnContext === context) &&
|
2522 | data && data.slot != null
|
2523 | ) {
|
2524 | var name = data.slot;
|
2525 | var slot = (slots[name] || (slots[name] = []));
|
2526 | if (child.tag === 'template') {
|
2527 | slot.push.apply(slot, child.children || []);
|
2528 | } else {
|
2529 | slot.push(child);
|
2530 | }
|
2531 | } else {
|
2532 | (slots.default || (slots.default = [])).push(child);
|
2533 | }
|
2534 | }
|
2535 |
|
2536 | for (var name$1 in slots) {
|
2537 | if (slots[name$1].every(isWhitespace)) {
|
2538 | delete slots[name$1];
|
2539 | }
|
2540 | }
|
2541 | return slots
|
2542 | }
|
2543 |
|
2544 | function isWhitespace (node) {
|
2545 | return (node.isComment && !node.asyncFactory) || node.text === ' '
|
2546 | }
|
2547 |
|
2548 |
|
2549 |
|
2550 | function isAsyncPlaceholder (node) {
|
2551 | return node.isComment && node.asyncFactory
|
2552 | }
|
2553 |
|
2554 |
|
2555 |
|
2556 | function normalizeScopedSlots (
|
2557 | slots,
|
2558 | normalSlots,
|
2559 | prevSlots
|
2560 | ) {
|
2561 | var res;
|
2562 | var hasNormalSlots = Object.keys(normalSlots).length > 0;
|
2563 | var isStable = slots ? !!slots.$stable : !hasNormalSlots;
|
2564 | var key = slots && slots.$key;
|
2565 | if (!slots) {
|
2566 | res = {};
|
2567 | } else if (slots._normalized) {
|
2568 |
|
2569 | return slots._normalized
|
2570 | } else if (
|
2571 | isStable &&
|
2572 | prevSlots &&
|
2573 | prevSlots !== emptyObject &&
|
2574 | key === prevSlots.$key &&
|
2575 | !hasNormalSlots &&
|
2576 | !prevSlots.$hasNormal
|
2577 | ) {
|
2578 |
|
2579 |
|
2580 | return prevSlots
|
2581 | } else {
|
2582 | res = {};
|
2583 | for (var key$1 in slots) {
|
2584 | if (slots[key$1] && key$1[0] !== '$') {
|
2585 | res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
|
2586 | }
|
2587 | }
|
2588 | }
|
2589 |
|
2590 | for (var key$2 in normalSlots) {
|
2591 | if (!(key$2 in res)) {
|
2592 | res[key$2] = proxyNormalSlot(normalSlots, key$2);
|
2593 | }
|
2594 | }
|
2595 |
|
2596 |
|
2597 | if (slots && Object.isExtensible(slots)) {
|
2598 | (slots)._normalized = res;
|
2599 | }
|
2600 | def(res, '$stable', isStable);
|
2601 | def(res, '$key', key);
|
2602 | def(res, '$hasNormal', hasNormalSlots);
|
2603 | return res
|
2604 | }
|
2605 |
|
2606 | function normalizeScopedSlot(normalSlots, key, fn) {
|
2607 | var normalized = function () {
|
2608 | var res = arguments.length ? fn.apply(null, arguments) : fn({});
|
2609 | res = res && typeof res === 'object' && !Array.isArray(res)
|
2610 | ? [res]
|
2611 | : normalizeChildren(res);
|
2612 | var vnode = res && res[0];
|
2613 | return res && (
|
2614 | !vnode ||
|
2615 | (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))
|
2616 | ) ? undefined
|
2617 | : res
|
2618 | };
|
2619 |
|
2620 |
|
2621 |
|
2622 | if (fn.proxy) {
|
2623 | Object.defineProperty(normalSlots, key, {
|
2624 | get: normalized,
|
2625 | enumerable: true,
|
2626 | configurable: true
|
2627 | });
|
2628 | }
|
2629 | return normalized
|
2630 | }
|
2631 |
|
2632 | function proxyNormalSlot(slots, key) {
|
2633 | return function () { return slots[key]; }
|
2634 | }
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 | function renderList (
|
2642 | val,
|
2643 | render
|
2644 | ) {
|
2645 | var ret, i, l, keys, key;
|
2646 | if (Array.isArray(val) || typeof val === 'string') {
|
2647 | ret = new Array(val.length);
|
2648 | for (i = 0, l = val.length; i < l; i++) {
|
2649 | ret[i] = render(val[i], i);
|
2650 | }
|
2651 | } else if (typeof val === 'number') {
|
2652 | ret = new Array(val);
|
2653 | for (i = 0; i < val; i++) {
|
2654 | ret[i] = render(i + 1, i);
|
2655 | }
|
2656 | } else if (isObject(val)) {
|
2657 | if (hasSymbol && val[Symbol.iterator]) {
|
2658 | ret = [];
|
2659 | var iterator = val[Symbol.iterator]();
|
2660 | var result = iterator.next();
|
2661 | while (!result.done) {
|
2662 | ret.push(render(result.value, ret.length));
|
2663 | result = iterator.next();
|
2664 | }
|
2665 | } else {
|
2666 | keys = Object.keys(val);
|
2667 | ret = new Array(keys.length);
|
2668 | for (i = 0, l = keys.length; i < l; i++) {
|
2669 | key = keys[i];
|
2670 | ret[i] = render(val[key], key, i);
|
2671 | }
|
2672 | }
|
2673 | }
|
2674 | if (!isDef(ret)) {
|
2675 | ret = [];
|
2676 | }
|
2677 | (ret)._isVList = true;
|
2678 | return ret
|
2679 | }
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 | function renderSlot (
|
2687 | name,
|
2688 | fallbackRender,
|
2689 | props,
|
2690 | bindObject
|
2691 | ) {
|
2692 | var scopedSlotFn = this.$scopedSlots[name];
|
2693 | var nodes;
|
2694 | if (scopedSlotFn) {
|
2695 |
|
2696 | props = props || {};
|
2697 | if (bindObject) {
|
2698 | if (!isObject(bindObject)) {
|
2699 | warn('slot v-bind without argument expects an Object', this);
|
2700 | }
|
2701 | props = extend(extend({}, bindObject), props);
|
2702 | }
|
2703 | nodes =
|
2704 | scopedSlotFn(props) ||
|
2705 | (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
|
2706 | } else {
|
2707 | nodes =
|
2708 | this.$slots[name] ||
|
2709 | (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
|
2710 | }
|
2711 |
|
2712 | var target = props && props.slot;
|
2713 | if (target) {
|
2714 | return this.$createElement('template', { slot: target }, nodes)
|
2715 | } else {
|
2716 | return nodes
|
2717 | }
|
2718 | }
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 | function resolveFilter (id) {
|
2726 | return resolveAsset(this.$options, 'filters', id, true) || identity
|
2727 | }
|
2728 |
|
2729 |
|
2730 |
|
2731 | function isKeyNotMatch (expect, actual) {
|
2732 | if (Array.isArray(expect)) {
|
2733 | return expect.indexOf(actual) === -1
|
2734 | } else {
|
2735 | return expect !== actual
|
2736 | }
|
2737 | }
|
2738 |
|
2739 |
|
2740 |
|
2741 |
|
2742 |
|
2743 |
|
2744 | function checkKeyCodes (
|
2745 | eventKeyCode,
|
2746 | key,
|
2747 | builtInKeyCode,
|
2748 | eventKeyName,
|
2749 | builtInKeyName
|
2750 | ) {
|
2751 | var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
|
2752 | if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
|
2753 | return isKeyNotMatch(builtInKeyName, eventKeyName)
|
2754 | } else if (mappedKeyCode) {
|
2755 | return isKeyNotMatch(mappedKeyCode, eventKeyCode)
|
2756 | } else if (eventKeyName) {
|
2757 | return hyphenate(eventKeyName) !== key
|
2758 | }
|
2759 | return eventKeyCode === undefined
|
2760 | }
|
2761 |
|
2762 |
|
2763 |
|
2764 |
|
2765 |
|
2766 |
|
2767 | function bindObjectProps (
|
2768 | data,
|
2769 | tag,
|
2770 | value,
|
2771 | asProp,
|
2772 | isSync
|
2773 | ) {
|
2774 | if (value) {
|
2775 | if (!isObject(value)) {
|
2776 | warn(
|
2777 | 'v-bind without argument expects an Object or Array value',
|
2778 | this
|
2779 | );
|
2780 | } else {
|
2781 | if (Array.isArray(value)) {
|
2782 | value = toObject(value);
|
2783 | }
|
2784 | var hash;
|
2785 | var loop = function ( key ) {
|
2786 | if (
|
2787 | key === 'class' ||
|
2788 | key === 'style' ||
|
2789 | isReservedAttribute(key)
|
2790 | ) {
|
2791 | hash = data;
|
2792 | } else {
|
2793 | var type = data.attrs && data.attrs.type;
|
2794 | hash = asProp || config.mustUseProp(tag, type, key)
|
2795 | ? data.domProps || (data.domProps = {})
|
2796 | : data.attrs || (data.attrs = {});
|
2797 | }
|
2798 | var camelizedKey = camelize(key);
|
2799 | var hyphenatedKey = hyphenate(key);
|
2800 | if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
|
2801 | hash[key] = value[key];
|
2802 |
|
2803 | if (isSync) {
|
2804 | var on = data.on || (data.on = {});
|
2805 | on[("update:" + key)] = function ($event) {
|
2806 | value[key] = $event;
|
2807 | };
|
2808 | }
|
2809 | }
|
2810 | };
|
2811 |
|
2812 | for (var key in value) loop( key );
|
2813 | }
|
2814 | }
|
2815 | return data
|
2816 | }
|
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 | function renderStatic (
|
2824 | index,
|
2825 | isInFor
|
2826 | ) {
|
2827 | var cached = this._staticTrees || (this._staticTrees = []);
|
2828 | var tree = cached[index];
|
2829 |
|
2830 |
|
2831 | if (tree && !isInFor) {
|
2832 | return tree
|
2833 | }
|
2834 |
|
2835 | tree = cached[index] = this.$options.staticRenderFns[index].call(
|
2836 | this._renderProxy,
|
2837 | null,
|
2838 | this
|
2839 | );
|
2840 | markStatic(tree, ("__static__" + index), false);
|
2841 | return tree
|
2842 | }
|
2843 |
|
2844 |
|
2845 |
|
2846 |
|
2847 |
|
2848 | function markOnce (
|
2849 | tree,
|
2850 | index,
|
2851 | key
|
2852 | ) {
|
2853 | markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
|
2854 | return tree
|
2855 | }
|
2856 |
|
2857 | function markStatic (
|
2858 | tree,
|
2859 | key,
|
2860 | isOnce
|
2861 | ) {
|
2862 | if (Array.isArray(tree)) {
|
2863 | for (var i = 0; i < tree.length; i++) {
|
2864 | if (tree[i] && typeof tree[i] !== 'string') {
|
2865 | markStaticNode(tree[i], (key + "_" + i), isOnce);
|
2866 | }
|
2867 | }
|
2868 | } else {
|
2869 | markStaticNode(tree, key, isOnce);
|
2870 | }
|
2871 | }
|
2872 |
|
2873 | function markStaticNode (node, key, isOnce) {
|
2874 | node.isStatic = true;
|
2875 | node.key = key;
|
2876 | node.isOnce = isOnce;
|
2877 | }
|
2878 |
|
2879 |
|
2880 |
|
2881 | function bindObjectListeners (data, value) {
|
2882 | if (value) {
|
2883 | if (!isPlainObject(value)) {
|
2884 | warn(
|
2885 | 'v-on without argument expects an Object value',
|
2886 | this
|
2887 | );
|
2888 | } else {
|
2889 | var on = data.on = data.on ? extend({}, data.on) : {};
|
2890 | for (var key in value) {
|
2891 | var existing = on[key];
|
2892 | var ours = value[key];
|
2893 | on[key] = existing ? [].concat(existing, ours) : ours;
|
2894 | }
|
2895 | }
|
2896 | }
|
2897 | return data
|
2898 | }
|
2899 |
|
2900 |
|
2901 |
|
2902 | function resolveScopedSlots (
|
2903 | fns, // see flow/vnode
|
2904 | res,
|
2905 |
|
2906 | hasDynamicKeys,
|
2907 | contentHashKey
|
2908 | ) {
|
2909 | res = res || { $stable: !hasDynamicKeys };
|
2910 | for (var i = 0; i < fns.length; i++) {
|
2911 | var slot = fns[i];
|
2912 | if (Array.isArray(slot)) {
|
2913 | resolveScopedSlots(slot, res, hasDynamicKeys);
|
2914 | } else if (slot) {
|
2915 |
|
2916 | if (slot.proxy) {
|
2917 | slot.fn.proxy = true;
|
2918 | }
|
2919 | res[slot.key] = slot.fn;
|
2920 | }
|
2921 | }
|
2922 | if (contentHashKey) {
|
2923 | (res).$key = contentHashKey;
|
2924 | }
|
2925 | return res
|
2926 | }
|
2927 |
|
2928 |
|
2929 |
|
2930 | function bindDynamicKeys (baseObj, values) {
|
2931 | for (var i = 0; i < values.length; i += 2) {
|
2932 | var key = values[i];
|
2933 | if (typeof key === 'string' && key) {
|
2934 | baseObj[values[i]] = values[i + 1];
|
2935 | } else if (key !== '' && key !== null) {
|
2936 |
|
2937 | warn(
|
2938 | ("Invalid value for dynamic directive argument (expected string or null): " + key),
|
2939 | this
|
2940 | );
|
2941 | }
|
2942 | }
|
2943 | return baseObj
|
2944 | }
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 | function prependModifier (value, symbol) {
|
2950 | return typeof value === 'string' ? symbol + value : value
|
2951 | }
|
2952 |
|
2953 |
|
2954 |
|
2955 | function installRenderHelpers (target) {
|
2956 | target._o = markOnce;
|
2957 | target._n = toNumber;
|
2958 | target._s = toString;
|
2959 | target._l = renderList;
|
2960 | target._t = renderSlot;
|
2961 | target._q = looseEqual;
|
2962 | target._i = looseIndexOf;
|
2963 | target._m = renderStatic;
|
2964 | target._f = resolveFilter;
|
2965 | target._k = checkKeyCodes;
|
2966 | target._b = bindObjectProps;
|
2967 | target._v = createTextVNode;
|
2968 | target._e = createEmptyVNode;
|
2969 | target._u = resolveScopedSlots;
|
2970 | target._g = bindObjectListeners;
|
2971 | target._d = bindDynamicKeys;
|
2972 | target._p = prependModifier;
|
2973 | }
|
2974 |
|
2975 |
|
2976 |
|
2977 | function FunctionalRenderContext (
|
2978 | data,
|
2979 | props,
|
2980 | children,
|
2981 | parent,
|
2982 | Ctor
|
2983 | ) {
|
2984 | var this$1 = this;
|
2985 |
|
2986 | var options = Ctor.options;
|
2987 |
|
2988 |
|
2989 | var contextVm;
|
2990 | if (hasOwn(parent, '_uid')) {
|
2991 | contextVm = Object.create(parent);
|
2992 |
|
2993 | contextVm._original = parent;
|
2994 | } else {
|
2995 |
|
2996 |
|
2997 |
|
2998 | contextVm = parent;
|
2999 |
|
3000 | parent = parent._original;
|
3001 | }
|
3002 | var isCompiled = isTrue(options._compiled);
|
3003 | var needNormalization = !isCompiled;
|
3004 |
|
3005 | this.data = data;
|
3006 | this.props = props;
|
3007 | this.children = children;
|
3008 | this.parent = parent;
|
3009 | this.listeners = data.on || emptyObject;
|
3010 | this.injections = resolveInject(options.inject, parent);
|
3011 | this.slots = function () {
|
3012 | if (!this$1.$slots) {
|
3013 | normalizeScopedSlots(
|
3014 | data.scopedSlots,
|
3015 | this$1.$slots = resolveSlots(children, parent)
|
3016 | );
|
3017 | }
|
3018 | return this$1.$slots
|
3019 | };
|
3020 |
|
3021 | Object.defineProperty(this, 'scopedSlots', ({
|
3022 | enumerable: true,
|
3023 | get: function get () {
|
3024 | return normalizeScopedSlots(data.scopedSlots, this.slots())
|
3025 | }
|
3026 | }));
|
3027 |
|
3028 |
|
3029 | if (isCompiled) {
|
3030 |
|
3031 | this.$options = options;
|
3032 |
|
3033 | this.$slots = this.slots();
|
3034 | this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
|
3035 | }
|
3036 |
|
3037 | if (options._scopeId) {
|
3038 | this._c = function (a, b, c, d) {
|
3039 | var vnode = createElement(contextVm, a, b, c, d, needNormalization);
|
3040 | if (vnode && !Array.isArray(vnode)) {
|
3041 | vnode.fnScopeId = options._scopeId;
|
3042 | vnode.fnContext = parent;
|
3043 | }
|
3044 | return vnode
|
3045 | };
|
3046 | } else {
|
3047 | this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
|
3048 | }
|
3049 | }
|
3050 |
|
3051 | installRenderHelpers(FunctionalRenderContext.prototype);
|
3052 |
|
3053 | function createFunctionalComponent (
|
3054 | Ctor,
|
3055 | propsData,
|
3056 | data,
|
3057 | contextVm,
|
3058 | children
|
3059 | ) {
|
3060 | var options = Ctor.options;
|
3061 | var props = {};
|
3062 | var propOptions = options.props;
|
3063 | if (isDef(propOptions)) {
|
3064 | for (var key in propOptions) {
|
3065 | props[key] = validateProp(key, propOptions, propsData || emptyObject);
|
3066 | }
|
3067 | } else {
|
3068 | if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
|
3069 | if (isDef(data.props)) { mergeProps(props, data.props); }
|
3070 | }
|
3071 |
|
3072 | var renderContext = new FunctionalRenderContext(
|
3073 | data,
|
3074 | props,
|
3075 | children,
|
3076 | contextVm,
|
3077 | Ctor
|
3078 | );
|
3079 |
|
3080 | var vnode = options.render.call(null, renderContext._c, renderContext);
|
3081 |
|
3082 | if (vnode instanceof VNode) {
|
3083 | return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
|
3084 | } else if (Array.isArray(vnode)) {
|
3085 | var vnodes = normalizeChildren(vnode) || [];
|
3086 | var res = new Array(vnodes.length);
|
3087 | for (var i = 0; i < vnodes.length; i++) {
|
3088 | res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
|
3089 | }
|
3090 | return res
|
3091 | }
|
3092 | }
|
3093 |
|
3094 | function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
|
3095 |
|
3096 |
|
3097 |
|
3098 | var clone = cloneVNode(vnode);
|
3099 | clone.fnContext = contextVm;
|
3100 | clone.fnOptions = options;
|
3101 | {
|
3102 | (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
|
3103 | }
|
3104 | if (data.slot) {
|
3105 | (clone.data || (clone.data = {})).slot = data.slot;
|
3106 | }
|
3107 | return clone
|
3108 | }
|
3109 |
|
3110 | function mergeProps (to, from) {
|
3111 | for (var key in from) {
|
3112 | to[camelize(key)] = from[key];
|
3113 | }
|
3114 | }
|
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 |
|
3120 |
|
3121 |
|
3122 |
|
3123 |
|
3124 |
|
3125 | var componentVNodeHooks = {
|
3126 | init: function init (vnode, hydrating) {
|
3127 | if (
|
3128 | vnode.componentInstance &&
|
3129 | !vnode.componentInstance._isDestroyed &&
|
3130 | vnode.data.keepAlive
|
3131 | ) {
|
3132 |
|
3133 | var mountedNode = vnode;
|
3134 | componentVNodeHooks.prepatch(mountedNode, mountedNode);
|
3135 | } else {
|
3136 | var child = vnode.componentInstance = createComponentInstanceForVnode(
|
3137 | vnode,
|
3138 | activeInstance
|
3139 | );
|
3140 | child.$mount(hydrating ? vnode.elm : undefined, hydrating);
|
3141 | }
|
3142 | },
|
3143 |
|
3144 | prepatch: function prepatch (oldVnode, vnode) {
|
3145 | var options = vnode.componentOptions;
|
3146 | var child = vnode.componentInstance = oldVnode.componentInstance;
|
3147 | updateChildComponent(
|
3148 | child,
|
3149 | options.propsData,
|
3150 | options.listeners,
|
3151 | vnode,
|
3152 | options.children
|
3153 | );
|
3154 | },
|
3155 |
|
3156 | insert: function insert (vnode) {
|
3157 | var context = vnode.context;
|
3158 | var componentInstance = vnode.componentInstance;
|
3159 | if (!componentInstance._isMounted) {
|
3160 | componentInstance._isMounted = true;
|
3161 | callHook(componentInstance, 'mounted');
|
3162 | }
|
3163 | if (vnode.data.keepAlive) {
|
3164 | if (context._isMounted) {
|
3165 |
|
3166 |
|
3167 |
|
3168 |
|
3169 |
|
3170 | queueActivatedComponent(componentInstance);
|
3171 | } else {
|
3172 | activateChildComponent(componentInstance, true );
|
3173 | }
|
3174 | }
|
3175 | },
|
3176 |
|
3177 | destroy: function destroy (vnode) {
|
3178 | var componentInstance = vnode.componentInstance;
|
3179 | if (!componentInstance._isDestroyed) {
|
3180 | if (!vnode.data.keepAlive) {
|
3181 | componentInstance.$destroy();
|
3182 | } else {
|
3183 | deactivateChildComponent(componentInstance, true );
|
3184 | }
|
3185 | }
|
3186 | }
|
3187 | };
|
3188 |
|
3189 | var hooksToMerge = Object.keys(componentVNodeHooks);
|
3190 |
|
3191 | function createComponent (
|
3192 | Ctor,
|
3193 | data,
|
3194 | context,
|
3195 | children,
|
3196 | tag
|
3197 | ) {
|
3198 | if (isUndef(Ctor)) {
|
3199 | return
|
3200 | }
|
3201 |
|
3202 | var baseCtor = context.$options._base;
|
3203 |
|
3204 |
|
3205 | if (isObject(Ctor)) {
|
3206 | Ctor = baseCtor.extend(Ctor);
|
3207 | }
|
3208 |
|
3209 |
|
3210 |
|
3211 | if (typeof Ctor !== 'function') {
|
3212 | {
|
3213 | warn(("Invalid Component definition: " + (String(Ctor))), context);
|
3214 | }
|
3215 | return
|
3216 | }
|
3217 |
|
3218 |
|
3219 | var asyncFactory;
|
3220 | if (isUndef(Ctor.cid)) {
|
3221 | asyncFactory = Ctor;
|
3222 | Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
|
3223 | if (Ctor === undefined) {
|
3224 |
|
3225 |
|
3226 |
|
3227 | return createAsyncPlaceholder(
|
3228 | asyncFactory,
|
3229 | data,
|
3230 | context,
|
3231 | children,
|
3232 | tag
|
3233 | )
|
3234 | }
|
3235 | }
|
3236 |
|
3237 | data = data || {};
|
3238 |
|
3239 |
|
3240 |
|
3241 | resolveConstructorOptions(Ctor);
|
3242 |
|
3243 |
|
3244 | if (isDef(data.model)) {
|
3245 | transformModel(Ctor.options, data);
|
3246 | }
|
3247 |
|
3248 |
|
3249 | var propsData = extractPropsFromVNodeData(data, Ctor, tag);
|
3250 |
|
3251 |
|
3252 | if (isTrue(Ctor.options.functional)) {
|
3253 | return createFunctionalComponent(Ctor, propsData, data, context, children)
|
3254 | }
|
3255 |
|
3256 |
|
3257 |
|
3258 | var listeners = data.on;
|
3259 |
|
3260 |
|
3261 | data.on = data.nativeOn;
|
3262 |
|
3263 | if (isTrue(Ctor.options.abstract)) {
|
3264 |
|
3265 |
|
3266 |
|
3267 |
|
3268 | var slot = data.slot;
|
3269 | data = {};
|
3270 | if (slot) {
|
3271 | data.slot = slot;
|
3272 | }
|
3273 | }
|
3274 |
|
3275 |
|
3276 | installComponentHooks(data);
|
3277 |
|
3278 |
|
3279 | var name = Ctor.options.name || tag;
|
3280 | var vnode = new VNode(
|
3281 | ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
|
3282 | data, undefined, undefined, undefined, context,
|
3283 | { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
|
3284 | asyncFactory
|
3285 | );
|
3286 |
|
3287 | return vnode
|
3288 | }
|
3289 |
|
3290 | function createComponentInstanceForVnode (
|
3291 | // we know it's MountedComponentVNode but flow doesn't
|
3292 | vnode,
|
3293 | // activeInstance in lifecycle state
|
3294 | parent
|
3295 | ) {
|
3296 | var options = {
|
3297 | _isComponent: true,
|
3298 | _parentVnode: vnode,
|
3299 | parent: parent
|
3300 | };
|
3301 |
|
3302 | var inlineTemplate = vnode.data.inlineTemplate;
|
3303 | if (isDef(inlineTemplate)) {
|
3304 | options.render = inlineTemplate.render;
|
3305 | options.staticRenderFns = inlineTemplate.staticRenderFns;
|
3306 | }
|
3307 | return new vnode.componentOptions.Ctor(options)
|
3308 | }
|
3309 |
|
3310 | function installComponentHooks (data) {
|
3311 | var hooks = data.hook || (data.hook = {});
|
3312 | for (var i = 0; i < hooksToMerge.length; i++) {
|
3313 | var key = hooksToMerge[i];
|
3314 | var existing = hooks[key];
|
3315 | var toMerge = componentVNodeHooks[key];
|
3316 | if (existing !== toMerge && !(existing && existing._merged)) {
|
3317 | hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
|
3318 | }
|
3319 | }
|
3320 | }
|
3321 |
|
3322 | function mergeHook$1 (f1, f2) {
|
3323 | var merged = function (a, b) {
|
3324 |
|
3325 | f1(a, b);
|
3326 | f2(a, b);
|
3327 | };
|
3328 | merged._merged = true;
|
3329 | return merged
|
3330 | }
|
3331 |
|
3332 |
|
3333 |
|
3334 | function transformModel (options, data) {
|
3335 | var prop = (options.model && options.model.prop) || 'value';
|
3336 | var event = (options.model && options.model.event) || 'input'
|
3337 | ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
|
3338 | var on = data.on || (data.on = {});
|
3339 | var existing = on[event];
|
3340 | var callback = data.model.callback;
|
3341 | if (isDef(existing)) {
|
3342 | if (
|
3343 | Array.isArray(existing)
|
3344 | ? existing.indexOf(callback) === -1
|
3345 | : existing !== callback
|
3346 | ) {
|
3347 | on[event] = [callback].concat(existing);
|
3348 | }
|
3349 | } else {
|
3350 | on[event] = callback;
|
3351 | }
|
3352 | }
|
3353 |
|
3354 |
|
3355 |
|
3356 | var SIMPLE_NORMALIZE = 1;
|
3357 | var ALWAYS_NORMALIZE = 2;
|
3358 |
|
3359 |
|
3360 |
|
3361 | function createElement (
|
3362 | context,
|
3363 | tag,
|
3364 | data,
|
3365 | children,
|
3366 | normalizationType,
|
3367 | alwaysNormalize
|
3368 | ) {
|
3369 | if (Array.isArray(data) || isPrimitive(data)) {
|
3370 | normalizationType = children;
|
3371 | children = data;
|
3372 | data = undefined;
|
3373 | }
|
3374 | if (isTrue(alwaysNormalize)) {
|
3375 | normalizationType = ALWAYS_NORMALIZE;
|
3376 | }
|
3377 | return _createElement(context, tag, data, children, normalizationType)
|
3378 | }
|
3379 |
|
3380 | function _createElement (
|
3381 | context,
|
3382 | tag,
|
3383 | data,
|
3384 | children,
|
3385 | normalizationType
|
3386 | ) {
|
3387 | if (isDef(data) && isDef((data).__ob__)) {
|
3388 | warn(
|
3389 | "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
|
3390 | 'Always create fresh vnode data objects in each render!',
|
3391 | context
|
3392 | );
|
3393 | return createEmptyVNode()
|
3394 | }
|
3395 |
|
3396 | if (isDef(data) && isDef(data.is)) {
|
3397 | tag = data.is;
|
3398 | }
|
3399 | if (!tag) {
|
3400 |
|
3401 | return createEmptyVNode()
|
3402 | }
|
3403 |
|
3404 | if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
|
3405 | ) {
|
3406 | {
|
3407 | warn(
|
3408 | 'Avoid using non-primitive value as key, ' +
|
3409 | 'use string/number value instead.',
|
3410 | context
|
3411 | );
|
3412 | }
|
3413 | }
|
3414 |
|
3415 | if (Array.isArray(children) &&
|
3416 | typeof children[0] === 'function'
|
3417 | ) {
|
3418 | data = data || {};
|
3419 | data.scopedSlots = { default: children[0] };
|
3420 | children.length = 0;
|
3421 | }
|
3422 | if (normalizationType === ALWAYS_NORMALIZE) {
|
3423 | children = normalizeChildren(children);
|
3424 | } else if (normalizationType === SIMPLE_NORMALIZE) {
|
3425 | children = simpleNormalizeChildren(children);
|
3426 | }
|
3427 | var vnode, ns;
|
3428 | if (typeof tag === 'string') {
|
3429 | var Ctor;
|
3430 | ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
|
3431 | if (config.isReservedTag(tag)) {
|
3432 |
|
3433 | if (isDef(data) && isDef(data.nativeOn) && data.tag !== 'component') {
|
3434 | warn(
|
3435 | ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
|
3436 | context
|
3437 | );
|
3438 | }
|
3439 | vnode = new VNode(
|
3440 | config.parsePlatformTagName(tag), data, children,
|
3441 | undefined, undefined, context
|
3442 | );
|
3443 | } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
|
3444 |
|
3445 | vnode = createComponent(Ctor, data, context, children, tag);
|
3446 | } else {
|
3447 |
|
3448 |
|
3449 |
|
3450 | vnode = new VNode(
|
3451 | tag, data, children,
|
3452 | undefined, undefined, context
|
3453 | );
|
3454 | }
|
3455 | } else {
|
3456 |
|
3457 | vnode = createComponent(tag, data, context, children);
|
3458 | }
|
3459 | if (Array.isArray(vnode)) {
|
3460 | return vnode
|
3461 | } else if (isDef(vnode)) {
|
3462 | if (isDef(ns)) { applyNS(vnode, ns); }
|
3463 | if (isDef(data)) { registerDeepBindings(data); }
|
3464 | return vnode
|
3465 | } else {
|
3466 | return createEmptyVNode()
|
3467 | }
|
3468 | }
|
3469 |
|
3470 | function applyNS (vnode, ns, force) {
|
3471 | vnode.ns = ns;
|
3472 | if (vnode.tag === 'foreignObject') {
|
3473 |
|
3474 | ns = undefined;
|
3475 | force = true;
|
3476 | }
|
3477 | if (isDef(vnode.children)) {
|
3478 | for (var i = 0, l = vnode.children.length; i < l; i++) {
|
3479 | var child = vnode.children[i];
|
3480 | if (isDef(child.tag) && (
|
3481 | isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
|
3482 | applyNS(child, ns, force);
|
3483 | }
|
3484 | }
|
3485 | }
|
3486 | }
|
3487 |
|
3488 |
|
3489 |
|
3490 |
|
3491 | function registerDeepBindings (data) {
|
3492 | if (isObject(data.style)) {
|
3493 | traverse(data.style);
|
3494 | }
|
3495 | if (isObject(data.class)) {
|
3496 | traverse(data.class);
|
3497 | }
|
3498 | }
|
3499 |
|
3500 |
|
3501 |
|
3502 | function initRender (vm) {
|
3503 | vm._vnode = null;
|
3504 | vm._staticTrees = null;
|
3505 | var options = vm.$options;
|
3506 | var parentVnode = vm.$vnode = options._parentVnode;
|
3507 | var renderContext = parentVnode && parentVnode.context;
|
3508 | vm.$slots = resolveSlots(options._renderChildren, renderContext);
|
3509 | vm.$scopedSlots = emptyObject;
|
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 | vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
|
3515 |
|
3516 |
|
3517 | vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
|
3518 |
|
3519 |
|
3520 |
|
3521 | var parentData = parentVnode && parentVnode.data;
|
3522 |
|
3523 |
|
3524 | {
|
3525 | defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
|
3526 | !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
|
3527 | }, true);
|
3528 | defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
|
3529 | !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
|
3530 | }, true);
|
3531 | }
|
3532 | }
|
3533 |
|
3534 | var currentRenderingInstance = null;
|
3535 |
|
3536 | function renderMixin (Vue) {
|
3537 |
|
3538 | installRenderHelpers(Vue.prototype);
|
3539 |
|
3540 | Vue.prototype.$nextTick = function (fn) {
|
3541 | return nextTick(fn, this)
|
3542 | };
|
3543 |
|
3544 | Vue.prototype._render = function () {
|
3545 | var vm = this;
|
3546 | var ref = vm.$options;
|
3547 | var render = ref.render;
|
3548 | var _parentVnode = ref._parentVnode;
|
3549 |
|
3550 | if (_parentVnode) {
|
3551 | vm.$scopedSlots = normalizeScopedSlots(
|
3552 | _parentVnode.data.scopedSlots,
|
3553 | vm.$slots,
|
3554 | vm.$scopedSlots
|
3555 | );
|
3556 | }
|
3557 |
|
3558 |
|
3559 |
|
3560 | vm.$vnode = _parentVnode;
|
3561 |
|
3562 | var vnode;
|
3563 | try {
|
3564 |
|
3565 |
|
3566 |
|
3567 | currentRenderingInstance = vm;
|
3568 | vnode = render.call(vm._renderProxy, vm.$createElement);
|
3569 | } catch (e) {
|
3570 | handleError(e, vm, "render");
|
3571 |
|
3572 |
|
3573 |
|
3574 | if (vm.$options.renderError) {
|
3575 | try {
|
3576 | vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
|
3577 | } catch (e) {
|
3578 | handleError(e, vm, "renderError");
|
3579 | vnode = vm._vnode;
|
3580 | }
|
3581 | } else {
|
3582 | vnode = vm._vnode;
|
3583 | }
|
3584 | } finally {
|
3585 | currentRenderingInstance = null;
|
3586 | }
|
3587 |
|
3588 | if (Array.isArray(vnode) && vnode.length === 1) {
|
3589 | vnode = vnode[0];
|
3590 | }
|
3591 |
|
3592 | if (!(vnode instanceof VNode)) {
|
3593 | if (Array.isArray(vnode)) {
|
3594 | warn(
|
3595 | 'Multiple root nodes returned from render function. Render function ' +
|
3596 | 'should return a single root node.',
|
3597 | vm
|
3598 | );
|
3599 | }
|
3600 | vnode = createEmptyVNode();
|
3601 | }
|
3602 |
|
3603 | vnode.parent = _parentVnode;
|
3604 | return vnode
|
3605 | };
|
3606 | }
|
3607 |
|
3608 |
|
3609 |
|
3610 | function ensureCtor (comp, base) {
|
3611 | if (
|
3612 | comp.__esModule ||
|
3613 | (hasSymbol && comp[Symbol.toStringTag] === 'Module')
|
3614 | ) {
|
3615 | comp = comp.default;
|
3616 | }
|
3617 | return isObject(comp)
|
3618 | ? base.extend(comp)
|
3619 | : comp
|
3620 | }
|
3621 |
|
3622 | function createAsyncPlaceholder (
|
3623 | factory,
|
3624 | data,
|
3625 | context,
|
3626 | children,
|
3627 | tag
|
3628 | ) {
|
3629 | var node = createEmptyVNode();
|
3630 | node.asyncFactory = factory;
|
3631 | node.asyncMeta = { data: data, context: context, children: children, tag: tag };
|
3632 | return node
|
3633 | }
|
3634 |
|
3635 | function resolveAsyncComponent (
|
3636 | factory,
|
3637 | baseCtor
|
3638 | ) {
|
3639 | if (isTrue(factory.error) && isDef(factory.errorComp)) {
|
3640 | return factory.errorComp
|
3641 | }
|
3642 |
|
3643 | if (isDef(factory.resolved)) {
|
3644 | return factory.resolved
|
3645 | }
|
3646 |
|
3647 | var owner = currentRenderingInstance;
|
3648 | if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
|
3649 |
|
3650 | factory.owners.push(owner);
|
3651 | }
|
3652 |
|
3653 | if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
|
3654 | return factory.loadingComp
|
3655 | }
|
3656 |
|
3657 | if (owner && !isDef(factory.owners)) {
|
3658 | var owners = factory.owners = [owner];
|
3659 | var sync = true;
|
3660 | var timerLoading = null;
|
3661 | var timerTimeout = null
|
3662 |
|
3663 | ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
|
3664 |
|
3665 | var forceRender = function (renderCompleted) {
|
3666 | for (var i = 0, l = owners.length; i < l; i++) {
|
3667 | (owners[i]).$forceUpdate();
|
3668 | }
|
3669 |
|
3670 | if (renderCompleted) {
|
3671 | owners.length = 0;
|
3672 | if (timerLoading !== null) {
|
3673 | clearTimeout(timerLoading);
|
3674 | timerLoading = null;
|
3675 | }
|
3676 | if (timerTimeout !== null) {
|
3677 | clearTimeout(timerTimeout);
|
3678 | timerTimeout = null;
|
3679 | }
|
3680 | }
|
3681 | };
|
3682 |
|
3683 | var resolve = once(function (res) {
|
3684 |
|
3685 | factory.resolved = ensureCtor(res, baseCtor);
|
3686 |
|
3687 |
|
3688 | if (!sync) {
|
3689 | forceRender(true);
|
3690 | } else {
|
3691 | owners.length = 0;
|
3692 | }
|
3693 | });
|
3694 |
|
3695 | var reject = once(function (reason) {
|
3696 | warn(
|
3697 | "Failed to resolve async component: " + (String(factory)) +
|
3698 | (reason ? ("\nReason: " + reason) : '')
|
3699 | );
|
3700 | if (isDef(factory.errorComp)) {
|
3701 | factory.error = true;
|
3702 | forceRender(true);
|
3703 | }
|
3704 | });
|
3705 |
|
3706 | var res = factory(resolve, reject);
|
3707 |
|
3708 | if (isObject(res)) {
|
3709 | if (isPromise(res)) {
|
3710 |
|
3711 | if (isUndef(factory.resolved)) {
|
3712 | res.then(resolve, reject);
|
3713 | }
|
3714 | } else if (isPromise(res.component)) {
|
3715 | res.component.then(resolve, reject);
|
3716 |
|
3717 | if (isDef(res.error)) {
|
3718 | factory.errorComp = ensureCtor(res.error, baseCtor);
|
3719 | }
|
3720 |
|
3721 | if (isDef(res.loading)) {
|
3722 | factory.loadingComp = ensureCtor(res.loading, baseCtor);
|
3723 | if (res.delay === 0) {
|
3724 | factory.loading = true;
|
3725 | } else {
|
3726 | timerLoading = setTimeout(function () {
|
3727 | timerLoading = null;
|
3728 | if (isUndef(factory.resolved) && isUndef(factory.error)) {
|
3729 | factory.loading = true;
|
3730 | forceRender(false);
|
3731 | }
|
3732 | }, res.delay || 200);
|
3733 | }
|
3734 | }
|
3735 |
|
3736 | if (isDef(res.timeout)) {
|
3737 | timerTimeout = setTimeout(function () {
|
3738 | timerTimeout = null;
|
3739 | if (isUndef(factory.resolved)) {
|
3740 | reject(
|
3741 | "timeout (" + (res.timeout) + "ms)"
|
3742 | );
|
3743 | }
|
3744 | }, res.timeout);
|
3745 | }
|
3746 | }
|
3747 | }
|
3748 |
|
3749 | sync = false;
|
3750 |
|
3751 | return factory.loading
|
3752 | ? factory.loadingComp
|
3753 | : factory.resolved
|
3754 | }
|
3755 | }
|
3756 |
|
3757 |
|
3758 |
|
3759 | function getFirstComponentChild (children) {
|
3760 | if (Array.isArray(children)) {
|
3761 | for (var i = 0; i < children.length; i++) {
|
3762 | var c = children[i];
|
3763 | if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
|
3764 | return c
|
3765 | }
|
3766 | }
|
3767 | }
|
3768 | }
|
3769 |
|
3770 |
|
3771 |
|
3772 |
|
3773 |
|
3774 | function initEvents (vm) {
|
3775 | vm._events = Object.create(null);
|
3776 | vm._hasHookEvent = false;
|
3777 |
|
3778 | var listeners = vm.$options._parentListeners;
|
3779 | if (listeners) {
|
3780 | updateComponentListeners(vm, listeners);
|
3781 | }
|
3782 | }
|
3783 |
|
3784 | var target;
|
3785 |
|
3786 | function add (event, fn) {
|
3787 | target.$on(event, fn);
|
3788 | }
|
3789 |
|
3790 | function remove$1 (event, fn) {
|
3791 | target.$off(event, fn);
|
3792 | }
|
3793 |
|
3794 | function createOnceHandler (event, fn) {
|
3795 | var _target = target;
|
3796 | return function onceHandler () {
|
3797 | var res = fn.apply(null, arguments);
|
3798 | if (res !== null) {
|
3799 | _target.$off(event, onceHandler);
|
3800 | }
|
3801 | }
|
3802 | }
|
3803 |
|
3804 | function updateComponentListeners (
|
3805 | vm,
|
3806 | listeners,
|
3807 | oldListeners
|
3808 | ) {
|
3809 | target = vm;
|
3810 | updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
|
3811 | target = undefined;
|
3812 | }
|
3813 |
|
3814 | function eventsMixin (Vue) {
|
3815 | var hookRE = /^hook:/;
|
3816 | Vue.prototype.$on = function (event, fn) {
|
3817 | var vm = this;
|
3818 | if (Array.isArray(event)) {
|
3819 | for (var i = 0, l = event.length; i < l; i++) {
|
3820 | vm.$on(event[i], fn);
|
3821 | }
|
3822 | } else {
|
3823 | (vm._events[event] || (vm._events[event] = [])).push(fn);
|
3824 |
|
3825 |
|
3826 | if (hookRE.test(event)) {
|
3827 | vm._hasHookEvent = true;
|
3828 | }
|
3829 | }
|
3830 | return vm
|
3831 | };
|
3832 |
|
3833 | Vue.prototype.$once = function (event, fn) {
|
3834 | var vm = this;
|
3835 | function on () {
|
3836 | vm.$off(event, on);
|
3837 | fn.apply(vm, arguments);
|
3838 | }
|
3839 | on.fn = fn;
|
3840 | vm.$on(event, on);
|
3841 | return vm
|
3842 | };
|
3843 |
|
3844 | Vue.prototype.$off = function (event, fn) {
|
3845 | var vm = this;
|
3846 |
|
3847 | if (!arguments.length) {
|
3848 | vm._events = Object.create(null);
|
3849 | return vm
|
3850 | }
|
3851 |
|
3852 | if (Array.isArray(event)) {
|
3853 | for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
|
3854 | vm.$off(event[i$1], fn);
|
3855 | }
|
3856 | return vm
|
3857 | }
|
3858 |
|
3859 | var cbs = vm._events[event];
|
3860 | if (!cbs) {
|
3861 | return vm
|
3862 | }
|
3863 | if (!fn) {
|
3864 | vm._events[event] = null;
|
3865 | return vm
|
3866 | }
|
3867 |
|
3868 | var cb;
|
3869 | var i = cbs.length;
|
3870 | while (i--) {
|
3871 | cb = cbs[i];
|
3872 | if (cb === fn || cb.fn === fn) {
|
3873 | cbs.splice(i, 1);
|
3874 | break
|
3875 | }
|
3876 | }
|
3877 | return vm
|
3878 | };
|
3879 |
|
3880 | Vue.prototype.$emit = function (event) {
|
3881 | var vm = this;
|
3882 | {
|
3883 | var lowerCaseEvent = event.toLowerCase();
|
3884 | if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
|
3885 | tip(
|
3886 | "Event \"" + lowerCaseEvent + "\" is emitted in component " +
|
3887 | (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
|
3888 | "Note that HTML attributes are case-insensitive and you cannot use " +
|
3889 | "v-on to listen to camelCase events when using in-DOM templates. " +
|
3890 | "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
|
3891 | );
|
3892 | }
|
3893 | }
|
3894 | var cbs = vm._events[event];
|
3895 | if (cbs) {
|
3896 | cbs = cbs.length > 1 ? toArray(cbs) : cbs;
|
3897 | var args = toArray(arguments, 1);
|
3898 | var info = "event handler for \"" + event + "\"";
|
3899 | for (var i = 0, l = cbs.length; i < l; i++) {
|
3900 | invokeWithErrorHandling(cbs[i], vm, args, vm, info);
|
3901 | }
|
3902 | }
|
3903 | return vm
|
3904 | };
|
3905 | }
|
3906 |
|
3907 |
|
3908 |
|
3909 | var activeInstance = null;
|
3910 | var isUpdatingChildComponent = false;
|
3911 |
|
3912 | function setActiveInstance(vm) {
|
3913 | var prevActiveInstance = activeInstance;
|
3914 | activeInstance = vm;
|
3915 | return function () {
|
3916 | activeInstance = prevActiveInstance;
|
3917 | }
|
3918 | }
|
3919 |
|
3920 | function initLifecycle (vm) {
|
3921 | var options = vm.$options;
|
3922 |
|
3923 |
|
3924 | var parent = options.parent;
|
3925 | if (parent && !options.abstract) {
|
3926 | while (parent.$options.abstract && parent.$parent) {
|
3927 | parent = parent.$parent;
|
3928 | }
|
3929 | parent.$children.push(vm);
|
3930 | }
|
3931 |
|
3932 | vm.$parent = parent;
|
3933 | vm.$root = parent ? parent.$root : vm;
|
3934 |
|
3935 | vm.$children = [];
|
3936 | vm.$refs = {};
|
3937 |
|
3938 | vm._watcher = null;
|
3939 | vm._inactive = null;
|
3940 | vm._directInactive = false;
|
3941 | vm._isMounted = false;
|
3942 | vm._isDestroyed = false;
|
3943 | vm._isBeingDestroyed = false;
|
3944 | }
|
3945 |
|
3946 | function lifecycleMixin (Vue) {
|
3947 | Vue.prototype._update = function (vnode, hydrating) {
|
3948 | var vm = this;
|
3949 | var prevEl = vm.$el;
|
3950 | var prevVnode = vm._vnode;
|
3951 | var restoreActiveInstance = setActiveInstance(vm);
|
3952 | vm._vnode = vnode;
|
3953 |
|
3954 |
|
3955 | if (!prevVnode) {
|
3956 |
|
3957 | vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false );
|
3958 | } else {
|
3959 |
|
3960 | vm.$el = vm.__patch__(prevVnode, vnode);
|
3961 | }
|
3962 | restoreActiveInstance();
|
3963 |
|
3964 | if (prevEl) {
|
3965 | prevEl.__vue__ = null;
|
3966 | }
|
3967 | if (vm.$el) {
|
3968 | vm.$el.__vue__ = vm;
|
3969 | }
|
3970 |
|
3971 | if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
|
3972 | vm.$parent.$el = vm.$el;
|
3973 | }
|
3974 |
|
3975 |
|
3976 | };
|
3977 |
|
3978 | Vue.prototype.$forceUpdate = function () {
|
3979 | var vm = this;
|
3980 | if (vm._watcher) {
|
3981 | vm._watcher.update();
|
3982 | }
|
3983 | };
|
3984 |
|
3985 | Vue.prototype.$destroy = function () {
|
3986 | var vm = this;
|
3987 | if (vm._isBeingDestroyed) {
|
3988 | return
|
3989 | }
|
3990 | callHook(vm, 'beforeDestroy');
|
3991 | vm._isBeingDestroyed = true;
|
3992 |
|
3993 | var parent = vm.$parent;
|
3994 | if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
|
3995 | remove(parent.$children, vm);
|
3996 | }
|
3997 |
|
3998 | if (vm._watcher) {
|
3999 | vm._watcher.teardown();
|
4000 | }
|
4001 | var i = vm._watchers.length;
|
4002 | while (i--) {
|
4003 | vm._watchers[i].teardown();
|
4004 | }
|
4005 |
|
4006 |
|
4007 | if (vm._data.__ob__) {
|
4008 | vm._data.__ob__.vmCount--;
|
4009 | }
|
4010 |
|
4011 | vm._isDestroyed = true;
|
4012 |
|
4013 | vm.__patch__(vm._vnode, null);
|
4014 |
|
4015 | callHook(vm, 'destroyed');
|
4016 |
|
4017 | vm.$off();
|
4018 |
|
4019 | if (vm.$el) {
|
4020 | vm.$el.__vue__ = null;
|
4021 | }
|
4022 |
|
4023 | if (vm.$vnode) {
|
4024 | vm.$vnode.parent = null;
|
4025 | }
|
4026 | };
|
4027 | }
|
4028 |
|
4029 | function mountComponent (
|
4030 | vm,
|
4031 | el,
|
4032 | hydrating
|
4033 | ) {
|
4034 | vm.$el = el;
|
4035 | if (!vm.$options.render) {
|
4036 | vm.$options.render = createEmptyVNode;
|
4037 | {
|
4038 |
|
4039 | if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
|
4040 | vm.$options.el || el) {
|
4041 | warn(
|
4042 | 'You are using the runtime-only build of Vue where the template ' +
|
4043 | 'compiler is not available. Either pre-compile the templates into ' +
|
4044 | 'render functions, or use the compiler-included build.',
|
4045 | vm
|
4046 | );
|
4047 | } else {
|
4048 | warn(
|
4049 | 'Failed to mount component: template or render function not defined.',
|
4050 | vm
|
4051 | );
|
4052 | }
|
4053 | }
|
4054 | }
|
4055 | callHook(vm, 'beforeMount');
|
4056 |
|
4057 | var updateComponent;
|
4058 |
|
4059 | if (config.performance && mark) {
|
4060 | updateComponent = function () {
|
4061 | var name = vm._name;
|
4062 | var id = vm._uid;
|
4063 | var startTag = "vue-perf-start:" + id;
|
4064 | var endTag = "vue-perf-end:" + id;
|
4065 |
|
4066 | mark(startTag);
|
4067 | var vnode = vm._render();
|
4068 | mark(endTag);
|
4069 | measure(("vue " + name + " render"), startTag, endTag);
|
4070 |
|
4071 | mark(startTag);
|
4072 | vm._update(vnode, hydrating);
|
4073 | mark(endTag);
|
4074 | measure(("vue " + name + " patch"), startTag, endTag);
|
4075 | };
|
4076 | } else {
|
4077 | updateComponent = function () {
|
4078 | vm._update(vm._render(), hydrating);
|
4079 | };
|
4080 | }
|
4081 |
|
4082 |
|
4083 |
|
4084 |
|
4085 | new Watcher(vm, updateComponent, noop, {
|
4086 | before: function before () {
|
4087 | if (vm._isMounted && !vm._isDestroyed) {
|
4088 | callHook(vm, 'beforeUpdate');
|
4089 | }
|
4090 | }
|
4091 | }, true );
|
4092 | hydrating = false;
|
4093 |
|
4094 |
|
4095 |
|
4096 | if (vm.$vnode == null) {
|
4097 | vm._isMounted = true;
|
4098 | callHook(vm, 'mounted');
|
4099 | }
|
4100 | return vm
|
4101 | }
|
4102 |
|
4103 | function updateChildComponent (
|
4104 | vm,
|
4105 | propsData,
|
4106 | listeners,
|
4107 | parentVnode,
|
4108 | renderChildren
|
4109 | ) {
|
4110 | {
|
4111 | isUpdatingChildComponent = true;
|
4112 | }
|
4113 |
|
4114 |
|
4115 |
|
4116 |
|
4117 |
|
4118 |
|
4119 |
|
4120 | var newScopedSlots = parentVnode.data.scopedSlots;
|
4121 | var oldScopedSlots = vm.$scopedSlots;
|
4122 | var hasDynamicScopedSlot = !!(
|
4123 | (newScopedSlots && !newScopedSlots.$stable) ||
|
4124 | (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
|
4125 | (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
|
4126 | (!newScopedSlots && vm.$scopedSlots.$key)
|
4127 | );
|
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 | var needsForceUpdate = !!(
|
4133 | renderChildren ||
|
4134 | vm.$options._renderChildren ||
|
4135 | hasDynamicScopedSlot
|
4136 | );
|
4137 |
|
4138 | vm.$options._parentVnode = parentVnode;
|
4139 | vm.$vnode = parentVnode;
|
4140 |
|
4141 | if (vm._vnode) {
|
4142 | vm._vnode.parent = parentVnode;
|
4143 | }
|
4144 | vm.$options._renderChildren = renderChildren;
|
4145 |
|
4146 |
|
4147 |
|
4148 |
|
4149 | vm.$attrs = parentVnode.data.attrs || emptyObject;
|
4150 | vm.$listeners = listeners || emptyObject;
|
4151 |
|
4152 |
|
4153 | if (propsData && vm.$options.props) {
|
4154 | toggleObserving(false);
|
4155 | var props = vm._props;
|
4156 | var propKeys = vm.$options._propKeys || [];
|
4157 | for (var i = 0; i < propKeys.length; i++) {
|
4158 | var key = propKeys[i];
|
4159 | var propOptions = vm.$options.props;
|
4160 | props[key] = validateProp(key, propOptions, propsData, vm);
|
4161 | }
|
4162 | toggleObserving(true);
|
4163 |
|
4164 | vm.$options.propsData = propsData;
|
4165 | }
|
4166 |
|
4167 |
|
4168 | listeners = listeners || emptyObject;
|
4169 | var oldListeners = vm.$options._parentListeners;
|
4170 | vm.$options._parentListeners = listeners;
|
4171 | updateComponentListeners(vm, listeners, oldListeners);
|
4172 |
|
4173 |
|
4174 | if (needsForceUpdate) {
|
4175 | vm.$slots = resolveSlots(renderChildren, parentVnode.context);
|
4176 | vm.$forceUpdate();
|
4177 | }
|
4178 |
|
4179 | {
|
4180 | isUpdatingChildComponent = false;
|
4181 | }
|
4182 | }
|
4183 |
|
4184 | function isInInactiveTree (vm) {
|
4185 | while (vm && (vm = vm.$parent)) {
|
4186 | if (vm._inactive) { return true }
|
4187 | }
|
4188 | return false
|
4189 | }
|
4190 |
|
4191 | function activateChildComponent (vm, direct) {
|
4192 | if (direct) {
|
4193 | vm._directInactive = false;
|
4194 | if (isInInactiveTree(vm)) {
|
4195 | return
|
4196 | }
|
4197 | } else if (vm._directInactive) {
|
4198 | return
|
4199 | }
|
4200 | if (vm._inactive || vm._inactive === null) {
|
4201 | vm._inactive = false;
|
4202 | for (var i = 0; i < vm.$children.length; i++) {
|
4203 | activateChildComponent(vm.$children[i]);
|
4204 | }
|
4205 | callHook(vm, 'activated');
|
4206 | }
|
4207 | }
|
4208 |
|
4209 | function deactivateChildComponent (vm, direct) {
|
4210 | if (direct) {
|
4211 | vm._directInactive = true;
|
4212 | if (isInInactiveTree(vm)) {
|
4213 | return
|
4214 | }
|
4215 | }
|
4216 | if (!vm._inactive) {
|
4217 | vm._inactive = true;
|
4218 | for (var i = 0; i < vm.$children.length; i++) {
|
4219 | deactivateChildComponent(vm.$children[i]);
|
4220 | }
|
4221 | callHook(vm, 'deactivated');
|
4222 | }
|
4223 | }
|
4224 |
|
4225 | function callHook (vm, hook) {
|
4226 |
|
4227 | pushTarget();
|
4228 | var handlers = vm.$options[hook];
|
4229 | var info = hook + " hook";
|
4230 | if (handlers) {
|
4231 | for (var i = 0, j = handlers.length; i < j; i++) {
|
4232 | invokeWithErrorHandling(handlers[i], vm, null, vm, info);
|
4233 | }
|
4234 | }
|
4235 | if (vm._hasHookEvent) {
|
4236 | vm.$emit('hook:' + hook);
|
4237 | }
|
4238 | popTarget();
|
4239 | }
|
4240 |
|
4241 |
|
4242 |
|
4243 | var MAX_UPDATE_COUNT = 100;
|
4244 |
|
4245 | var queue = [];
|
4246 | var activatedChildren = [];
|
4247 | var has = {};
|
4248 | var circular = {};
|
4249 | var waiting = false;
|
4250 | var flushing = false;
|
4251 | var index = 0;
|
4252 |
|
4253 |
|
4254 |
|
4255 |
|
4256 | function resetSchedulerState () {
|
4257 | index = queue.length = activatedChildren.length = 0;
|
4258 | has = {};
|
4259 | {
|
4260 | circular = {};
|
4261 | }
|
4262 | waiting = flushing = false;
|
4263 | }
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 |
|
4269 |
|
4270 | var currentFlushTimestamp = 0;
|
4271 |
|
4272 |
|
4273 | var getNow = Date.now;
|
4274 |
|
4275 |
|
4276 |
|
4277 |
|
4278 |
|
4279 |
|
4280 |
|
4281 | if (inBrowser && !isIE) {
|
4282 | var performance = window.performance;
|
4283 | if (
|
4284 | performance &&
|
4285 | typeof performance.now === 'function' &&
|
4286 | getNow() > document.createEvent('Event').timeStamp
|
4287 | ) {
|
4288 |
|
4289 |
|
4290 |
|
4291 |
|
4292 | getNow = function () { return performance.now(); };
|
4293 | }
|
4294 | }
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 | function flushSchedulerQueue () {
|
4300 | currentFlushTimestamp = getNow();
|
4301 | flushing = true;
|
4302 | var watcher, id;
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 |
|
4311 |
|
4312 | queue.sort(function (a, b) { return a.id - b.id; });
|
4313 |
|
4314 |
|
4315 |
|
4316 | for (index = 0; index < queue.length; index++) {
|
4317 | watcher = queue[index];
|
4318 | if (watcher.before) {
|
4319 | watcher.before();
|
4320 | }
|
4321 | id = watcher.id;
|
4322 | has[id] = null;
|
4323 | watcher.run();
|
4324 |
|
4325 | if (has[id] != null) {
|
4326 | circular[id] = (circular[id] || 0) + 1;
|
4327 | if (circular[id] > MAX_UPDATE_COUNT) {
|
4328 | warn(
|
4329 | 'You may have an infinite update loop ' + (
|
4330 | watcher.user
|
4331 | ? ("in watcher with expression \"" + (watcher.expression) + "\"")
|
4332 | : "in a component render function."
|
4333 | ),
|
4334 | watcher.vm
|
4335 | );
|
4336 | break
|
4337 | }
|
4338 | }
|
4339 | }
|
4340 |
|
4341 |
|
4342 | var activatedQueue = activatedChildren.slice();
|
4343 | var updatedQueue = queue.slice();
|
4344 |
|
4345 | resetSchedulerState();
|
4346 |
|
4347 |
|
4348 | callActivatedHooks(activatedQueue);
|
4349 | callUpdatedHooks(updatedQueue);
|
4350 |
|
4351 |
|
4352 |
|
4353 | if (devtools && config.devtools) {
|
4354 | devtools.emit('flush');
|
4355 | }
|
4356 | }
|
4357 |
|
4358 | function callUpdatedHooks (queue) {
|
4359 | var i = queue.length;
|
4360 | while (i--) {
|
4361 | var watcher = queue[i];
|
4362 | var vm = watcher.vm;
|
4363 | if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
|
4364 | callHook(vm, 'updated');
|
4365 | }
|
4366 | }
|
4367 | }
|
4368 |
|
4369 |
|
4370 |
|
4371 |
|
4372 |
|
4373 | function queueActivatedComponent (vm) {
|
4374 |
|
4375 |
|
4376 | vm._inactive = false;
|
4377 | activatedChildren.push(vm);
|
4378 | }
|
4379 |
|
4380 | function callActivatedHooks (queue) {
|
4381 | for (var i = 0; i < queue.length; i++) {
|
4382 | queue[i]._inactive = true;
|
4383 | activateChildComponent(queue[i], true );
|
4384 | }
|
4385 | }
|
4386 |
|
4387 |
|
4388 |
|
4389 |
|
4390 |
|
4391 |
|
4392 | function queueWatcher (watcher) {
|
4393 | var id = watcher.id;
|
4394 | if (has[id] == null) {
|
4395 | has[id] = true;
|
4396 | if (!flushing) {
|
4397 | queue.push(watcher);
|
4398 | } else {
|
4399 |
|
4400 |
|
4401 | var i = queue.length - 1;
|
4402 | while (i > index && queue[i].id > watcher.id) {
|
4403 | i--;
|
4404 | }
|
4405 | queue.splice(i + 1, 0, watcher);
|
4406 | }
|
4407 |
|
4408 | if (!waiting) {
|
4409 | waiting = true;
|
4410 |
|
4411 | if (!config.async) {
|
4412 | flushSchedulerQueue();
|
4413 | return
|
4414 | }
|
4415 | nextTick(flushSchedulerQueue);
|
4416 | }
|
4417 | }
|
4418 | }
|
4419 |
|
4420 |
|
4421 |
|
4422 |
|
4423 |
|
4424 | var uid$2 = 0;
|
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 | var Watcher = function Watcher (
|
4432 | vm,
|
4433 | expOrFn,
|
4434 | cb,
|
4435 | options,
|
4436 | isRenderWatcher
|
4437 | ) {
|
4438 | this.vm = vm;
|
4439 | if (isRenderWatcher) {
|
4440 | vm._watcher = this;
|
4441 | }
|
4442 | vm._watchers.push(this);
|
4443 |
|
4444 | if (options) {
|
4445 | this.deep = !!options.deep;
|
4446 | this.user = !!options.user;
|
4447 | this.lazy = !!options.lazy;
|
4448 | this.sync = !!options.sync;
|
4449 | this.before = options.before;
|
4450 | } else {
|
4451 | this.deep = this.user = this.lazy = this.sync = false;
|
4452 | }
|
4453 | this.cb = cb;
|
4454 | this.id = ++uid$2;
|
4455 | this.active = true;
|
4456 | this.dirty = this.lazy;
|
4457 | this.deps = [];
|
4458 | this.newDeps = [];
|
4459 | this.depIds = new _Set();
|
4460 | this.newDepIds = new _Set();
|
4461 | this.expression = expOrFn.toString();
|
4462 |
|
4463 | if (typeof expOrFn === 'function') {
|
4464 | this.getter = expOrFn;
|
4465 | } else {
|
4466 | this.getter = parsePath(expOrFn);
|
4467 | if (!this.getter) {
|
4468 | this.getter = noop;
|
4469 | warn(
|
4470 | "Failed watching path: \"" + expOrFn + "\" " +
|
4471 | 'Watcher only accepts simple dot-delimited paths. ' +
|
4472 | 'For full control, use a function instead.',
|
4473 | vm
|
4474 | );
|
4475 | }
|
4476 | }
|
4477 | this.value = this.lazy
|
4478 | ? undefined
|
4479 | : this.get();
|
4480 | };
|
4481 |
|
4482 |
|
4483 |
|
4484 |
|
4485 | Watcher.prototype.get = function get () {
|
4486 | pushTarget(this);
|
4487 | var value;
|
4488 | var vm = this.vm;
|
4489 | try {
|
4490 | value = this.getter.call(vm, vm);
|
4491 | } catch (e) {
|
4492 | if (this.user) {
|
4493 | handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
|
4494 | } else {
|
4495 | throw e
|
4496 | }
|
4497 | } finally {
|
4498 |
|
4499 |
|
4500 | if (this.deep) {
|
4501 | traverse(value);
|
4502 | }
|
4503 | popTarget();
|
4504 | this.cleanupDeps();
|
4505 | }
|
4506 | return value
|
4507 | };
|
4508 |
|
4509 |
|
4510 |
|
4511 |
|
4512 | Watcher.prototype.addDep = function addDep (dep) {
|
4513 | var id = dep.id;
|
4514 | if (!this.newDepIds.has(id)) {
|
4515 | this.newDepIds.add(id);
|
4516 | this.newDeps.push(dep);
|
4517 | if (!this.depIds.has(id)) {
|
4518 | dep.addSub(this);
|
4519 | }
|
4520 | }
|
4521 | };
|
4522 |
|
4523 |
|
4524 |
|
4525 |
|
4526 | Watcher.prototype.cleanupDeps = function cleanupDeps () {
|
4527 | var i = this.deps.length;
|
4528 | while (i--) {
|
4529 | var dep = this.deps[i];
|
4530 | if (!this.newDepIds.has(dep.id)) {
|
4531 | dep.removeSub(this);
|
4532 | }
|
4533 | }
|
4534 | var tmp = this.depIds;
|
4535 | this.depIds = this.newDepIds;
|
4536 | this.newDepIds = tmp;
|
4537 | this.newDepIds.clear();
|
4538 | tmp = this.deps;
|
4539 | this.deps = this.newDeps;
|
4540 | this.newDeps = tmp;
|
4541 | this.newDeps.length = 0;
|
4542 | };
|
4543 |
|
4544 |
|
4545 |
|
4546 |
|
4547 |
|
4548 | Watcher.prototype.update = function update () {
|
4549 |
|
4550 | if (this.lazy) {
|
4551 | this.dirty = true;
|
4552 | } else if (this.sync) {
|
4553 | this.run();
|
4554 | } else {
|
4555 | queueWatcher(this);
|
4556 | }
|
4557 | };
|
4558 |
|
4559 |
|
4560 |
|
4561 |
|
4562 |
|
4563 | Watcher.prototype.run = function run () {
|
4564 | if (this.active) {
|
4565 | var value = this.get();
|
4566 | if (
|
4567 | value !== this.value ||
|
4568 |
|
4569 |
|
4570 |
|
4571 | isObject(value) ||
|
4572 | this.deep
|
4573 | ) {
|
4574 |
|
4575 | var oldValue = this.value;
|
4576 | this.value = value;
|
4577 | if (this.user) {
|
4578 | var info = "callback for watcher \"" + (this.expression) + "\"";
|
4579 | invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
|
4580 | } else {
|
4581 | this.cb.call(this.vm, value, oldValue);
|
4582 | }
|
4583 | }
|
4584 | }
|
4585 | };
|
4586 |
|
4587 |
|
4588 |
|
4589 |
|
4590 |
|
4591 | Watcher.prototype.evaluate = function evaluate () {
|
4592 | this.value = this.get();
|
4593 | this.dirty = false;
|
4594 | };
|
4595 |
|
4596 |
|
4597 |
|
4598 |
|
4599 | Watcher.prototype.depend = function depend () {
|
4600 | var i = this.deps.length;
|
4601 | while (i--) {
|
4602 | this.deps[i].depend();
|
4603 | }
|
4604 | };
|
4605 |
|
4606 |
|
4607 |
|
4608 |
|
4609 | Watcher.prototype.teardown = function teardown () {
|
4610 | if (this.active) {
|
4611 |
|
4612 |
|
4613 |
|
4614 | if (!this.vm._isBeingDestroyed) {
|
4615 | remove(this.vm._watchers, this);
|
4616 | }
|
4617 | var i = this.deps.length;
|
4618 | while (i--) {
|
4619 | this.deps[i].removeSub(this);
|
4620 | }
|
4621 | this.active = false;
|
4622 | }
|
4623 | };
|
4624 |
|
4625 |
|
4626 |
|
4627 | var sharedPropertyDefinition = {
|
4628 | enumerable: true,
|
4629 | configurable: true,
|
4630 | get: noop,
|
4631 | set: noop
|
4632 | };
|
4633 |
|
4634 | function proxy (target, sourceKey, key) {
|
4635 | sharedPropertyDefinition.get = function proxyGetter () {
|
4636 | return this[sourceKey][key]
|
4637 | };
|
4638 | sharedPropertyDefinition.set = function proxySetter (val) {
|
4639 | this[sourceKey][key] = val;
|
4640 | };
|
4641 | Object.defineProperty(target, key, sharedPropertyDefinition);
|
4642 | }
|
4643 |
|
4644 | function initState (vm) {
|
4645 | vm._watchers = [];
|
4646 | var opts = vm.$options;
|
4647 | if (opts.props) { initProps(vm, opts.props); }
|
4648 | if (opts.methods) { initMethods(vm, opts.methods); }
|
4649 | if (opts.data) {
|
4650 | initData(vm);
|
4651 | } else {
|
4652 | observe(vm._data = {}, true );
|
4653 | }
|
4654 | if (opts.computed) { initComputed(vm, opts.computed); }
|
4655 | if (opts.watch && opts.watch !== nativeWatch) {
|
4656 | initWatch(vm, opts.watch);
|
4657 | }
|
4658 | }
|
4659 |
|
4660 | function initProps (vm, propsOptions) {
|
4661 | var propsData = vm.$options.propsData || {};
|
4662 | var props = vm._props = {};
|
4663 |
|
4664 |
|
4665 | var keys = vm.$options._propKeys = [];
|
4666 | var isRoot = !vm.$parent;
|
4667 |
|
4668 | if (!isRoot) {
|
4669 | toggleObserving(false);
|
4670 | }
|
4671 | var loop = function ( key ) {
|
4672 | keys.push(key);
|
4673 | var value = validateProp(key, propsOptions, propsData, vm);
|
4674 |
|
4675 | {
|
4676 | var hyphenatedKey = hyphenate(key);
|
4677 | if (isReservedAttribute(hyphenatedKey) ||
|
4678 | config.isReservedAttr(hyphenatedKey)) {
|
4679 | warn(
|
4680 | ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
|
4681 | vm
|
4682 | );
|
4683 | }
|
4684 | defineReactive$$1(props, key, value, function () {
|
4685 | if (!isRoot && !isUpdatingChildComponent) {
|
4686 | warn(
|
4687 | "Avoid mutating a prop directly since the value will be " +
|
4688 | "overwritten whenever the parent component re-renders. " +
|
4689 | "Instead, use a data or computed property based on the prop's " +
|
4690 | "value. Prop being mutated: \"" + key + "\"",
|
4691 | vm
|
4692 | );
|
4693 | }
|
4694 | });
|
4695 | }
|
4696 |
|
4697 |
|
4698 |
|
4699 | if (!(key in vm)) {
|
4700 | proxy(vm, "_props", key);
|
4701 | }
|
4702 | };
|
4703 |
|
4704 | for (var key in propsOptions) loop( key );
|
4705 | toggleObserving(true);
|
4706 | }
|
4707 |
|
4708 | function initData (vm) {
|
4709 | var data = vm.$options.data;
|
4710 | data = vm._data = typeof data === 'function'
|
4711 | ? getData(data, vm)
|
4712 | : data || {};
|
4713 | if (!isPlainObject(data)) {
|
4714 | data = {};
|
4715 | warn(
|
4716 | 'data functions should return an object:\n' +
|
4717 | 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
|
4718 | vm
|
4719 | );
|
4720 | }
|
4721 |
|
4722 | var keys = Object.keys(data);
|
4723 | var props = vm.$options.props;
|
4724 | var methods = vm.$options.methods;
|
4725 | var i = keys.length;
|
4726 | while (i--) {
|
4727 | var key = keys[i];
|
4728 | {
|
4729 | if (methods && hasOwn(methods, key)) {
|
4730 | warn(
|
4731 | ("Method \"" + key + "\" has already been defined as a data property."),
|
4732 | vm
|
4733 | );
|
4734 | }
|
4735 | }
|
4736 | if (props && hasOwn(props, key)) {
|
4737 | warn(
|
4738 | "The data property \"" + key + "\" is already declared as a prop. " +
|
4739 | "Use prop default value instead.",
|
4740 | vm
|
4741 | );
|
4742 | } else if (!isReserved(key)) {
|
4743 | proxy(vm, "_data", key);
|
4744 | }
|
4745 | }
|
4746 |
|
4747 | observe(data, true );
|
4748 | }
|
4749 |
|
4750 | function getData (data, vm) {
|
4751 |
|
4752 | pushTarget();
|
4753 | try {
|
4754 | return data.call(vm, vm)
|
4755 | } catch (e) {
|
4756 | handleError(e, vm, "data()");
|
4757 | return {}
|
4758 | } finally {
|
4759 | popTarget();
|
4760 | }
|
4761 | }
|
4762 |
|
4763 | var computedWatcherOptions = { lazy: true };
|
4764 |
|
4765 | function initComputed (vm, computed) {
|
4766 |
|
4767 | var watchers = vm._computedWatchers = Object.create(null);
|
4768 |
|
4769 | var isSSR = isServerRendering();
|
4770 |
|
4771 | for (var key in computed) {
|
4772 | var userDef = computed[key];
|
4773 | var getter = typeof userDef === 'function' ? userDef : userDef.get;
|
4774 | if (getter == null) {
|
4775 | warn(
|
4776 | ("Getter is missing for computed property \"" + key + "\"."),
|
4777 | vm
|
4778 | );
|
4779 | }
|
4780 |
|
4781 | if (!isSSR) {
|
4782 |
|
4783 | watchers[key] = new Watcher(
|
4784 | vm,
|
4785 | getter || noop,
|
4786 | noop,
|
4787 | computedWatcherOptions
|
4788 | );
|
4789 | }
|
4790 |
|
4791 |
|
4792 |
|
4793 |
|
4794 | if (!(key in vm)) {
|
4795 | defineComputed(vm, key, userDef);
|
4796 | } else {
|
4797 | if (key in vm.$data) {
|
4798 | warn(("The computed property \"" + key + "\" is already defined in data."), vm);
|
4799 | } else if (vm.$options.props && key in vm.$options.props) {
|
4800 | warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
|
4801 | } else if (vm.$options.methods && key in vm.$options.methods) {
|
4802 | warn(("The computed property \"" + key + "\" is already defined as a method."), vm);
|
4803 | }
|
4804 | }
|
4805 | }
|
4806 | }
|
4807 |
|
4808 | function defineComputed (
|
4809 | target,
|
4810 | key,
|
4811 | userDef
|
4812 | ) {
|
4813 | var shouldCache = !isServerRendering();
|
4814 | if (typeof userDef === 'function') {
|
4815 | sharedPropertyDefinition.get = shouldCache
|
4816 | ? createComputedGetter(key)
|
4817 | : createGetterInvoker(userDef);
|
4818 | sharedPropertyDefinition.set = noop;
|
4819 | } else {
|
4820 | sharedPropertyDefinition.get = userDef.get
|
4821 | ? shouldCache && userDef.cache !== false
|
4822 | ? createComputedGetter(key)
|
4823 | : createGetterInvoker(userDef.get)
|
4824 | : noop;
|
4825 | sharedPropertyDefinition.set = userDef.set || noop;
|
4826 | }
|
4827 | if (sharedPropertyDefinition.set === noop) {
|
4828 | sharedPropertyDefinition.set = function () {
|
4829 | warn(
|
4830 | ("Computed property \"" + key + "\" was assigned to but it has no setter."),
|
4831 | this
|
4832 | );
|
4833 | };
|
4834 | }
|
4835 | Object.defineProperty(target, key, sharedPropertyDefinition);
|
4836 | }
|
4837 |
|
4838 | function createComputedGetter (key) {
|
4839 | return function computedGetter () {
|
4840 | var watcher = this._computedWatchers && this._computedWatchers[key];
|
4841 | if (watcher) {
|
4842 | if (watcher.dirty) {
|
4843 | watcher.evaluate();
|
4844 | }
|
4845 | if (Dep.target) {
|
4846 | watcher.depend();
|
4847 | }
|
4848 | return watcher.value
|
4849 | }
|
4850 | }
|
4851 | }
|
4852 |
|
4853 | function createGetterInvoker(fn) {
|
4854 | return function computedGetter () {
|
4855 | return fn.call(this, this)
|
4856 | }
|
4857 | }
|
4858 |
|
4859 | function initMethods (vm, methods) {
|
4860 | var props = vm.$options.props;
|
4861 | for (var key in methods) {
|
4862 | {
|
4863 | if (typeof methods[key] !== 'function') {
|
4864 | warn(
|
4865 | "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
|
4866 | "Did you reference the function correctly?",
|
4867 | vm
|
4868 | );
|
4869 | }
|
4870 | if (props && hasOwn(props, key)) {
|
4871 | warn(
|
4872 | ("Method \"" + key + "\" has already been defined as a prop."),
|
4873 | vm
|
4874 | );
|
4875 | }
|
4876 | if ((key in vm) && isReserved(key)) {
|
4877 | warn(
|
4878 | "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
|
4879 | "Avoid defining component methods that start with _ or $."
|
4880 | );
|
4881 | }
|
4882 | }
|
4883 | vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
|
4884 | }
|
4885 | }
|
4886 |
|
4887 | function initWatch (vm, watch) {
|
4888 | for (var key in watch) {
|
4889 | var handler = watch[key];
|
4890 | if (Array.isArray(handler)) {
|
4891 | for (var i = 0; i < handler.length; i++) {
|
4892 | createWatcher(vm, key, handler[i]);
|
4893 | }
|
4894 | } else {
|
4895 | createWatcher(vm, key, handler);
|
4896 | }
|
4897 | }
|
4898 | }
|
4899 |
|
4900 | function createWatcher (
|
4901 | vm,
|
4902 | expOrFn,
|
4903 | handler,
|
4904 | options
|
4905 | ) {
|
4906 | if (isPlainObject(handler)) {
|
4907 | options = handler;
|
4908 | handler = handler.handler;
|
4909 | }
|
4910 | if (typeof handler === 'string') {
|
4911 | handler = vm[handler];
|
4912 | }
|
4913 | return vm.$watch(expOrFn, handler, options)
|
4914 | }
|
4915 |
|
4916 | function stateMixin (Vue) {
|
4917 |
|
4918 |
|
4919 |
|
4920 | var dataDef = {};
|
4921 | dataDef.get = function () { return this._data };
|
4922 | var propsDef = {};
|
4923 | propsDef.get = function () { return this._props };
|
4924 | {
|
4925 | dataDef.set = function () {
|
4926 | warn(
|
4927 | 'Avoid replacing instance root $data. ' +
|
4928 | 'Use nested data properties instead.',
|
4929 | this
|
4930 | );
|
4931 | };
|
4932 | propsDef.set = function () {
|
4933 | warn("$props is readonly.", this);
|
4934 | };
|
4935 | }
|
4936 | Object.defineProperty(Vue.prototype, '$data', dataDef);
|
4937 | Object.defineProperty(Vue.prototype, '$props', propsDef);
|
4938 |
|
4939 | Vue.prototype.$set = set;
|
4940 | Vue.prototype.$delete = del;
|
4941 |
|
4942 | Vue.prototype.$watch = function (
|
4943 | expOrFn,
|
4944 | cb,
|
4945 | options
|
4946 | ) {
|
4947 | var vm = this;
|
4948 | if (isPlainObject(cb)) {
|
4949 | return createWatcher(vm, expOrFn, cb, options)
|
4950 | }
|
4951 | options = options || {};
|
4952 | options.user = true;
|
4953 | var watcher = new Watcher(vm, expOrFn, cb, options);
|
4954 | if (options.immediate) {
|
4955 | var info = "callback for immediate watcher \"" + (watcher.expression) + "\"";
|
4956 | pushTarget();
|
4957 | invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
|
4958 | popTarget();
|
4959 | }
|
4960 | return function unwatchFn () {
|
4961 | watcher.teardown();
|
4962 | }
|
4963 | };
|
4964 | }
|
4965 |
|
4966 |
|
4967 |
|
4968 | var uid$3 = 0;
|
4969 |
|
4970 | function initMixin (Vue) {
|
4971 | Vue.prototype._init = function (options) {
|
4972 | var vm = this;
|
4973 |
|
4974 | vm._uid = uid$3++;
|
4975 |
|
4976 | var startTag, endTag;
|
4977 |
|
4978 | if (config.performance && mark) {
|
4979 | startTag = "vue-perf-start:" + (vm._uid);
|
4980 | endTag = "vue-perf-end:" + (vm._uid);
|
4981 | mark(startTag);
|
4982 | }
|
4983 |
|
4984 |
|
4985 | vm._isVue = true;
|
4986 |
|
4987 | if (options && options._isComponent) {
|
4988 |
|
4989 |
|
4990 |
|
4991 | initInternalComponent(vm, options);
|
4992 | } else {
|
4993 | vm.$options = mergeOptions(
|
4994 | resolveConstructorOptions(vm.constructor),
|
4995 | options || {},
|
4996 | vm
|
4997 | );
|
4998 | }
|
4999 |
|
5000 | {
|
5001 | initProxy(vm);
|
5002 | }
|
5003 |
|
5004 | vm._self = vm;
|
5005 | initLifecycle(vm);
|
5006 | initEvents(vm);
|
5007 | initRender(vm);
|
5008 | callHook(vm, 'beforeCreate');
|
5009 | initInjections(vm);
|
5010 | initState(vm);
|
5011 | initProvide(vm);
|
5012 | callHook(vm, 'created');
|
5013 |
|
5014 |
|
5015 | if (config.performance && mark) {
|
5016 | vm._name = formatComponentName(vm, false);
|
5017 | mark(endTag);
|
5018 | measure(("vue " + (vm._name) + " init"), startTag, endTag);
|
5019 | }
|
5020 |
|
5021 | if (vm.$options.el) {
|
5022 | vm.$mount(vm.$options.el);
|
5023 | }
|
5024 | };
|
5025 | }
|
5026 |
|
5027 | function initInternalComponent (vm, options) {
|
5028 | var opts = vm.$options = Object.create(vm.constructor.options);
|
5029 |
|
5030 | var parentVnode = options._parentVnode;
|
5031 | opts.parent = options.parent;
|
5032 | opts._parentVnode = parentVnode;
|
5033 |
|
5034 | var vnodeComponentOptions = parentVnode.componentOptions;
|
5035 | opts.propsData = vnodeComponentOptions.propsData;
|
5036 | opts._parentListeners = vnodeComponentOptions.listeners;
|
5037 | opts._renderChildren = vnodeComponentOptions.children;
|
5038 | opts._componentTag = vnodeComponentOptions.tag;
|
5039 |
|
5040 | if (options.render) {
|
5041 | opts.render = options.render;
|
5042 | opts.staticRenderFns = options.staticRenderFns;
|
5043 | }
|
5044 | }
|
5045 |
|
5046 | function resolveConstructorOptions (Ctor) {
|
5047 | var options = Ctor.options;
|
5048 | if (Ctor.super) {
|
5049 | var superOptions = resolveConstructorOptions(Ctor.super);
|
5050 | var cachedSuperOptions = Ctor.superOptions;
|
5051 | if (superOptions !== cachedSuperOptions) {
|
5052 |
|
5053 |
|
5054 | Ctor.superOptions = superOptions;
|
5055 |
|
5056 | var modifiedOptions = resolveModifiedOptions(Ctor);
|
5057 |
|
5058 | if (modifiedOptions) {
|
5059 | extend(Ctor.extendOptions, modifiedOptions);
|
5060 | }
|
5061 | options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
|
5062 | if (options.name) {
|
5063 | options.components[options.name] = Ctor;
|
5064 | }
|
5065 | }
|
5066 | }
|
5067 | return options
|
5068 | }
|
5069 |
|
5070 | function resolveModifiedOptions (Ctor) {
|
5071 | var modified;
|
5072 | var latest = Ctor.options;
|
5073 | var sealed = Ctor.sealedOptions;
|
5074 | for (var key in latest) {
|
5075 | if (latest[key] !== sealed[key]) {
|
5076 | if (!modified) { modified = {}; }
|
5077 | modified[key] = latest[key];
|
5078 | }
|
5079 | }
|
5080 | return modified
|
5081 | }
|
5082 |
|
5083 | function Vue (options) {
|
5084 | if (!(this instanceof Vue)
|
5085 | ) {
|
5086 | warn('Vue is a constructor and should be called with the `new` keyword');
|
5087 | }
|
5088 | this._init(options);
|
5089 | }
|
5090 |
|
5091 | initMixin(Vue);
|
5092 | stateMixin(Vue);
|
5093 | eventsMixin(Vue);
|
5094 | lifecycleMixin(Vue);
|
5095 | renderMixin(Vue);
|
5096 |
|
5097 |
|
5098 |
|
5099 | function initUse (Vue) {
|
5100 | Vue.use = function (plugin) {
|
5101 | var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
|
5102 | if (installedPlugins.indexOf(plugin) > -1) {
|
5103 | return this
|
5104 | }
|
5105 |
|
5106 |
|
5107 | var args = toArray(arguments, 1);
|
5108 | args.unshift(this);
|
5109 | if (typeof plugin.install === 'function') {
|
5110 | plugin.install.apply(plugin, args);
|
5111 | } else if (typeof plugin === 'function') {
|
5112 | plugin.apply(null, args);
|
5113 | }
|
5114 | installedPlugins.push(plugin);
|
5115 | return this
|
5116 | };
|
5117 | }
|
5118 |
|
5119 |
|
5120 |
|
5121 | function initMixin$1 (Vue) {
|
5122 | Vue.mixin = function (mixin) {
|
5123 | this.options = mergeOptions(this.options, mixin);
|
5124 | return this
|
5125 | };
|
5126 | }
|
5127 |
|
5128 |
|
5129 |
|
5130 | function initExtend (Vue) {
|
5131 | |
5132 |
|
5133 |
|
5134 |
|
5135 |
|
5136 | Vue.cid = 0;
|
5137 | var cid = 1;
|
5138 |
|
5139 | |
5140 |
|
5141 |
|
5142 | Vue.extend = function (extendOptions) {
|
5143 | extendOptions = extendOptions || {};
|
5144 | var Super = this;
|
5145 | var SuperId = Super.cid;
|
5146 | var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
|
5147 | if (cachedCtors[SuperId]) {
|
5148 | return cachedCtors[SuperId]
|
5149 | }
|
5150 |
|
5151 | var name = extendOptions.name || Super.options.name;
|
5152 | if (name) {
|
5153 | validateComponentName(name);
|
5154 | }
|
5155 |
|
5156 | var Sub = function VueComponent (options) {
|
5157 | this._init(options);
|
5158 | };
|
5159 | Sub.prototype = Object.create(Super.prototype);
|
5160 | Sub.prototype.constructor = Sub;
|
5161 | Sub.cid = cid++;
|
5162 | Sub.options = mergeOptions(
|
5163 | Super.options,
|
5164 | extendOptions
|
5165 | );
|
5166 | Sub['super'] = Super;
|
5167 |
|
5168 |
|
5169 |
|
5170 |
|
5171 | if (Sub.options.props) {
|
5172 | initProps$1(Sub);
|
5173 | }
|
5174 | if (Sub.options.computed) {
|
5175 | initComputed$1(Sub);
|
5176 | }
|
5177 |
|
5178 |
|
5179 | Sub.extend = Super.extend;
|
5180 | Sub.mixin = Super.mixin;
|
5181 | Sub.use = Super.use;
|
5182 |
|
5183 |
|
5184 |
|
5185 | ASSET_TYPES.forEach(function (type) {
|
5186 | Sub[type] = Super[type];
|
5187 | });
|
5188 |
|
5189 | if (name) {
|
5190 | Sub.options.components[name] = Sub;
|
5191 | }
|
5192 |
|
5193 |
|
5194 |
|
5195 |
|
5196 | Sub.superOptions = Super.options;
|
5197 | Sub.extendOptions = extendOptions;
|
5198 | Sub.sealedOptions = extend({}, Sub.options);
|
5199 |
|
5200 |
|
5201 | cachedCtors[SuperId] = Sub;
|
5202 | return Sub
|
5203 | };
|
5204 | }
|
5205 |
|
5206 | function initProps$1 (Comp) {
|
5207 | var props = Comp.options.props;
|
5208 | for (var key in props) {
|
5209 | proxy(Comp.prototype, "_props", key);
|
5210 | }
|
5211 | }
|
5212 |
|
5213 | function initComputed$1 (Comp) {
|
5214 | var computed = Comp.options.computed;
|
5215 | for (var key in computed) {
|
5216 | defineComputed(Comp.prototype, key, computed[key]);
|
5217 | }
|
5218 | }
|
5219 |
|
5220 |
|
5221 |
|
5222 | function initAssetRegisters (Vue) {
|
5223 | |
5224 |
|
5225 |
|
5226 | ASSET_TYPES.forEach(function (type) {
|
5227 | Vue[type] = function (
|
5228 | id,
|
5229 | definition
|
5230 | ) {
|
5231 | if (!definition) {
|
5232 | return this.options[type + 's'][id]
|
5233 | } else {
|
5234 |
|
5235 | if (type === 'component') {
|
5236 | validateComponentName(id);
|
5237 | }
|
5238 | if (type === 'component' && isPlainObject(definition)) {
|
5239 | definition.name = definition.name || id;
|
5240 | definition = this.options._base.extend(definition);
|
5241 | }
|
5242 | if (type === 'directive' && typeof definition === 'function') {
|
5243 | definition = { bind: definition, update: definition };
|
5244 | }
|
5245 | this.options[type + 's'][id] = definition;
|
5246 | return definition
|
5247 | }
|
5248 | };
|
5249 | });
|
5250 | }
|
5251 |
|
5252 |
|
5253 |
|
5254 |
|
5255 |
|
5256 |
|
5257 |
|
5258 | function getComponentName (opts) {
|
5259 | return opts && (opts.Ctor.options.name || opts.tag)
|
5260 | }
|
5261 |
|
5262 | function matches (pattern, name) {
|
5263 | if (Array.isArray(pattern)) {
|
5264 | return pattern.indexOf(name) > -1
|
5265 | } else if (typeof pattern === 'string') {
|
5266 | return pattern.split(',').indexOf(name) > -1
|
5267 | } else if (isRegExp(pattern)) {
|
5268 | return pattern.test(name)
|
5269 | }
|
5270 |
|
5271 | return false
|
5272 | }
|
5273 |
|
5274 | function pruneCache (keepAliveInstance, filter) {
|
5275 | var cache = keepAliveInstance.cache;
|
5276 | var keys = keepAliveInstance.keys;
|
5277 | var _vnode = keepAliveInstance._vnode;
|
5278 | for (var key in cache) {
|
5279 | var entry = cache[key];
|
5280 | if (entry) {
|
5281 | var name = entry.name;
|
5282 | if (name && !filter(name)) {
|
5283 | pruneCacheEntry(cache, key, keys, _vnode);
|
5284 | }
|
5285 | }
|
5286 | }
|
5287 | }
|
5288 |
|
5289 | function pruneCacheEntry (
|
5290 | cache,
|
5291 | key,
|
5292 | keys,
|
5293 | current
|
5294 | ) {
|
5295 | var entry = cache[key];
|
5296 | if (entry && (!current || entry.tag !== current.tag)) {
|
5297 | entry.componentInstance.$destroy();
|
5298 | }
|
5299 | cache[key] = null;
|
5300 | remove(keys, key);
|
5301 | }
|
5302 |
|
5303 | var patternTypes = [String, RegExp, Array];
|
5304 |
|
5305 | var KeepAlive = {
|
5306 | name: 'keep-alive',
|
5307 | abstract: true,
|
5308 |
|
5309 | props: {
|
5310 | include: patternTypes,
|
5311 | exclude: patternTypes,
|
5312 | max: [String, Number]
|
5313 | },
|
5314 |
|
5315 | methods: {
|
5316 | cacheVNode: function cacheVNode() {
|
5317 | var ref = this;
|
5318 | var cache = ref.cache;
|
5319 | var keys = ref.keys;
|
5320 | var vnodeToCache = ref.vnodeToCache;
|
5321 | var keyToCache = ref.keyToCache;
|
5322 | if (vnodeToCache) {
|
5323 | var tag = vnodeToCache.tag;
|
5324 | var componentInstance = vnodeToCache.componentInstance;
|
5325 | var componentOptions = vnodeToCache.componentOptions;
|
5326 | cache[keyToCache] = {
|
5327 | name: getComponentName(componentOptions),
|
5328 | tag: tag,
|
5329 | componentInstance: componentInstance,
|
5330 | };
|
5331 | keys.push(keyToCache);
|
5332 |
|
5333 | if (this.max && keys.length > parseInt(this.max)) {
|
5334 | pruneCacheEntry(cache, keys[0], keys, this._vnode);
|
5335 | }
|
5336 | this.vnodeToCache = null;
|
5337 | }
|
5338 | }
|
5339 | },
|
5340 |
|
5341 | created: function created () {
|
5342 | this.cache = Object.create(null);
|
5343 | this.keys = [];
|
5344 | },
|
5345 |
|
5346 | destroyed: function destroyed () {
|
5347 | for (var key in this.cache) {
|
5348 | pruneCacheEntry(this.cache, key, this.keys);
|
5349 | }
|
5350 | },
|
5351 |
|
5352 | mounted: function mounted () {
|
5353 | var this$1 = this;
|
5354 |
|
5355 | this.cacheVNode();
|
5356 | this.$watch('include', function (val) {
|
5357 | pruneCache(this$1, function (name) { return matches(val, name); });
|
5358 | });
|
5359 | this.$watch('exclude', function (val) {
|
5360 | pruneCache(this$1, function (name) { return !matches(val, name); });
|
5361 | });
|
5362 | },
|
5363 |
|
5364 | updated: function updated () {
|
5365 | this.cacheVNode();
|
5366 | },
|
5367 |
|
5368 | render: function render () {
|
5369 | var slot = this.$slots.default;
|
5370 | var vnode = getFirstComponentChild(slot);
|
5371 | var componentOptions = vnode && vnode.componentOptions;
|
5372 | if (componentOptions) {
|
5373 |
|
5374 | var name = getComponentName(componentOptions);
|
5375 | var ref = this;
|
5376 | var include = ref.include;
|
5377 | var exclude = ref.exclude;
|
5378 | if (
|
5379 |
|
5380 | (include && (!name || !matches(include, name))) ||
|
5381 |
|
5382 | (exclude && name && matches(exclude, name))
|
5383 | ) {
|
5384 | return vnode
|
5385 | }
|
5386 |
|
5387 | var ref$1 = this;
|
5388 | var cache = ref$1.cache;
|
5389 | var keys = ref$1.keys;
|
5390 | var key = vnode.key == null
|
5391 |
|
5392 |
|
5393 | ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
|
5394 | : vnode.key;
|
5395 | if (cache[key]) {
|
5396 | vnode.componentInstance = cache[key].componentInstance;
|
5397 |
|
5398 | remove(keys, key);
|
5399 | keys.push(key);
|
5400 | } else {
|
5401 |
|
5402 | this.vnodeToCache = vnode;
|
5403 | this.keyToCache = key;
|
5404 | }
|
5405 |
|
5406 | vnode.data.keepAlive = true;
|
5407 | }
|
5408 | return vnode || (slot && slot[0])
|
5409 | }
|
5410 | };
|
5411 |
|
5412 | var builtInComponents = {
|
5413 | KeepAlive: KeepAlive
|
5414 | };
|
5415 |
|
5416 |
|
5417 |
|
5418 | function initGlobalAPI (Vue) {
|
5419 |
|
5420 | var configDef = {};
|
5421 | configDef.get = function () { return config; };
|
5422 | {
|
5423 | configDef.set = function () {
|
5424 | warn(
|
5425 | 'Do not replace the Vue.config object, set individual fields instead.'
|
5426 | );
|
5427 | };
|
5428 | }
|
5429 | Object.defineProperty(Vue, 'config', configDef);
|
5430 |
|
5431 |
|
5432 |
|
5433 |
|
5434 | Vue.util = {
|
5435 | warn: warn,
|
5436 | extend: extend,
|
5437 | mergeOptions: mergeOptions,
|
5438 | defineReactive: defineReactive$$1
|
5439 | };
|
5440 |
|
5441 | Vue.set = set;
|
5442 | Vue.delete = del;
|
5443 | Vue.nextTick = nextTick;
|
5444 |
|
5445 | // 2.6 explicit observable API
|
5446 | Vue.observable = function (obj) {
|
5447 | observe(obj);
|
5448 | return obj
|
5449 | };
|
5450 |
|
5451 | Vue.options = Object.create(null);
|
5452 | ASSET_TYPES.forEach(function (type) {
|
5453 | Vue.options[type + 's'] = Object.create(null);
|
5454 | });
|
5455 |
|
5456 |
|
5457 |
|
5458 | Vue.options._base = Vue;
|
5459 |
|
5460 | extend(Vue.options.components, builtInComponents);
|
5461 |
|
5462 | initUse(Vue);
|
5463 | initMixin$1(Vue);
|
5464 | initExtend(Vue);
|
5465 | initAssetRegisters(Vue);
|
5466 | }
|
5467 |
|
5468 | initGlobalAPI(Vue);
|
5469 |
|
5470 | Object.defineProperty(Vue.prototype, '$isServer', {
|
5471 | get: isServerRendering
|
5472 | });
|
5473 |
|
5474 | Object.defineProperty(Vue.prototype, '$ssrContext', {
|
5475 | get: function get () {
|
5476 |
|
5477 | return this.$vnode && this.$vnode.ssrContext
|
5478 | }
|
5479 | });
|
5480 |
|
5481 |
|
5482 | Object.defineProperty(Vue, 'FunctionalRenderContext', {
|
5483 | value: FunctionalRenderContext
|
5484 | });
|
5485 |
|
5486 | Vue.version = '2.6.14';
|
5487 |
|
5488 |
|
5489 |
|
5490 |
|
5491 |
|
5492 | var isReservedAttr = makeMap('style,class');
|
5493 |
|
5494 |
|
5495 | var acceptValue = makeMap('input,textarea,option,select,progress');
|
5496 | var mustUseProp = function (tag, type, attr) {
|
5497 | return (
|
5498 | (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
|
5499 | (attr === 'selected' && tag === 'option') ||
|
5500 | (attr === 'checked' && tag === 'input') ||
|
5501 | (attr === 'muted' && tag === 'video')
|
5502 | )
|
5503 | };
|
5504 |
|
5505 | var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
|
5506 |
|
5507 | var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
|
5508 |
|
5509 | var convertEnumeratedValue = function (key, value) {
|
5510 | return isFalsyAttrValue(value) || value === 'false'
|
5511 | ? 'false'
|
5512 |
|
5513 | : key === 'contenteditable' && isValidContentEditableValue(value)
|
5514 | ? value
|
5515 | : 'true'
|
5516 | };
|
5517 |
|
5518 | var isBooleanAttr = makeMap(
|
5519 | 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
|
5520 | 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
|
5521 | 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
|
5522 | 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
|
5523 | 'required,reversed,scoped,seamless,selected,sortable,' +
|
5524 | 'truespeed,typemustmatch,visible'
|
5525 | );
|
5526 |
|
5527 | var xlinkNS = 'http://www.w3.org/1999/xlink';
|
5528 |
|
5529 | var isXlink = function (name) {
|
5530 | return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
|
5531 | };
|
5532 |
|
5533 | var getXlinkProp = function (name) {
|
5534 | return isXlink(name) ? name.slice(6, name.length) : ''
|
5535 | };
|
5536 |
|
5537 | var isFalsyAttrValue = function (val) {
|
5538 | return val == null || val === false
|
5539 | };
|
5540 |
|
5541 |
|
5542 |
|
5543 | function genClassForVnode (vnode) {
|
5544 | var data = vnode.data;
|
5545 | var parentNode = vnode;
|
5546 | var childNode = vnode;
|
5547 | while (isDef(childNode.componentInstance)) {
|
5548 | childNode = childNode.componentInstance._vnode;
|
5549 | if (childNode && childNode.data) {
|
5550 | data = mergeClassData(childNode.data, data);
|
5551 | }
|
5552 | }
|
5553 | while (isDef(parentNode = parentNode.parent)) {
|
5554 | if (parentNode && parentNode.data) {
|
5555 | data = mergeClassData(data, parentNode.data);
|
5556 | }
|
5557 | }
|
5558 | return renderClass(data.staticClass, data.class)
|
5559 | }
|
5560 |
|
5561 | function mergeClassData (child, parent) {
|
5562 | return {
|
5563 | staticClass: concat(child.staticClass, parent.staticClass),
|
5564 | class: isDef(child.class)
|
5565 | ? [child.class, parent.class]
|
5566 | : parent.class
|
5567 | }
|
5568 | }
|
5569 |
|
5570 | function renderClass (
|
5571 | staticClass,
|
5572 | dynamicClass
|
5573 | ) {
|
5574 | if (isDef(staticClass) || isDef(dynamicClass)) {
|
5575 | return concat(staticClass, stringifyClass(dynamicClass))
|
5576 | }
|
5577 |
|
5578 | return ''
|
5579 | }
|
5580 |
|
5581 | function concat (a, b) {
|
5582 | return a ? b ? (a + ' ' + b) : a : (b || '')
|
5583 | }
|
5584 |
|
5585 | function stringifyClass (value) {
|
5586 | if (Array.isArray(value)) {
|
5587 | return stringifyArray(value)
|
5588 | }
|
5589 | if (isObject(value)) {
|
5590 | return stringifyObject(value)
|
5591 | }
|
5592 | if (typeof value === 'string') {
|
5593 | return value
|
5594 | }
|
5595 |
|
5596 | return ''
|
5597 | }
|
5598 |
|
5599 | function stringifyArray (value) {
|
5600 | var res = '';
|
5601 | var stringified;
|
5602 | for (var i = 0, l = value.length; i < l; i++) {
|
5603 | if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
|
5604 | if (res) { res += ' '; }
|
5605 | res += stringified;
|
5606 | }
|
5607 | }
|
5608 | return res
|
5609 | }
|
5610 |
|
5611 | function stringifyObject (value) {
|
5612 | var res = '';
|
5613 | for (var key in value) {
|
5614 | if (value[key]) {
|
5615 | if (res) { res += ' '; }
|
5616 | res += key;
|
5617 | }
|
5618 | }
|
5619 | return res
|
5620 | }
|
5621 |
|
5622 |
|
5623 |
|
5624 | var namespaceMap = {
|
5625 | svg: 'http://www.w3.org/2000/svg',
|
5626 | math: 'http://www.w3.org/1998/Math/MathML'
|
5627 | };
|
5628 |
|
5629 | var isHTMLTag = makeMap(
|
5630 | 'html,body,base,head,link,meta,style,title,' +
|
5631 | 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
|
5632 | 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
|
5633 | 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
|
5634 | 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
|
5635 | 'embed,object,param,source,canvas,script,noscript,del,ins,' +
|
5636 | 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
|
5637 | 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
|
5638 | 'output,progress,select,textarea,' +
|
5639 | 'details,dialog,menu,menuitem,summary,' +
|
5640 | 'content,element,shadow,template,blockquote,iframe,tfoot'
|
5641 | );
|
5642 |
|
5643 |
|
5644 |
|
5645 | var isSVG = makeMap(
|
5646 | 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
|
5647 | 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
|
5648 | 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
|
5649 | true
|
5650 | );
|
5651 |
|
5652 | var isPreTag = function (tag) { return tag === 'pre'; };
|
5653 |
|
5654 | var isReservedTag = function (tag) {
|
5655 | return isHTMLTag(tag) || isSVG(tag)
|
5656 | };
|
5657 |
|
5658 | function getTagNamespace (tag) {
|
5659 | if (isSVG(tag)) {
|
5660 | return 'svg'
|
5661 | }
|
5662 |
|
5663 |
|
5664 | if (tag === 'math') {
|
5665 | return 'math'
|
5666 | }
|
5667 | }
|
5668 |
|
5669 | var unknownElementCache = Object.create(null);
|
5670 | function isUnknownElement (tag) {
|
5671 |
|
5672 | if (!inBrowser) {
|
5673 | return true
|
5674 | }
|
5675 | if (isReservedTag(tag)) {
|
5676 | return false
|
5677 | }
|
5678 | tag = tag.toLowerCase();
|
5679 |
|
5680 | if (unknownElementCache[tag] != null) {
|
5681 | return unknownElementCache[tag]
|
5682 | }
|
5683 | var el = document.createElement(tag);
|
5684 | if (tag.indexOf('-') > -1) {
|
5685 |
|
5686 | return (unknownElementCache[tag] = (
|
5687 | el.constructor === window.HTMLUnknownElement ||
|
5688 | el.constructor === window.HTMLElement
|
5689 | ))
|
5690 | } else {
|
5691 | return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
|
5692 | }
|
5693 | }
|
5694 |
|
5695 | var isTextInputType = makeMap('text,number,password,search,email,tel,url');
|
5696 |
|
5697 |
|
5698 |
|
5699 |
|
5700 |
|
5701 |
|
5702 | function query (el) {
|
5703 | if (typeof el === 'string') {
|
5704 | var selected = document.querySelector(el);
|
5705 | if (!selected) {
|
5706 | warn(
|
5707 | 'Cannot find element: ' + el
|
5708 | );
|
5709 | return document.createElement('div')
|
5710 | }
|
5711 | return selected
|
5712 | } else {
|
5713 | return el
|
5714 | }
|
5715 | }
|
5716 |
|
5717 |
|
5718 |
|
5719 | function createElement$1 (tagName, vnode) {
|
5720 | var elm = document.createElement(tagName);
|
5721 | if (tagName !== 'select') {
|
5722 | return elm
|
5723 | }
|
5724 |
|
5725 | if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
|
5726 | elm.setAttribute('multiple', 'multiple');
|
5727 | }
|
5728 | return elm
|
5729 | }
|
5730 |
|
5731 | function createElementNS (namespace, tagName) {
|
5732 | return document.createElementNS(namespaceMap[namespace], tagName)
|
5733 | }
|
5734 |
|
5735 | function createTextNode (text) {
|
5736 | return document.createTextNode(text)
|
5737 | }
|
5738 |
|
5739 | function createComment (text) {
|
5740 | return document.createComment(text)
|
5741 | }
|
5742 |
|
5743 | function insertBefore (parentNode, newNode, referenceNode) {
|
5744 | parentNode.insertBefore(newNode, referenceNode);
|
5745 | }
|
5746 |
|
5747 | function removeChild (node, child) {
|
5748 | node.removeChild(child);
|
5749 | }
|
5750 |
|
5751 | function appendChild (node, child) {
|
5752 | node.appendChild(child);
|
5753 | }
|
5754 |
|
5755 | function parentNode (node) {
|
5756 | return node.parentNode
|
5757 | }
|
5758 |
|
5759 | function nextSibling (node) {
|
5760 | return node.nextSibling
|
5761 | }
|
5762 |
|
5763 | function tagName (node) {
|
5764 | return node.tagName
|
5765 | }
|
5766 |
|
5767 | function setTextContent (node, text) {
|
5768 | node.textContent = text;
|
5769 | }
|
5770 |
|
5771 | function setStyleScope (node, scopeId) {
|
5772 | node.setAttribute(scopeId, '');
|
5773 | }
|
5774 |
|
5775 | var nodeOps = Object.freeze({
|
5776 | createElement: createElement$1,
|
5777 | createElementNS: createElementNS,
|
5778 | createTextNode: createTextNode,
|
5779 | createComment: createComment,
|
5780 | insertBefore: insertBefore,
|
5781 | removeChild: removeChild,
|
5782 | appendChild: appendChild,
|
5783 | parentNode: parentNode,
|
5784 | nextSibling: nextSibling,
|
5785 | tagName: tagName,
|
5786 | setTextContent: setTextContent,
|
5787 | setStyleScope: setStyleScope
|
5788 | });
|
5789 |
|
5790 |
|
5791 |
|
5792 | var ref = {
|
5793 | create: function create (_, vnode) {
|
5794 | registerRef(vnode);
|
5795 | },
|
5796 | update: function update (oldVnode, vnode) {
|
5797 | if (oldVnode.data.ref !== vnode.data.ref) {
|
5798 | registerRef(oldVnode, true);
|
5799 | registerRef(vnode);
|
5800 | }
|
5801 | },
|
5802 | destroy: function destroy (vnode) {
|
5803 | registerRef(vnode, true);
|
5804 | }
|
5805 | };
|
5806 |
|
5807 | function registerRef (vnode, isRemoval) {
|
5808 | var key = vnode.data.ref;
|
5809 | if (!isDef(key)) { return }
|
5810 |
|
5811 | var vm = vnode.context;
|
5812 | var ref = vnode.componentInstance || vnode.elm;
|
5813 | var refs = vm.$refs;
|
5814 | if (isRemoval) {
|
5815 | if (Array.isArray(refs[key])) {
|
5816 | remove(refs[key], ref);
|
5817 | } else if (refs[key] === ref) {
|
5818 | refs[key] = undefined;
|
5819 | }
|
5820 | } else {
|
5821 | if (vnode.data.refInFor) {
|
5822 | if (!Array.isArray(refs[key])) {
|
5823 | refs[key] = [ref];
|
5824 | } else if (refs[key].indexOf(ref) < 0) {
|
5825 |
|
5826 | refs[key].push(ref);
|
5827 | }
|
5828 | } else {
|
5829 | refs[key] = ref;
|
5830 | }
|
5831 | }
|
5832 | }
|
5833 |
|
5834 |
|
5835 |
|
5836 |
|
5837 |
|
5838 |
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 | var emptyNode = new VNode('', {}, []);
|
5847 |
|
5848 | var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
|
5849 |
|
5850 | function sameVnode (a, b) {
|
5851 | return (
|
5852 | a.key === b.key &&
|
5853 | a.asyncFactory === b.asyncFactory && (
|
5854 | (
|
5855 | a.tag === b.tag &&
|
5856 | a.isComment === b.isComment &&
|
5857 | isDef(a.data) === isDef(b.data) &&
|
5858 | sameInputType(a, b)
|
5859 | ) || (
|
5860 | isTrue(a.isAsyncPlaceholder) &&
|
5861 | isUndef(b.asyncFactory.error)
|
5862 | )
|
5863 | )
|
5864 | )
|
5865 | }
|
5866 |
|
5867 | function sameInputType (a, b) {
|
5868 | if (a.tag !== 'input') { return true }
|
5869 | var i;
|
5870 | var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
|
5871 | var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
|
5872 | return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
|
5873 | }
|
5874 |
|
5875 | function createKeyToOldIdx (children, beginIdx, endIdx) {
|
5876 | var i, key;
|
5877 | var map = {};
|
5878 | for (i = beginIdx; i <= endIdx; ++i) {
|
5879 | key = children[i].key;
|
5880 | if (isDef(key)) { map[key] = i; }
|
5881 | }
|
5882 | return map
|
5883 | }
|
5884 |
|
5885 | function createPatchFunction (backend) {
|
5886 | var i, j;
|
5887 | var cbs = {};
|
5888 |
|
5889 | var modules = backend.modules;
|
5890 | var nodeOps = backend.nodeOps;
|
5891 |
|
5892 | for (i = 0; i < hooks.length; ++i) {
|
5893 | cbs[hooks[i]] = [];
|
5894 | for (j = 0; j < modules.length; ++j) {
|
5895 | if (isDef(modules[j][hooks[i]])) {
|
5896 | cbs[hooks[i]].push(modules[j][hooks[i]]);
|
5897 | }
|
5898 | }
|
5899 | }
|
5900 |
|
5901 | function emptyNodeAt (elm) {
|
5902 | return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
|
5903 | }
|
5904 |
|
5905 | function createRmCb (childElm, listeners) {
|
5906 | function remove$$1 () {
|
5907 | if (--remove$$1.listeners === 0) {
|
5908 | removeNode(childElm);
|
5909 | }
|
5910 | }
|
5911 | remove$$1.listeners = listeners;
|
5912 | return remove$$1
|
5913 | }
|
5914 |
|
5915 | function removeNode (el) {
|
5916 | var parent = nodeOps.parentNode(el);
|
5917 |
|
5918 | if (isDef(parent)) {
|
5919 | nodeOps.removeChild(parent, el);
|
5920 | }
|
5921 | }
|
5922 |
|
5923 | function isUnknownElement$$1 (vnode, inVPre) {
|
5924 | return (
|
5925 | !inVPre &&
|
5926 | !vnode.ns &&
|
5927 | !(
|
5928 | config.ignoredElements.length &&
|
5929 | config.ignoredElements.some(function (ignore) {
|
5930 | return isRegExp(ignore)
|
5931 | ? ignore.test(vnode.tag)
|
5932 | : ignore === vnode.tag
|
5933 | })
|
5934 | ) &&
|
5935 | config.isUnknownElement(vnode.tag)
|
5936 | )
|
5937 | }
|
5938 |
|
5939 | var creatingElmInVPre = 0;
|
5940 |
|
5941 | function createElm (
|
5942 | vnode,
|
5943 | insertedVnodeQueue,
|
5944 | parentElm,
|
5945 | refElm,
|
5946 | nested,
|
5947 | ownerArray,
|
5948 | index
|
5949 | ) {
|
5950 | if (isDef(vnode.elm) && isDef(ownerArray)) {
|
5951 |
|
5952 |
|
5953 |
|
5954 |
|
5955 |
|
5956 | vnode = ownerArray[index] = cloneVNode(vnode);
|
5957 | }
|
5958 |
|
5959 | vnode.isRootInsert = !nested;
|
5960 | if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
|
5961 | return
|
5962 | }
|
5963 |
|
5964 | var data = vnode.data;
|
5965 | var children = vnode.children;
|
5966 | var tag = vnode.tag;
|
5967 | if (isDef(tag)) {
|
5968 | {
|
5969 | if (data && data.pre) {
|
5970 | creatingElmInVPre++;
|
5971 | }
|
5972 | if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
|
5973 | warn(
|
5974 | 'Unknown custom element: <' + tag + '> - did you ' +
|
5975 | 'register the component correctly? For recursive components, ' +
|
5976 | 'make sure to provide the "name" option.',
|
5977 | vnode.context
|
5978 | );
|
5979 | }
|
5980 | }
|
5981 |
|
5982 | vnode.elm = vnode.ns
|
5983 | ? nodeOps.createElementNS(vnode.ns, tag)
|
5984 | : nodeOps.createElement(tag, vnode);
|
5985 | setScope(vnode);
|
5986 |
|
5987 |
|
5988 | {
|
5989 | createChildren(vnode, children, insertedVnodeQueue);
|
5990 | if (isDef(data)) {
|
5991 | invokeCreateHooks(vnode, insertedVnodeQueue);
|
5992 | }
|
5993 | insert(parentElm, vnode.elm, refElm);
|
5994 | }
|
5995 |
|
5996 | if (data && data.pre) {
|
5997 | creatingElmInVPre--;
|
5998 | }
|
5999 | } else if (isTrue(vnode.isComment)) {
|
6000 | vnode.elm = nodeOps.createComment(vnode.text);
|
6001 | insert(parentElm, vnode.elm, refElm);
|
6002 | } else {
|
6003 | vnode.elm = nodeOps.createTextNode(vnode.text);
|
6004 | insert(parentElm, vnode.elm, refElm);
|
6005 | }
|
6006 | }
|
6007 |
|
6008 | function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
|
6009 | var i = vnode.data;
|
6010 | if (isDef(i)) {
|
6011 | var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
|
6012 | if (isDef(i = i.hook) && isDef(i = i.init)) {
|
6013 | i(vnode, false );
|
6014 | }
|
6015 |
|
6016 |
|
6017 |
|
6018 |
|
6019 | if (isDef(vnode.componentInstance)) {
|
6020 | initComponent(vnode, insertedVnodeQueue);
|
6021 | insert(parentElm, vnode.elm, refElm);
|
6022 | if (isTrue(isReactivated)) {
|
6023 | reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
|
6024 | }
|
6025 | return true
|
6026 | }
|
6027 | }
|
6028 | }
|
6029 |
|
6030 | function initComponent (vnode, insertedVnodeQueue) {
|
6031 | if (isDef(vnode.data.pendingInsert)) {
|
6032 | insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
|
6033 | vnode.data.pendingInsert = null;
|
6034 | }
|
6035 | vnode.elm = vnode.componentInstance.$el;
|
6036 | if (isPatchable(vnode)) {
|
6037 | invokeCreateHooks(vnode, insertedVnodeQueue);
|
6038 | setScope(vnode);
|
6039 | } else {
|
6040 |
|
6041 |
|
6042 | registerRef(vnode);
|
6043 |
|
6044 | insertedVnodeQueue.push(vnode);
|
6045 | }
|
6046 | }
|
6047 |
|
6048 | function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
|
6049 | var i;
|
6050 |
|
6051 |
|
6052 |
|
6053 |
|
6054 | var innerNode = vnode;
|
6055 | while (innerNode.componentInstance) {
|
6056 | innerNode = innerNode.componentInstance._vnode;
|
6057 | if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
|
6058 | for (i = 0; i < cbs.activate.length; ++i) {
|
6059 | cbs.activate[i](emptyNode, innerNode);
|
6060 | }
|
6061 | insertedVnodeQueue.push(innerNode);
|
6062 | break
|
6063 | }
|
6064 | }
|
6065 |
|
6066 |
|
6067 | insert(parentElm, vnode.elm, refElm);
|
6068 | }
|
6069 |
|
6070 | function insert (parent, elm, ref$$1) {
|
6071 | if (isDef(parent)) {
|
6072 | if (isDef(ref$$1)) {
|
6073 | if (nodeOps.parentNode(ref$$1) === parent) {
|
6074 | nodeOps.insertBefore(parent, elm, ref$$1);
|
6075 | }
|
6076 | } else {
|
6077 | nodeOps.appendChild(parent, elm);
|
6078 | }
|
6079 | }
|
6080 | }
|
6081 |
|
6082 | function createChildren (vnode, children, insertedVnodeQueue) {
|
6083 | if (Array.isArray(children)) {
|
6084 | {
|
6085 | checkDuplicateKeys(children);
|
6086 | }
|
6087 | for (var i = 0; i < children.length; ++i) {
|
6088 | createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
|
6089 | }
|
6090 | } else if (isPrimitive(vnode.text)) {
|
6091 | nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
|
6092 | }
|
6093 | }
|
6094 |
|
6095 | function isPatchable (vnode) {
|
6096 | while (vnode.componentInstance) {
|
6097 | vnode = vnode.componentInstance._vnode;
|
6098 | }
|
6099 | return isDef(vnode.tag)
|
6100 | }
|
6101 |
|
6102 | function invokeCreateHooks (vnode, insertedVnodeQueue) {
|
6103 | for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
|
6104 | cbs.create[i$1](emptyNode, vnode);
|
6105 | }
|
6106 | i = vnode.data.hook;
|
6107 | if (isDef(i)) {
|
6108 | if (isDef(i.create)) { i.create(emptyNode, vnode); }
|
6109 | if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
|
6110 | }
|
6111 | }
|
6112 |
|
6113 |
|
6114 |
|
6115 |
|
6116 | function setScope (vnode) {
|
6117 | var i;
|
6118 | if (isDef(i = vnode.fnScopeId)) {
|
6119 | nodeOps.setStyleScope(vnode.elm, i);
|
6120 | } else {
|
6121 | var ancestor = vnode;
|
6122 | while (ancestor) {
|
6123 | if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
|
6124 | nodeOps.setStyleScope(vnode.elm, i);
|
6125 | }
|
6126 | ancestor = ancestor.parent;
|
6127 | }
|
6128 | }
|
6129 |
|
6130 | if (isDef(i = activeInstance) &&
|
6131 | i !== vnode.context &&
|
6132 | i !== vnode.fnContext &&
|
6133 | isDef(i = i.$options._scopeId)
|
6134 | ) {
|
6135 | nodeOps.setStyleScope(vnode.elm, i);
|
6136 | }
|
6137 | }
|
6138 |
|
6139 | function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
|
6140 | for (; startIdx <= endIdx; ++startIdx) {
|
6141 | createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
|
6142 | }
|
6143 | }
|
6144 |
|
6145 | function invokeDestroyHook (vnode) {
|
6146 | var i, j;
|
6147 | var data = vnode.data;
|
6148 | if (isDef(data)) {
|
6149 | if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
|
6150 | for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
|
6151 | }
|
6152 | if (isDef(i = vnode.children)) {
|
6153 | for (j = 0; j < vnode.children.length; ++j) {
|
6154 | invokeDestroyHook(vnode.children[j]);
|
6155 | }
|
6156 | }
|
6157 | }
|
6158 |
|
6159 | function removeVnodes (vnodes, startIdx, endIdx) {
|
6160 | for (; startIdx <= endIdx; ++startIdx) {
|
6161 | var ch = vnodes[startIdx];
|
6162 | if (isDef(ch)) {
|
6163 | if (isDef(ch.tag)) {
|
6164 | removeAndInvokeRemoveHook(ch);
|
6165 | invokeDestroyHook(ch);
|
6166 | } else {
|
6167 | removeNode(ch.elm);
|
6168 | }
|
6169 | }
|
6170 | }
|
6171 | }
|
6172 |
|
6173 | function removeAndInvokeRemoveHook (vnode, rm) {
|
6174 | if (isDef(rm) || isDef(vnode.data)) {
|
6175 | var i;
|
6176 | var listeners = cbs.remove.length + 1;
|
6177 | if (isDef(rm)) {
|
6178 |
|
6179 |
|
6180 | rm.listeners += listeners;
|
6181 | } else {
|
6182 |
|
6183 | rm = createRmCb(vnode.elm, listeners);
|
6184 | }
|
6185 |
|
6186 | if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
|
6187 | removeAndInvokeRemoveHook(i, rm);
|
6188 | }
|
6189 | for (i = 0; i < cbs.remove.length; ++i) {
|
6190 | cbs.remove[i](vnode, rm);
|
6191 | }
|
6192 | if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
|
6193 | i(vnode, rm);
|
6194 | } else {
|
6195 | rm();
|
6196 | }
|
6197 | } else {
|
6198 | removeNode(vnode.elm);
|
6199 | }
|
6200 | }
|
6201 |
|
6202 | function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
|
6203 | var oldStartIdx = 0;
|
6204 | var newStartIdx = 0;
|
6205 | var oldEndIdx = oldCh.length - 1;
|
6206 | var oldStartVnode = oldCh[0];
|
6207 | var oldEndVnode = oldCh[oldEndIdx];
|
6208 | var newEndIdx = newCh.length - 1;
|
6209 | var newStartVnode = newCh[0];
|
6210 | var newEndVnode = newCh[newEndIdx];
|
6211 | var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
|
6212 |
|
6213 |
|
6214 |
|
6215 |
|
6216 | var canMove = !removeOnly;
|
6217 |
|
6218 | {
|
6219 | checkDuplicateKeys(newCh);
|
6220 | }
|
6221 |
|
6222 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
6223 | if (isUndef(oldStartVnode)) {
|
6224 | oldStartVnode = oldCh[++oldStartIdx];
|
6225 | } else if (isUndef(oldEndVnode)) {
|
6226 | oldEndVnode = oldCh[--oldEndIdx];
|
6227 | } else if (sameVnode(oldStartVnode, newStartVnode)) {
|
6228 | patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
|
6229 | oldStartVnode = oldCh[++oldStartIdx];
|
6230 | newStartVnode = newCh[++newStartIdx];
|
6231 | } else if (sameVnode(oldEndVnode, newEndVnode)) {
|
6232 | patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
|
6233 | oldEndVnode = oldCh[--oldEndIdx];
|
6234 | newEndVnode = newCh[--newEndIdx];
|
6235 | } else if (sameVnode(oldStartVnode, newEndVnode)) {
|
6236 | patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
|
6237 | canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
|
6238 | oldStartVnode = oldCh[++oldStartIdx];
|
6239 | newEndVnode = newCh[--newEndIdx];
|
6240 | } else if (sameVnode(oldEndVnode, newStartVnode)) {
|
6241 | patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
|
6242 | canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
|
6243 | oldEndVnode = oldCh[--oldEndIdx];
|
6244 | newStartVnode = newCh[++newStartIdx];
|
6245 | } else {
|
6246 | if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
|
6247 | idxInOld = isDef(newStartVnode.key)
|
6248 | ? oldKeyToIdx[newStartVnode.key]
|
6249 | : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
|
6250 | if (isUndef(idxInOld)) {
|
6251 | createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
|
6252 | } else {
|
6253 | vnodeToMove = oldCh[idxInOld];
|
6254 | if (sameVnode(vnodeToMove, newStartVnode)) {
|
6255 | patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
|
6256 | oldCh[idxInOld] = undefined;
|
6257 | canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
|
6258 | } else {
|
6259 |
|
6260 | createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
|
6261 | }
|
6262 | }
|
6263 | newStartVnode = newCh[++newStartIdx];
|
6264 | }
|
6265 | }
|
6266 | if (oldStartIdx > oldEndIdx) {
|
6267 | refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
|
6268 | addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
|
6269 | } else if (newStartIdx > newEndIdx) {
|
6270 | removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
6271 | }
|
6272 | }
|
6273 |
|
6274 | function checkDuplicateKeys (children) {
|
6275 | var seenKeys = {};
|
6276 | for (var i = 0; i < children.length; i++) {
|
6277 | var vnode = children[i];
|
6278 | var key = vnode.key;
|
6279 | if (isDef(key)) {
|
6280 | if (seenKeys[key]) {
|
6281 | warn(
|
6282 | ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
|
6283 | vnode.context
|
6284 | );
|
6285 | } else {
|
6286 | seenKeys[key] = true;
|
6287 | }
|
6288 | }
|
6289 | }
|
6290 | }
|
6291 |
|
6292 | function findIdxInOld (node, oldCh, start, end) {
|
6293 | for (var i = start; i < end; i++) {
|
6294 | var c = oldCh[i];
|
6295 | if (isDef(c) && sameVnode(node, c)) { return i }
|
6296 | }
|
6297 | }
|
6298 |
|
6299 | function patchVnode (
|
6300 | oldVnode,
|
6301 | vnode,
|
6302 | insertedVnodeQueue,
|
6303 | ownerArray,
|
6304 | index,
|
6305 | removeOnly
|
6306 | ) {
|
6307 | if (oldVnode === vnode) {
|
6308 | return
|
6309 | }
|
6310 |
|
6311 | if (isDef(vnode.elm) && isDef(ownerArray)) {
|
6312 |
|
6313 | vnode = ownerArray[index] = cloneVNode(vnode);
|
6314 | }
|
6315 |
|
6316 | var elm = vnode.elm = oldVnode.elm;
|
6317 |
|
6318 | if (isTrue(oldVnode.isAsyncPlaceholder)) {
|
6319 | if (isDef(vnode.asyncFactory.resolved)) {
|
6320 | hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
|
6321 | } else {
|
6322 | vnode.isAsyncPlaceholder = true;
|
6323 | }
|
6324 | return
|
6325 | }
|
6326 |
|
6327 |
|
6328 |
|
6329 |
|
6330 |
|
6331 | if (isTrue(vnode.isStatic) &&
|
6332 | isTrue(oldVnode.isStatic) &&
|
6333 | vnode.key === oldVnode.key &&
|
6334 | (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
|
6335 | ) {
|
6336 | vnode.componentInstance = oldVnode.componentInstance;
|
6337 | return
|
6338 | }
|
6339 |
|
6340 | var i;
|
6341 | var data = vnode.data;
|
6342 | if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
|
6343 | i(oldVnode, vnode);
|
6344 | }
|
6345 |
|
6346 | var oldCh = oldVnode.children;
|
6347 | var ch = vnode.children;
|
6348 | if (isDef(data) && isPatchable(vnode)) {
|
6349 | for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
|
6350 | if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
|
6351 | }
|
6352 | if (isUndef(vnode.text)) {
|
6353 | if (isDef(oldCh) && isDef(ch)) {
|
6354 | if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
|
6355 | } else if (isDef(ch)) {
|
6356 | {
|
6357 | checkDuplicateKeys(ch);
|
6358 | }
|
6359 | if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
|
6360 | addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
|
6361 | } else if (isDef(oldCh)) {
|
6362 | removeVnodes(oldCh, 0, oldCh.length - 1);
|
6363 | } else if (isDef(oldVnode.text)) {
|
6364 | nodeOps.setTextContent(elm, '');
|
6365 | }
|
6366 | } else if (oldVnode.text !== vnode.text) {
|
6367 | nodeOps.setTextContent(elm, vnode.text);
|
6368 | }
|
6369 | if (isDef(data)) {
|
6370 | if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
|
6371 | }
|
6372 | }
|
6373 |
|
6374 | function invokeInsertHook (vnode, queue, initial) {
|
6375 |
|
6376 |
|
6377 | if (isTrue(initial) && isDef(vnode.parent)) {
|
6378 | vnode.parent.data.pendingInsert = queue;
|
6379 | } else {
|
6380 | for (var i = 0; i < queue.length; ++i) {
|
6381 | queue[i].data.hook.insert(queue[i]);
|
6382 | }
|
6383 | }
|
6384 | }
|
6385 |
|
6386 | var hydrationBailed = false;
|
6387 |
|
6388 |
|
6389 |
|
6390 |
|
6391 | var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
|
6392 |
|
6393 |
|
6394 | function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
|
6395 | var i;
|
6396 | var tag = vnode.tag;
|
6397 | var data = vnode.data;
|
6398 | var children = vnode.children;
|
6399 | inVPre = inVPre || (data && data.pre);
|
6400 | vnode.elm = elm;
|
6401 |
|
6402 | if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
|
6403 | vnode.isAsyncPlaceholder = true;
|
6404 | return true
|
6405 | }
|
6406 |
|
6407 | {
|
6408 | if (!assertNodeMatch(elm, vnode, inVPre)) {
|
6409 | return false
|
6410 | }
|
6411 | }
|
6412 | if (isDef(data)) {
|
6413 | if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true ); }
|
6414 | if (isDef(i = vnode.componentInstance)) {
|
6415 |
|
6416 | initComponent(vnode, insertedVnodeQueue);
|
6417 | return true
|
6418 | }
|
6419 | }
|
6420 | if (isDef(tag)) {
|
6421 | if (isDef(children)) {
|
6422 |
|
6423 | if (!elm.hasChildNodes()) {
|
6424 | createChildren(vnode, children, insertedVnodeQueue);
|
6425 | } else {
|
6426 |
|
6427 | if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
|
6428 | if (i !== elm.innerHTML) {
|
6429 |
|
6430 | if (typeof console !== 'undefined' &&
|
6431 | !hydrationBailed
|
6432 | ) {
|
6433 | hydrationBailed = true;
|
6434 | console.warn('Parent: ', elm);
|
6435 | console.warn('server innerHTML: ', i);
|
6436 | console.warn('client innerHTML: ', elm.innerHTML);
|
6437 | }
|
6438 | return false
|
6439 | }
|
6440 | } else {
|
6441 |
|
6442 | var childrenMatch = true;
|
6443 | var childNode = elm.firstChild;
|
6444 | for (var i$1 = 0; i$1 < children.length; i$1++) {
|
6445 | if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
|
6446 | childrenMatch = false;
|
6447 | break
|
6448 | }
|
6449 | childNode = childNode.nextSibling;
|
6450 | }
|
6451 |
|
6452 |
|
6453 | if (!childrenMatch || childNode) {
|
6454 |
|
6455 | if (typeof console !== 'undefined' &&
|
6456 | !hydrationBailed
|
6457 | ) {
|
6458 | hydrationBailed = true;
|
6459 | console.warn('Parent: ', elm);
|
6460 | console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
|
6461 | }
|
6462 | return false
|
6463 | }
|
6464 | }
|
6465 | }
|
6466 | }
|
6467 | if (isDef(data)) {
|
6468 | var fullInvoke = false;
|
6469 | for (var key in data) {
|
6470 | if (!isRenderedModule(key)) {
|
6471 | fullInvoke = true;
|
6472 | invokeCreateHooks(vnode, insertedVnodeQueue);
|
6473 | break
|
6474 | }
|
6475 | }
|
6476 | if (!fullInvoke && data['class']) {
|
6477 |
|
6478 | traverse(data['class']);
|
6479 | }
|
6480 | }
|
6481 | } else if (elm.data !== vnode.text) {
|
6482 | elm.data = vnode.text;
|
6483 | }
|
6484 | return true
|
6485 | }
|
6486 |
|
6487 | function assertNodeMatch (node, vnode, inVPre) {
|
6488 | if (isDef(vnode.tag)) {
|
6489 | return vnode.tag.indexOf('vue-component') === 0 || (
|
6490 | !isUnknownElement$$1(vnode, inVPre) &&
|
6491 | vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
|
6492 | )
|
6493 | } else {
|
6494 | return node.nodeType === (vnode.isComment ? 8 : 3)
|
6495 | }
|
6496 | }
|
6497 |
|
6498 | return function patch (oldVnode, vnode, hydrating, removeOnly) {
|
6499 | if (isUndef(vnode)) {
|
6500 | if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
|
6501 | return
|
6502 | }
|
6503 |
|
6504 | var isInitialPatch = false;
|
6505 | var insertedVnodeQueue = [];
|
6506 |
|
6507 | if (isUndef(oldVnode)) {
|
6508 |
|
6509 | isInitialPatch = true;
|
6510 | createElm(vnode, insertedVnodeQueue);
|
6511 | } else {
|
6512 | var isRealElement = isDef(oldVnode.nodeType);
|
6513 | if (!isRealElement && sameVnode(oldVnode, vnode)) {
|
6514 |
|
6515 | patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
|
6516 | } else {
|
6517 | if (isRealElement) {
|
6518 |
|
6519 |
|
6520 |
|
6521 | if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
|
6522 | oldVnode.removeAttribute(SSR_ATTR);
|
6523 | hydrating = true;
|
6524 | }
|
6525 | if (isTrue(hydrating)) {
|
6526 | if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
|
6527 | invokeInsertHook(vnode, insertedVnodeQueue, true);
|
6528 | return oldVnode
|
6529 | } else {
|
6530 | warn(
|
6531 | 'The client-side rendered virtual DOM tree is not matching ' +
|
6532 | 'server-rendered content. This is likely caused by incorrect ' +
|
6533 | 'HTML markup, for example nesting block-level elements inside ' +
|
6534 | '<p>, or missing <tbody>. Bailing hydration and performing ' +
|
6535 | 'full client-side render.'
|
6536 | );
|
6537 | }
|
6538 | }
|
6539 |
|
6540 |
|
6541 | oldVnode = emptyNodeAt(oldVnode);
|
6542 | }
|
6543 |
|
6544 |
|
6545 | var oldElm = oldVnode.elm;
|
6546 | var parentElm = nodeOps.parentNode(oldElm);
|
6547 |
|
6548 |
|
6549 | createElm(
|
6550 | vnode,
|
6551 | insertedVnodeQueue,
|
6552 |
|
6553 |
|
6554 |
|
6555 | oldElm._leaveCb ? null : parentElm,
|
6556 | nodeOps.nextSibling(oldElm)
|
6557 | );
|
6558 |
|
6559 |
|
6560 | if (isDef(vnode.parent)) {
|
6561 | var ancestor = vnode.parent;
|
6562 | var patchable = isPatchable(vnode);
|
6563 | while (ancestor) {
|
6564 | for (var i = 0; i < cbs.destroy.length; ++i) {
|
6565 | cbs.destroy[i](ancestor);
|
6566 | }
|
6567 | ancestor.elm = vnode.elm;
|
6568 | if (patchable) {
|
6569 | for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
|
6570 | cbs.create[i$1](emptyNode, ancestor);
|
6571 | }
|
6572 |
|
6573 |
|
6574 |
|
6575 | var insert = ancestor.data.hook.insert;
|
6576 | if (insert.merged) {
|
6577 |
|
6578 | for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
|
6579 | insert.fns[i$2]();
|
6580 | }
|
6581 | }
|
6582 | } else {
|
6583 | registerRef(ancestor);
|
6584 | }
|
6585 | ancestor = ancestor.parent;
|
6586 | }
|
6587 | }
|
6588 |
|
6589 |
|
6590 | if (isDef(parentElm)) {
|
6591 | removeVnodes([oldVnode], 0, 0);
|
6592 | } else if (isDef(oldVnode.tag)) {
|
6593 | invokeDestroyHook(oldVnode);
|
6594 | }
|
6595 | }
|
6596 | }
|
6597 |
|
6598 | invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
|
6599 | return vnode.elm
|
6600 | }
|
6601 | }
|
6602 |
|
6603 |
|
6604 |
|
6605 | var directives = {
|
6606 | create: updateDirectives,
|
6607 | update: updateDirectives,
|
6608 | destroy: function unbindDirectives (vnode) {
|
6609 | updateDirectives(vnode, emptyNode);
|
6610 | }
|
6611 | };
|
6612 |
|
6613 | function updateDirectives (oldVnode, vnode) {
|
6614 | if (oldVnode.data.directives || vnode.data.directives) {
|
6615 | _update(oldVnode, vnode);
|
6616 | }
|
6617 | }
|
6618 |
|
6619 | function _update (oldVnode, vnode) {
|
6620 | var isCreate = oldVnode === emptyNode;
|
6621 | var isDestroy = vnode === emptyNode;
|
6622 | var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
|
6623 | var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
|
6624 |
|
6625 | var dirsWithInsert = [];
|
6626 | var dirsWithPostpatch = [];
|
6627 |
|
6628 | var key, oldDir, dir;
|
6629 | for (key in newDirs) {
|
6630 | oldDir = oldDirs[key];
|
6631 | dir = newDirs[key];
|
6632 | if (!oldDir) {
|
6633 |
|
6634 | callHook$1(dir, 'bind', vnode, oldVnode);
|
6635 | if (dir.def && dir.def.inserted) {
|
6636 | dirsWithInsert.push(dir);
|
6637 | }
|
6638 | } else {
|
6639 |
|
6640 | dir.oldValue = oldDir.value;
|
6641 | dir.oldArg = oldDir.arg;
|
6642 | callHook$1(dir, 'update', vnode, oldVnode);
|
6643 | if (dir.def && dir.def.componentUpdated) {
|
6644 | dirsWithPostpatch.push(dir);
|
6645 | }
|
6646 | }
|
6647 | }
|
6648 |
|
6649 | if (dirsWithInsert.length) {
|
6650 | var callInsert = function () {
|
6651 | for (var i = 0; i < dirsWithInsert.length; i++) {
|
6652 | callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
|
6653 | }
|
6654 | };
|
6655 | if (isCreate) {
|
6656 | mergeVNodeHook(vnode, 'insert', callInsert);
|
6657 | } else {
|
6658 | callInsert();
|
6659 | }
|
6660 | }
|
6661 |
|
6662 | if (dirsWithPostpatch.length) {
|
6663 | mergeVNodeHook(vnode, 'postpatch', function () {
|
6664 | for (var i = 0; i < dirsWithPostpatch.length; i++) {
|
6665 | callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
|
6666 | }
|
6667 | });
|
6668 | }
|
6669 |
|
6670 | if (!isCreate) {
|
6671 | for (key in oldDirs) {
|
6672 | if (!newDirs[key]) {
|
6673 |
|
6674 | callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
|
6675 | }
|
6676 | }
|
6677 | }
|
6678 | }
|
6679 |
|
6680 | var emptyModifiers = Object.create(null);
|
6681 |
|
6682 | function normalizeDirectives$1 (
|
6683 | dirs,
|
6684 | vm
|
6685 | ) {
|
6686 | var res = Object.create(null);
|
6687 | if (!dirs) {
|
6688 |
|
6689 | return res
|
6690 | }
|
6691 | var i, dir;
|
6692 | for (i = 0; i < dirs.length; i++) {
|
6693 | dir = dirs[i];
|
6694 | if (!dir.modifiers) {
|
6695 |
|
6696 | dir.modifiers = emptyModifiers;
|
6697 | }
|
6698 | res[getRawDirName(dir)] = dir;
|
6699 | dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
|
6700 | }
|
6701 |
|
6702 | return res
|
6703 | }
|
6704 |
|
6705 | function getRawDirName (dir) {
|
6706 | return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
|
6707 | }
|
6708 |
|
6709 | function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
|
6710 | var fn = dir.def && dir.def[hook];
|
6711 | if (fn) {
|
6712 | try {
|
6713 | fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
|
6714 | } catch (e) {
|
6715 | handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
|
6716 | }
|
6717 | }
|
6718 | }
|
6719 |
|
6720 | var baseModules = [
|
6721 | ref,
|
6722 | directives
|
6723 | ];
|
6724 |
|
6725 |
|
6726 |
|
6727 | function updateAttrs (oldVnode, vnode) {
|
6728 | var opts = vnode.componentOptions;
|
6729 | if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
|
6730 | return
|
6731 | }
|
6732 | if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
|
6733 | return
|
6734 | }
|
6735 | var key, cur, old;
|
6736 | var elm = vnode.elm;
|
6737 | var oldAttrs = oldVnode.data.attrs || {};
|
6738 | var attrs = vnode.data.attrs || {};
|
6739 |
|
6740 | if (isDef(attrs.__ob__)) {
|
6741 | attrs = vnode.data.attrs = extend({}, attrs);
|
6742 | }
|
6743 |
|
6744 | for (key in attrs) {
|
6745 | cur = attrs[key];
|
6746 | old = oldAttrs[key];
|
6747 | if (old !== cur) {
|
6748 | setAttr(elm, key, cur, vnode.data.pre);
|
6749 | }
|
6750 | }
|
6751 |
|
6752 |
|
6753 |
|
6754 | if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
|
6755 | setAttr(elm, 'value', attrs.value);
|
6756 | }
|
6757 | for (key in oldAttrs) {
|
6758 | if (isUndef(attrs[key])) {
|
6759 | if (isXlink(key)) {
|
6760 | elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
|
6761 | } else if (!isEnumeratedAttr(key)) {
|
6762 | elm.removeAttribute(key);
|
6763 | }
|
6764 | }
|
6765 | }
|
6766 | }
|
6767 |
|
6768 | function setAttr (el, key, value, isInPre) {
|
6769 | if (isInPre || el.tagName.indexOf('-') > -1) {
|
6770 | baseSetAttr(el, key, value);
|
6771 | } else if (isBooleanAttr(key)) {
|
6772 |
|
6773 |
|
6774 | if (isFalsyAttrValue(value)) {
|
6775 | el.removeAttribute(key);
|
6776 | } else {
|
6777 |
|
6778 |
|
6779 | value = key === 'allowfullscreen' && el.tagName === 'EMBED'
|
6780 | ? 'true'
|
6781 | : key;
|
6782 | el.setAttribute(key, value);
|
6783 | }
|
6784 | } else if (isEnumeratedAttr(key)) {
|
6785 | el.setAttribute(key, convertEnumeratedValue(key, value));
|
6786 | } else if (isXlink(key)) {
|
6787 | if (isFalsyAttrValue(value)) {
|
6788 | el.removeAttributeNS(xlinkNS, getXlinkProp(key));
|
6789 | } else {
|
6790 | el.setAttributeNS(xlinkNS, key, value);
|
6791 | }
|
6792 | } else {
|
6793 | baseSetAttr(el, key, value);
|
6794 | }
|
6795 | }
|
6796 |
|
6797 | function baseSetAttr (el, key, value) {
|
6798 | if (isFalsyAttrValue(value)) {
|
6799 | el.removeAttribute(key);
|
6800 | } else {
|
6801 |
|
6802 |
|
6803 |
|
6804 |
|
6805 | if (
|
6806 | isIE && !isIE9 &&
|
6807 | el.tagName === 'TEXTAREA' &&
|
6808 | key === 'placeholder' && value !== '' && !el.__ieph
|
6809 | ) {
|
6810 | var blocker = function (e) {
|
6811 | e.stopImmediatePropagation();
|
6812 | el.removeEventListener('input', blocker);
|
6813 | };
|
6814 | el.addEventListener('input', blocker);
|
6815 |
|
6816 | el.__ieph = true;
|
6817 | }
|
6818 | el.setAttribute(key, value);
|
6819 | }
|
6820 | }
|
6821 |
|
6822 | var attrs = {
|
6823 | create: updateAttrs,
|
6824 | update: updateAttrs
|
6825 | };
|
6826 |
|
6827 |
|
6828 |
|
6829 | function updateClass (oldVnode, vnode) {
|
6830 | var el = vnode.elm;
|
6831 | var data = vnode.data;
|
6832 | var oldData = oldVnode.data;
|
6833 | if (
|
6834 | isUndef(data.staticClass) &&
|
6835 | isUndef(data.class) && (
|
6836 | isUndef(oldData) || (
|
6837 | isUndef(oldData.staticClass) &&
|
6838 | isUndef(oldData.class)
|
6839 | )
|
6840 | )
|
6841 | ) {
|
6842 | return
|
6843 | }
|
6844 |
|
6845 | var cls = genClassForVnode(vnode);
|
6846 |
|
6847 |
|
6848 | var transitionClass = el._transitionClasses;
|
6849 | if (isDef(transitionClass)) {
|
6850 | cls = concat(cls, stringifyClass(transitionClass));
|
6851 | }
|
6852 |
|
6853 |
|
6854 | if (cls !== el._prevClass) {
|
6855 | el.setAttribute('class', cls);
|
6856 | el._prevClass = cls;
|
6857 | }
|
6858 | }
|
6859 |
|
6860 | var klass = {
|
6861 | create: updateClass,
|
6862 | update: updateClass
|
6863 | };
|
6864 |
|
6865 |
|
6866 |
|
6867 | var validDivisionCharRE = /[\w).+\-_$\]]/;
|
6868 |
|
6869 | function parseFilters (exp) {
|
6870 | var inSingle = false;
|
6871 | var inDouble = false;
|
6872 | var inTemplateString = false;
|
6873 | var inRegex = false;
|
6874 | var curly = 0;
|
6875 | var square = 0;
|
6876 | var paren = 0;
|
6877 | var lastFilterIndex = 0;
|
6878 | var c, prev, i, expression, filters;
|
6879 |
|
6880 | for (i = 0; i < exp.length; i++) {
|
6881 | prev = c;
|
6882 | c = exp.charCodeAt(i);
|
6883 | if (inSingle) {
|
6884 | if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
|
6885 | } else if (inDouble) {
|
6886 | if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
|
6887 | } else if (inTemplateString) {
|
6888 | if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
|
6889 | } else if (inRegex) {
|
6890 | if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
|
6891 | } else if (
|
6892 | c === 0x7C &&
|
6893 | exp.charCodeAt(i + 1) !== 0x7C &&
|
6894 | exp.charCodeAt(i - 1) !== 0x7C &&
|
6895 | !curly && !square && !paren
|
6896 | ) {
|
6897 | if (expression === undefined) {
|
6898 |
|
6899 | lastFilterIndex = i + 1;
|
6900 | expression = exp.slice(0, i).trim();
|
6901 | } else {
|
6902 | pushFilter();
|
6903 | }
|
6904 | } else {
|
6905 | switch (c) {
|
6906 | case 0x22: inDouble = true; break
|
6907 | case 0x27: inSingle = true; break
|
6908 | case 0x60: inTemplateString = true; break
|
6909 | case 0x28: paren++; break
|
6910 | case 0x29: paren--; break
|
6911 | case 0x5B: square++; break
|
6912 | case 0x5D: square--; break
|
6913 | case 0x7B: curly++; break
|
6914 | case 0x7D: curly--; break
|
6915 | }
|
6916 | if (c === 0x2f) {
|
6917 | var j = i - 1;
|
6918 | var p = (void 0);
|
6919 |
|
6920 | for (; j >= 0; j--) {
|
6921 | p = exp.charAt(j);
|
6922 | if (p !== ' ') { break }
|
6923 | }
|
6924 | if (!p || !validDivisionCharRE.test(p)) {
|
6925 | inRegex = true;
|
6926 | }
|
6927 | }
|
6928 | }
|
6929 | }
|
6930 |
|
6931 | if (expression === undefined) {
|
6932 | expression = exp.slice(0, i).trim();
|
6933 | } else if (lastFilterIndex !== 0) {
|
6934 | pushFilter();
|
6935 | }
|
6936 |
|
6937 | function pushFilter () {
|
6938 | (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
|
6939 | lastFilterIndex = i + 1;
|
6940 | }
|
6941 |
|
6942 | if (filters) {
|
6943 | for (i = 0; i < filters.length; i++) {
|
6944 | expression = wrapFilter(expression, filters[i]);
|
6945 | }
|
6946 | }
|
6947 |
|
6948 | return expression
|
6949 | }
|
6950 |
|
6951 | function wrapFilter (exp, filter) {
|
6952 | var i = filter.indexOf('(');
|
6953 | if (i < 0) {
|
6954 |
|
6955 | return ("_f(\"" + filter + "\")(" + exp + ")")
|
6956 | } else {
|
6957 | var name = filter.slice(0, i);
|
6958 | var args = filter.slice(i + 1);
|
6959 | return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
|
6960 | }
|
6961 | }
|
6962 |
|
6963 |
|
6964 |
|
6965 |
|
6966 |
|
6967 |
|
6968 | function baseWarn (msg, range) {
|
6969 | console.error(("[Vue compiler]: " + msg));
|
6970 | }
|
6971 |
|
6972 |
|
6973 | function pluckModuleFunction (
|
6974 | modules,
|
6975 | key
|
6976 | ) {
|
6977 | return modules
|
6978 | ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
|
6979 | : []
|
6980 | }
|
6981 |
|
6982 | function addProp (el, name, value, range, dynamic) {
|
6983 | (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
|
6984 | el.plain = false;
|
6985 | }
|
6986 |
|
6987 | function addAttr (el, name, value, range, dynamic) {
|
6988 | var attrs = dynamic
|
6989 | ? (el.dynamicAttrs || (el.dynamicAttrs = []))
|
6990 | : (el.attrs || (el.attrs = []));
|
6991 | attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
|
6992 | el.plain = false;
|
6993 | }
|
6994 |
|
6995 |
|
6996 | function addRawAttr (el, name, value, range) {
|
6997 | el.attrsMap[name] = value;
|
6998 | el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
|
6999 | }
|
7000 |
|
7001 | function addDirective (
|
7002 | el,
|
7003 | name,
|
7004 | rawName,
|
7005 | value,
|
7006 | arg,
|
7007 | isDynamicArg,
|
7008 | modifiers,
|
7009 | range
|
7010 | ) {
|
7011 | (el.directives || (el.directives = [])).push(rangeSetItem({
|
7012 | name: name,
|
7013 | rawName: rawName,
|
7014 | value: value,
|
7015 | arg: arg,
|
7016 | isDynamicArg: isDynamicArg,
|
7017 | modifiers: modifiers
|
7018 | }, range));
|
7019 | el.plain = false;
|
7020 | }
|
7021 |
|
7022 | function prependModifierMarker (symbol, name, dynamic) {
|
7023 | return dynamic
|
7024 | ? ("_p(" + name + ",\"" + symbol + "\")")
|
7025 | : symbol + name
|
7026 | }
|
7027 |
|
7028 | function addHandler (
|
7029 | el,
|
7030 | name,
|
7031 | value,
|
7032 | modifiers,
|
7033 | important,
|
7034 | warn,
|
7035 | range,
|
7036 | dynamic
|
7037 | ) {
|
7038 | modifiers = modifiers || emptyObject;
|
7039 |
|
7040 |
|
7041 | if (
|
7042 | warn &&
|
7043 | modifiers.prevent && modifiers.passive
|
7044 | ) {
|
7045 | warn(
|
7046 | 'passive and prevent can\'t be used together. ' +
|
7047 | 'Passive handler can\'t prevent default event.',
|
7048 | range
|
7049 | );
|
7050 | }
|
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 | if (modifiers.right) {
|
7056 | if (dynamic) {
|
7057 | name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
|
7058 | } else if (name === 'click') {
|
7059 | name = 'contextmenu';
|
7060 | delete modifiers.right;
|
7061 | }
|
7062 | } else if (modifiers.middle) {
|
7063 | if (dynamic) {
|
7064 | name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
|
7065 | } else if (name === 'click') {
|
7066 | name = 'mouseup';
|
7067 | }
|
7068 | }
|
7069 |
|
7070 |
|
7071 | if (modifiers.capture) {
|
7072 | delete modifiers.capture;
|
7073 | name = prependModifierMarker('!', name, dynamic);
|
7074 | }
|
7075 | if (modifiers.once) {
|
7076 | delete modifiers.once;
|
7077 | name = prependModifierMarker('~', name, dynamic);
|
7078 | }
|
7079 |
|
7080 | if (modifiers.passive) {
|
7081 | delete modifiers.passive;
|
7082 | name = prependModifierMarker('&', name, dynamic);
|
7083 | }
|
7084 |
|
7085 | var events;
|
7086 | if (modifiers.native) {
|
7087 | delete modifiers.native;
|
7088 | events = el.nativeEvents || (el.nativeEvents = {});
|
7089 | } else {
|
7090 | events = el.events || (el.events = {});
|
7091 | }
|
7092 |
|
7093 | var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
|
7094 | if (modifiers !== emptyObject) {
|
7095 | newHandler.modifiers = modifiers;
|
7096 | }
|
7097 |
|
7098 | var handlers = events[name];
|
7099 |
|
7100 | if (Array.isArray(handlers)) {
|
7101 | important ? handlers.unshift(newHandler) : handlers.push(newHandler);
|
7102 | } else if (handlers) {
|
7103 | events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
|
7104 | } else {
|
7105 | events[name] = newHandler;
|
7106 | }
|
7107 |
|
7108 | el.plain = false;
|
7109 | }
|
7110 |
|
7111 | function getRawBindingAttr (
|
7112 | el,
|
7113 | name
|
7114 | ) {
|
7115 | return el.rawAttrsMap[':' + name] ||
|
7116 | el.rawAttrsMap['v-bind:' + name] ||
|
7117 | el.rawAttrsMap[name]
|
7118 | }
|
7119 |
|
7120 | function getBindingAttr (
|
7121 | el,
|
7122 | name,
|
7123 | getStatic
|
7124 | ) {
|
7125 | var dynamicValue =
|
7126 | getAndRemoveAttr(el, ':' + name) ||
|
7127 | getAndRemoveAttr(el, 'v-bind:' + name);
|
7128 | if (dynamicValue != null) {
|
7129 | return parseFilters(dynamicValue)
|
7130 | } else if (getStatic !== false) {
|
7131 | var staticValue = getAndRemoveAttr(el, name);
|
7132 | if (staticValue != null) {
|
7133 | return JSON.stringify(staticValue)
|
7134 | }
|
7135 | }
|
7136 | }
|
7137 |
|
7138 |
|
7139 |
|
7140 |
|
7141 |
|
7142 | function getAndRemoveAttr (
|
7143 | el,
|
7144 | name,
|
7145 | removeFromMap
|
7146 | ) {
|
7147 | var val;
|
7148 | if ((val = el.attrsMap[name]) != null) {
|
7149 | var list = el.attrsList;
|
7150 | for (var i = 0, l = list.length; i < l; i++) {
|
7151 | if (list[i].name === name) {
|
7152 | list.splice(i, 1);
|
7153 | break
|
7154 | }
|
7155 | }
|
7156 | }
|
7157 | if (removeFromMap) {
|
7158 | delete el.attrsMap[name];
|
7159 | }
|
7160 | return val
|
7161 | }
|
7162 |
|
7163 | function getAndRemoveAttrByRegex (
|
7164 | el,
|
7165 | name
|
7166 | ) {
|
7167 | var list = el.attrsList;
|
7168 | for (var i = 0, l = list.length; i < l; i++) {
|
7169 | var attr = list[i];
|
7170 | if (name.test(attr.name)) {
|
7171 | list.splice(i, 1);
|
7172 | return attr
|
7173 | }
|
7174 | }
|
7175 | }
|
7176 |
|
7177 | function rangeSetItem (
|
7178 | item,
|
7179 | range
|
7180 | ) {
|
7181 | if (range) {
|
7182 | if (range.start != null) {
|
7183 | item.start = range.start;
|
7184 | }
|
7185 | if (range.end != null) {
|
7186 | item.end = range.end;
|
7187 | }
|
7188 | }
|
7189 | return item
|
7190 | }
|
7191 |
|
7192 |
|
7193 |
|
7194 |
|
7195 |
|
7196 |
|
7197 | function genComponentModel (
|
7198 | el,
|
7199 | value,
|
7200 | modifiers
|
7201 | ) {
|
7202 | var ref = modifiers || {};
|
7203 | var number = ref.number;
|
7204 | var trim = ref.trim;
|
7205 |
|
7206 | var baseValueExpression = '$$v';
|
7207 | var valueExpression = baseValueExpression;
|
7208 | if (trim) {
|
7209 | valueExpression =
|
7210 | "(typeof " + baseValueExpression + " === 'string'" +
|
7211 | "? " + baseValueExpression + ".trim()" +
|
7212 | ": " + baseValueExpression + ")";
|
7213 | }
|
7214 | if (number) {
|
7215 | valueExpression = "_n(" + valueExpression + ")";
|
7216 | }
|
7217 | var assignment = genAssignmentCode(value, valueExpression);
|
7218 |
|
7219 | el.model = {
|
7220 | value: ("(" + value + ")"),
|
7221 | expression: JSON.stringify(value),
|
7222 | callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
|
7223 | };
|
7224 | }
|
7225 |
|
7226 |
|
7227 |
|
7228 |
|
7229 | function genAssignmentCode (
|
7230 | value,
|
7231 | assignment
|
7232 | ) {
|
7233 | var res = parseModel(value);
|
7234 | if (res.key === null) {
|
7235 | return (value + "=" + assignment)
|
7236 | } else {
|
7237 | return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
|
7238 | }
|
7239 | }
|
7240 |
|
7241 |
|
7242 |
|
7243 |
|
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 |
|
7249 |
|
7250 |
|
7251 |
|
7252 |
|
7253 |
|
7254 |
|
7255 |
|
7256 | var len, str, chr, index$1, expressionPos, expressionEndPos;
|
7257 |
|
7258 |
|
7259 |
|
7260 | function parseModel (val) {
|
7261 |
|
7262 |
|
7263 | val = val.trim();
|
7264 | len = val.length;
|
7265 |
|
7266 | if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
|
7267 | index$1 = val.lastIndexOf('.');
|
7268 | if (index$1 > -1) {
|
7269 | return {
|
7270 | exp: val.slice(0, index$1),
|
7271 | key: '"' + val.slice(index$1 + 1) + '"'
|
7272 | }
|
7273 | } else {
|
7274 | return {
|
7275 | exp: val,
|
7276 | key: null
|
7277 | }
|
7278 | }
|
7279 | }
|
7280 |
|
7281 | str = val;
|
7282 | index$1 = expressionPos = expressionEndPos = 0;
|
7283 |
|
7284 | while (!eof()) {
|
7285 | chr = next();
|
7286 |
|
7287 | if (isStringStart(chr)) {
|
7288 | parseString(chr);
|
7289 | } else if (chr === 0x5B) {
|
7290 | parseBracket(chr);
|
7291 | }
|
7292 | }
|
7293 |
|
7294 | return {
|
7295 | exp: val.slice(0, expressionPos),
|
7296 | key: val.slice(expressionPos + 1, expressionEndPos)
|
7297 | }
|
7298 | }
|
7299 |
|
7300 | function next () {
|
7301 | return str.charCodeAt(++index$1)
|
7302 | }
|
7303 |
|
7304 | function eof () {
|
7305 | return index$1 >= len
|
7306 | }
|
7307 |
|
7308 | function isStringStart (chr) {
|
7309 | return chr === 0x22 || chr === 0x27
|
7310 | }
|
7311 |
|
7312 | function parseBracket (chr) {
|
7313 | var inBracket = 1;
|
7314 | expressionPos = index$1;
|
7315 | while (!eof()) {
|
7316 | chr = next();
|
7317 | if (isStringStart(chr)) {
|
7318 | parseString(chr);
|
7319 | continue
|
7320 | }
|
7321 | if (chr === 0x5B) { inBracket++; }
|
7322 | if (chr === 0x5D) { inBracket--; }
|
7323 | if (inBracket === 0) {
|
7324 | expressionEndPos = index$1;
|
7325 | break
|
7326 | }
|
7327 | }
|
7328 | }
|
7329 |
|
7330 | function parseString (chr) {
|
7331 | var stringQuote = chr;
|
7332 | while (!eof()) {
|
7333 | chr = next();
|
7334 | if (chr === stringQuote) {
|
7335 | break
|
7336 | }
|
7337 | }
|
7338 | }
|
7339 |
|
7340 |
|
7341 |
|
7342 | var warn$1;
|
7343 |
|
7344 |
|
7345 |
|
7346 | var RANGE_TOKEN = '__r';
|
7347 | var CHECKBOX_RADIO_TOKEN = '__c';
|
7348 |
|
7349 | function model (
|
7350 | el,
|
7351 | dir,
|
7352 | _warn
|
7353 | ) {
|
7354 | warn$1 = _warn;
|
7355 | var value = dir.value;
|
7356 | var modifiers = dir.modifiers;
|
7357 | var tag = el.tag;
|
7358 | var type = el.attrsMap.type;
|
7359 |
|
7360 | {
|
7361 |
|
7362 |
|
7363 | if (tag === 'input' && type === 'file') {
|
7364 | warn$1(
|
7365 | "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
|
7366 | "File inputs are read only. Use a v-on:change listener instead.",
|
7367 | el.rawAttrsMap['v-model']
|
7368 | );
|
7369 | }
|
7370 | }
|
7371 |
|
7372 | if (el.component) {
|
7373 | genComponentModel(el, value, modifiers);
|
7374 |
|
7375 | return false
|
7376 | } else if (tag === 'select') {
|
7377 | genSelect(el, value, modifiers);
|
7378 | } else if (tag === 'input' && type === 'checkbox') {
|
7379 | genCheckboxModel(el, value, modifiers);
|
7380 | } else if (tag === 'input' && type === 'radio') {
|
7381 | genRadioModel(el, value, modifiers);
|
7382 | } else if (tag === 'input' || tag === 'textarea') {
|
7383 | genDefaultModel(el, value, modifiers);
|
7384 | } else if (!config.isReservedTag(tag)) {
|
7385 | genComponentModel(el, value, modifiers);
|
7386 |
|
7387 | return false
|
7388 | } else {
|
7389 | warn$1(
|
7390 | "<" + (el.tag) + " v-model=\"" + value + "\">: " +
|
7391 | "v-model is not supported on this element type. " +
|
7392 | 'If you are working with contenteditable, it\'s recommended to ' +
|
7393 | 'wrap a library dedicated for that purpose inside a custom component.',
|
7394 | el.rawAttrsMap['v-model']
|
7395 | );
|
7396 | }
|
7397 |
|
7398 |
|
7399 | return true
|
7400 | }
|
7401 |
|
7402 | function genCheckboxModel (
|
7403 | el,
|
7404 | value,
|
7405 | modifiers
|
7406 | ) {
|
7407 | var number = modifiers && modifiers.number;
|
7408 | var valueBinding = getBindingAttr(el, 'value') || 'null';
|
7409 | var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
|
7410 | var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
|
7411 | addProp(el, 'checked',
|
7412 | "Array.isArray(" + value + ")" +
|
7413 | "?_i(" + value + "," + valueBinding + ")>-1" + (
|
7414 | trueValueBinding === 'true'
|
7415 | ? (":(" + value + ")")
|
7416 | : (":_q(" + value + "," + trueValueBinding + ")")
|
7417 | )
|
7418 | );
|
7419 | addHandler(el, 'change',
|
7420 | "var $$a=" + value + "," +
|
7421 | '$$el=$event.target,' +
|
7422 | "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
|
7423 | 'if(Array.isArray($$a)){' +
|
7424 | "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
|
7425 | '$$i=_i($$a,$$v);' +
|
7426 | "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
|
7427 | "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
|
7428 | "}else{" + (genAssignmentCode(value, '$$c')) + "}",
|
7429 | null, true
|
7430 | );
|
7431 | }
|
7432 |
|
7433 | function genRadioModel (
|
7434 | el,
|
7435 | value,
|
7436 | modifiers
|
7437 | ) {
|
7438 | var number = modifiers && modifiers.number;
|
7439 | var valueBinding = getBindingAttr(el, 'value') || 'null';
|
7440 | valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
|
7441 | addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
|
7442 | addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
|
7443 | }
|
7444 |
|
7445 | function genSelect (
|
7446 | el,
|
7447 | value,
|
7448 | modifiers
|
7449 | ) {
|
7450 | var number = modifiers && modifiers.number;
|
7451 | var selectedVal = "Array.prototype.filter" +
|
7452 | ".call($event.target.options,function(o){return o.selected})" +
|
7453 | ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
|
7454 | "return " + (number ? '_n(val)' : 'val') + "})";
|
7455 |
|
7456 | var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
|
7457 | var code = "var $$selectedVal = " + selectedVal + ";";
|
7458 | code = code + " " + (genAssignmentCode(value, assignment));
|
7459 | addHandler(el, 'change', code, null, true);
|
7460 | }
|
7461 |
|
7462 | function genDefaultModel (
|
7463 | el,
|
7464 | value,
|
7465 | modifiers
|
7466 | ) {
|
7467 | var type = el.attrsMap.type;
|
7468 |
|
7469 |
|
7470 |
|
7471 | {
|
7472 | var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
|
7473 | var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
|
7474 | if (value$1 && !typeBinding) {
|
7475 | var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
|
7476 | warn$1(
|
7477 | binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
|
7478 | 'because the latter already expands to a value binding internally',
|
7479 | el.rawAttrsMap[binding]
|
7480 | );
|
7481 | }
|
7482 | }
|
7483 |
|
7484 | var ref = modifiers || {};
|
7485 | var lazy = ref.lazy;
|
7486 | var number = ref.number;
|
7487 | var trim = ref.trim;
|
7488 | var needCompositionGuard = !lazy && type !== 'range';
|
7489 | var event = lazy
|
7490 | ? 'change'
|
7491 | : type === 'range'
|
7492 | ? RANGE_TOKEN
|
7493 | : 'input';
|
7494 |
|
7495 | var valueExpression = '$event.target.value';
|
7496 | if (trim) {
|
7497 | valueExpression = "$event.target.value.trim()";
|
7498 | }
|
7499 | if (number) {
|
7500 | valueExpression = "_n(" + valueExpression + ")";
|
7501 | }
|
7502 |
|
7503 | var code = genAssignmentCode(value, valueExpression);
|
7504 | if (needCompositionGuard) {
|
7505 | code = "if($event.target.composing)return;" + code;
|
7506 | }
|
7507 |
|
7508 | addProp(el, 'value', ("(" + value + ")"));
|
7509 | addHandler(el, event, code, null, true);
|
7510 | if (trim || number) {
|
7511 | addHandler(el, 'blur', '$forceUpdate()');
|
7512 | }
|
7513 | }
|
7514 |
|
7515 |
|
7516 |
|
7517 |
|
7518 |
|
7519 |
|
7520 |
|
7521 | function normalizeEvents (on) {
|
7522 |
|
7523 | if (isDef(on[RANGE_TOKEN])) {
|
7524 |
|
7525 | var event = isIE ? 'change' : 'input';
|
7526 | on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
|
7527 | delete on[RANGE_TOKEN];
|
7528 | }
|
7529 |
|
7530 |
|
7531 |
|
7532 | if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
|
7533 | on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
|
7534 | delete on[CHECKBOX_RADIO_TOKEN];
|
7535 | }
|
7536 | }
|
7537 |
|
7538 | var target$1;
|
7539 |
|
7540 | function createOnceHandler$1 (event, handler, capture) {
|
7541 | var _target = target$1;
|
7542 | return function onceHandler () {
|
7543 | var res = handler.apply(null, arguments);
|
7544 | if (res !== null) {
|
7545 | remove$2(event, onceHandler, capture, _target);
|
7546 | }
|
7547 | }
|
7548 | }
|
7549 |
|
7550 |
|
7551 |
|
7552 |
|
7553 | var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
|
7554 |
|
7555 | function add$1 (
|
7556 | name,
|
7557 | handler,
|
7558 | capture,
|
7559 | passive
|
7560 | ) {
|
7561 |
|
7562 |
|
7563 |
|
7564 |
|
7565 |
|
7566 |
|
7567 | if (useMicrotaskFix) {
|
7568 | var attachedTimestamp = currentFlushTimestamp;
|
7569 | var original = handler;
|
7570 | handler = original._wrapper = function (e) {
|
7571 | if (
|
7572 |
|
7573 |
|
7574 |
|
7575 | e.target === e.currentTarget ||
|
7576 |
|
7577 | e.timeStamp >= attachedTimestamp ||
|
7578 |
|
7579 |
|
7580 |
|
7581 | e.timeStamp <= 0 ||
|
7582 |
|
7583 |
|
7584 |
|
7585 | e.target.ownerDocument !== document
|
7586 | ) {
|
7587 | return original.apply(this, arguments)
|
7588 | }
|
7589 | };
|
7590 | }
|
7591 | target$1.addEventListener(
|
7592 | name,
|
7593 | handler,
|
7594 | supportsPassive
|
7595 | ? { capture: capture, passive: passive }
|
7596 | : capture
|
7597 | );
|
7598 | }
|
7599 |
|
7600 | function remove$2 (
|
7601 | name,
|
7602 | handler,
|
7603 | capture,
|
7604 | _target
|
7605 | ) {
|
7606 | (_target || target$1).removeEventListener(
|
7607 | name,
|
7608 | handler._wrapper || handler,
|
7609 | capture
|
7610 | );
|
7611 | }
|
7612 |
|
7613 | function updateDOMListeners (oldVnode, vnode) {
|
7614 | if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
|
7615 | return
|
7616 | }
|
7617 | var on = vnode.data.on || {};
|
7618 | var oldOn = oldVnode.data.on || {};
|
7619 | target$1 = vnode.elm;
|
7620 | normalizeEvents(on);
|
7621 | updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
|
7622 | target$1 = undefined;
|
7623 | }
|
7624 |
|
7625 | var events = {
|
7626 | create: updateDOMListeners,
|
7627 | update: updateDOMListeners
|
7628 | };
|
7629 |
|
7630 |
|
7631 |
|
7632 | var svgContainer;
|
7633 |
|
7634 | function updateDOMProps (oldVnode, vnode) {
|
7635 | if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
|
7636 | return
|
7637 | }
|
7638 | var key, cur;
|
7639 | var elm = vnode.elm;
|
7640 | var oldProps = oldVnode.data.domProps || {};
|
7641 | var props = vnode.data.domProps || {};
|
7642 |
|
7643 | if (isDef(props.__ob__)) {
|
7644 | props = vnode.data.domProps = extend({}, props);
|
7645 | }
|
7646 |
|
7647 | for (key in oldProps) {
|
7648 | if (!(key in props)) {
|
7649 | elm[key] = '';
|
7650 | }
|
7651 | }
|
7652 |
|
7653 | for (key in props) {
|
7654 | cur = props[key];
|
7655 |
|
7656 |
|
7657 |
|
7658 | if (key === 'textContent' || key === 'innerHTML') {
|
7659 | if (vnode.children) { vnode.children.length = 0; }
|
7660 | if (cur === oldProps[key]) { continue }
|
7661 |
|
7662 |
|
7663 | if (elm.childNodes.length === 1) {
|
7664 | elm.removeChild(elm.childNodes[0]);
|
7665 | }
|
7666 | }
|
7667 |
|
7668 | if (key === 'value' && elm.tagName !== 'PROGRESS') {
|
7669 |
|
7670 |
|
7671 | elm._value = cur;
|
7672 |
|
7673 | var strCur = isUndef(cur) ? '' : String(cur);
|
7674 | if (shouldUpdateValue(elm, strCur)) {
|
7675 | elm.value = strCur;
|
7676 | }
|
7677 | } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
|
7678 |
|
7679 | svgContainer = svgContainer || document.createElement('div');
|
7680 | svgContainer.innerHTML = "<svg>" + cur + "</svg>";
|
7681 | var svg = svgContainer.firstChild;
|
7682 | while (elm.firstChild) {
|
7683 | elm.removeChild(elm.firstChild);
|
7684 | }
|
7685 | while (svg.firstChild) {
|
7686 | elm.appendChild(svg.firstChild);
|
7687 | }
|
7688 | } else if (
|
7689 |
|
7690 |
|
7691 |
|
7692 |
|
7693 | cur !== oldProps[key]
|
7694 | ) {
|
7695 |
|
7696 |
|
7697 | try {
|
7698 | elm[key] = cur;
|
7699 | } catch (e) {}
|
7700 | }
|
7701 | }
|
7702 | }
|
7703 |
|
7704 |
|
7705 |
|
7706 |
|
7707 | function shouldUpdateValue (elm, checkVal) {
|
7708 | return (!elm.composing && (
|
7709 | elm.tagName === 'OPTION' ||
|
7710 | isNotInFocusAndDirty(elm, checkVal) ||
|
7711 | isDirtyWithModifiers(elm, checkVal)
|
7712 | ))
|
7713 | }
|
7714 |
|
7715 | function isNotInFocusAndDirty (elm, checkVal) {
|
7716 |
|
7717 |
|
7718 | var notInFocus = true;
|
7719 |
|
7720 |
|
7721 | try { notInFocus = document.activeElement !== elm; } catch (e) {}
|
7722 | return notInFocus && elm.value !== checkVal
|
7723 | }
|
7724 |
|
7725 | function isDirtyWithModifiers (elm, newVal) {
|
7726 | var value = elm.value;
|
7727 | var modifiers = elm._vModifiers;
|
7728 | if (isDef(modifiers)) {
|
7729 | if (modifiers.number) {
|
7730 | return toNumber(value) !== toNumber(newVal)
|
7731 | }
|
7732 | if (modifiers.trim) {
|
7733 | return value.trim() !== newVal.trim()
|
7734 | }
|
7735 | }
|
7736 | return value !== newVal
|
7737 | }
|
7738 |
|
7739 | var domProps = {
|
7740 | create: updateDOMProps,
|
7741 | update: updateDOMProps
|
7742 | };
|
7743 |
|
7744 |
|
7745 |
|
7746 | var parseStyleText = cached(function (cssText) {
|
7747 | var res = {};
|
7748 | var listDelimiter = /;(?![^(]*\))/g;
|
7749 | var propertyDelimiter = /:(.+)/;
|
7750 | cssText.split(listDelimiter).forEach(function (item) {
|
7751 | if (item) {
|
7752 | var tmp = item.split(propertyDelimiter);
|
7753 | tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
7754 | }
|
7755 | });
|
7756 | return res
|
7757 | });
|
7758 |
|
7759 |
|
7760 | function normalizeStyleData (data) {
|
7761 | var style = normalizeStyleBinding(data.style);
|
7762 |
|
7763 |
|
7764 | return data.staticStyle
|
7765 | ? extend(data.staticStyle, style)
|
7766 | : style
|
7767 | }
|
7768 |
|
7769 |
|
7770 | function normalizeStyleBinding (bindingStyle) {
|
7771 | if (Array.isArray(bindingStyle)) {
|
7772 | return toObject(bindingStyle)
|
7773 | }
|
7774 | if (typeof bindingStyle === 'string') {
|
7775 | return parseStyleText(bindingStyle)
|
7776 | }
|
7777 | return bindingStyle
|
7778 | }
|
7779 |
|
7780 |
|
7781 |
|
7782 |
|
7783 |
|
7784 | function getStyle (vnode, checkChild) {
|
7785 | var res = {};
|
7786 | var styleData;
|
7787 |
|
7788 | if (checkChild) {
|
7789 | var childNode = vnode;
|
7790 | while (childNode.componentInstance) {
|
7791 | childNode = childNode.componentInstance._vnode;
|
7792 | if (
|
7793 | childNode && childNode.data &&
|
7794 | (styleData = normalizeStyleData(childNode.data))
|
7795 | ) {
|
7796 | extend(res, styleData);
|
7797 | }
|
7798 | }
|
7799 | }
|
7800 |
|
7801 | if ((styleData = normalizeStyleData(vnode.data))) {
|
7802 | extend(res, styleData);
|
7803 | }
|
7804 |
|
7805 | var parentNode = vnode;
|
7806 | while ((parentNode = parentNode.parent)) {
|
7807 | if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
|
7808 | extend(res, styleData);
|
7809 | }
|
7810 | }
|
7811 | return res
|
7812 | }
|
7813 |
|
7814 |
|
7815 |
|
7816 | var cssVarRE = /^--/;
|
7817 | var importantRE = /\s*!important$/;
|
7818 | var setProp = function (el, name, val) {
|
7819 |
|
7820 | if (cssVarRE.test(name)) {
|
7821 | el.style.setProperty(name, val);
|
7822 | } else if (importantRE.test(val)) {
|
7823 | el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
|
7824 | } else {
|
7825 | var normalizedName = normalize(name);
|
7826 | if (Array.isArray(val)) {
|
7827 |
|
7828 |
|
7829 |
|
7830 | for (var i = 0, len = val.length; i < len; i++) {
|
7831 | el.style[normalizedName] = val[i];
|
7832 | }
|
7833 | } else {
|
7834 | el.style[normalizedName] = val;
|
7835 | }
|
7836 | }
|
7837 | };
|
7838 |
|
7839 | var vendorNames = ['Webkit', 'Moz', 'ms'];
|
7840 |
|
7841 | var emptyStyle;
|
7842 | var normalize = cached(function (prop) {
|
7843 | emptyStyle = emptyStyle || document.createElement('div').style;
|
7844 | prop = camelize(prop);
|
7845 | if (prop !== 'filter' && (prop in emptyStyle)) {
|
7846 | return prop
|
7847 | }
|
7848 | var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
|
7849 | for (var i = 0; i < vendorNames.length; i++) {
|
7850 | var name = vendorNames[i] + capName;
|
7851 | if (name in emptyStyle) {
|
7852 | return name
|
7853 | }
|
7854 | }
|
7855 | });
|
7856 |
|
7857 | function updateStyle (oldVnode, vnode) {
|
7858 | var data = vnode.data;
|
7859 | var oldData = oldVnode.data;
|
7860 |
|
7861 | if (isUndef(data.staticStyle) && isUndef(data.style) &&
|
7862 | isUndef(oldData.staticStyle) && isUndef(oldData.style)
|
7863 | ) {
|
7864 | return
|
7865 | }
|
7866 |
|
7867 | var cur, name;
|
7868 | var el = vnode.elm;
|
7869 | var oldStaticStyle = oldData.staticStyle;
|
7870 | var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
|
7871 |
|
7872 |
|
7873 | var oldStyle = oldStaticStyle || oldStyleBinding;
|
7874 |
|
7875 | var style = normalizeStyleBinding(vnode.data.style) || {};
|
7876 |
|
7877 |
|
7878 |
|
7879 |
|
7880 | vnode.data.normalizedStyle = isDef(style.__ob__)
|
7881 | ? extend({}, style)
|
7882 | : style;
|
7883 |
|
7884 | var newStyle = getStyle(vnode, true);
|
7885 |
|
7886 | for (name in oldStyle) {
|
7887 | if (isUndef(newStyle[name])) {
|
7888 | setProp(el, name, '');
|
7889 | }
|
7890 | }
|
7891 | for (name in newStyle) {
|
7892 | cur = newStyle[name];
|
7893 | if (cur !== oldStyle[name]) {
|
7894 |
|
7895 | setProp(el, name, cur == null ? '' : cur);
|
7896 | }
|
7897 | }
|
7898 | }
|
7899 |
|
7900 | var style = {
|
7901 | create: updateStyle,
|
7902 | update: updateStyle
|
7903 | };
|
7904 |
|
7905 |
|
7906 |
|
7907 | var whitespaceRE = /\s+/;
|
7908 |
|
7909 |
|
7910 |
|
7911 |
|
7912 |
|
7913 | function addClass (el, cls) {
|
7914 |
|
7915 | if (!cls || !(cls = cls.trim())) {
|
7916 | return
|
7917 | }
|
7918 |
|
7919 |
|
7920 | if (el.classList) {
|
7921 | if (cls.indexOf(' ') > -1) {
|
7922 | cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
|
7923 | } else {
|
7924 | el.classList.add(cls);
|
7925 | }
|
7926 | } else {
|
7927 | var cur = " " + (el.getAttribute('class') || '') + " ";
|
7928 | if (cur.indexOf(' ' + cls + ' ') < 0) {
|
7929 | el.setAttribute('class', (cur + cls).trim());
|
7930 | }
|
7931 | }
|
7932 | }
|
7933 |
|
7934 |
|
7935 |
|
7936 |
|
7937 |
|
7938 | function removeClass (el, cls) {
|
7939 |
|
7940 | if (!cls || !(cls = cls.trim())) {
|
7941 | return
|
7942 | }
|
7943 |
|
7944 |
|
7945 | if (el.classList) {
|
7946 | if (cls.indexOf(' ') > -1) {
|
7947 | cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
|
7948 | } else {
|
7949 | el.classList.remove(cls);
|
7950 | }
|
7951 | if (!el.classList.length) {
|
7952 | el.removeAttribute('class');
|
7953 | }
|
7954 | } else {
|
7955 | var cur = " " + (el.getAttribute('class') || '') + " ";
|
7956 | var tar = ' ' + cls + ' ';
|
7957 | while (cur.indexOf(tar) >= 0) {
|
7958 | cur = cur.replace(tar, ' ');
|
7959 | }
|
7960 | cur = cur.trim();
|
7961 | if (cur) {
|
7962 | el.setAttribute('class', cur);
|
7963 | } else {
|
7964 | el.removeAttribute('class');
|
7965 | }
|
7966 | }
|
7967 | }
|
7968 |
|
7969 |
|
7970 |
|
7971 | function resolveTransition (def$$1) {
|
7972 | if (!def$$1) {
|
7973 | return
|
7974 | }
|
7975 |
|
7976 | if (typeof def$$1 === 'object') {
|
7977 | var res = {};
|
7978 | if (def$$1.css !== false) {
|
7979 | extend(res, autoCssTransition(def$$1.name || 'v'));
|
7980 | }
|
7981 | extend(res, def$$1);
|
7982 | return res
|
7983 | } else if (typeof def$$1 === 'string') {
|
7984 | return autoCssTransition(def$$1)
|
7985 | }
|
7986 | }
|
7987 |
|
7988 | var autoCssTransition = cached(function (name) {
|
7989 | return {
|
7990 | enterClass: (name + "-enter"),
|
7991 | enterToClass: (name + "-enter-to"),
|
7992 | enterActiveClass: (name + "-enter-active"),
|
7993 | leaveClass: (name + "-leave"),
|
7994 | leaveToClass: (name + "-leave-to"),
|
7995 | leaveActiveClass: (name + "-leave-active")
|
7996 | }
|
7997 | });
|
7998 |
|
7999 | var hasTransition = inBrowser && !isIE9;
|
8000 | var TRANSITION = 'transition';
|
8001 | var ANIMATION = 'animation';
|
8002 |
|
8003 |
|
8004 | var transitionProp = 'transition';
|
8005 | var transitionEndEvent = 'transitionend';
|
8006 | var animationProp = 'animation';
|
8007 | var animationEndEvent = 'animationend';
|
8008 | if (hasTransition) {
|
8009 |
|
8010 | if (window.ontransitionend === undefined &&
|
8011 | window.onwebkittransitionend !== undefined
|
8012 | ) {
|
8013 | transitionProp = 'WebkitTransition';
|
8014 | transitionEndEvent = 'webkitTransitionEnd';
|
8015 | }
|
8016 | if (window.onanimationend === undefined &&
|
8017 | window.onwebkitanimationend !== undefined
|
8018 | ) {
|
8019 | animationProp = 'WebkitAnimation';
|
8020 | animationEndEvent = 'webkitAnimationEnd';
|
8021 | }
|
8022 | }
|
8023 |
|
8024 |
|
8025 | var raf = inBrowser
|
8026 | ? window.requestAnimationFrame
|
8027 | ? window.requestAnimationFrame.bind(window)
|
8028 | : setTimeout
|
8029 | : function (fn) { return fn(); };
|
8030 |
|
8031 | function nextFrame (fn) {
|
8032 | raf(function () {
|
8033 | raf(fn);
|
8034 | });
|
8035 | }
|
8036 |
|
8037 | function addTransitionClass (el, cls) {
|
8038 | var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
|
8039 | if (transitionClasses.indexOf(cls) < 0) {
|
8040 | transitionClasses.push(cls);
|
8041 | addClass(el, cls);
|
8042 | }
|
8043 | }
|
8044 |
|
8045 | function removeTransitionClass (el, cls) {
|
8046 | if (el._transitionClasses) {
|
8047 | remove(el._transitionClasses, cls);
|
8048 | }
|
8049 | removeClass(el, cls);
|
8050 | }
|
8051 |
|
8052 | function whenTransitionEnds (
|
8053 | el,
|
8054 | expectedType,
|
8055 | cb
|
8056 | ) {
|
8057 | var ref = getTransitionInfo(el, expectedType);
|
8058 | var type = ref.type;
|
8059 | var timeout = ref.timeout;
|
8060 | var propCount = ref.propCount;
|
8061 | if (!type) { return cb() }
|
8062 | var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
|
8063 | var ended = 0;
|
8064 | var end = function () {
|
8065 | el.removeEventListener(event, onEnd);
|
8066 | cb();
|
8067 | };
|
8068 | var onEnd = function (e) {
|
8069 | if (e.target === el) {
|
8070 | if (++ended >= propCount) {
|
8071 | end();
|
8072 | }
|
8073 | }
|
8074 | };
|
8075 | setTimeout(function () {
|
8076 | if (ended < propCount) {
|
8077 | end();
|
8078 | }
|
8079 | }, timeout + 1);
|
8080 | el.addEventListener(event, onEnd);
|
8081 | }
|
8082 |
|
8083 | var transformRE = /\b(transform|all)(,|$)/;
|
8084 |
|
8085 | function getTransitionInfo (el, expectedType) {
|
8086 | var styles = window.getComputedStyle(el);
|
8087 |
|
8088 | var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
|
8089 | var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
|
8090 | var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
8091 | var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
|
8092 | var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
|
8093 | var animationTimeout = getTimeout(animationDelays, animationDurations);
|
8094 |
|
8095 | var type;
|
8096 | var timeout = 0;
|
8097 | var propCount = 0;
|
8098 |
|
8099 | if (expectedType === TRANSITION) {
|
8100 | if (transitionTimeout > 0) {
|
8101 | type = TRANSITION;
|
8102 | timeout = transitionTimeout;
|
8103 | propCount = transitionDurations.length;
|
8104 | }
|
8105 | } else if (expectedType === ANIMATION) {
|
8106 | if (animationTimeout > 0) {
|
8107 | type = ANIMATION;
|
8108 | timeout = animationTimeout;
|
8109 | propCount = animationDurations.length;
|
8110 | }
|
8111 | } else {
|
8112 | timeout = Math.max(transitionTimeout, animationTimeout);
|
8113 | type = timeout > 0
|
8114 | ? transitionTimeout > animationTimeout
|
8115 | ? TRANSITION
|
8116 | : ANIMATION
|
8117 | : null;
|
8118 | propCount = type
|
8119 | ? type === TRANSITION
|
8120 | ? transitionDurations.length
|
8121 | : animationDurations.length
|
8122 | : 0;
|
8123 | }
|
8124 | var hasTransform =
|
8125 | type === TRANSITION &&
|
8126 | transformRE.test(styles[transitionProp + 'Property']);
|
8127 | return {
|
8128 | type: type,
|
8129 | timeout: timeout,
|
8130 | propCount: propCount,
|
8131 | hasTransform: hasTransform
|
8132 | }
|
8133 | }
|
8134 |
|
8135 | function getTimeout (delays, durations) {
|
8136 |
|
8137 | while (delays.length < durations.length) {
|
8138 | delays = delays.concat(delays);
|
8139 | }
|
8140 |
|
8141 | return Math.max.apply(null, durations.map(function (d, i) {
|
8142 | return toMs(d) + toMs(delays[i])
|
8143 | }))
|
8144 | }
|
8145 |
|
8146 |
|
8147 |
|
8148 |
|
8149 |
|
8150 | function toMs (s) {
|
8151 | return Number(s.slice(0, -1).replace(',', '.')) * 1000
|
8152 | }
|
8153 |
|
8154 |
|
8155 |
|
8156 | function enter (vnode, toggleDisplay) {
|
8157 | var el = vnode.elm;
|
8158 |
|
8159 |
|
8160 | if (isDef(el._leaveCb)) {
|
8161 | el._leaveCb.cancelled = true;
|
8162 | el._leaveCb();
|
8163 | }
|
8164 |
|
8165 | var data = resolveTransition(vnode.data.transition);
|
8166 | if (isUndef(data)) {
|
8167 | return
|
8168 | }
|
8169 |
|
8170 |
|
8171 | if (isDef(el._enterCb) || el.nodeType !== 1) {
|
8172 | return
|
8173 | }
|
8174 |
|
8175 | var css = data.css;
|
8176 | var type = data.type;
|
8177 | var enterClass = data.enterClass;
|
8178 | var enterToClass = data.enterToClass;
|
8179 | var enterActiveClass = data.enterActiveClass;
|
8180 | var appearClass = data.appearClass;
|
8181 | var appearToClass = data.appearToClass;
|
8182 | var appearActiveClass = data.appearActiveClass;
|
8183 | var beforeEnter = data.beforeEnter;
|
8184 | var enter = data.enter;
|
8185 | var afterEnter = data.afterEnter;
|
8186 | var enterCancelled = data.enterCancelled;
|
8187 | var beforeAppear = data.beforeAppear;
|
8188 | var appear = data.appear;
|
8189 | var afterAppear = data.afterAppear;
|
8190 | var appearCancelled = data.appearCancelled;
|
8191 | var duration = data.duration;
|
8192 |
|
8193 |
|
8194 |
|
8195 |
|
8196 |
|
8197 | var context = activeInstance;
|
8198 | var transitionNode = activeInstance.$vnode;
|
8199 | while (transitionNode && transitionNode.parent) {
|
8200 | context = transitionNode.context;
|
8201 | transitionNode = transitionNode.parent;
|
8202 | }
|
8203 |
|
8204 | var isAppear = !context._isMounted || !vnode.isRootInsert;
|
8205 |
|
8206 | if (isAppear && !appear && appear !== '') {
|
8207 | return
|
8208 | }
|
8209 |
|
8210 | var startClass = isAppear && appearClass
|
8211 | ? appearClass
|
8212 | : enterClass;
|
8213 | var activeClass = isAppear && appearActiveClass
|
8214 | ? appearActiveClass
|
8215 | : enterActiveClass;
|
8216 | var toClass = isAppear && appearToClass
|
8217 | ? appearToClass
|
8218 | : enterToClass;
|
8219 |
|
8220 | var beforeEnterHook = isAppear
|
8221 | ? (beforeAppear || beforeEnter)
|
8222 | : beforeEnter;
|
8223 | var enterHook = isAppear
|
8224 | ? (typeof appear === 'function' ? appear : enter)
|
8225 | : enter;
|
8226 | var afterEnterHook = isAppear
|
8227 | ? (afterAppear || afterEnter)
|
8228 | : afterEnter;
|
8229 | var enterCancelledHook = isAppear
|
8230 | ? (appearCancelled || enterCancelled)
|
8231 | : enterCancelled;
|
8232 |
|
8233 | var explicitEnterDuration = toNumber(
|
8234 | isObject(duration)
|
8235 | ? duration.enter
|
8236 | : duration
|
8237 | );
|
8238 |
|
8239 | if (explicitEnterDuration != null) {
|
8240 | checkDuration(explicitEnterDuration, 'enter', vnode);
|
8241 | }
|
8242 |
|
8243 | var expectsCSS = css !== false && !isIE9;
|
8244 | var userWantsControl = getHookArgumentsLength(enterHook);
|
8245 |
|
8246 | var cb = el._enterCb = once(function () {
|
8247 | if (expectsCSS) {
|
8248 | removeTransitionClass(el, toClass);
|
8249 | removeTransitionClass(el, activeClass);
|
8250 | }
|
8251 | if (cb.cancelled) {
|
8252 | if (expectsCSS) {
|
8253 | removeTransitionClass(el, startClass);
|
8254 | }
|
8255 | enterCancelledHook && enterCancelledHook(el);
|
8256 | } else {
|
8257 | afterEnterHook && afterEnterHook(el);
|
8258 | }
|
8259 | el._enterCb = null;
|
8260 | });
|
8261 |
|
8262 | if (!vnode.data.show) {
|
8263 |
|
8264 | mergeVNodeHook(vnode, 'insert', function () {
|
8265 | var parent = el.parentNode;
|
8266 | var pendingNode = parent && parent._pending && parent._pending[vnode.key];
|
8267 | if (pendingNode &&
|
8268 | pendingNode.tag === vnode.tag &&
|
8269 | pendingNode.elm._leaveCb
|
8270 | ) {
|
8271 | pendingNode.elm._leaveCb();
|
8272 | }
|
8273 | enterHook && enterHook(el, cb);
|
8274 | });
|
8275 | }
|
8276 |
|
8277 |
|
8278 | beforeEnterHook && beforeEnterHook(el);
|
8279 | if (expectsCSS) {
|
8280 | addTransitionClass(el, startClass);
|
8281 | addTransitionClass(el, activeClass);
|
8282 | nextFrame(function () {
|
8283 | removeTransitionClass(el, startClass);
|
8284 | if (!cb.cancelled) {
|
8285 | addTransitionClass(el, toClass);
|
8286 | if (!userWantsControl) {
|
8287 | if (isValidDuration(explicitEnterDuration)) {
|
8288 | setTimeout(cb, explicitEnterDuration);
|
8289 | } else {
|
8290 | whenTransitionEnds(el, type, cb);
|
8291 | }
|
8292 | }
|
8293 | }
|
8294 | });
|
8295 | }
|
8296 |
|
8297 | if (vnode.data.show) {
|
8298 | toggleDisplay && toggleDisplay();
|
8299 | enterHook && enterHook(el, cb);
|
8300 | }
|
8301 |
|
8302 | if (!expectsCSS && !userWantsControl) {
|
8303 | cb();
|
8304 | }
|
8305 | }
|
8306 |
|
8307 | function leave (vnode, rm) {
|
8308 | var el = vnode.elm;
|
8309 |
|
8310 |
|
8311 | if (isDef(el._enterCb)) {
|
8312 | el._enterCb.cancelled = true;
|
8313 | el._enterCb();
|
8314 | }
|
8315 |
|
8316 | var data = resolveTransition(vnode.data.transition);
|
8317 | if (isUndef(data) || el.nodeType !== 1) {
|
8318 | return rm()
|
8319 | }
|
8320 |
|
8321 |
|
8322 | if (isDef(el._leaveCb)) {
|
8323 | return
|
8324 | }
|
8325 |
|
8326 | var css = data.css;
|
8327 | var type = data.type;
|
8328 | var leaveClass = data.leaveClass;
|
8329 | var leaveToClass = data.leaveToClass;
|
8330 | var leaveActiveClass = data.leaveActiveClass;
|
8331 | var beforeLeave = data.beforeLeave;
|
8332 | var leave = data.leave;
|
8333 | var afterLeave = data.afterLeave;
|
8334 | var leaveCancelled = data.leaveCancelled;
|
8335 | var delayLeave = data.delayLeave;
|
8336 | var duration = data.duration;
|
8337 |
|
8338 | var expectsCSS = css !== false && !isIE9;
|
8339 | var userWantsControl = getHookArgumentsLength(leave);
|
8340 |
|
8341 | var explicitLeaveDuration = toNumber(
|
8342 | isObject(duration)
|
8343 | ? duration.leave
|
8344 | : duration
|
8345 | );
|
8346 |
|
8347 | if (isDef(explicitLeaveDuration)) {
|
8348 | checkDuration(explicitLeaveDuration, 'leave', vnode);
|
8349 | }
|
8350 |
|
8351 | var cb = el._leaveCb = once(function () {
|
8352 | if (el.parentNode && el.parentNode._pending) {
|
8353 | el.parentNode._pending[vnode.key] = null;
|
8354 | }
|
8355 | if (expectsCSS) {
|
8356 | removeTransitionClass(el, leaveToClass);
|
8357 | removeTransitionClass(el, leaveActiveClass);
|
8358 | }
|
8359 | if (cb.cancelled) {
|
8360 | if (expectsCSS) {
|
8361 | removeTransitionClass(el, leaveClass);
|
8362 | }
|
8363 | leaveCancelled && leaveCancelled(el);
|
8364 | } else {
|
8365 | rm();
|
8366 | afterLeave && afterLeave(el);
|
8367 | }
|
8368 | el._leaveCb = null;
|
8369 | });
|
8370 |
|
8371 | if (delayLeave) {
|
8372 | delayLeave(performLeave);
|
8373 | } else {
|
8374 | performLeave();
|
8375 | }
|
8376 |
|
8377 | function performLeave () {
|
8378 |
|
8379 | if (cb.cancelled) {
|
8380 | return
|
8381 | }
|
8382 |
|
8383 | if (!vnode.data.show && el.parentNode) {
|
8384 | (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
|
8385 | }
|
8386 | beforeLeave && beforeLeave(el);
|
8387 | if (expectsCSS) {
|
8388 | addTransitionClass(el, leaveClass);
|
8389 | addTransitionClass(el, leaveActiveClass);
|
8390 | nextFrame(function () {
|
8391 | removeTransitionClass(el, leaveClass);
|
8392 | if (!cb.cancelled) {
|
8393 | addTransitionClass(el, leaveToClass);
|
8394 | if (!userWantsControl) {
|
8395 | if (isValidDuration(explicitLeaveDuration)) {
|
8396 | setTimeout(cb, explicitLeaveDuration);
|
8397 | } else {
|
8398 | whenTransitionEnds(el, type, cb);
|
8399 | }
|
8400 | }
|
8401 | }
|
8402 | });
|
8403 | }
|
8404 | leave && leave(el, cb);
|
8405 | if (!expectsCSS && !userWantsControl) {
|
8406 | cb();
|
8407 | }
|
8408 | }
|
8409 | }
|
8410 |
|
8411 |
|
8412 | function checkDuration (val, name, vnode) {
|
8413 | if (typeof val !== 'number') {
|
8414 | warn(
|
8415 | "<transition> explicit " + name + " duration is not a valid number - " +
|
8416 | "got " + (JSON.stringify(val)) + ".",
|
8417 | vnode.context
|
8418 | );
|
8419 | } else if (isNaN(val)) {
|
8420 | warn(
|
8421 | "<transition> explicit " + name + " duration is NaN - " +
|
8422 | 'the duration expression might be incorrect.',
|
8423 | vnode.context
|
8424 | );
|
8425 | }
|
8426 | }
|
8427 |
|
8428 | function isValidDuration (val) {
|
8429 | return typeof val === 'number' && !isNaN(val)
|
8430 | }
|
8431 |
|
8432 |
|
8433 |
|
8434 |
|
8435 |
|
8436 |
|
8437 |
|
8438 | function getHookArgumentsLength (fn) {
|
8439 | if (isUndef(fn)) {
|
8440 | return false
|
8441 | }
|
8442 | var invokerFns = fn.fns;
|
8443 | if (isDef(invokerFns)) {
|
8444 |
|
8445 | return getHookArgumentsLength(
|
8446 | Array.isArray(invokerFns)
|
8447 | ? invokerFns[0]
|
8448 | : invokerFns
|
8449 | )
|
8450 | } else {
|
8451 | return (fn._length || fn.length) > 1
|
8452 | }
|
8453 | }
|
8454 |
|
8455 | function _enter (_, vnode) {
|
8456 | if (vnode.data.show !== true) {
|
8457 | enter(vnode);
|
8458 | }
|
8459 | }
|
8460 |
|
8461 | var transition = inBrowser ? {
|
8462 | create: _enter,
|
8463 | activate: _enter,
|
8464 | remove: function remove$$1 (vnode, rm) {
|
8465 |
|
8466 | if (vnode.data.show !== true) {
|
8467 | leave(vnode, rm);
|
8468 | } else {
|
8469 | rm();
|
8470 | }
|
8471 | }
|
8472 | } : {};
|
8473 |
|
8474 | var platformModules = [
|
8475 | attrs,
|
8476 | klass,
|
8477 | events,
|
8478 | domProps,
|
8479 | style,
|
8480 | transition
|
8481 | ];
|
8482 |
|
8483 |
|
8484 |
|
8485 |
|
8486 |
|
8487 | var modules = platformModules.concat(baseModules);
|
8488 |
|
8489 | var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
|
8490 |
|
8491 |
|
8492 |
|
8493 |
|
8494 |
|
8495 |
|
8496 |
|
8497 | if (isIE9) {
|
8498 |
|
8499 | document.addEventListener('selectionchange', function () {
|
8500 | var el = document.activeElement;
|
8501 | if (el && el.vmodel) {
|
8502 | trigger(el, 'input');
|
8503 | }
|
8504 | });
|
8505 | }
|
8506 |
|
8507 | var directive = {
|
8508 | inserted: function inserted (el, binding, vnode, oldVnode) {
|
8509 | if (vnode.tag === 'select') {
|
8510 |
|
8511 | if (oldVnode.elm && !oldVnode.elm._vOptions) {
|
8512 | mergeVNodeHook(vnode, 'postpatch', function () {
|
8513 | directive.componentUpdated(el, binding, vnode);
|
8514 | });
|
8515 | } else {
|
8516 | setSelected(el, binding, vnode.context);
|
8517 | }
|
8518 | el._vOptions = [].map.call(el.options, getValue);
|
8519 | } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
|
8520 | el._vModifiers = binding.modifiers;
|
8521 | if (!binding.modifiers.lazy) {
|
8522 | el.addEventListener('compositionstart', onCompositionStart);
|
8523 | el.addEventListener('compositionend', onCompositionEnd);
|
8524 |
|
8525 |
|
8526 |
|
8527 |
|
8528 | el.addEventListener('change', onCompositionEnd);
|
8529 |
|
8530 | if (isIE9) {
|
8531 | el.vmodel = true;
|
8532 | }
|
8533 | }
|
8534 | }
|
8535 | },
|
8536 |
|
8537 | componentUpdated: function componentUpdated (el, binding, vnode) {
|
8538 | if (vnode.tag === 'select') {
|
8539 | setSelected(el, binding, vnode.context);
|
8540 |
|
8541 |
|
8542 |
|
8543 |
|
8544 | var prevOptions = el._vOptions;
|
8545 | var curOptions = el._vOptions = [].map.call(el.options, getValue);
|
8546 | if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
|
8547 |
|
8548 |
|
8549 | var needReset = el.multiple
|
8550 | ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
|
8551 | : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
|
8552 | if (needReset) {
|
8553 | trigger(el, 'change');
|
8554 | }
|
8555 | }
|
8556 | }
|
8557 | }
|
8558 | };
|
8559 |
|
8560 | function setSelected (el, binding, vm) {
|
8561 | actuallySetSelected(el, binding, vm);
|
8562 |
|
8563 | if (isIE || isEdge) {
|
8564 | setTimeout(function () {
|
8565 | actuallySetSelected(el, binding, vm);
|
8566 | }, 0);
|
8567 | }
|
8568 | }
|
8569 |
|
8570 | function actuallySetSelected (el, binding, vm) {
|
8571 | var value = binding.value;
|
8572 | var isMultiple = el.multiple;
|
8573 | if (isMultiple && !Array.isArray(value)) {
|
8574 | warn(
|
8575 | "<select multiple v-model=\"" + (binding.expression) + "\"> " +
|
8576 | "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
|
8577 | vm
|
8578 | );
|
8579 | return
|
8580 | }
|
8581 | var selected, option;
|
8582 | for (var i = 0, l = el.options.length; i < l; i++) {
|
8583 | option = el.options[i];
|
8584 | if (isMultiple) {
|
8585 | selected = looseIndexOf(value, getValue(option)) > -1;
|
8586 | if (option.selected !== selected) {
|
8587 | option.selected = selected;
|
8588 | }
|
8589 | } else {
|
8590 | if (looseEqual(getValue(option), value)) {
|
8591 | if (el.selectedIndex !== i) {
|
8592 | el.selectedIndex = i;
|
8593 | }
|
8594 | return
|
8595 | }
|
8596 | }
|
8597 | }
|
8598 | if (!isMultiple) {
|
8599 | el.selectedIndex = -1;
|
8600 | }
|
8601 | }
|
8602 |
|
8603 | function hasNoMatchingOption (value, options) {
|
8604 | return options.every(function (o) { return !looseEqual(o, value); })
|
8605 | }
|
8606 |
|
8607 | function getValue (option) {
|
8608 | return '_value' in option
|
8609 | ? option._value
|
8610 | : option.value
|
8611 | }
|
8612 |
|
8613 | function onCompositionStart (e) {
|
8614 | e.target.composing = true;
|
8615 | }
|
8616 |
|
8617 | function onCompositionEnd (e) {
|
8618 |
|
8619 | if (!e.target.composing) { return }
|
8620 | e.target.composing = false;
|
8621 | trigger(e.target, 'input');
|
8622 | }
|
8623 |
|
8624 | function trigger (el, type) {
|
8625 | var e = document.createEvent('HTMLEvents');
|
8626 | e.initEvent(type, true, true);
|
8627 | el.dispatchEvent(e);
|
8628 | }
|
8629 |
|
8630 |
|
8631 |
|
8632 |
|
8633 | function locateNode (vnode) {
|
8634 | return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
|
8635 | ? locateNode(vnode.componentInstance._vnode)
|
8636 | : vnode
|
8637 | }
|
8638 |
|
8639 | var show = {
|
8640 | bind: function bind (el, ref, vnode) {
|
8641 | var value = ref.value;
|
8642 |
|
8643 | vnode = locateNode(vnode);
|
8644 | var transition$$1 = vnode.data && vnode.data.transition;
|
8645 | var originalDisplay = el.__vOriginalDisplay =
|
8646 | el.style.display === 'none' ? '' : el.style.display;
|
8647 | if (value && transition$$1) {
|
8648 | vnode.data.show = true;
|
8649 | enter(vnode, function () {
|
8650 | el.style.display = originalDisplay;
|
8651 | });
|
8652 | } else {
|
8653 | el.style.display = value ? originalDisplay : 'none';
|
8654 | }
|
8655 | },
|
8656 |
|
8657 | update: function update (el, ref, vnode) {
|
8658 | var value = ref.value;
|
8659 | var oldValue = ref.oldValue;
|
8660 |
|
8661 |
|
8662 | if (!value === !oldValue) { return }
|
8663 | vnode = locateNode(vnode);
|
8664 | var transition$$1 = vnode.data && vnode.data.transition;
|
8665 | if (transition$$1) {
|
8666 | vnode.data.show = true;
|
8667 | if (value) {
|
8668 | enter(vnode, function () {
|
8669 | el.style.display = el.__vOriginalDisplay;
|
8670 | });
|
8671 | } else {
|
8672 | leave(vnode, function () {
|
8673 | el.style.display = 'none';
|
8674 | });
|
8675 | }
|
8676 | } else {
|
8677 | el.style.display = value ? el.__vOriginalDisplay : 'none';
|
8678 | }
|
8679 | },
|
8680 |
|
8681 | unbind: function unbind (
|
8682 | el,
|
8683 | binding,
|
8684 | vnode,
|
8685 | oldVnode,
|
8686 | isDestroy
|
8687 | ) {
|
8688 | if (!isDestroy) {
|
8689 | el.style.display = el.__vOriginalDisplay;
|
8690 | }
|
8691 | }
|
8692 | };
|
8693 |
|
8694 | var platformDirectives = {
|
8695 | model: directive,
|
8696 | show: show
|
8697 | };
|
8698 |
|
8699 |
|
8700 |
|
8701 | var transitionProps = {
|
8702 | name: String,
|
8703 | appear: Boolean,
|
8704 | css: Boolean,
|
8705 | mode: String,
|
8706 | type: String,
|
8707 | enterClass: String,
|
8708 | leaveClass: String,
|
8709 | enterToClass: String,
|
8710 | leaveToClass: String,
|
8711 | enterActiveClass: String,
|
8712 | leaveActiveClass: String,
|
8713 | appearClass: String,
|
8714 | appearActiveClass: String,
|
8715 | appearToClass: String,
|
8716 | duration: [Number, String, Object]
|
8717 | };
|
8718 |
|
8719 |
|
8720 |
|
8721 | function getRealChild (vnode) {
|
8722 | var compOptions = vnode && vnode.componentOptions;
|
8723 | if (compOptions && compOptions.Ctor.options.abstract) {
|
8724 | return getRealChild(getFirstComponentChild(compOptions.children))
|
8725 | } else {
|
8726 | return vnode
|
8727 | }
|
8728 | }
|
8729 |
|
8730 | function extractTransitionData (comp) {
|
8731 | var data = {};
|
8732 | var options = comp.$options;
|
8733 |
|
8734 | for (var key in options.propsData) {
|
8735 | data[key] = comp[key];
|
8736 | }
|
8737 |
|
8738 |
|
8739 | var listeners = options._parentListeners;
|
8740 | for (var key$1 in listeners) {
|
8741 | data[camelize(key$1)] = listeners[key$1];
|
8742 | }
|
8743 | return data
|
8744 | }
|
8745 |
|
8746 | function placeholder (h, rawChild) {
|
8747 | if (/\d-keep-alive$/.test(rawChild.tag)) {
|
8748 | return h('keep-alive', {
|
8749 | props: rawChild.componentOptions.propsData
|
8750 | })
|
8751 | }
|
8752 | }
|
8753 |
|
8754 | function hasParentTransition (vnode) {
|
8755 | while ((vnode = vnode.parent)) {
|
8756 | if (vnode.data.transition) {
|
8757 | return true
|
8758 | }
|
8759 | }
|
8760 | }
|
8761 |
|
8762 | function isSameChild (child, oldChild) {
|
8763 | return oldChild.key === child.key && oldChild.tag === child.tag
|
8764 | }
|
8765 |
|
8766 | var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
|
8767 |
|
8768 | var isVShowDirective = function (d) { return d.name === 'show'; };
|
8769 |
|
8770 | var Transition = {
|
8771 | name: 'transition',
|
8772 | props: transitionProps,
|
8773 | abstract: true,
|
8774 |
|
8775 | render: function render (h) {
|
8776 | var this$1 = this;
|
8777 |
|
8778 | var children = this.$slots.default;
|
8779 | if (!children) {
|
8780 | return
|
8781 | }
|
8782 |
|
8783 |
|
8784 | children = children.filter(isNotTextNode);
|
8785 |
|
8786 | if (!children.length) {
|
8787 | return
|
8788 | }
|
8789 |
|
8790 |
|
8791 | if (children.length > 1) {
|
8792 | warn(
|
8793 | '<transition> can only be used on a single element. Use ' +
|
8794 | '<transition-group> for lists.',
|
8795 | this.$parent
|
8796 | );
|
8797 | }
|
8798 |
|
8799 | var mode = this.mode;
|
8800 |
|
8801 |
|
8802 | if (mode && mode !== 'in-out' && mode !== 'out-in'
|
8803 | ) {
|
8804 | warn(
|
8805 | 'invalid <transition> mode: ' + mode,
|
8806 | this.$parent
|
8807 | );
|
8808 | }
|
8809 |
|
8810 | var rawChild = children[0];
|
8811 |
|
8812 |
|
8813 |
|
8814 | if (hasParentTransition(this.$vnode)) {
|
8815 | return rawChild
|
8816 | }
|
8817 |
|
8818 |
|
8819 |
|
8820 | var child = getRealChild(rawChild);
|
8821 |
|
8822 | if (!child) {
|
8823 | return rawChild
|
8824 | }
|
8825 |
|
8826 | if (this._leaving) {
|
8827 | return placeholder(h, rawChild)
|
8828 | }
|
8829 |
|
8830 |
|
8831 |
|
8832 |
|
8833 | var id = "__transition-" + (this._uid) + "-";
|
8834 | child.key = child.key == null
|
8835 | ? child.isComment
|
8836 | ? id + 'comment'
|
8837 | : id + child.tag
|
8838 | : isPrimitive(child.key)
|
8839 | ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
|
8840 | : child.key;
|
8841 |
|
8842 | var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
|
8843 | var oldRawChild = this._vnode;
|
8844 | var oldChild = getRealChild(oldRawChild);
|
8845 |
|
8846 |
|
8847 |
|
8848 | if (child.data.directives && child.data.directives.some(isVShowDirective)) {
|
8849 | child.data.show = true;
|
8850 | }
|
8851 |
|
8852 | if (
|
8853 | oldChild &&
|
8854 | oldChild.data &&
|
8855 | !isSameChild(child, oldChild) &&
|
8856 | !isAsyncPlaceholder(oldChild) &&
|
8857 |
|
8858 | !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
|
8859 | ) {
|
8860 |
|
8861 |
|
8862 | var oldData = oldChild.data.transition = extend({}, data);
|
8863 |
|
8864 | if (mode === 'out-in') {
|
8865 |
|
8866 | this._leaving = true;
|
8867 | mergeVNodeHook(oldData, 'afterLeave', function () {
|
8868 | this$1._leaving = false;
|
8869 | this$1.$forceUpdate();
|
8870 | });
|
8871 | return placeholder(h, rawChild)
|
8872 | } else if (mode === 'in-out') {
|
8873 | if (isAsyncPlaceholder(child)) {
|
8874 | return oldRawChild
|
8875 | }
|
8876 | var delayedLeave;
|
8877 | var performLeave = function () { delayedLeave(); };
|
8878 | mergeVNodeHook(data, 'afterEnter', performLeave);
|
8879 | mergeVNodeHook(data, 'enterCancelled', performLeave);
|
8880 | mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
|
8881 | }
|
8882 | }
|
8883 |
|
8884 | return rawChild
|
8885 | }
|
8886 | };
|
8887 |
|
8888 |
|
8889 |
|
8890 | var props = extend({
|
8891 | tag: String,
|
8892 | moveClass: String
|
8893 | }, transitionProps);
|
8894 |
|
8895 | delete props.mode;
|
8896 |
|
8897 | var TransitionGroup = {
|
8898 | props: props,
|
8899 |
|
8900 | beforeMount: function beforeMount () {
|
8901 | var this$1 = this;
|
8902 |
|
8903 | var update = this._update;
|
8904 | this._update = function (vnode, hydrating) {
|
8905 | var restoreActiveInstance = setActiveInstance(this$1);
|
8906 |
|
8907 | this$1.__patch__(
|
8908 | this$1._vnode,
|
8909 | this$1.kept,
|
8910 | false,
|
8911 | true
|
8912 | );
|
8913 | this$1._vnode = this$1.kept;
|
8914 | restoreActiveInstance();
|
8915 | update.call(this$1, vnode, hydrating);
|
8916 | };
|
8917 | },
|
8918 |
|
8919 | render: function render (h) {
|
8920 | var tag = this.tag || this.$vnode.data.tag || 'span';
|
8921 | var map = Object.create(null);
|
8922 | var prevChildren = this.prevChildren = this.children;
|
8923 | var rawChildren = this.$slots.default || [];
|
8924 | var children = this.children = [];
|
8925 | var transitionData = extractTransitionData(this);
|
8926 |
|
8927 | for (var i = 0; i < rawChildren.length; i++) {
|
8928 | var c = rawChildren[i];
|
8929 | if (c.tag) {
|
8930 | if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
|
8931 | children.push(c);
|
8932 | map[c.key] = c
|
8933 | ;(c.data || (c.data = {})).transition = transitionData;
|
8934 | } else {
|
8935 | var opts = c.componentOptions;
|
8936 | var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
|
8937 | warn(("<transition-group> children must be keyed: <" + name + ">"));
|
8938 | }
|
8939 | }
|
8940 | }
|
8941 |
|
8942 | if (prevChildren) {
|
8943 | var kept = [];
|
8944 | var removed = [];
|
8945 | for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
|
8946 | var c$1 = prevChildren[i$1];
|
8947 | c$1.data.transition = transitionData;
|
8948 | c$1.data.pos = c$1.elm.getBoundingClientRect();
|
8949 | if (map[c$1.key]) {
|
8950 | kept.push(c$1);
|
8951 | } else {
|
8952 | removed.push(c$1);
|
8953 | }
|
8954 | }
|
8955 | this.kept = h(tag, null, kept);
|
8956 | this.removed = removed;
|
8957 | }
|
8958 |
|
8959 | return h(tag, null, children)
|
8960 | },
|
8961 |
|
8962 | updated: function updated () {
|
8963 | var children = this.prevChildren;
|
8964 | var moveClass = this.moveClass || ((this.name || 'v') + '-move');
|
8965 | if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
|
8966 | return
|
8967 | }
|
8968 |
|
8969 |
|
8970 |
|
8971 | children.forEach(callPendingCbs);
|
8972 | children.forEach(recordPosition);
|
8973 | children.forEach(applyTranslation);
|
8974 |
|
8975 |
|
8976 |
|
8977 |
|
8978 | this._reflow = document.body.offsetHeight;
|
8979 |
|
8980 | children.forEach(function (c) {
|
8981 | if (c.data.moved) {
|
8982 | var el = c.elm;
|
8983 | var s = el.style;
|
8984 | addTransitionClass(el, moveClass);
|
8985 | s.transform = s.WebkitTransform = s.transitionDuration = '';
|
8986 | el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
|
8987 | if (e && e.target !== el) {
|
8988 | return
|
8989 | }
|
8990 | if (!e || /transform$/.test(e.propertyName)) {
|
8991 | el.removeEventListener(transitionEndEvent, cb);
|
8992 | el._moveCb = null;
|
8993 | removeTransitionClass(el, moveClass);
|
8994 | }
|
8995 | });
|
8996 | }
|
8997 | });
|
8998 | },
|
8999 |
|
9000 | methods: {
|
9001 | hasMove: function hasMove (el, moveClass) {
|
9002 |
|
9003 | if (!hasTransition) {
|
9004 | return false
|
9005 | }
|
9006 |
|
9007 | if (this._hasMove) {
|
9008 | return this._hasMove
|
9009 | }
|
9010 |
|
9011 |
|
9012 |
|
9013 |
|
9014 |
|
9015 | var clone = el.cloneNode();
|
9016 | if (el._transitionClasses) {
|
9017 | el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
|
9018 | }
|
9019 | addClass(clone, moveClass);
|
9020 | clone.style.display = 'none';
|
9021 | this.$el.appendChild(clone);
|
9022 | var info = getTransitionInfo(clone);
|
9023 | this.$el.removeChild(clone);
|
9024 | return (this._hasMove = info.hasTransform)
|
9025 | }
|
9026 | }
|
9027 | };
|
9028 |
|
9029 | function callPendingCbs (c) {
|
9030 |
|
9031 | if (c.elm._moveCb) {
|
9032 | c.elm._moveCb();
|
9033 | }
|
9034 |
|
9035 | if (c.elm._enterCb) {
|
9036 | c.elm._enterCb();
|
9037 | }
|
9038 | }
|
9039 |
|
9040 | function recordPosition (c) {
|
9041 | c.data.newPos = c.elm.getBoundingClientRect();
|
9042 | }
|
9043 |
|
9044 | function applyTranslation (c) {
|
9045 | var oldPos = c.data.pos;
|
9046 | var newPos = c.data.newPos;
|
9047 | var dx = oldPos.left - newPos.left;
|
9048 | var dy = oldPos.top - newPos.top;
|
9049 | if (dx || dy) {
|
9050 | c.data.moved = true;
|
9051 | var s = c.elm.style;
|
9052 | s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
|
9053 | s.transitionDuration = '0s';
|
9054 | }
|
9055 | }
|
9056 |
|
9057 | var platformComponents = {
|
9058 | Transition: Transition,
|
9059 | TransitionGroup: TransitionGroup
|
9060 | };
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 | Vue.config.mustUseProp = mustUseProp;
|
9066 | Vue.config.isReservedTag = isReservedTag;
|
9067 | Vue.config.isReservedAttr = isReservedAttr;
|
9068 | Vue.config.getTagNamespace = getTagNamespace;
|
9069 | Vue.config.isUnknownElement = isUnknownElement;
|
9070 |
|
9071 |
|
9072 | extend(Vue.options.directives, platformDirectives);
|
9073 | extend(Vue.options.components, platformComponents);
|
9074 |
|
9075 |
|
9076 | Vue.prototype.__patch__ = inBrowser ? patch : noop;
|
9077 |
|
9078 |
|
9079 | Vue.prototype.$mount = function (
|
9080 | el,
|
9081 | hydrating
|
9082 | ) {
|
9083 | el = el && inBrowser ? query(el) : undefined;
|
9084 | return mountComponent(this, el, hydrating)
|
9085 | };
|
9086 |
|
9087 |
|
9088 |
|
9089 | if (inBrowser) {
|
9090 | setTimeout(function () {
|
9091 | if (config.devtools) {
|
9092 | if (devtools) {
|
9093 | devtools.emit('init', Vue);
|
9094 | } else {
|
9095 | console[console.info ? 'info' : 'log'](
|
9096 | 'Download the Vue Devtools extension for a better development experience:\n' +
|
9097 | 'https://github.com/vuejs/vue-devtools'
|
9098 | );
|
9099 | }
|
9100 | }
|
9101 | if (config.productionTip !== false &&
|
9102 | typeof console !== 'undefined'
|
9103 | ) {
|
9104 | console[console.info ? 'info' : 'log'](
|
9105 | "You are running Vue in development mode.\n" +
|
9106 | "Make sure to turn on production mode when deploying for production.\n" +
|
9107 | "See more tips at https://vuejs.org/guide/deployment.html"
|
9108 | );
|
9109 | }
|
9110 | }, 0);
|
9111 | }
|
9112 |
|
9113 |
|
9114 |
|
9115 | var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
|
9116 | var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
|
9117 |
|
9118 | var buildRegex = cached(function (delimiters) {
|
9119 | var open = delimiters[0].replace(regexEscapeRE, '\\$&');
|
9120 | var close = delimiters[1].replace(regexEscapeRE, '\\$&');
|
9121 | return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
|
9122 | });
|
9123 |
|
9124 |
|
9125 |
|
9126 | function parseText (
|
9127 | text,
|
9128 | delimiters
|
9129 | ) {
|
9130 | var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
|
9131 | if (!tagRE.test(text)) {
|
9132 | return
|
9133 | }
|
9134 | var tokens = [];
|
9135 | var rawTokens = [];
|
9136 | var lastIndex = tagRE.lastIndex = 0;
|
9137 | var match, index, tokenValue;
|
9138 | while ((match = tagRE.exec(text))) {
|
9139 | index = match.index;
|
9140 |
|
9141 | if (index > lastIndex) {
|
9142 | rawTokens.push(tokenValue = text.slice(lastIndex, index));
|
9143 | tokens.push(JSON.stringify(tokenValue));
|
9144 | }
|
9145 |
|
9146 | var exp = parseFilters(match[1].trim());
|
9147 | tokens.push(("_s(" + exp + ")"));
|
9148 | rawTokens.push({ '@binding': exp });
|
9149 | lastIndex = index + match[0].length;
|
9150 | }
|
9151 | if (lastIndex < text.length) {
|
9152 | rawTokens.push(tokenValue = text.slice(lastIndex));
|
9153 | tokens.push(JSON.stringify(tokenValue));
|
9154 | }
|
9155 | return {
|
9156 | expression: tokens.join('+'),
|
9157 | tokens: rawTokens
|
9158 | }
|
9159 | }
|
9160 |
|
9161 |
|
9162 |
|
9163 | function transformNode (el, options) {
|
9164 | var warn = options.warn || baseWarn;
|
9165 | var staticClass = getAndRemoveAttr(el, 'class');
|
9166 | if (staticClass) {
|
9167 | var res = parseText(staticClass, options.delimiters);
|
9168 | if (res) {
|
9169 | warn(
|
9170 | "class=\"" + staticClass + "\": " +
|
9171 | 'Interpolation inside attributes has been removed. ' +
|
9172 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
9173 | 'instead of <div class="{{ val }}">, use <div :class="val">.',
|
9174 | el.rawAttrsMap['class']
|
9175 | );
|
9176 | }
|
9177 | }
|
9178 | if (staticClass) {
|
9179 | el.staticClass = JSON.stringify(staticClass);
|
9180 | }
|
9181 | var classBinding = getBindingAttr(el, 'class', false );
|
9182 | if (classBinding) {
|
9183 | el.classBinding = classBinding;
|
9184 | }
|
9185 | }
|
9186 |
|
9187 | function genData (el) {
|
9188 | var data = '';
|
9189 | if (el.staticClass) {
|
9190 | data += "staticClass:" + (el.staticClass) + ",";
|
9191 | }
|
9192 | if (el.classBinding) {
|
9193 | data += "class:" + (el.classBinding) + ",";
|
9194 | }
|
9195 | return data
|
9196 | }
|
9197 |
|
9198 | var klass$1 = {
|
9199 | staticKeys: ['staticClass'],
|
9200 | transformNode: transformNode,
|
9201 | genData: genData
|
9202 | };
|
9203 |
|
9204 |
|
9205 |
|
9206 | function transformNode$1 (el, options) {
|
9207 | var warn = options.warn || baseWarn;
|
9208 | var staticStyle = getAndRemoveAttr(el, 'style');
|
9209 | if (staticStyle) {
|
9210 |
|
9211 | {
|
9212 | var res = parseText(staticStyle, options.delimiters);
|
9213 | if (res) {
|
9214 | warn(
|
9215 | "style=\"" + staticStyle + "\": " +
|
9216 | 'Interpolation inside attributes has been removed. ' +
|
9217 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
9218 | 'instead of <div style="{{ val }}">, use <div :style="val">.',
|
9219 | el.rawAttrsMap['style']
|
9220 | );
|
9221 | }
|
9222 | }
|
9223 | el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
|
9224 | }
|
9225 |
|
9226 | var styleBinding = getBindingAttr(el, 'style', false );
|
9227 | if (styleBinding) {
|
9228 | el.styleBinding = styleBinding;
|
9229 | }
|
9230 | }
|
9231 |
|
9232 | function genData$1 (el) {
|
9233 | var data = '';
|
9234 | if (el.staticStyle) {
|
9235 | data += "staticStyle:" + (el.staticStyle) + ",";
|
9236 | }
|
9237 | if (el.styleBinding) {
|
9238 | data += "style:(" + (el.styleBinding) + "),";
|
9239 | }
|
9240 | return data
|
9241 | }
|
9242 |
|
9243 | var style$1 = {
|
9244 | staticKeys: ['staticStyle'],
|
9245 | transformNode: transformNode$1,
|
9246 | genData: genData$1
|
9247 | };
|
9248 |
|
9249 |
|
9250 |
|
9251 | var decoder;
|
9252 |
|
9253 | var he = {
|
9254 | decode: function decode (html) {
|
9255 | decoder = decoder || document.createElement('div');
|
9256 | decoder.innerHTML = html;
|
9257 | return decoder.textContent
|
9258 | }
|
9259 | };
|
9260 |
|
9261 |
|
9262 |
|
9263 | var isUnaryTag = makeMap(
|
9264 | 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
|
9265 | 'link,meta,param,source,track,wbr'
|
9266 | );
|
9267 |
|
9268 |
|
9269 |
|
9270 | var canBeLeftOpenTag = makeMap(
|
9271 | 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
|
9272 | );
|
9273 |
|
9274 |
|
9275 |
|
9276 | var isNonPhrasingTag = makeMap(
|
9277 | 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
|
9278 | 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
|
9279 | 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
|
9280 | 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
|
9281 | 'title,tr,track'
|
9282 | );
|
9283 |
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 |
|
9289 | var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
9290 | var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
9291 | var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
|
9292 | var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
|
9293 | var startTagOpen = new RegExp(("^<" + qnameCapture));
|
9294 | var startTagClose = /^\s*(\/?)>/;
|
9295 | var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
|
9296 | var doctype = /^<!DOCTYPE [^>]+>/i;
|
9297 |
|
9298 | var comment = /^<!\--/;
|
9299 | var conditionalComment = /^<!\[/;
|
9300 |
|
9301 |
|
9302 | var isPlainTextElement = makeMap('script,style,textarea', true);
|
9303 | var reCache = {};
|
9304 |
|
9305 | var decodingMap = {
|
9306 | '<': '<',
|
9307 | '>': '>',
|
9308 | '"': '"',
|
9309 | '&': '&',
|
9310 | ' ': '\n',
|
9311 | '	': '\t',
|
9312 | ''': "'"
|
9313 | };
|
9314 | var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
|
9315 | var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
|
9316 |
|
9317 |
|
9318 | var isIgnoreNewlineTag = makeMap('pre,textarea', true);
|
9319 | var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
|
9320 |
|
9321 | function decodeAttr (value, shouldDecodeNewlines) {
|
9322 | var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
|
9323 | return value.replace(re, function (match) { return decodingMap[match]; })
|
9324 | }
|
9325 |
|
9326 | function parseHTML (html, options) {
|
9327 | var stack = [];
|
9328 | var expectHTML = options.expectHTML;
|
9329 | var isUnaryTag$$1 = options.isUnaryTag || no;
|
9330 | var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
|
9331 | var index = 0;
|
9332 | var last, lastTag;
|
9333 | while (html) {
|
9334 | last = html;
|
9335 |
|
9336 | if (!lastTag || !isPlainTextElement(lastTag)) {
|
9337 | var textEnd = html.indexOf('<');
|
9338 | if (textEnd === 0) {
|
9339 |
|
9340 | if (comment.test(html)) {
|
9341 | var commentEnd = html.indexOf('-->');
|
9342 |
|
9343 | if (commentEnd >= 0) {
|
9344 | if (options.shouldKeepComment) {
|
9345 | options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
|
9346 | }
|
9347 | advance(commentEnd + 3);
|
9348 | continue
|
9349 | }
|
9350 | }
|
9351 |
|
9352 |
|
9353 | if (conditionalComment.test(html)) {
|
9354 | var conditionalEnd = html.indexOf(']>');
|
9355 |
|
9356 | if (conditionalEnd >= 0) {
|
9357 | advance(conditionalEnd + 2);
|
9358 | continue
|
9359 | }
|
9360 | }
|
9361 |
|
9362 |
|
9363 | var doctypeMatch = html.match(doctype);
|
9364 | if (doctypeMatch) {
|
9365 | advance(doctypeMatch[0].length);
|
9366 | continue
|
9367 | }
|
9368 |
|
9369 |
|
9370 | var endTagMatch = html.match(endTag);
|
9371 | if (endTagMatch) {
|
9372 | var curIndex = index;
|
9373 | advance(endTagMatch[0].length);
|
9374 | parseEndTag(endTagMatch[1], curIndex, index);
|
9375 | continue
|
9376 | }
|
9377 |
|
9378 |
|
9379 | var startTagMatch = parseStartTag();
|
9380 | if (startTagMatch) {
|
9381 | handleStartTag(startTagMatch);
|
9382 | if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
|
9383 | advance(1);
|
9384 | }
|
9385 | continue
|
9386 | }
|
9387 | }
|
9388 |
|
9389 | var text = (void 0), rest = (void 0), next = (void 0);
|
9390 | if (textEnd >= 0) {
|
9391 | rest = html.slice(textEnd);
|
9392 | while (
|
9393 | !endTag.test(rest) &&
|
9394 | !startTagOpen.test(rest) &&
|
9395 | !comment.test(rest) &&
|
9396 | !conditionalComment.test(rest)
|
9397 | ) {
|
9398 |
|
9399 | next = rest.indexOf('<', 1);
|
9400 | if (next < 0) { break }
|
9401 | textEnd += next;
|
9402 | rest = html.slice(textEnd);
|
9403 | }
|
9404 | text = html.substring(0, textEnd);
|
9405 | }
|
9406 |
|
9407 | if (textEnd < 0) {
|
9408 | text = html;
|
9409 | }
|
9410 |
|
9411 | if (text) {
|
9412 | advance(text.length);
|
9413 | }
|
9414 |
|
9415 | if (options.chars && text) {
|
9416 | options.chars(text, index - text.length, index);
|
9417 | }
|
9418 | } else {
|
9419 | var endTagLength = 0;
|
9420 | var stackedTag = lastTag.toLowerCase();
|
9421 | var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
|
9422 | var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
|
9423 | endTagLength = endTag.length;
|
9424 | if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
|
9425 | text = text
|
9426 | .replace(/<!\--([\s\S]*?)-->/g, '$1')
|
9427 | .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
|
9428 | }
|
9429 | if (shouldIgnoreFirstNewline(stackedTag, text)) {
|
9430 | text = text.slice(1);
|
9431 | }
|
9432 | if (options.chars) {
|
9433 | options.chars(text);
|
9434 | }
|
9435 | return ''
|
9436 | });
|
9437 | index += html.length - rest$1.length;
|
9438 | html = rest$1;
|
9439 | parseEndTag(stackedTag, index - endTagLength, index);
|
9440 | }
|
9441 |
|
9442 | if (html === last) {
|
9443 | options.chars && options.chars(html);
|
9444 | if (!stack.length && options.warn) {
|
9445 | options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
|
9446 | }
|
9447 | break
|
9448 | }
|
9449 | }
|
9450 |
|
9451 |
|
9452 | parseEndTag();
|
9453 |
|
9454 | function advance (n) {
|
9455 | index += n;
|
9456 | html = html.substring(n);
|
9457 | }
|
9458 |
|
9459 | function parseStartTag () {
|
9460 | var start = html.match(startTagOpen);
|
9461 | if (start) {
|
9462 | var match = {
|
9463 | tagName: start[1],
|
9464 | attrs: [],
|
9465 | start: index
|
9466 | };
|
9467 | advance(start[0].length);
|
9468 | var end, attr;
|
9469 | while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
|
9470 | attr.start = index;
|
9471 | advance(attr[0].length);
|
9472 | attr.end = index;
|
9473 | match.attrs.push(attr);
|
9474 | }
|
9475 | if (end) {
|
9476 | match.unarySlash = end[1];
|
9477 | advance(end[0].length);
|
9478 | match.end = index;
|
9479 | return match
|
9480 | }
|
9481 | }
|
9482 | }
|
9483 |
|
9484 | function handleStartTag (match) {
|
9485 | var tagName = match.tagName;
|
9486 | var unarySlash = match.unarySlash;
|
9487 |
|
9488 | if (expectHTML) {
|
9489 | if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
|
9490 | parseEndTag(lastTag);
|
9491 | }
|
9492 | if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
|
9493 | parseEndTag(tagName);
|
9494 | }
|
9495 | }
|
9496 |
|
9497 | var unary = isUnaryTag$$1(tagName) || !!unarySlash;
|
9498 |
|
9499 | var l = match.attrs.length;
|
9500 | var attrs = new Array(l);
|
9501 | for (var i = 0; i < l; i++) {
|
9502 | var args = match.attrs[i];
|
9503 | var value = args[3] || args[4] || args[5] || '';
|
9504 | var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
|
9505 | ? options.shouldDecodeNewlinesForHref
|
9506 | : options.shouldDecodeNewlines;
|
9507 | attrs[i] = {
|
9508 | name: args[1],
|
9509 | value: decodeAttr(value, shouldDecodeNewlines)
|
9510 | };
|
9511 | if (options.outputSourceRange) {
|
9512 | attrs[i].start = args.start + args[0].match(/^\s*/).length;
|
9513 | attrs[i].end = args.end;
|
9514 | }
|
9515 | }
|
9516 |
|
9517 | if (!unary) {
|
9518 | stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
|
9519 | lastTag = tagName;
|
9520 | }
|
9521 |
|
9522 | if (options.start) {
|
9523 | options.start(tagName, attrs, unary, match.start, match.end);
|
9524 | }
|
9525 | }
|
9526 |
|
9527 | function parseEndTag (tagName, start, end) {
|
9528 | var pos, lowerCasedTagName;
|
9529 | if (start == null) { start = index; }
|
9530 | if (end == null) { end = index; }
|
9531 |
|
9532 |
|
9533 | if (tagName) {
|
9534 | lowerCasedTagName = tagName.toLowerCase();
|
9535 | for (pos = stack.length - 1; pos >= 0; pos--) {
|
9536 | if (stack[pos].lowerCasedTag === lowerCasedTagName) {
|
9537 | break
|
9538 | }
|
9539 | }
|
9540 | } else {
|
9541 |
|
9542 | pos = 0;
|
9543 | }
|
9544 |
|
9545 | if (pos >= 0) {
|
9546 |
|
9547 | for (var i = stack.length - 1; i >= pos; i--) {
|
9548 | if (i > pos || !tagName &&
|
9549 | options.warn
|
9550 | ) {
|
9551 | options.warn(
|
9552 | ("tag <" + (stack[i].tag) + "> has no matching end tag."),
|
9553 | { start: stack[i].start, end: stack[i].end }
|
9554 | );
|
9555 | }
|
9556 | if (options.end) {
|
9557 | options.end(stack[i].tag, start, end);
|
9558 | }
|
9559 | }
|
9560 |
|
9561 |
|
9562 | stack.length = pos;
|
9563 | lastTag = pos && stack[pos - 1].tag;
|
9564 | } else if (lowerCasedTagName === 'br') {
|
9565 | if (options.start) {
|
9566 | options.start(tagName, [], true, start, end);
|
9567 | }
|
9568 | } else if (lowerCasedTagName === 'p') {
|
9569 | if (options.start) {
|
9570 | options.start(tagName, [], false, start, end);
|
9571 | }
|
9572 | if (options.end) {
|
9573 | options.end(tagName, start, end);
|
9574 | }
|
9575 | }
|
9576 | }
|
9577 | }
|
9578 |
|
9579 |
|
9580 |
|
9581 | var onRE = /^@|^v-on:/;
|
9582 | var dirRE = /^v-|^@|^:|^#/;
|
9583 | var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
9584 | var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
9585 | var stripParensRE = /^\(|\)$/g;
|
9586 | var dynamicArgRE = /^\[.*\]$/;
|
9587 |
|
9588 | var argRE = /:(.*)$/;
|
9589 | var bindRE = /^:|^\.|^v-bind:/;
|
9590 | var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
|
9591 |
|
9592 | var slotRE = /^v-slot(:|$)|^#/;
|
9593 |
|
9594 | var lineBreakRE = /[\r\n]/;
|
9595 | var whitespaceRE$1 = /[ \f\t\r\n]+/g;
|
9596 |
|
9597 | var invalidAttributeRE = /[\s"'<>\/=]/;
|
9598 |
|
9599 | var decodeHTMLCached = cached(he.decode);
|
9600 |
|
9601 | var emptySlotScopeToken = "_empty_";
|
9602 |
|
9603 |
|
9604 | var warn$2;
|
9605 | var delimiters;
|
9606 | var transforms;
|
9607 | var preTransforms;
|
9608 | var postTransforms;
|
9609 | var platformIsPreTag;
|
9610 | var platformMustUseProp;
|
9611 | var platformGetTagNamespace;
|
9612 | var maybeComponent;
|
9613 |
|
9614 | function createASTElement (
|
9615 | tag,
|
9616 | attrs,
|
9617 | parent
|
9618 | ) {
|
9619 | return {
|
9620 | type: 1,
|
9621 | tag: tag,
|
9622 | attrsList: attrs,
|
9623 | attrsMap: makeAttrsMap(attrs),
|
9624 | rawAttrsMap: {},
|
9625 | parent: parent,
|
9626 | children: []
|
9627 | }
|
9628 | }
|
9629 |
|
9630 |
|
9631 |
|
9632 |
|
9633 | function parse (
|
9634 | template,
|
9635 | options
|
9636 | ) {
|
9637 | warn$2 = options.warn || baseWarn;
|
9638 |
|
9639 | platformIsPreTag = options.isPreTag || no;
|
9640 | platformMustUseProp = options.mustUseProp || no;
|
9641 | platformGetTagNamespace = options.getTagNamespace || no;
|
9642 | var isReservedTag = options.isReservedTag || no;
|
9643 | maybeComponent = function (el) { return !!(
|
9644 | el.component ||
|
9645 | el.attrsMap[':is'] ||
|
9646 | el.attrsMap['v-bind:is'] ||
|
9647 | !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag))
|
9648 | ); };
|
9649 | transforms = pluckModuleFunction(options.modules, 'transformNode');
|
9650 | preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
|
9651 | postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
|
9652 |
|
9653 | delimiters = options.delimiters;
|
9654 |
|
9655 | var stack = [];
|
9656 | var preserveWhitespace = options.preserveWhitespace !== false;
|
9657 | var whitespaceOption = options.whitespace;
|
9658 | var root;
|
9659 | var currentParent;
|
9660 | var inVPre = false;
|
9661 | var inPre = false;
|
9662 | var warned = false;
|
9663 |
|
9664 | function warnOnce (msg, range) {
|
9665 | if (!warned) {
|
9666 | warned = true;
|
9667 | warn$2(msg, range);
|
9668 | }
|
9669 | }
|
9670 |
|
9671 | function closeElement (element) {
|
9672 | trimEndingWhitespace(element);
|
9673 | if (!inVPre && !element.processed) {
|
9674 | element = processElement(element, options);
|
9675 | }
|
9676 |
|
9677 | if (!stack.length && element !== root) {
|
9678 |
|
9679 | if (root.if && (element.elseif || element.else)) {
|
9680 | {
|
9681 | checkRootConstraints(element);
|
9682 | }
|
9683 | addIfCondition(root, {
|
9684 | exp: element.elseif,
|
9685 | block: element
|
9686 | });
|
9687 | } else {
|
9688 | warnOnce(
|
9689 | "Component template should contain exactly one root element. " +
|
9690 | "If you are using v-if on multiple elements, " +
|
9691 | "use v-else-if to chain them instead.",
|
9692 | { start: element.start }
|
9693 | );
|
9694 | }
|
9695 | }
|
9696 | if (currentParent && !element.forbidden) {
|
9697 | if (element.elseif || element.else) {
|
9698 | processIfConditions(element, currentParent);
|
9699 | } else {
|
9700 | if (element.slotScope) {
|
9701 |
|
9702 |
|
9703 |
|
9704 | var name = element.slotTarget || '"default"'
|
9705 | ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
|
9706 | }
|
9707 | currentParent.children.push(element);
|
9708 | element.parent = currentParent;
|
9709 | }
|
9710 | }
|
9711 |
|
9712 |
|
9713 |
|
9714 | element.children = element.children.filter(function (c) { return !(c).slotScope; });
|
9715 |
|
9716 | trimEndingWhitespace(element);
|
9717 |
|
9718 |
|
9719 | if (element.pre) {
|
9720 | inVPre = false;
|
9721 | }
|
9722 | if (platformIsPreTag(element.tag)) {
|
9723 | inPre = false;
|
9724 | }
|
9725 |
|
9726 | for (var i = 0; i < postTransforms.length; i++) {
|
9727 | postTransforms[i](element, options);
|
9728 | }
|
9729 | }
|
9730 |
|
9731 | function trimEndingWhitespace (el) {
|
9732 |
|
9733 | if (!inPre) {
|
9734 | var lastNode;
|
9735 | while (
|
9736 | (lastNode = el.children[el.children.length - 1]) &&
|
9737 | lastNode.type === 3 &&
|
9738 | lastNode.text === ' '
|
9739 | ) {
|
9740 | el.children.pop();
|
9741 | }
|
9742 | }
|
9743 | }
|
9744 |
|
9745 | function checkRootConstraints (el) {
|
9746 | if (el.tag === 'slot' || el.tag === 'template') {
|
9747 | warnOnce(
|
9748 | "Cannot use <" + (el.tag) + "> as component root element because it may " +
|
9749 | 'contain multiple nodes.',
|
9750 | { start: el.start }
|
9751 | );
|
9752 | }
|
9753 | if (el.attrsMap.hasOwnProperty('v-for')) {
|
9754 | warnOnce(
|
9755 | 'Cannot use v-for on stateful component root element because ' +
|
9756 | 'it renders multiple elements.',
|
9757 | el.rawAttrsMap['v-for']
|
9758 | );
|
9759 | }
|
9760 | }
|
9761 |
|
9762 | parseHTML(template, {
|
9763 | warn: warn$2,
|
9764 | expectHTML: options.expectHTML,
|
9765 | isUnaryTag: options.isUnaryTag,
|
9766 | canBeLeftOpenTag: options.canBeLeftOpenTag,
|
9767 | shouldDecodeNewlines: options.shouldDecodeNewlines,
|
9768 | shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
|
9769 | shouldKeepComment: options.comments,
|
9770 | outputSourceRange: options.outputSourceRange,
|
9771 | start: function start (tag, attrs, unary, start$1, end) {
|
9772 |
|
9773 |
|
9774 | var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
|
9775 |
|
9776 |
|
9777 |
|
9778 | if (isIE && ns === 'svg') {
|
9779 | attrs = guardIESVGBug(attrs);
|
9780 | }
|
9781 |
|
9782 | var element = createASTElement(tag, attrs, currentParent);
|
9783 | if (ns) {
|
9784 | element.ns = ns;
|
9785 | }
|
9786 |
|
9787 | {
|
9788 | if (options.outputSourceRange) {
|
9789 | element.start = start$1;
|
9790 | element.end = end;
|
9791 | element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
|
9792 | cumulated[attr.name] = attr;
|
9793 | return cumulated
|
9794 | }, {});
|
9795 | }
|
9796 | attrs.forEach(function (attr) {
|
9797 | if (invalidAttributeRE.test(attr.name)) {
|
9798 | warn$2(
|
9799 | "Invalid dynamic argument expression: attribute names cannot contain " +
|
9800 | "spaces, quotes, <, >, / or =.",
|
9801 | {
|
9802 | start: attr.start + attr.name.indexOf("["),
|
9803 | end: attr.start + attr.name.length
|
9804 | }
|
9805 | );
|
9806 | }
|
9807 | });
|
9808 | }
|
9809 |
|
9810 | if (isForbiddenTag(element) && !isServerRendering()) {
|
9811 | element.forbidden = true;
|
9812 | warn$2(
|
9813 | 'Templates should only be responsible for mapping the state to the ' +
|
9814 | 'UI. Avoid placing tags with side-effects in your templates, such as ' +
|
9815 | "<" + tag + ">" + ', as they will not be parsed.',
|
9816 | { start: element.start }
|
9817 | );
|
9818 | }
|
9819 |
|
9820 |
|
9821 | for (var i = 0; i < preTransforms.length; i++) {
|
9822 | element = preTransforms[i](element, options) || element;
|
9823 | }
|
9824 |
|
9825 | if (!inVPre) {
|
9826 | processPre(element);
|
9827 | if (element.pre) {
|
9828 | inVPre = true;
|
9829 | }
|
9830 | }
|
9831 | if (platformIsPreTag(element.tag)) {
|
9832 | inPre = true;
|
9833 | }
|
9834 | if (inVPre) {
|
9835 | processRawAttrs(element);
|
9836 | } else if (!element.processed) {
|
9837 |
|
9838 | processFor(element);
|
9839 | processIf(element);
|
9840 | processOnce(element);
|
9841 | }
|
9842 |
|
9843 | if (!root) {
|
9844 | root = element;
|
9845 | {
|
9846 | checkRootConstraints(root);
|
9847 | }
|
9848 | }
|
9849 |
|
9850 | if (!unary) {
|
9851 | currentParent = element;
|
9852 | stack.push(element);
|
9853 | } else {
|
9854 | closeElement(element);
|
9855 | }
|
9856 | },
|
9857 |
|
9858 | end: function end (tag, start, end$1) {
|
9859 | var element = stack[stack.length - 1];
|
9860 |
|
9861 | stack.length -= 1;
|
9862 | currentParent = stack[stack.length - 1];
|
9863 | if (options.outputSourceRange) {
|
9864 | element.end = end$1;
|
9865 | }
|
9866 | closeElement(element);
|
9867 | },
|
9868 |
|
9869 | chars: function chars (text, start, end) {
|
9870 | if (!currentParent) {
|
9871 | {
|
9872 | if (text === template) {
|
9873 | warnOnce(
|
9874 | 'Component template requires a root element, rather than just text.',
|
9875 | { start: start }
|
9876 | );
|
9877 | } else if ((text = text.trim())) {
|
9878 | warnOnce(
|
9879 | ("text \"" + text + "\" outside root element will be ignored."),
|
9880 | { start: start }
|
9881 | );
|
9882 | }
|
9883 | }
|
9884 | return
|
9885 | }
|
9886 |
|
9887 |
|
9888 | if (isIE &&
|
9889 | currentParent.tag === 'textarea' &&
|
9890 | currentParent.attrsMap.placeholder === text
|
9891 | ) {
|
9892 | return
|
9893 | }
|
9894 | var children = currentParent.children;
|
9895 | if (inPre || text.trim()) {
|
9896 | text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
|
9897 | } else if (!children.length) {
|
9898 |
|
9899 | text = '';
|
9900 | } else if (whitespaceOption) {
|
9901 | if (whitespaceOption === 'condense') {
|
9902 |
|
9903 |
|
9904 | text = lineBreakRE.test(text) ? '' : ' ';
|
9905 | } else {
|
9906 | text = ' ';
|
9907 | }
|
9908 | } else {
|
9909 | text = preserveWhitespace ? ' ' : '';
|
9910 | }
|
9911 | if (text) {
|
9912 | if (!inPre && whitespaceOption === 'condense') {
|
9913 |
|
9914 | text = text.replace(whitespaceRE$1, ' ');
|
9915 | }
|
9916 | var res;
|
9917 | var child;
|
9918 | if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
|
9919 | child = {
|
9920 | type: 2,
|
9921 | expression: res.expression,
|
9922 | tokens: res.tokens,
|
9923 | text: text
|
9924 | };
|
9925 | } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
|
9926 | child = {
|
9927 | type: 3,
|
9928 | text: text
|
9929 | };
|
9930 | }
|
9931 | if (child) {
|
9932 | if (options.outputSourceRange) {
|
9933 | child.start = start;
|
9934 | child.end = end;
|
9935 | }
|
9936 | children.push(child);
|
9937 | }
|
9938 | }
|
9939 | },
|
9940 | comment: function comment (text, start, end) {
|
9941 |
|
9942 |
|
9943 | if (currentParent) {
|
9944 | var child = {
|
9945 | type: 3,
|
9946 | text: text,
|
9947 | isComment: true
|
9948 | };
|
9949 | if (options.outputSourceRange) {
|
9950 | child.start = start;
|
9951 | child.end = end;
|
9952 | }
|
9953 | currentParent.children.push(child);
|
9954 | }
|
9955 | }
|
9956 | });
|
9957 | return root
|
9958 | }
|
9959 |
|
9960 | function processPre (el) {
|
9961 | if (getAndRemoveAttr(el, 'v-pre') != null) {
|
9962 | el.pre = true;
|
9963 | }
|
9964 | }
|
9965 |
|
9966 | function processRawAttrs (el) {
|
9967 | var list = el.attrsList;
|
9968 | var len = list.length;
|
9969 | if (len) {
|
9970 | var attrs = el.attrs = new Array(len);
|
9971 | for (var i = 0; i < len; i++) {
|
9972 | attrs[i] = {
|
9973 | name: list[i].name,
|
9974 | value: JSON.stringify(list[i].value)
|
9975 | };
|
9976 | if (list[i].start != null) {
|
9977 | attrs[i].start = list[i].start;
|
9978 | attrs[i].end = list[i].end;
|
9979 | }
|
9980 | }
|
9981 | } else if (!el.pre) {
|
9982 |
|
9983 | el.plain = true;
|
9984 | }
|
9985 | }
|
9986 |
|
9987 | function processElement (
|
9988 | element,
|
9989 | options
|
9990 | ) {
|
9991 | processKey(element);
|
9992 |
|
9993 |
|
9994 |
|
9995 | element.plain = (
|
9996 | !element.key &&
|
9997 | !element.scopedSlots &&
|
9998 | !element.attrsList.length
|
9999 | );
|
10000 |
|
10001 | processRef(element);
|
10002 | processSlotContent(element);
|
10003 | processSlotOutlet(element);
|
10004 | processComponent(element);
|
10005 | for (var i = 0; i < transforms.length; i++) {
|
10006 | element = transforms[i](element, options) || element;
|
10007 | }
|
10008 | processAttrs(element);
|
10009 | return element
|
10010 | }
|
10011 |
|
10012 | function processKey (el) {
|
10013 | var exp = getBindingAttr(el, 'key');
|
10014 | if (exp) {
|
10015 | {
|
10016 | if (el.tag === 'template') {
|
10017 | warn$2(
|
10018 | "<template> cannot be keyed. Place the key on real elements instead.",
|
10019 | getRawBindingAttr(el, 'key')
|
10020 | );
|
10021 | }
|
10022 | if (el.for) {
|
10023 | var iterator = el.iterator2 || el.iterator1;
|
10024 | var parent = el.parent;
|
10025 | if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
|
10026 | warn$2(
|
10027 | "Do not use v-for index as key on <transition-group> children, " +
|
10028 | "this is the same as not using keys.",
|
10029 | getRawBindingAttr(el, 'key'),
|
10030 | true
|
10031 | );
|
10032 | }
|
10033 | }
|
10034 | }
|
10035 | el.key = exp;
|
10036 | }
|
10037 | }
|
10038 |
|
10039 | function processRef (el) {
|
10040 | var ref = getBindingAttr(el, 'ref');
|
10041 | if (ref) {
|
10042 | el.ref = ref;
|
10043 | el.refInFor = checkInFor(el);
|
10044 | }
|
10045 | }
|
10046 |
|
10047 | function processFor (el) {
|
10048 | var exp;
|
10049 | if ((exp = getAndRemoveAttr(el, 'v-for'))) {
|
10050 | var res = parseFor(exp);
|
10051 | if (res) {
|
10052 | extend(el, res);
|
10053 | } else {
|
10054 | warn$2(
|
10055 | ("Invalid v-for expression: " + exp),
|
10056 | el.rawAttrsMap['v-for']
|
10057 | );
|
10058 | }
|
10059 | }
|
10060 | }
|
10061 |
|
10062 |
|
10063 |
|
10064 | function parseFor (exp) {
|
10065 | var inMatch = exp.match(forAliasRE);
|
10066 | if (!inMatch) { return }
|
10067 | var res = {};
|
10068 | res.for = inMatch[2].trim();
|
10069 | var alias = inMatch[1].trim().replace(stripParensRE, '');
|
10070 | var iteratorMatch = alias.match(forIteratorRE);
|
10071 | if (iteratorMatch) {
|
10072 | res.alias = alias.replace(forIteratorRE, '').trim();
|
10073 | res.iterator1 = iteratorMatch[1].trim();
|
10074 | if (iteratorMatch[2]) {
|
10075 | res.iterator2 = iteratorMatch[2].trim();
|
10076 | }
|
10077 | } else {
|
10078 | res.alias = alias;
|
10079 | }
|
10080 | return res
|
10081 | }
|
10082 |
|
10083 | function processIf (el) {
|
10084 | var exp = getAndRemoveAttr(el, 'v-if');
|
10085 | if (exp) {
|
10086 | el.if = exp;
|
10087 | addIfCondition(el, {
|
10088 | exp: exp,
|
10089 | block: el
|
10090 | });
|
10091 | } else {
|
10092 | if (getAndRemoveAttr(el, 'v-else') != null) {
|
10093 | el.else = true;
|
10094 | }
|
10095 | var elseif = getAndRemoveAttr(el, 'v-else-if');
|
10096 | if (elseif) {
|
10097 | el.elseif = elseif;
|
10098 | }
|
10099 | }
|
10100 | }
|
10101 |
|
10102 | function processIfConditions (el, parent) {
|
10103 | var prev = findPrevElement(parent.children);
|
10104 | if (prev && prev.if) {
|
10105 | addIfCondition(prev, {
|
10106 | exp: el.elseif,
|
10107 | block: el
|
10108 | });
|
10109 | } else {
|
10110 | warn$2(
|
10111 | "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
|
10112 | "used on element <" + (el.tag) + "> without corresponding v-if.",
|
10113 | el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
|
10114 | );
|
10115 | }
|
10116 | }
|
10117 |
|
10118 | function findPrevElement (children) {
|
10119 | var i = children.length;
|
10120 | while (i--) {
|
10121 | if (children[i].type === 1) {
|
10122 | return children[i]
|
10123 | } else {
|
10124 | if (children[i].text !== ' ') {
|
10125 | warn$2(
|
10126 | "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
|
10127 | "will be ignored.",
|
10128 | children[i]
|
10129 | );
|
10130 | }
|
10131 | children.pop();
|
10132 | }
|
10133 | }
|
10134 | }
|
10135 |
|
10136 | function addIfCondition (el, condition) {
|
10137 | if (!el.ifConditions) {
|
10138 | el.ifConditions = [];
|
10139 | }
|
10140 | el.ifConditions.push(condition);
|
10141 | }
|
10142 |
|
10143 | function processOnce (el) {
|
10144 | var once$$1 = getAndRemoveAttr(el, 'v-once');
|
10145 | if (once$$1 != null) {
|
10146 | el.once = true;
|
10147 | }
|
10148 | }
|
10149 |
|
10150 |
|
10151 |
|
10152 | function processSlotContent (el) {
|
10153 | var slotScope;
|
10154 | if (el.tag === 'template') {
|
10155 | slotScope = getAndRemoveAttr(el, 'scope');
|
10156 |
|
10157 | if (slotScope) {
|
10158 | warn$2(
|
10159 | "the \"scope\" attribute for scoped slots have been deprecated and " +
|
10160 | "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
|
10161 | "can also be used on plain elements in addition to <template> to " +
|
10162 | "denote scoped slots.",
|
10163 | el.rawAttrsMap['scope'],
|
10164 | true
|
10165 | );
|
10166 | }
|
10167 | el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
|
10168 | } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
|
10169 |
|
10170 | if (el.attrsMap['v-for']) {
|
10171 | warn$2(
|
10172 | "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
|
10173 | "(v-for takes higher priority). Use a wrapper <template> for the " +
|
10174 | "scoped slot to make it clearer.",
|
10175 | el.rawAttrsMap['slot-scope'],
|
10176 | true
|
10177 | );
|
10178 | }
|
10179 | el.slotScope = slotScope;
|
10180 | }
|
10181 |
|
10182 |
|
10183 | var slotTarget = getBindingAttr(el, 'slot');
|
10184 | if (slotTarget) {
|
10185 | el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
|
10186 | el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
|
10187 |
|
10188 |
|
10189 | if (el.tag !== 'template' && !el.slotScope) {
|
10190 | addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
|
10191 | }
|
10192 | }
|
10193 |
|
10194 |
|
10195 | {
|
10196 | if (el.tag === 'template') {
|
10197 |
|
10198 | var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
|
10199 | if (slotBinding) {
|
10200 | {
|
10201 | if (el.slotTarget || el.slotScope) {
|
10202 | warn$2(
|
10203 | "Unexpected mixed usage of different slot syntaxes.",
|
10204 | el
|
10205 | );
|
10206 | }
|
10207 | if (el.parent && !maybeComponent(el.parent)) {
|
10208 | warn$2(
|
10209 | "<template v-slot> can only appear at the root level inside " +
|
10210 | "the receiving component",
|
10211 | el
|
10212 | );
|
10213 | }
|
10214 | }
|
10215 | var ref = getSlotName(slotBinding);
|
10216 | var name = ref.name;
|
10217 | var dynamic = ref.dynamic;
|
10218 | el.slotTarget = name;
|
10219 | el.slotTargetDynamic = dynamic;
|
10220 | el.slotScope = slotBinding.value || emptySlotScopeToken;
|
10221 | }
|
10222 | } else {
|
10223 |
|
10224 | var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
|
10225 | if (slotBinding$1) {
|
10226 | {
|
10227 | if (!maybeComponent(el)) {
|
10228 | warn$2(
|
10229 | "v-slot can only be used on components or <template>.",
|
10230 | slotBinding$1
|
10231 | );
|
10232 | }
|
10233 | if (el.slotScope || el.slotTarget) {
|
10234 | warn$2(
|
10235 | "Unexpected mixed usage of different slot syntaxes.",
|
10236 | el
|
10237 | );
|
10238 | }
|
10239 | if (el.scopedSlots) {
|
10240 | warn$2(
|
10241 | "To avoid scope ambiguity, the default slot should also use " +
|
10242 | "<template> syntax when there are other named slots.",
|
10243 | slotBinding$1
|
10244 | );
|
10245 | }
|
10246 | }
|
10247 |
|
10248 | var slots = el.scopedSlots || (el.scopedSlots = {});
|
10249 | var ref$1 = getSlotName(slotBinding$1);
|
10250 | var name$1 = ref$1.name;
|
10251 | var dynamic$1 = ref$1.dynamic;
|
10252 | var slotContainer = slots[name$1] = createASTElement('template', [], el);
|
10253 | slotContainer.slotTarget = name$1;
|
10254 | slotContainer.slotTargetDynamic = dynamic$1;
|
10255 | slotContainer.children = el.children.filter(function (c) {
|
10256 | if (!c.slotScope) {
|
10257 | c.parent = slotContainer;
|
10258 | return true
|
10259 | }
|
10260 | });
|
10261 | slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
|
10262 |
|
10263 | el.children = [];
|
10264 |
|
10265 | el.plain = false;
|
10266 | }
|
10267 | }
|
10268 | }
|
10269 | }
|
10270 |
|
10271 | function getSlotName (binding) {
|
10272 | var name = binding.name.replace(slotRE, '');
|
10273 | if (!name) {
|
10274 | if (binding.name[0] !== '#') {
|
10275 | name = 'default';
|
10276 | } else {
|
10277 | warn$2(
|
10278 | "v-slot shorthand syntax requires a slot name.",
|
10279 | binding
|
10280 | );
|
10281 | }
|
10282 | }
|
10283 | return dynamicArgRE.test(name)
|
10284 |
|
10285 | ? { name: name.slice(1, -1), dynamic: true }
|
10286 |
|
10287 | : { name: ("\"" + name + "\""), dynamic: false }
|
10288 | }
|
10289 |
|
10290 |
|
10291 | function processSlotOutlet (el) {
|
10292 | if (el.tag === 'slot') {
|
10293 | el.slotName = getBindingAttr(el, 'name');
|
10294 | if (el.key) {
|
10295 | warn$2(
|
10296 | "`key` does not work on <slot> because slots are abstract outlets " +
|
10297 | "and can possibly expand into multiple elements. " +
|
10298 | "Use the key on a wrapping element instead.",
|
10299 | getRawBindingAttr(el, 'key')
|
10300 | );
|
10301 | }
|
10302 | }
|
10303 | }
|
10304 |
|
10305 | function processComponent (el) {
|
10306 | var binding;
|
10307 | if ((binding = getBindingAttr(el, 'is'))) {
|
10308 | el.component = binding;
|
10309 | }
|
10310 | if (getAndRemoveAttr(el, 'inline-template') != null) {
|
10311 | el.inlineTemplate = true;
|
10312 | }
|
10313 | }
|
10314 |
|
10315 | function processAttrs (el) {
|
10316 | var list = el.attrsList;
|
10317 | var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
|
10318 | for (i = 0, l = list.length; i < l; i++) {
|
10319 | name = rawName = list[i].name;
|
10320 | value = list[i].value;
|
10321 | if (dirRE.test(name)) {
|
10322 |
|
10323 | el.hasBindings = true;
|
10324 |
|
10325 | modifiers = parseModifiers(name.replace(dirRE, ''));
|
10326 |
|
10327 | if (modifiers) {
|
10328 | name = name.replace(modifierRE, '');
|
10329 | }
|
10330 | if (bindRE.test(name)) {
|
10331 | name = name.replace(bindRE, '');
|
10332 | value = parseFilters(value);
|
10333 | isDynamic = dynamicArgRE.test(name);
|
10334 | if (isDynamic) {
|
10335 | name = name.slice(1, -1);
|
10336 | }
|
10337 | if (
|
10338 | value.trim().length === 0
|
10339 | ) {
|
10340 | warn$2(
|
10341 | ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
|
10342 | );
|
10343 | }
|
10344 | if (modifiers) {
|
10345 | if (modifiers.prop && !isDynamic) {
|
10346 | name = camelize(name);
|
10347 | if (name === 'innerHtml') { name = 'innerHTML'; }
|
10348 | }
|
10349 | if (modifiers.camel && !isDynamic) {
|
10350 | name = camelize(name);
|
10351 | }
|
10352 | if (modifiers.sync) {
|
10353 | syncGen = genAssignmentCode(value, "$event");
|
10354 | if (!isDynamic) {
|
10355 | addHandler(
|
10356 | el,
|
10357 | ("update:" + (camelize(name))),
|
10358 | syncGen,
|
10359 | null,
|
10360 | false,
|
10361 | warn$2,
|
10362 | list[i]
|
10363 | );
|
10364 | if (hyphenate(name) !== camelize(name)) {
|
10365 | addHandler(
|
10366 | el,
|
10367 | ("update:" + (hyphenate(name))),
|
10368 | syncGen,
|
10369 | null,
|
10370 | false,
|
10371 | warn$2,
|
10372 | list[i]
|
10373 | );
|
10374 | }
|
10375 | } else {
|
10376 |
|
10377 | addHandler(
|
10378 | el,
|
10379 | ("\"update:\"+(" + name + ")"),
|
10380 | syncGen,
|
10381 | null,
|
10382 | false,
|
10383 | warn$2,
|
10384 | list[i],
|
10385 | true
|
10386 | );
|
10387 | }
|
10388 | }
|
10389 | }
|
10390 | if ((modifiers && modifiers.prop) || (
|
10391 | !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
|
10392 | )) {
|
10393 | addProp(el, name, value, list[i], isDynamic);
|
10394 | } else {
|
10395 | addAttr(el, name, value, list[i], isDynamic);
|
10396 | }
|
10397 | } else if (onRE.test(name)) {
|
10398 | name = name.replace(onRE, '');
|
10399 | isDynamic = dynamicArgRE.test(name);
|
10400 | if (isDynamic) {
|
10401 | name = name.slice(1, -1);
|
10402 | }
|
10403 | addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
|
10404 | } else {
|
10405 | name = name.replace(dirRE, '');
|
10406 |
|
10407 | var argMatch = name.match(argRE);
|
10408 | var arg = argMatch && argMatch[1];
|
10409 | isDynamic = false;
|
10410 | if (arg) {
|
10411 | name = name.slice(0, -(arg.length + 1));
|
10412 | if (dynamicArgRE.test(arg)) {
|
10413 | arg = arg.slice(1, -1);
|
10414 | isDynamic = true;
|
10415 | }
|
10416 | }
|
10417 | addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
|
10418 | if (name === 'model') {
|
10419 | checkForAliasModel(el, value);
|
10420 | }
|
10421 | }
|
10422 | } else {
|
10423 |
|
10424 | {
|
10425 | var res = parseText(value, delimiters);
|
10426 | if (res) {
|
10427 | warn$2(
|
10428 | name + "=\"" + value + "\": " +
|
10429 | 'Interpolation inside attributes has been removed. ' +
|
10430 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
10431 | 'instead of <div id="{{ val }}">, use <div :id="val">.',
|
10432 | list[i]
|
10433 | );
|
10434 | }
|
10435 | }
|
10436 | addAttr(el, name, JSON.stringify(value), list[i]);
|
10437 |
|
10438 |
|
10439 | if (!el.component &&
|
10440 | name === 'muted' &&
|
10441 | platformMustUseProp(el.tag, el.attrsMap.type, name)) {
|
10442 | addProp(el, name, 'true', list[i]);
|
10443 | }
|
10444 | }
|
10445 | }
|
10446 | }
|
10447 |
|
10448 | function checkInFor (el) {
|
10449 | var parent = el;
|
10450 | while (parent) {
|
10451 | if (parent.for !== undefined) {
|
10452 | return true
|
10453 | }
|
10454 | parent = parent.parent;
|
10455 | }
|
10456 | return false
|
10457 | }
|
10458 |
|
10459 | function parseModifiers (name) {
|
10460 | var match = name.match(modifierRE);
|
10461 | if (match) {
|
10462 | var ret = {};
|
10463 | match.forEach(function (m) { ret[m.slice(1)] = true; });
|
10464 | return ret
|
10465 | }
|
10466 | }
|
10467 |
|
10468 | function makeAttrsMap (attrs) {
|
10469 | var map = {};
|
10470 | for (var i = 0, l = attrs.length; i < l; i++) {
|
10471 | if (
|
10472 | map[attrs[i].name] && !isIE && !isEdge
|
10473 | ) {
|
10474 | warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
|
10475 | }
|
10476 | map[attrs[i].name] = attrs[i].value;
|
10477 | }
|
10478 | return map
|
10479 | }
|
10480 |
|
10481 |
|
10482 | function isTextTag (el) {
|
10483 | return el.tag === 'script' || el.tag === 'style'
|
10484 | }
|
10485 |
|
10486 | function isForbiddenTag (el) {
|
10487 | return (
|
10488 | el.tag === 'style' ||
|
10489 | (el.tag === 'script' && (
|
10490 | !el.attrsMap.type ||
|
10491 | el.attrsMap.type === 'text/javascript'
|
10492 | ))
|
10493 | )
|
10494 | }
|
10495 |
|
10496 | var ieNSBug = /^xmlns:NS\d+/;
|
10497 | var ieNSPrefix = /^NS\d+:/;
|
10498 |
|
10499 |
|
10500 | function guardIESVGBug (attrs) {
|
10501 | var res = [];
|
10502 | for (var i = 0; i < attrs.length; i++) {
|
10503 | var attr = attrs[i];
|
10504 | if (!ieNSBug.test(attr.name)) {
|
10505 | attr.name = attr.name.replace(ieNSPrefix, '');
|
10506 | res.push(attr);
|
10507 | }
|
10508 | }
|
10509 | return res
|
10510 | }
|
10511 |
|
10512 | function checkForAliasModel (el, value) {
|
10513 | var _el = el;
|
10514 | while (_el) {
|
10515 | if (_el.for && _el.alias === value) {
|
10516 | warn$2(
|
10517 | "<" + (el.tag) + " v-model=\"" + value + "\">: " +
|
10518 | "You are binding v-model directly to a v-for iteration alias. " +
|
10519 | "This will not be able to modify the v-for source array because " +
|
10520 | "writing to the alias is like modifying a function local variable. " +
|
10521 | "Consider using an array of objects and use v-model on an object property instead.",
|
10522 | el.rawAttrsMap['v-model']
|
10523 | );
|
10524 | }
|
10525 | _el = _el.parent;
|
10526 | }
|
10527 | }
|
10528 |
|
10529 |
|
10530 |
|
10531 | function preTransformNode (el, options) {
|
10532 | if (el.tag === 'input') {
|
10533 | var map = el.attrsMap;
|
10534 | if (!map['v-model']) {
|
10535 | return
|
10536 | }
|
10537 |
|
10538 | var typeBinding;
|
10539 | if (map[':type'] || map['v-bind:type']) {
|
10540 | typeBinding = getBindingAttr(el, 'type');
|
10541 | }
|
10542 | if (!map.type && !typeBinding && map['v-bind']) {
|
10543 | typeBinding = "(" + (map['v-bind']) + ").type";
|
10544 | }
|
10545 |
|
10546 | if (typeBinding) {
|
10547 | var ifCondition = getAndRemoveAttr(el, 'v-if', true);
|
10548 | var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
|
10549 | var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
|
10550 | var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
|
10551 |
|
10552 | var branch0 = cloneASTElement(el);
|
10553 |
|
10554 | processFor(branch0);
|
10555 | addRawAttr(branch0, 'type', 'checkbox');
|
10556 | processElement(branch0, options);
|
10557 | branch0.processed = true;
|
10558 | branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
|
10559 | addIfCondition(branch0, {
|
10560 | exp: branch0.if,
|
10561 | block: branch0
|
10562 | });
|
10563 |
|
10564 | var branch1 = cloneASTElement(el);
|
10565 | getAndRemoveAttr(branch1, 'v-for', true);
|
10566 | addRawAttr(branch1, 'type', 'radio');
|
10567 | processElement(branch1, options);
|
10568 | addIfCondition(branch0, {
|
10569 | exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
|
10570 | block: branch1
|
10571 | });
|
10572 |
|
10573 | var branch2 = cloneASTElement(el);
|
10574 | getAndRemoveAttr(branch2, 'v-for', true);
|
10575 | addRawAttr(branch2, ':type', typeBinding);
|
10576 | processElement(branch2, options);
|
10577 | addIfCondition(branch0, {
|
10578 | exp: ifCondition,
|
10579 | block: branch2
|
10580 | });
|
10581 |
|
10582 | if (hasElse) {
|
10583 | branch0.else = true;
|
10584 | } else if (elseIfCondition) {
|
10585 | branch0.elseif = elseIfCondition;
|
10586 | }
|
10587 |
|
10588 | return branch0
|
10589 | }
|
10590 | }
|
10591 | }
|
10592 |
|
10593 | function cloneASTElement (el) {
|
10594 | return createASTElement(el.tag, el.attrsList.slice(), el.parent)
|
10595 | }
|
10596 |
|
10597 | var model$1 = {
|
10598 | preTransformNode: preTransformNode
|
10599 | };
|
10600 |
|
10601 | var modules$1 = [
|
10602 | klass$1,
|
10603 | style$1,
|
10604 | model$1
|
10605 | ];
|
10606 |
|
10607 |
|
10608 |
|
10609 | function text (el, dir) {
|
10610 | if (dir.value) {
|
10611 | addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
|
10612 | }
|
10613 | }
|
10614 |
|
10615 |
|
10616 |
|
10617 | function html (el, dir) {
|
10618 | if (dir.value) {
|
10619 | addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
|
10620 | }
|
10621 | }
|
10622 |
|
10623 | var directives$1 = {
|
10624 | model: model,
|
10625 | text: text,
|
10626 | html: html
|
10627 | };
|
10628 |
|
10629 |
|
10630 |
|
10631 | var baseOptions = {
|
10632 | expectHTML: true,
|
10633 | modules: modules$1,
|
10634 | directives: directives$1,
|
10635 | isPreTag: isPreTag,
|
10636 | isUnaryTag: isUnaryTag,
|
10637 | mustUseProp: mustUseProp,
|
10638 | canBeLeftOpenTag: canBeLeftOpenTag,
|
10639 | isReservedTag: isReservedTag,
|
10640 | getTagNamespace: getTagNamespace,
|
10641 | staticKeys: genStaticKeys(modules$1)
|
10642 | };
|
10643 |
|
10644 |
|
10645 |
|
10646 | var isStaticKey;
|
10647 | var isPlatformReservedTag;
|
10648 |
|
10649 | var genStaticKeysCached = cached(genStaticKeys$1);
|
10650 |
|
10651 |
|
10652 |
|
10653 |
|
10654 |
|
10655 |
|
10656 |
|
10657 |
|
10658 |
|
10659 |
|
10660 |
|
10661 |
|
10662 | function optimize (root, options) {
|
10663 | if (!root) { return }
|
10664 | isStaticKey = genStaticKeysCached(options.staticKeys || '');
|
10665 | isPlatformReservedTag = options.isReservedTag || no;
|
10666 |
|
10667 | markStatic$1(root);
|
10668 |
|
10669 | markStaticRoots(root, false);
|
10670 | }
|
10671 |
|
10672 | function genStaticKeys$1 (keys) {
|
10673 | return makeMap(
|
10674 | 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
|
10675 | (keys ? ',' + keys : '')
|
10676 | )
|
10677 | }
|
10678 |
|
10679 | function markStatic$1 (node) {
|
10680 | node.static = isStatic(node);
|
10681 | if (node.type === 1) {
|
10682 |
|
10683 |
|
10684 |
|
10685 | if (
|
10686 | !isPlatformReservedTag(node.tag) &&
|
10687 | node.tag !== 'slot' &&
|
10688 | node.attrsMap['inline-template'] == null
|
10689 | ) {
|
10690 | return
|
10691 | }
|
10692 | for (var i = 0, l = node.children.length; i < l; i++) {
|
10693 | var child = node.children[i];
|
10694 | markStatic$1(child);
|
10695 | if (!child.static) {
|
10696 | node.static = false;
|
10697 | }
|
10698 | }
|
10699 | if (node.ifConditions) {
|
10700 | for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
10701 | var block = node.ifConditions[i$1].block;
|
10702 | markStatic$1(block);
|
10703 | if (!block.static) {
|
10704 | node.static = false;
|
10705 | }
|
10706 | }
|
10707 | }
|
10708 | }
|
10709 | }
|
10710 |
|
10711 | function markStaticRoots (node, isInFor) {
|
10712 | if (node.type === 1) {
|
10713 | if (node.static || node.once) {
|
10714 | node.staticInFor = isInFor;
|
10715 | }
|
10716 |
|
10717 |
|
10718 |
|
10719 | if (node.static && node.children.length && !(
|
10720 | node.children.length === 1 &&
|
10721 | node.children[0].type === 3
|
10722 | )) {
|
10723 | node.staticRoot = true;
|
10724 | return
|
10725 | } else {
|
10726 | node.staticRoot = false;
|
10727 | }
|
10728 | if (node.children) {
|
10729 | for (var i = 0, l = node.children.length; i < l; i++) {
|
10730 | markStaticRoots(node.children[i], isInFor || !!node.for);
|
10731 | }
|
10732 | }
|
10733 | if (node.ifConditions) {
|
10734 | for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
10735 | markStaticRoots(node.ifConditions[i$1].block, isInFor);
|
10736 | }
|
10737 | }
|
10738 | }
|
10739 | }
|
10740 |
|
10741 | function isStatic (node) {
|
10742 | if (node.type === 2) {
|
10743 | return false
|
10744 | }
|
10745 | if (node.type === 3) {
|
10746 | return true
|
10747 | }
|
10748 | return !!(node.pre || (
|
10749 | !node.hasBindings &&
|
10750 | !node.if && !node.for &&
|
10751 | !isBuiltInTag(node.tag) &&
|
10752 | isPlatformReservedTag(node.tag) &&
|
10753 | !isDirectChildOfTemplateFor(node) &&
|
10754 | Object.keys(node).every(isStaticKey)
|
10755 | ))
|
10756 | }
|
10757 |
|
10758 | function isDirectChildOfTemplateFor (node) {
|
10759 | while (node.parent) {
|
10760 | node = node.parent;
|
10761 | if (node.tag !== 'template') {
|
10762 | return false
|
10763 | }
|
10764 | if (node.for) {
|
10765 | return true
|
10766 | }
|
10767 | }
|
10768 | return false
|
10769 | }
|
10770 |
|
10771 |
|
10772 |
|
10773 | var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
|
10774 | var fnInvokeRE = /\([^)]*?\);*$/;
|
10775 | var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
10776 |
|
10777 |
|
10778 | var keyCodes = {
|
10779 | esc: 27,
|
10780 | tab: 9,
|
10781 | enter: 13,
|
10782 | space: 32,
|
10783 | up: 38,
|
10784 | left: 37,
|
10785 | right: 39,
|
10786 | down: 40,
|
10787 | 'delete': [8, 46]
|
10788 | };
|
10789 |
|
10790 |
|
10791 | var keyNames = {
|
10792 |
|
10793 | esc: ['Esc', 'Escape'],
|
10794 | tab: 'Tab',
|
10795 | enter: 'Enter',
|
10796 |
|
10797 | space: [' ', 'Spacebar'],
|
10798 |
|
10799 | up: ['Up', 'ArrowUp'],
|
10800 | left: ['Left', 'ArrowLeft'],
|
10801 | right: ['Right', 'ArrowRight'],
|
10802 | down: ['Down', 'ArrowDown'],
|
10803 |
|
10804 | 'delete': ['Backspace', 'Delete', 'Del']
|
10805 | };
|
10806 |
|
10807 |
|
10808 |
|
10809 |
|
10810 | var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
|
10811 |
|
10812 | var modifierCode = {
|
10813 | stop: '$event.stopPropagation();',
|
10814 | prevent: '$event.preventDefault();',
|
10815 | self: genGuard("$event.target !== $event.currentTarget"),
|
10816 | ctrl: genGuard("!$event.ctrlKey"),
|
10817 | shift: genGuard("!$event.shiftKey"),
|
10818 | alt: genGuard("!$event.altKey"),
|
10819 | meta: genGuard("!$event.metaKey"),
|
10820 | left: genGuard("'button' in $event && $event.button !== 0"),
|
10821 | middle: genGuard("'button' in $event && $event.button !== 1"),
|
10822 | right: genGuard("'button' in $event && $event.button !== 2")
|
10823 | };
|
10824 |
|
10825 | function genHandlers (
|
10826 | events,
|
10827 | isNative
|
10828 | ) {
|
10829 | var prefix = isNative ? 'nativeOn:' : 'on:';
|
10830 | var staticHandlers = "";
|
10831 | var dynamicHandlers = "";
|
10832 | for (var name in events) {
|
10833 | var handlerCode = genHandler(events[name]);
|
10834 | if (events[name] && events[name].dynamic) {
|
10835 | dynamicHandlers += name + "," + handlerCode + ",";
|
10836 | } else {
|
10837 | staticHandlers += "\"" + name + "\":" + handlerCode + ",";
|
10838 | }
|
10839 | }
|
10840 | staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
|
10841 | if (dynamicHandlers) {
|
10842 | return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
|
10843 | } else {
|
10844 | return prefix + staticHandlers
|
10845 | }
|
10846 | }
|
10847 |
|
10848 | function genHandler (handler) {
|
10849 | if (!handler) {
|
10850 | return 'function(){}'
|
10851 | }
|
10852 |
|
10853 | if (Array.isArray(handler)) {
|
10854 | return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
|
10855 | }
|
10856 |
|
10857 | var isMethodPath = simplePathRE.test(handler.value);
|
10858 | var isFunctionExpression = fnExpRE.test(handler.value);
|
10859 | var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
|
10860 |
|
10861 | if (!handler.modifiers) {
|
10862 | if (isMethodPath || isFunctionExpression) {
|
10863 | return handler.value
|
10864 | }
|
10865 | return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}")
|
10866 | } else {
|
10867 | var code = '';
|
10868 | var genModifierCode = '';
|
10869 | var keys = [];
|
10870 | for (var key in handler.modifiers) {
|
10871 | if (modifierCode[key]) {
|
10872 | genModifierCode += modifierCode[key];
|
10873 |
|
10874 | if (keyCodes[key]) {
|
10875 | keys.push(key);
|
10876 | }
|
10877 | } else if (key === 'exact') {
|
10878 | var modifiers = (handler.modifiers);
|
10879 | genModifierCode += genGuard(
|
10880 | ['ctrl', 'shift', 'alt', 'meta']
|
10881 | .filter(function (keyModifier) { return !modifiers[keyModifier]; })
|
10882 | .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
|
10883 | .join('||')
|
10884 | );
|
10885 | } else {
|
10886 | keys.push(key);
|
10887 | }
|
10888 | }
|
10889 | if (keys.length) {
|
10890 | code += genKeyFilter(keys);
|
10891 | }
|
10892 |
|
10893 | if (genModifierCode) {
|
10894 | code += genModifierCode;
|
10895 | }
|
10896 | var handlerCode = isMethodPath
|
10897 | ? ("return " + (handler.value) + ".apply(null, arguments)")
|
10898 | : isFunctionExpression
|
10899 | ? ("return (" + (handler.value) + ").apply(null, arguments)")
|
10900 | : isFunctionInvocation
|
10901 | ? ("return " + (handler.value))
|
10902 | : handler.value;
|
10903 | return ("function($event){" + code + handlerCode + "}")
|
10904 | }
|
10905 | }
|
10906 |
|
10907 | function genKeyFilter (keys) {
|
10908 | return (
|
10909 |
|
10910 |
|
10911 |
|
10912 | "if(!$event.type.indexOf('key')&&" +
|
10913 | (keys.map(genFilterCode).join('&&')) + ")return null;"
|
10914 | )
|
10915 | }
|
10916 |
|
10917 | function genFilterCode (key) {
|
10918 | var keyVal = parseInt(key, 10);
|
10919 | if (keyVal) {
|
10920 | return ("$event.keyCode!==" + keyVal)
|
10921 | }
|
10922 | var keyCode = keyCodes[key];
|
10923 | var keyName = keyNames[key];
|
10924 | return (
|
10925 | "_k($event.keyCode," +
|
10926 | (JSON.stringify(key)) + "," +
|
10927 | (JSON.stringify(keyCode)) + "," +
|
10928 | "$event.key," +
|
10929 | "" + (JSON.stringify(keyName)) +
|
10930 | ")"
|
10931 | )
|
10932 | }
|
10933 |
|
10934 |
|
10935 |
|
10936 | function on (el, dir) {
|
10937 | if (dir.modifiers) {
|
10938 | warn("v-on without argument does not support modifiers.");
|
10939 | }
|
10940 | el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
|
10941 | }
|
10942 |
|
10943 |
|
10944 |
|
10945 | function bind$1 (el, dir) {
|
10946 | el.wrapData = function (code) {
|
10947 | return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
|
10948 | };
|
10949 | }
|
10950 |
|
10951 |
|
10952 |
|
10953 | var baseDirectives = {
|
10954 | on: on,
|
10955 | bind: bind$1,
|
10956 | cloak: noop
|
10957 | };
|
10958 |
|
10959 |
|
10960 |
|
10961 |
|
10962 |
|
10963 |
|
10964 |
|
10965 | var CodegenState = function CodegenState (options) {
|
10966 | this.options = options;
|
10967 | this.warn = options.warn || baseWarn;
|
10968 | this.transforms = pluckModuleFunction(options.modules, 'transformCode');
|
10969 | this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
10970 | this.directives = extend(extend({}, baseDirectives), options.directives);
|
10971 | var isReservedTag = options.isReservedTag || no;
|
10972 | this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
|
10973 | this.onceId = 0;
|
10974 | this.staticRenderFns = [];
|
10975 | this.pre = false;
|
10976 | };
|
10977 |
|
10978 |
|
10979 |
|
10980 | function generate (
|
10981 | ast,
|
10982 | options
|
10983 | ) {
|
10984 | var state = new CodegenState(options);
|
10985 |
|
10986 | var code = ast ? (ast.tag === 'script' ? 'null' : genElement(ast, state)) : '_c("div")';
|
10987 | return {
|
10988 | render: ("with(this){return " + code + "}"),
|
10989 | staticRenderFns: state.staticRenderFns
|
10990 | }
|
10991 | }
|
10992 |
|
10993 | function genElement (el, state) {
|
10994 | if (el.parent) {
|
10995 | el.pre = el.pre || el.parent.pre;
|
10996 | }
|
10997 |
|
10998 | if (el.staticRoot && !el.staticProcessed) {
|
10999 | return genStatic(el, state)
|
11000 | } else if (el.once && !el.onceProcessed) {
|
11001 | return genOnce(el, state)
|
11002 | } else if (el.for && !el.forProcessed) {
|
11003 | return genFor(el, state)
|
11004 | } else if (el.if && !el.ifProcessed) {
|
11005 | return genIf(el, state)
|
11006 | } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
|
11007 | return genChildren(el, state) || 'void 0'
|
11008 | } else if (el.tag === 'slot') {
|
11009 | return genSlot(el, state)
|
11010 | } else {
|
11011 |
|
11012 | var code;
|
11013 | if (el.component) {
|
11014 | code = genComponent(el.component, el, state);
|
11015 | } else {
|
11016 | var data;
|
11017 | if (!el.plain || (el.pre && state.maybeComponent(el))) {
|
11018 | data = genData$2(el, state);
|
11019 | }
|
11020 |
|
11021 | var children = el.inlineTemplate ? null : genChildren(el, state, true);
|
11022 | code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
|
11023 | }
|
11024 |
|
11025 | for (var i = 0; i < state.transforms.length; i++) {
|
11026 | code = state.transforms[i](el, code);
|
11027 | }
|
11028 | return code
|
11029 | }
|
11030 | }
|
11031 |
|
11032 |
|
11033 | function genStatic (el, state) {
|
11034 | el.staticProcessed = true;
|
11035 |
|
11036 |
|
11037 |
|
11038 | var originalPreState = state.pre;
|
11039 | if (el.pre) {
|
11040 | state.pre = el.pre;
|
11041 | }
|
11042 | state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
|
11043 | state.pre = originalPreState;
|
11044 | return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
|
11045 | }
|
11046 |
|
11047 |
|
11048 | function genOnce (el, state) {
|
11049 | el.onceProcessed = true;
|
11050 | if (el.if && !el.ifProcessed) {
|
11051 | return genIf(el, state)
|
11052 | } else if (el.staticInFor) {
|
11053 | var key = '';
|
11054 | var parent = el.parent;
|
11055 | while (parent) {
|
11056 | if (parent.for) {
|
11057 | key = parent.key;
|
11058 | break
|
11059 | }
|
11060 | parent = parent.parent;
|
11061 | }
|
11062 | if (!key) {
|
11063 | state.warn(
|
11064 | "v-once can only be used inside v-for that is keyed. ",
|
11065 | el.rawAttrsMap['v-once']
|
11066 | );
|
11067 | return genElement(el, state)
|
11068 | }
|
11069 | return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
|
11070 | } else {
|
11071 | return genStatic(el, state)
|
11072 | }
|
11073 | }
|
11074 |
|
11075 | function genIf (
|
11076 | el,
|
11077 | state,
|
11078 | altGen,
|
11079 | altEmpty
|
11080 | ) {
|
11081 | el.ifProcessed = true;
|
11082 | return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
|
11083 | }
|
11084 |
|
11085 | function genIfConditions (
|
11086 | conditions,
|
11087 | state,
|
11088 | altGen,
|
11089 | altEmpty
|
11090 | ) {
|
11091 | if (!conditions.length) {
|
11092 | return altEmpty || '_e()'
|
11093 | }
|
11094 |
|
11095 | var condition = conditions.shift();
|
11096 | if (condition.exp) {
|
11097 | return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
|
11098 | } else {
|
11099 | return ("" + (genTernaryExp(condition.block)))
|
11100 | }
|
11101 |
|
11102 |
|
11103 | function genTernaryExp (el) {
|
11104 | return altGen
|
11105 | ? altGen(el, state)
|
11106 | : el.once
|
11107 | ? genOnce(el, state)
|
11108 | : genElement(el, state)
|
11109 | }
|
11110 | }
|
11111 |
|
11112 | function genFor (
|
11113 | el,
|
11114 | state,
|
11115 | altGen,
|
11116 | altHelper
|
11117 | ) {
|
11118 | var exp = el.for;
|
11119 | var alias = el.alias;
|
11120 | var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
|
11121 | var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
|
11122 |
|
11123 | if (state.maybeComponent(el) &&
|
11124 | el.tag !== 'slot' &&
|
11125 | el.tag !== 'template' &&
|
11126 | !el.key
|
11127 | ) {
|
11128 | state.warn(
|
11129 | "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
|
11130 | "v-for should have explicit keys. " +
|
11131 | "See https://vuejs.org/guide/list.html#key for more info.",
|
11132 | el.rawAttrsMap['v-for'],
|
11133 | true
|
11134 | );
|
11135 | }
|
11136 |
|
11137 | el.forProcessed = true;
|
11138 | return (altHelper || '_l') + "((" + exp + ")," +
|
11139 | "function(" + alias + iterator1 + iterator2 + "){" +
|
11140 | "return " + ((altGen || genElement)(el, state)) +
|
11141 | '})'
|
11142 | }
|
11143 |
|
11144 | function genData$2 (el, state) {
|
11145 | var data = '{';
|
11146 |
|
11147 |
|
11148 |
|
11149 | var dirs = genDirectives(el, state);
|
11150 | if (dirs) { data += dirs + ','; }
|
11151 |
|
11152 |
|
11153 | if (el.key) {
|
11154 | data += "key:" + (el.key) + ",";
|
11155 | }
|
11156 |
|
11157 | if (el.ref) {
|
11158 | data += "ref:" + (el.ref) + ",";
|
11159 | }
|
11160 | if (el.refInFor) {
|
11161 | data += "refInFor:true,";
|
11162 | }
|
11163 |
|
11164 | if (el.pre) {
|
11165 | data += "pre:true,";
|
11166 | }
|
11167 |
|
11168 | if (el.component) {
|
11169 | data += "tag:\"" + (el.tag) + "\",";
|
11170 | }
|
11171 |
|
11172 | for (var i = 0; i < state.dataGenFns.length; i++) {
|
11173 | data += state.dataGenFns[i](el);
|
11174 | }
|
11175 |
|
11176 | if (el.attrs) {
|
11177 | data += "attrs:" + (genProps(el.attrs)) + ",";
|
11178 | }
|
11179 |
|
11180 | if (el.props) {
|
11181 | data += "domProps:" + (genProps(el.props)) + ",";
|
11182 | }
|
11183 |
|
11184 | if (el.events) {
|
11185 | data += (genHandlers(el.events, false)) + ",";
|
11186 | }
|
11187 | if (el.nativeEvents) {
|
11188 | data += (genHandlers(el.nativeEvents, true)) + ",";
|
11189 | }
|
11190 |
|
11191 |
|
11192 | if (el.slotTarget && !el.slotScope) {
|
11193 | data += "slot:" + (el.slotTarget) + ",";
|
11194 | }
|
11195 |
|
11196 | if (el.scopedSlots) {
|
11197 | data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
|
11198 | }
|
11199 |
|
11200 | if (el.model) {
|
11201 | data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
|
11202 | }
|
11203 |
|
11204 | if (el.inlineTemplate) {
|
11205 | var inlineTemplate = genInlineTemplate(el, state);
|
11206 | if (inlineTemplate) {
|
11207 | data += inlineTemplate + ",";
|
11208 | }
|
11209 | }
|
11210 | data = data.replace(/,$/, '') + '}';
|
11211 |
|
11212 |
|
11213 |
|
11214 | if (el.dynamicAttrs) {
|
11215 | data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
|
11216 | }
|
11217 |
|
11218 | if (el.wrapData) {
|
11219 | data = el.wrapData(data);
|
11220 | }
|
11221 |
|
11222 | if (el.wrapListeners) {
|
11223 | data = el.wrapListeners(data);
|
11224 | }
|
11225 | return data
|
11226 | }
|
11227 |
|
11228 | function genDirectives (el, state) {
|
11229 | var dirs = el.directives;
|
11230 | if (!dirs) { return }
|
11231 | var res = 'directives:[';
|
11232 | var hasRuntime = false;
|
11233 | var i, l, dir, needRuntime;
|
11234 | for (i = 0, l = dirs.length; i < l; i++) {
|
11235 | dir = dirs[i];
|
11236 | needRuntime = true;
|
11237 | var gen = state.directives[dir.name];
|
11238 | if (gen) {
|
11239 |
|
11240 |
|
11241 | needRuntime = !!gen(el, dir, state.warn);
|
11242 | }
|
11243 | if (needRuntime) {
|
11244 | hasRuntime = true;
|
11245 | res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
|
11246 | }
|
11247 | }
|
11248 | if (hasRuntime) {
|
11249 | return res.slice(0, -1) + ']'
|
11250 | }
|
11251 | }
|
11252 |
|
11253 | function genInlineTemplate (el, state) {
|
11254 | var ast = el.children[0];
|
11255 | if (el.children.length !== 1 || ast.type !== 1) {
|
11256 | state.warn(
|
11257 | 'Inline-template components must have exactly one child element.',
|
11258 | { start: el.start }
|
11259 | );
|
11260 | }
|
11261 | if (ast && ast.type === 1) {
|
11262 | var inlineRenderFns = generate(ast, state.options);
|
11263 | return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
|
11264 | }
|
11265 | }
|
11266 |
|
11267 | function genScopedSlots (
|
11268 | el,
|
11269 | slots,
|
11270 | state
|
11271 | ) {
|
11272 |
|
11273 |
|
11274 |
|
11275 |
|
11276 | var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
|
11277 | var slot = slots[key];
|
11278 | return (
|
11279 | slot.slotTargetDynamic ||
|
11280 | slot.if ||
|
11281 | slot.for ||
|
11282 | containsSlotChild(slot)
|
11283 | )
|
11284 | });
|
11285 |
|
11286 |
|
11287 |
|
11288 |
|
11289 |
|
11290 | var needsKey = !!el.if;
|
11291 |
|
11292 |
|
11293 |
|
11294 |
|
11295 |
|
11296 |
|
11297 | if (!needsForceUpdate) {
|
11298 | var parent = el.parent;
|
11299 | while (parent) {
|
11300 | if (
|
11301 | (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
|
11302 | parent.for
|
11303 | ) {
|
11304 | needsForceUpdate = true;
|
11305 | break
|
11306 | }
|
11307 | if (parent.if) {
|
11308 | needsKey = true;
|
11309 | }
|
11310 | parent = parent.parent;
|
11311 | }
|
11312 | }
|
11313 |
|
11314 | var generatedSlots = Object.keys(slots)
|
11315 | .map(function (key) { return genScopedSlot(slots[key], state); })
|
11316 | .join(',');
|
11317 |
|
11318 | return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
|
11319 | }
|
11320 |
|
11321 | function hash(str) {
|
11322 | var hash = 5381;
|
11323 | var i = str.length;
|
11324 | while(i) {
|
11325 | hash = (hash * 33) ^ str.charCodeAt(--i);
|
11326 | }
|
11327 | return hash >>> 0
|
11328 | }
|
11329 |
|
11330 | function containsSlotChild (el) {
|
11331 | if (el.type === 1) {
|
11332 | if (el.tag === 'slot') {
|
11333 | return true
|
11334 | }
|
11335 | return el.children.some(containsSlotChild)
|
11336 | }
|
11337 | return false
|
11338 | }
|
11339 |
|
11340 | function genScopedSlot (
|
11341 | el,
|
11342 | state
|
11343 | ) {
|
11344 | var isLegacySyntax = el.attrsMap['slot-scope'];
|
11345 | if (el.if && !el.ifProcessed && !isLegacySyntax) {
|
11346 | return genIf(el, state, genScopedSlot, "null")
|
11347 | }
|
11348 | if (el.for && !el.forProcessed) {
|
11349 | return genFor(el, state, genScopedSlot)
|
11350 | }
|
11351 | var slotScope = el.slotScope === emptySlotScopeToken
|
11352 | ? ""
|
11353 | : String(el.slotScope);
|
11354 | var fn = "function(" + slotScope + "){" +
|
11355 | "return " + (el.tag === 'template'
|
11356 | ? el.if && isLegacySyntax
|
11357 | ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
|
11358 | : genChildren(el, state) || 'undefined'
|
11359 | : genElement(el, state)) + "}";
|
11360 |
|
11361 | var reverseProxy = slotScope ? "" : ",proxy:true";
|
11362 | return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
|
11363 | }
|
11364 |
|
11365 | function genChildren (
|
11366 | el,
|
11367 | state,
|
11368 | checkSkip,
|
11369 | altGenElement,
|
11370 | altGenNode
|
11371 | ) {
|
11372 | var children = el.children;
|
11373 | if (children.length) {
|
11374 | var el$1 = children[0];
|
11375 |
|
11376 | if (children.length === 1 &&
|
11377 | el$1.for &&
|
11378 | el$1.tag !== 'template' &&
|
11379 | el$1.tag !== 'slot'
|
11380 | ) {
|
11381 | var normalizationType = checkSkip
|
11382 | ? state.maybeComponent(el$1) ? ",1" : ",0"
|
11383 | : "";
|
11384 | return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
|
11385 | }
|
11386 | var normalizationType$1 = checkSkip
|
11387 | ? getNormalizationType(children, state.maybeComponent)
|
11388 | : 0;
|
11389 | var gen = altGenNode || genNode;
|
11390 | return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
|
11391 | }
|
11392 | }
|
11393 |
|
11394 |
|
11395 |
|
11396 |
|
11397 |
|
11398 | function getNormalizationType (
|
11399 | children,
|
11400 | maybeComponent
|
11401 | ) {
|
11402 | var res = 0;
|
11403 | for (var i = 0; i < children.length; i++) {
|
11404 | var el = children[i];
|
11405 | if (el.type !== 1) {
|
11406 | continue
|
11407 | }
|
11408 | if (needsNormalization(el) ||
|
11409 | (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
|
11410 | res = 2;
|
11411 | break
|
11412 | }
|
11413 | if (maybeComponent(el) ||
|
11414 | (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
|
11415 | res = 1;
|
11416 | }
|
11417 | }
|
11418 | return res
|
11419 | }
|
11420 |
|
11421 | function needsNormalization (el) {
|
11422 | return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
|
11423 | }
|
11424 |
|
11425 | function genNode (node, state) {
|
11426 | if (node.type === 1) {
|
11427 | return genElement(node, state)
|
11428 | } else if (node.type === 3 && node.isComment) {
|
11429 | return genComment(node)
|
11430 | } else {
|
11431 | return genText(node)
|
11432 | }
|
11433 | }
|
11434 |
|
11435 | function genText (text) {
|
11436 | return ("_v(" + (text.type === 2
|
11437 | ? text.expression
|
11438 | : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
|
11439 | }
|
11440 |
|
11441 | function genComment (comment) {
|
11442 | return ("_e(" + (JSON.stringify(comment.text)) + ")")
|
11443 | }
|
11444 |
|
11445 | function genSlot (el, state) {
|
11446 | var slotName = el.slotName || '"default"';
|
11447 | var children = genChildren(el, state);
|
11448 | var res = "_t(" + slotName + (children ? (",function(){return " + children + "}") : '');
|
11449 | var attrs = el.attrs || el.dynamicAttrs
|
11450 | ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
|
11451 |
|
11452 | name: camelize(attr.name),
|
11453 | value: attr.value,
|
11454 | dynamic: attr.dynamic
|
11455 | }); }))
|
11456 | : null;
|
11457 | var bind$$1 = el.attrsMap['v-bind'];
|
11458 | if ((attrs || bind$$1) && !children) {
|
11459 | res += ",null";
|
11460 | }
|
11461 | if (attrs) {
|
11462 | res += "," + attrs;
|
11463 | }
|
11464 | if (bind$$1) {
|
11465 | res += (attrs ? '' : ',null') + "," + bind$$1;
|
11466 | }
|
11467 | return res + ')'
|
11468 | }
|
11469 |
|
11470 |
|
11471 | function genComponent (
|
11472 | componentName,
|
11473 | el,
|
11474 | state
|
11475 | ) {
|
11476 | var children = el.inlineTemplate ? null : genChildren(el, state, true);
|
11477 | return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
|
11478 | }
|
11479 |
|
11480 | function genProps (props) {
|
11481 | var staticProps = "";
|
11482 | var dynamicProps = "";
|
11483 | for (var i = 0; i < props.length; i++) {
|
11484 | var prop = props[i];
|
11485 | var value = transformSpecialNewlines(prop.value);
|
11486 | if (prop.dynamic) {
|
11487 | dynamicProps += (prop.name) + "," + value + ",";
|
11488 | } else {
|
11489 | staticProps += "\"" + (prop.name) + "\":" + value + ",";
|
11490 | }
|
11491 | }
|
11492 | staticProps = "{" + (staticProps.slice(0, -1)) + "}";
|
11493 | if (dynamicProps) {
|
11494 | return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
|
11495 | } else {
|
11496 | return staticProps
|
11497 | }
|
11498 | }
|
11499 |
|
11500 |
|
11501 | function transformSpecialNewlines (text) {
|
11502 | return text
|
11503 | .replace(/\u2028/g, '\\u2028')
|
11504 | .replace(/\u2029/g, '\\u2029')
|
11505 | }
|
11506 |
|
11507 |
|
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 |
|
11513 | var prohibitedKeywordRE = new RegExp('\\b' + (
|
11514 | 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
11515 | 'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
11516 | 'extends,finally,continue,debugger,function,arguments'
|
11517 | ).split(',').join('\\b|\\b') + '\\b');
|
11518 |
|
11519 |
|
11520 | var unaryOperatorsRE = new RegExp('\\b' + (
|
11521 | 'delete,typeof,void'
|
11522 | ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
|
11523 |
|
11524 |
|
11525 | var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
11526 |
|
11527 |
|
11528 | function detectErrors (ast, warn) {
|
11529 | if (ast) {
|
11530 | checkNode(ast, warn);
|
11531 | }
|
11532 | }
|
11533 |
|
11534 | function checkNode (node, warn) {
|
11535 | if (node.type === 1) {
|
11536 | for (var name in node.attrsMap) {
|
11537 | if (dirRE.test(name)) {
|
11538 | var value = node.attrsMap[name];
|
11539 | if (value) {
|
11540 | var range = node.rawAttrsMap[name];
|
11541 | if (name === 'v-for') {
|
11542 | checkFor(node, ("v-for=\"" + value + "\""), warn, range);
|
11543 | } else if (name === 'v-slot' || name[0] === '#') {
|
11544 | checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
|
11545 | } else if (onRE.test(name)) {
|
11546 | checkEvent(value, (name + "=\"" + value + "\""), warn, range);
|
11547 | } else {
|
11548 | checkExpression(value, (name + "=\"" + value + "\""), warn, range);
|
11549 | }
|
11550 | }
|
11551 | }
|
11552 | }
|
11553 | if (node.children) {
|
11554 | for (var i = 0; i < node.children.length; i++) {
|
11555 | checkNode(node.children[i], warn);
|
11556 | }
|
11557 | }
|
11558 | } else if (node.type === 2) {
|
11559 | checkExpression(node.expression, node.text, warn, node);
|
11560 | }
|
11561 | }
|
11562 |
|
11563 | function checkEvent (exp, text, warn, range) {
|
11564 | var stripped = exp.replace(stripStringRE, '');
|
11565 | var keywordMatch = stripped.match(unaryOperatorsRE);
|
11566 | if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
|
11567 | warn(
|
11568 | "avoid using JavaScript unary operator as property name: " +
|
11569 | "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
|
11570 | range
|
11571 | );
|
11572 | }
|
11573 | checkExpression(exp, text, warn, range);
|
11574 | }
|
11575 |
|
11576 | function checkFor (node, text, warn, range) {
|
11577 | checkExpression(node.for || '', text, warn, range);
|
11578 | checkIdentifier(node.alias, 'v-for alias', text, warn, range);
|
11579 | checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
|
11580 | checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
|
11581 | }
|
11582 |
|
11583 | function checkIdentifier (
|
11584 | ident,
|
11585 | type,
|
11586 | text,
|
11587 | warn,
|
11588 | range
|
11589 | ) {
|
11590 | if (typeof ident === 'string') {
|
11591 | try {
|
11592 | new Function(("var " + ident + "=_"));
|
11593 | } catch (e) {
|
11594 | warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
|
11595 | }
|
11596 | }
|
11597 | }
|
11598 |
|
11599 | function checkExpression (exp, text, warn, range) {
|
11600 | try {
|
11601 | new Function(("return " + exp));
|
11602 | } catch (e) {
|
11603 | var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
|
11604 | if (keywordMatch) {
|
11605 | warn(
|
11606 | "avoid using JavaScript keyword as property name: " +
|
11607 | "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
|
11608 | range
|
11609 | );
|
11610 | } else {
|
11611 | warn(
|
11612 | "invalid expression: " + (e.message) + " in\n\n" +
|
11613 | " " + exp + "\n\n" +
|
11614 | " Raw expression: " + (text.trim()) + "\n",
|
11615 | range
|
11616 | );
|
11617 | }
|
11618 | }
|
11619 | }
|
11620 |
|
11621 | function checkFunctionParameterExpression (exp, text, warn, range) {
|
11622 | try {
|
11623 | new Function(exp, '');
|
11624 | } catch (e) {
|
11625 | warn(
|
11626 | "invalid function parameter expression: " + (e.message) + " in\n\n" +
|
11627 | " " + exp + "\n\n" +
|
11628 | " Raw expression: " + (text.trim()) + "\n",
|
11629 | range
|
11630 | );
|
11631 | }
|
11632 | }
|
11633 |
|
11634 |
|
11635 |
|
11636 | var range = 2;
|
11637 |
|
11638 | function generateCodeFrame (
|
11639 | source,
|
11640 | start,
|
11641 | end
|
11642 | ) {
|
11643 | if ( start === void 0 ) start = 0;
|
11644 | if ( end === void 0 ) end = source.length;
|
11645 |
|
11646 | var lines = source.split(/\r?\n/);
|
11647 | var count = 0;
|
11648 | var res = [];
|
11649 | for (var i = 0; i < lines.length; i++) {
|
11650 | count += lines[i].length + 1;
|
11651 | if (count >= start) {
|
11652 | for (var j = i - range; j <= i + range || end > count; j++) {
|
11653 | if (j < 0 || j >= lines.length) { continue }
|
11654 | res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
|
11655 | var lineLength = lines[j].length;
|
11656 | if (j === i) {
|
11657 |
|
11658 | var pad = start - (count - lineLength) + 1;
|
11659 | var length = end > count ? lineLength - pad : end - start;
|
11660 | res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
|
11661 | } else if (j > i) {
|
11662 | if (end > count) {
|
11663 | var length$1 = Math.min(end - count, lineLength);
|
11664 | res.push(" | " + repeat$1("^", length$1));
|
11665 | }
|
11666 | count += lineLength + 1;
|
11667 | }
|
11668 | }
|
11669 | break
|
11670 | }
|
11671 | }
|
11672 | return res.join('\n')
|
11673 | }
|
11674 |
|
11675 | function repeat$1 (str, n) {
|
11676 | var result = '';
|
11677 | if (n > 0) {
|
11678 | while (true) {
|
11679 | if (n & 1) { result += str; }
|
11680 | n >>>= 1;
|
11681 | if (n <= 0) { break }
|
11682 | str += str;
|
11683 | }
|
11684 | }
|
11685 | return result
|
11686 | }
|
11687 |
|
11688 |
|
11689 |
|
11690 |
|
11691 |
|
11692 | function createFunction (code, errors) {
|
11693 | try {
|
11694 | return new Function(code)
|
11695 | } catch (err) {
|
11696 | errors.push({ err: err, code: code });
|
11697 | return noop
|
11698 | }
|
11699 | }
|
11700 |
|
11701 | function createCompileToFunctionFn (compile) {
|
11702 | var cache = Object.create(null);
|
11703 |
|
11704 | return function compileToFunctions (
|
11705 | template,
|
11706 | options,
|
11707 | vm
|
11708 | ) {
|
11709 | options = extend({}, options);
|
11710 | var warn$$1 = options.warn || warn;
|
11711 | delete options.warn;
|
11712 |
|
11713 |
|
11714 | {
|
11715 |
|
11716 | try {
|
11717 | new Function('return 1');
|
11718 | } catch (e) {
|
11719 | if (e.toString().match(/unsafe-eval|CSP/)) {
|
11720 | warn$$1(
|
11721 | 'It seems you are using the standalone build of Vue.js in an ' +
|
11722 | 'environment with Content Security Policy that prohibits unsafe-eval. ' +
|
11723 | 'The template compiler cannot work in this environment. Consider ' +
|
11724 | 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
|
11725 | 'templates into render functions.'
|
11726 | );
|
11727 | }
|
11728 | }
|
11729 | }
|
11730 |
|
11731 |
|
11732 | var key = options.delimiters
|
11733 | ? String(options.delimiters) + template
|
11734 | : template;
|
11735 | if (cache[key]) {
|
11736 | return cache[key]
|
11737 | }
|
11738 |
|
11739 |
|
11740 | var compiled = compile(template, options);
|
11741 |
|
11742 |
|
11743 | {
|
11744 | if (compiled.errors && compiled.errors.length) {
|
11745 | if (options.outputSourceRange) {
|
11746 | compiled.errors.forEach(function (e) {
|
11747 | warn$$1(
|
11748 | "Error compiling template:\n\n" + (e.msg) + "\n\n" +
|
11749 | generateCodeFrame(template, e.start, e.end),
|
11750 | vm
|
11751 | );
|
11752 | });
|
11753 | } else {
|
11754 | warn$$1(
|
11755 | "Error compiling template:\n\n" + template + "\n\n" +
|
11756 | compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
|
11757 | vm
|
11758 | );
|
11759 | }
|
11760 | }
|
11761 | if (compiled.tips && compiled.tips.length) {
|
11762 | if (options.outputSourceRange) {
|
11763 | compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
|
11764 | } else {
|
11765 | compiled.tips.forEach(function (msg) { return tip(msg, vm); });
|
11766 | }
|
11767 | }
|
11768 | }
|
11769 |
|
11770 |
|
11771 | var res = {};
|
11772 | var fnGenErrors = [];
|
11773 | res.render = createFunction(compiled.render, fnGenErrors);
|
11774 | res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
|
11775 | return createFunction(code, fnGenErrors)
|
11776 | });
|
11777 |
|
11778 |
|
11779 |
|
11780 |
|
11781 |
|
11782 | {
|
11783 | if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
|
11784 | warn$$1(
|
11785 | "Failed to generate render function:\n\n" +
|
11786 | fnGenErrors.map(function (ref) {
|
11787 | var err = ref.err;
|
11788 | var code = ref.code;
|
11789 |
|
11790 | return ((err.toString()) + " in\n\n" + code + "\n");
|
11791 | }).join('\n'),
|
11792 | vm
|
11793 | );
|
11794 | }
|
11795 | }
|
11796 |
|
11797 | return (cache[key] = res)
|
11798 | }
|
11799 | }
|
11800 |
|
11801 |
|
11802 |
|
11803 | function createCompilerCreator (baseCompile) {
|
11804 | return function createCompiler (baseOptions) {
|
11805 | function compile (
|
11806 | template,
|
11807 | options
|
11808 | ) {
|
11809 | var finalOptions = Object.create(baseOptions);
|
11810 | var errors = [];
|
11811 | var tips = [];
|
11812 |
|
11813 | var warn = function (msg, range, tip) {
|
11814 | (tip ? tips : errors).push(msg);
|
11815 | };
|
11816 |
|
11817 | if (options) {
|
11818 | if (options.outputSourceRange) {
|
11819 |
|
11820 | var leadingSpaceLength = template.match(/^\s*/)[0].length;
|
11821 |
|
11822 | warn = function (msg, range, tip) {
|
11823 | var data = { msg: msg };
|
11824 | if (range) {
|
11825 | if (range.start != null) {
|
11826 | data.start = range.start + leadingSpaceLength;
|
11827 | }
|
11828 | if (range.end != null) {
|
11829 | data.end = range.end + leadingSpaceLength;
|
11830 | }
|
11831 | }
|
11832 | (tip ? tips : errors).push(data);
|
11833 | };
|
11834 | }
|
11835 |
|
11836 | if (options.modules) {
|
11837 | finalOptions.modules =
|
11838 | (baseOptions.modules || []).concat(options.modules);
|
11839 | }
|
11840 |
|
11841 | if (options.directives) {
|
11842 | finalOptions.directives = extend(
|
11843 | Object.create(baseOptions.directives || null),
|
11844 | options.directives
|
11845 | );
|
11846 | }
|
11847 |
|
11848 | for (var key in options) {
|
11849 | if (key !== 'modules' && key !== 'directives') {
|
11850 | finalOptions[key] = options[key];
|
11851 | }
|
11852 | }
|
11853 | }
|
11854 |
|
11855 | finalOptions.warn = warn;
|
11856 |
|
11857 | var compiled = baseCompile(template.trim(), finalOptions);
|
11858 | {
|
11859 | detectErrors(compiled.ast, warn);
|
11860 | }
|
11861 | compiled.errors = errors;
|
11862 | compiled.tips = tips;
|
11863 | return compiled
|
11864 | }
|
11865 |
|
11866 | return {
|
11867 | compile: compile,
|
11868 | compileToFunctions: createCompileToFunctionFn(compile)
|
11869 | }
|
11870 | }
|
11871 | }
|
11872 |
|
11873 |
|
11874 |
|
11875 |
|
11876 |
|
11877 |
|
11878 | var createCompiler = createCompilerCreator(function baseCompile (
|
11879 | template,
|
11880 | options
|
11881 | ) {
|
11882 | var ast = parse(template.trim(), options);
|
11883 | if (options.optimize !== false) {
|
11884 | optimize(ast, options);
|
11885 | }
|
11886 | var code = generate(ast, options);
|
11887 | return {
|
11888 | ast: ast,
|
11889 | render: code.render,
|
11890 | staticRenderFns: code.staticRenderFns
|
11891 | }
|
11892 | });
|
11893 |
|
11894 |
|
11895 |
|
11896 | var ref$1 = createCompiler(baseOptions);
|
11897 | var compile = ref$1.compile;
|
11898 | var compileToFunctions = ref$1.compileToFunctions;
|
11899 |
|
11900 |
|
11901 |
|
11902 |
|
11903 | var div;
|
11904 | function getShouldDecode (href) {
|
11905 | div = div || document.createElement('div');
|
11906 | div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
|
11907 | return div.innerHTML.indexOf(' ') > 0
|
11908 | }
|
11909 |
|
11910 |
|
11911 | var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
|
11912 |
|
11913 | var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
|
11914 |
|
11915 |
|
11916 |
|
11917 | var idToTemplate = cached(function (id) {
|
11918 | var el = query(id);
|
11919 | return el && el.innerHTML
|
11920 | });
|
11921 |
|
11922 | var mount = Vue.prototype.$mount;
|
11923 | Vue.prototype.$mount = function (
|
11924 | el,
|
11925 | hydrating
|
11926 | ) {
|
11927 | el = el && query(el);
|
11928 |
|
11929 |
|
11930 | if (el === document.body || el === document.documentElement) {
|
11931 | warn(
|
11932 | "Do not mount Vue to <html> or <body> - mount to normal elements instead."
|
11933 | );
|
11934 | return this
|
11935 | }
|
11936 |
|
11937 | var options = this.$options;
|
11938 |
|
11939 | if (!options.render) {
|
11940 | var template = options.template;
|
11941 | if (template) {
|
11942 | if (typeof template === 'string') {
|
11943 | if (template.charAt(0) === '#') {
|
11944 | template = idToTemplate(template);
|
11945 |
|
11946 | if (!template) {
|
11947 | warn(
|
11948 | ("Template element not found or is empty: " + (options.template)),
|
11949 | this
|
11950 | );
|
11951 | }
|
11952 | }
|
11953 | } else if (template.nodeType) {
|
11954 | template = template.innerHTML;
|
11955 | } else {
|
11956 | {
|
11957 | warn('invalid template option:' + template, this);
|
11958 | }
|
11959 | return this
|
11960 | }
|
11961 | } else if (el) {
|
11962 | template = getOuterHTML(el);
|
11963 | }
|
11964 | if (template) {
|
11965 |
|
11966 | if (config.performance && mark) {
|
11967 | mark('compile');
|
11968 | }
|
11969 |
|
11970 | var ref = compileToFunctions(template, {
|
11971 | outputSourceRange: "development" !== 'production',
|
11972 | shouldDecodeNewlines: shouldDecodeNewlines,
|
11973 | shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
|
11974 | delimiters: options.delimiters,
|
11975 | comments: options.comments
|
11976 | }, this);
|
11977 | var render = ref.render;
|
11978 | var staticRenderFns = ref.staticRenderFns;
|
11979 | options.render = render;
|
11980 | options.staticRenderFns = staticRenderFns;
|
11981 |
|
11982 |
|
11983 | if (config.performance && mark) {
|
11984 | mark('compile end');
|
11985 | measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
|
11986 | }
|
11987 | }
|
11988 | }
|
11989 | return mount.call(this, el, hydrating)
|
11990 | };
|
11991 |
|
11992 |
|
11993 |
|
11994 |
|
11995 |
|
11996 | function getOuterHTML (el) {
|
11997 | if (el.outerHTML) {
|
11998 | return el.outerHTML
|
11999 | } else {
|
12000 | var container = document.createElement('div');
|
12001 | container.appendChild(el.cloneNode(true));
|
12002 | return container.innerHTML
|
12003 | }
|
12004 | }
|
12005 |
|
12006 | Vue.compile = compileToFunctions;
|
12007 |
|
12008 | module.exports = Vue;
|