1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | var emptyObject = Object.freeze({});
|
9 |
|
10 |
|
11 |
|
12 | function isUndef (v) {
|
13 | return v === undefined || v === null
|
14 | }
|
15 |
|
16 | function isDef (v) {
|
17 | return v !== undefined && v !== null
|
18 | }
|
19 |
|
20 | function isTrue (v) {
|
21 | return v === true
|
22 | }
|
23 |
|
24 | function isFalse (v) {
|
25 | return v === false
|
26 | }
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function isPrimitive (value) {
|
32 | return (
|
33 | typeof value === 'string' ||
|
34 | typeof value === 'number' ||
|
35 |
|
36 | typeof value === 'symbol' ||
|
37 | typeof value === 'boolean'
|
38 | )
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | function isObject (obj) {
|
47 | return obj !== null && typeof obj === 'object'
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | var _toString = Object.prototype.toString;
|
54 |
|
55 | function toRawType (value) {
|
56 | return _toString.call(value).slice(8, -1)
|
57 | }
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | function isPlainObject (obj) {
|
64 | return _toString.call(obj) === '[object Object]'
|
65 | }
|
66 |
|
67 | function isRegExp (v) {
|
68 | return _toString.call(v) === '[object RegExp]'
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | function isValidArrayIndex (val) {
|
75 | var n = parseFloat(String(val));
|
76 | return n >= 0 && Math.floor(n) === n && isFinite(val)
|
77 | }
|
78 |
|
79 | function isPromise (val) {
|
80 | return (
|
81 | isDef(val) &&
|
82 | typeof val.then === 'function' &&
|
83 | typeof val.catch === 'function'
|
84 | )
|
85 | }
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | function toString (val) {
|
91 | return val == null
|
92 | ? ''
|
93 | : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
|
94 | ? JSON.stringify(val, null, 2)
|
95 | : String(val)
|
96 | }
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | function toNumber (val) {
|
103 | var n = parseFloat(val);
|
104 | return isNaN(n) ? val : n
|
105 | }
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | function makeMap (
|
112 | str,
|
113 | expectsLowerCase
|
114 | ) {
|
115 | var map = Object.create(null);
|
116 | var list = str.split(',');
|
117 | for (var i = 0; i < list.length; i++) {
|
118 | map[list[i]] = true;
|
119 | }
|
120 | return expectsLowerCase
|
121 | ? function (val) { return map[val.toLowerCase()]; }
|
122 | : function (val) { return map[val]; }
|
123 | }
|
124 |
|
125 |
|
126 |
|
127 |
|
128 | var isBuiltInTag = makeMap('slot,component', true);
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | function remove (arr, item) {
|
139 | if (arr.length) {
|
140 | var index = arr.indexOf(item);
|
141 | if (index > -1) {
|
142 | return arr.splice(index, 1)
|
143 | }
|
144 | }
|
145 | }
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
151 | function hasOwn (obj, key) {
|
152 | return hasOwnProperty.call(obj, key)
|
153 | }
|
154 |
|
155 |
|
156 |
|
157 |
|
158 | function cached (fn) {
|
159 | var cache = Object.create(null);
|
160 | return (function cachedFn (str) {
|
161 | var hit = cache[str];
|
162 | return hit || (cache[str] = fn(str))
|
163 | })
|
164 | }
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | var camelizeRE = /-(\w)/g;
|
170 | var camelize = cached(function (str) {
|
171 | return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
|
172 | });
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | var capitalize = cached(function (str) {
|
178 | return str.charAt(0).toUpperCase() + str.slice(1)
|
179 | });
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | var hyphenateRE = /\B([A-Z])/g;
|
185 | var hyphenate = cached(function (str) {
|
186 | return str.replace(hyphenateRE, '-$1').toLowerCase()
|
187 | });
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 | function polyfillBind (fn, ctx) {
|
199 | function boundFn (a) {
|
200 | var l = arguments.length;
|
201 | return l
|
202 | ? l > 1
|
203 | ? fn.apply(ctx, arguments)
|
204 | : fn.call(ctx, a)
|
205 | : fn.call(ctx)
|
206 | }
|
207 |
|
208 | boundFn._length = fn.length;
|
209 | return boundFn
|
210 | }
|
211 |
|
212 | function nativeBind (fn, ctx) {
|
213 | return fn.bind(ctx)
|
214 | }
|
215 |
|
216 | var bind = Function.prototype.bind
|
217 | ? nativeBind
|
218 | : polyfillBind;
|
219 |
|
220 |
|
221 |
|
222 |
|
223 | function toArray (list, start) {
|
224 | start = start || 0;
|
225 | var i = list.length - start;
|
226 | var ret = new Array(i);
|
227 | while (i--) {
|
228 | ret[i] = list[i + start];
|
229 | }
|
230 | return ret
|
231 | }
|
232 |
|
233 |
|
234 |
|
235 |
|
236 | function extend (to, _from) {
|
237 | for (var key in _from) {
|
238 | to[key] = _from[key];
|
239 | }
|
240 | return to
|
241 | }
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | function toObject (arr) {
|
247 | var res = {};
|
248 | for (var i = 0; i < arr.length; i++) {
|
249 | if (arr[i]) {
|
250 | extend(res, arr[i]);
|
251 | }
|
252 | }
|
253 | return res
|
254 | }
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 | function noop (a, b, c) {}
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | var no = function (a, b, c) { return false; };
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 | var identity = function (_) { return _; };
|
276 |
|
277 |
|
278 |
|
279 |
|
280 | function genStaticKeys (modules) {
|
281 | return modules.reduce(function (keys, m) {
|
282 | return keys.concat(m.staticKeys || [])
|
283 | }, []).join(',')
|
284 | }
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | function looseEqual (a, b) {
|
291 | if (a === b) { return true }
|
292 | var isObjectA = isObject(a);
|
293 | var isObjectB = isObject(b);
|
294 | if (isObjectA && isObjectB) {
|
295 | try {
|
296 | var isArrayA = Array.isArray(a);
|
297 | var isArrayB = Array.isArray(b);
|
298 | if (isArrayA && isArrayB) {
|
299 | return a.length === b.length && a.every(function (e, i) {
|
300 | return looseEqual(e, b[i])
|
301 | })
|
302 | } else if (a instanceof Date && b instanceof Date) {
|
303 | return a.getTime() === b.getTime()
|
304 | } else if (!isArrayA && !isArrayB) {
|
305 | var keysA = Object.keys(a);
|
306 | var keysB = Object.keys(b);
|
307 | return keysA.length === keysB.length && keysA.every(function (key) {
|
308 | return looseEqual(a[key], b[key])
|
309 | })
|
310 | } else {
|
311 |
|
312 | return false
|
313 | }
|
314 | } catch (e) {
|
315 |
|
316 | return false
|
317 | }
|
318 | } else if (!isObjectA && !isObjectB) {
|
319 | return String(a) === String(b)
|
320 | } else {
|
321 | return false
|
322 | }
|
323 | }
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 | function looseIndexOf (arr, val) {
|
331 | for (var i = 0; i < arr.length; i++) {
|
332 | if (looseEqual(arr[i], val)) { return i }
|
333 | }
|
334 | return -1
|
335 | }
|
336 |
|
337 |
|
338 |
|
339 |
|
340 | function once (fn) {
|
341 | var called = false;
|
342 | return function () {
|
343 | if (!called) {
|
344 | called = true;
|
345 | fn.apply(this, arguments);
|
346 | }
|
347 | }
|
348 | }
|
349 |
|
350 | var SSR_ATTR = 'data-server-rendered';
|
351 |
|
352 | var ASSET_TYPES = [
|
353 | 'component',
|
354 | 'directive',
|
355 | 'filter'
|
356 | ];
|
357 |
|
358 | var LIFECYCLE_HOOKS = [
|
359 | 'beforeCreate',
|
360 | 'created',
|
361 | 'beforeMount',
|
362 | 'mounted',
|
363 | 'beforeUpdate',
|
364 | 'updated',
|
365 | 'beforeDestroy',
|
366 | 'destroyed',
|
367 | 'activated',
|
368 | 'deactivated',
|
369 | 'errorCaptured',
|
370 | 'serverPrefetch'
|
371 | ];
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 | var config = ({
|
378 | |
379 |
|
380 |
|
381 |
|
382 | optionMergeStrategies: Object.create(null),
|
383 |
|
384 | |
385 |
|
386 |
|
387 | silent: false,
|
388 |
|
389 | |
390 |
|
391 |
|
392 | productionTip: process.env.NODE_ENV !== 'production',
|
393 |
|
394 | |
395 |
|
396 |
|
397 | devtools: process.env.NODE_ENV !== 'production',
|
398 |
|
399 | |
400 |
|
401 |
|
402 | performance: false,
|
403 |
|
404 | |
405 |
|
406 |
|
407 | errorHandler: null,
|
408 |
|
409 | |
410 |
|
411 |
|
412 | warnHandler: null,
|
413 |
|
414 | |
415 |
|
416 |
|
417 | ignoredElements: [],
|
418 |
|
419 | |
420 |
|
421 |
|
422 |
|
423 | keyCodes: Object.create(null),
|
424 |
|
425 | |
426 |
|
427 |
|
428 |
|
429 | isReservedTag: no,
|
430 |
|
431 | |
432 |
|
433 |
|
434 |
|
435 | isReservedAttr: no,
|
436 |
|
437 | |
438 |
|
439 |
|
440 |
|
441 | isUnknownElement: no,
|
442 |
|
443 | |
444 |
|
445 |
|
446 | getTagNamespace: noop,
|
447 |
|
448 | |
449 |
|
450 |
|
451 | parsePlatformTagName: identity,
|
452 |
|
453 | |
454 |
|
455 |
|
456 |
|
457 | mustUseProp: no,
|
458 |
|
459 | |
460 |
|
461 |
|
462 |
|
463 | async: true,
|
464 |
|
465 | |
466 |
|
467 |
|
468 | _lifecycleHooks: LIFECYCLE_HOOKS
|
469 | });
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 | var unicodeLetters = 'a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD';
|
479 |
|
480 |
|
481 |
|
482 |
|
483 | function isReserved (str) {
|
484 | var c = (str + '').charCodeAt(0);
|
485 | return c === 0x24 || c === 0x5F
|
486 | }
|
487 |
|
488 |
|
489 |
|
490 |
|
491 | function def (obj, key, val, enumerable) {
|
492 | Object.defineProperty(obj, key, {
|
493 | value: val,
|
494 | enumerable: !!enumerable,
|
495 | writable: true,
|
496 | configurable: true
|
497 | });
|
498 | }
|
499 |
|
500 |
|
501 |
|
502 |
|
503 | var bailRE = new RegExp(("[^" + unicodeLetters + ".$_\\d]"));
|
504 | function parsePath (path) {
|
505 | if (bailRE.test(path)) {
|
506 | return
|
507 | }
|
508 | var segments = path.split('.');
|
509 | return function (obj) {
|
510 | for (var i = 0; i < segments.length; i++) {
|
511 | if (!obj) { return }
|
512 | obj = obj[segments[i]];
|
513 | }
|
514 | return obj
|
515 | }
|
516 | }
|
517 |
|
518 |
|
519 |
|
520 |
|
521 | var hasProto = '__proto__' in {};
|
522 |
|
523 |
|
524 | var inBrowser = typeof window !== 'undefined';
|
525 | var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
|
526 | var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
|
527 | var UA = inBrowser && window.navigator.userAgent.toLowerCase();
|
528 | var isIE = UA && /msie|trident/.test(UA);
|
529 | var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
|
530 | var isEdge = UA && UA.indexOf('edge/') > 0;
|
531 | var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
|
532 | var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
|
533 | var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
534 | var isPhantomJS = UA && /phantomjs/.test(UA);
|
535 |
|
536 |
|
537 | var nativeWatch = ({}).watch;
|
538 |
|
539 | var supportsPassive = false;
|
540 | if (inBrowser) {
|
541 | try {
|
542 | var opts = {};
|
543 | Object.defineProperty(opts, 'passive', ({
|
544 | get: function get () {
|
545 |
|
546 | supportsPassive = true;
|
547 | }
|
548 | }));
|
549 | window.addEventListener('test-passive', null, opts);
|
550 | } catch (e) {}
|
551 | }
|
552 |
|
553 |
|
554 |
|
555 | var _isServer;
|
556 | var isServerRendering = function () {
|
557 | if (_isServer === undefined) {
|
558 |
|
559 | if (!inBrowser && !inWeex && typeof global !== 'undefined') {
|
560 |
|
561 |
|
562 | _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
|
563 | } else {
|
564 | _isServer = false;
|
565 | }
|
566 | }
|
567 | return _isServer
|
568 | };
|
569 |
|
570 |
|
571 | var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
572 |
|
573 |
|
574 | function isNative (Ctor) {
|
575 | return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
|
576 | }
|
577 |
|
578 | var hasSymbol =
|
579 | typeof Symbol !== 'undefined' && isNative(Symbol) &&
|
580 | typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
|
581 |
|
582 | var _Set;
|
583 |
|
584 | if (typeof Set !== 'undefined' && isNative(Set)) {
|
585 |
|
586 | _Set = Set;
|
587 | } else {
|
588 |
|
589 | _Set = (function () {
|
590 | function Set () {
|
591 | this.set = Object.create(null);
|
592 | }
|
593 | Set.prototype.has = function has (key) {
|
594 | return this.set[key] === true
|
595 | };
|
596 | Set.prototype.add = function add (key) {
|
597 | this.set[key] = true;
|
598 | };
|
599 | Set.prototype.clear = function clear () {
|
600 | this.set = Object.create(null);
|
601 | };
|
602 |
|
603 | return Set;
|
604 | }());
|
605 | }
|
606 |
|
607 |
|
608 |
|
609 | var warn = noop;
|
610 | var tip = noop;
|
611 | var generateComponentTrace = (noop);
|
612 | var formatComponentName = (noop);
|
613 |
|
614 | if (process.env.NODE_ENV !== 'production') {
|
615 | var hasConsole = typeof console !== 'undefined';
|
616 | var classifyRE = /(?:^|[-_])(\w)/g;
|
617 | var classify = function (str) { return str
|
618 | .replace(classifyRE, function (c) { return c.toUpperCase(); })
|
619 | .replace(/[-_]/g, ''); };
|
620 |
|
621 | warn = function (msg, vm) {
|
622 | var trace = vm ? generateComponentTrace(vm) : '';
|
623 |
|
624 | if (config.warnHandler) {
|
625 | config.warnHandler.call(null, msg, vm, trace);
|
626 | } else if (hasConsole && (!config.silent)) {
|
627 | console.error(("[Vue warn]: " + msg + trace));
|
628 | }
|
629 | };
|
630 |
|
631 | tip = function (msg, vm) {
|
632 | if (hasConsole && (!config.silent)) {
|
633 | console.warn("[Vue tip]: " + msg + (
|
634 | vm ? generateComponentTrace(vm) : ''
|
635 | ));
|
636 | }
|
637 | };
|
638 |
|
639 | formatComponentName = function (vm, includeFile) {
|
640 | if (vm.$root === vm) {
|
641 | return '<Root>'
|
642 | }
|
643 | var options = typeof vm === 'function' && vm.cid != null
|
644 | ? vm.options
|
645 | : vm._isVue
|
646 | ? vm.$options || vm.constructor.options
|
647 | : vm;
|
648 | var name = options.name || options._componentTag;
|
649 | var file = options.__file;
|
650 | if (!name && file) {
|
651 | var match = file.match(/([^/\\]+)\.vue$/);
|
652 | name = match && match[1];
|
653 | }
|
654 |
|
655 | return (
|
656 | (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
|
657 | (file && includeFile !== false ? (" at " + file) : '')
|
658 | )
|
659 | };
|
660 |
|
661 | var repeat = function (str, n) {
|
662 | var res = '';
|
663 | while (n) {
|
664 | if (n % 2 === 1) { res += str; }
|
665 | if (n > 1) { str += str; }
|
666 | n >>= 1;
|
667 | }
|
668 | return res
|
669 | };
|
670 |
|
671 | generateComponentTrace = function (vm) {
|
672 | if (vm._isVue && vm.$parent) {
|
673 | var tree = [];
|
674 | var currentRecursiveSequence = 0;
|
675 | while (vm) {
|
676 | if (tree.length > 0) {
|
677 | var last = tree[tree.length - 1];
|
678 | if (last.constructor === vm.constructor) {
|
679 | currentRecursiveSequence++;
|
680 | vm = vm.$parent;
|
681 | continue
|
682 | } else if (currentRecursiveSequence > 0) {
|
683 | tree[tree.length - 1] = [last, currentRecursiveSequence];
|
684 | currentRecursiveSequence = 0;
|
685 | }
|
686 | }
|
687 | tree.push(vm);
|
688 | vm = vm.$parent;
|
689 | }
|
690 | return '\n\nfound in\n\n' + tree
|
691 | .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
|
692 | ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
|
693 | : formatComponentName(vm))); })
|
694 | .join('\n')
|
695 | } else {
|
696 | return ("\n\n(found in " + (formatComponentName(vm)) + ")")
|
697 | }
|
698 | };
|
699 | }
|
700 |
|
701 |
|
702 |
|
703 | var uid = 0;
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 | var Dep = function Dep () {
|
710 | this.id = uid++;
|
711 | this.subs = [];
|
712 | };
|
713 |
|
714 | Dep.prototype.addSub = function addSub (sub) {
|
715 | this.subs.push(sub);
|
716 | };
|
717 |
|
718 | Dep.prototype.removeSub = function removeSub (sub) {
|
719 | remove(this.subs, sub);
|
720 | };
|
721 |
|
722 | Dep.prototype.depend = function depend () {
|
723 | if (Dep.target) {
|
724 | Dep.target.addDep(this);
|
725 | }
|
726 | };
|
727 |
|
728 | Dep.prototype.notify = function notify () {
|
729 |
|
730 | var subs = this.subs.slice();
|
731 | if (process.env.NODE_ENV !== 'production' && !config.async) {
|
732 |
|
733 |
|
734 |
|
735 | subs.sort(function (a, b) { return a.id - b.id; });
|
736 | }
|
737 | for (var i = 0, l = subs.length; i < l; i++) {
|
738 | subs[i].update();
|
739 | }
|
740 | };
|
741 |
|
742 |
|
743 |
|
744 |
|
745 | Dep.target = null;
|
746 | var targetStack = [];
|
747 |
|
748 | function pushTarget (target) {
|
749 | targetStack.push(target);
|
750 | Dep.target = target;
|
751 | }
|
752 |
|
753 | function popTarget () {
|
754 | targetStack.pop();
|
755 | Dep.target = targetStack[targetStack.length - 1];
|
756 | }
|
757 |
|
758 |
|
759 |
|
760 | var VNode = function VNode (
|
761 | tag,
|
762 | data,
|
763 | children,
|
764 | text,
|
765 | elm,
|
766 | context,
|
767 | componentOptions,
|
768 | asyncFactory
|
769 | ) {
|
770 | this.tag = tag;
|
771 | this.data = data;
|
772 | this.children = children;
|
773 | this.text = text;
|
774 | this.elm = elm;
|
775 | this.ns = undefined;
|
776 | this.context = context;
|
777 | this.fnContext = undefined;
|
778 | this.fnOptions = undefined;
|
779 | this.fnScopeId = undefined;
|
780 | this.key = data && data.key;
|
781 | this.componentOptions = componentOptions;
|
782 | this.componentInstance = undefined;
|
783 | this.parent = undefined;
|
784 | this.raw = false;
|
785 | this.isStatic = false;
|
786 | this.isRootInsert = true;
|
787 | this.isComment = false;
|
788 | this.isCloned = false;
|
789 | this.isOnce = false;
|
790 | this.asyncFactory = asyncFactory;
|
791 | this.asyncMeta = undefined;
|
792 | this.isAsyncPlaceholder = false;
|
793 | };
|
794 |
|
795 | var prototypeAccessors = { child: { configurable: true } };
|
796 |
|
797 |
|
798 |
|
799 | prototypeAccessors.child.get = function () {
|
800 | return this.componentInstance
|
801 | };
|
802 |
|
803 | Object.defineProperties( VNode.prototype, prototypeAccessors );
|
804 |
|
805 | var createEmptyVNode = function (text) {
|
806 | if ( text === void 0 ) text = '';
|
807 |
|
808 | var node = new VNode();
|
809 | node.text = text;
|
810 | node.isComment = true;
|
811 | return node
|
812 | };
|
813 |
|
814 | function createTextVNode (val) {
|
815 | return new VNode(undefined, undefined, undefined, String(val))
|
816 | }
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 | function cloneVNode (vnode) {
|
823 | var cloned = new VNode(
|
824 | vnode.tag,
|
825 | vnode.data,
|
826 |
|
827 |
|
828 |
|
829 | vnode.children && vnode.children.slice(),
|
830 | vnode.text,
|
831 | vnode.elm,
|
832 | vnode.context,
|
833 | vnode.componentOptions,
|
834 | vnode.asyncFactory
|
835 | );
|
836 | cloned.ns = vnode.ns;
|
837 | cloned.isStatic = vnode.isStatic;
|
838 | cloned.key = vnode.key;
|
839 | cloned.isComment = vnode.isComment;
|
840 | cloned.fnContext = vnode.fnContext;
|
841 | cloned.fnOptions = vnode.fnOptions;
|
842 | cloned.fnScopeId = vnode.fnScopeId;
|
843 | cloned.asyncMeta = vnode.asyncMeta;
|
844 | cloned.isCloned = true;
|
845 | return cloned
|
846 | }
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 | var arrayProto = Array.prototype;
|
854 | var arrayMethods = Object.create(arrayProto);
|
855 |
|
856 | var methodsToPatch = [
|
857 | 'push',
|
858 | 'pop',
|
859 | 'shift',
|
860 | 'unshift',
|
861 | 'splice',
|
862 | 'sort',
|
863 | 'reverse'
|
864 | ];
|
865 |
|
866 |
|
867 |
|
868 |
|
869 | methodsToPatch.forEach(function (method) {
|
870 |
|
871 | var original = arrayProto[method];
|
872 | def(arrayMethods, method, function mutator () {
|
873 | var args = [], len = arguments.length;
|
874 | while ( len-- ) args[ len ] = arguments[ len ];
|
875 |
|
876 | var result = original.apply(this, args);
|
877 | var ob = this.__ob__;
|
878 | var inserted;
|
879 | switch (method) {
|
880 | case 'push':
|
881 | case 'unshift':
|
882 | inserted = args;
|
883 | break
|
884 | case 'splice':
|
885 | inserted = args.slice(2);
|
886 | break
|
887 | }
|
888 | if (inserted) { ob.observeArray(inserted); }
|
889 |
|
890 | ob.dep.notify();
|
891 | return result
|
892 | });
|
893 | });
|
894 |
|
895 |
|
896 |
|
897 | var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 | var shouldObserve = true;
|
904 |
|
905 | function toggleObserving (value) {
|
906 | shouldObserve = value;
|
907 | }
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 | var Observer = function Observer (value) {
|
916 | this.value = value;
|
917 | this.dep = new Dep();
|
918 | this.vmCount = 0;
|
919 | def(value, '__ob__', this);
|
920 | if (Array.isArray(value)) {
|
921 | if (hasProto) {
|
922 | protoAugment(value, arrayMethods);
|
923 | } else {
|
924 | copyAugment(value, arrayMethods, arrayKeys);
|
925 | }
|
926 | this.observeArray(value);
|
927 | } else {
|
928 | this.walk(value);
|
929 | }
|
930 | };
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 | Observer.prototype.walk = function walk (obj) {
|
938 | var keys = Object.keys(obj);
|
939 | for (var i = 0; i < keys.length; i++) {
|
940 | defineReactive$$1(obj, keys[i]);
|
941 | }
|
942 | };
|
943 |
|
944 |
|
945 |
|
946 |
|
947 | Observer.prototype.observeArray = function observeArray (items) {
|
948 | for (var i = 0, l = items.length; i < l; i++) {
|
949 | observe(items[i]);
|
950 | }
|
951 | };
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 | function protoAugment (target, src) {
|
960 |
|
961 | target.__proto__ = src;
|
962 |
|
963 | }
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 | function copyAugment (target, src, keys) {
|
971 | for (var i = 0, l = keys.length; i < l; i++) {
|
972 | var key = keys[i];
|
973 | def(target, key, src[key]);
|
974 | }
|
975 | }
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 | function observe (value, asRootData) {
|
983 | if (!isObject(value) || value instanceof VNode) {
|
984 | return
|
985 | }
|
986 | var ob;
|
987 | if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
988 | ob = value.__ob__;
|
989 | } else if (
|
990 | shouldObserve &&
|
991 | !isServerRendering() &&
|
992 | (Array.isArray(value) || isPlainObject(value)) &&
|
993 | Object.isExtensible(value) &&
|
994 | !value._isVue
|
995 | ) {
|
996 | ob = new Observer(value);
|
997 | }
|
998 | if (asRootData && ob) {
|
999 | ob.vmCount++;
|
1000 | }
|
1001 | return ob
|
1002 | }
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 | function defineReactive$$1 (
|
1008 | obj,
|
1009 | key,
|
1010 | val,
|
1011 | customSetter,
|
1012 | shallow
|
1013 | ) {
|
1014 | var dep = new Dep();
|
1015 |
|
1016 | var property = Object.getOwnPropertyDescriptor(obj, key);
|
1017 | if (property && property.configurable === false) {
|
1018 | return
|
1019 | }
|
1020 |
|
1021 |
|
1022 | var getter = property && property.get;
|
1023 | var setter = property && property.set;
|
1024 | if ((!getter || setter) && arguments.length === 2) {
|
1025 | val = obj[key];
|
1026 | }
|
1027 |
|
1028 | var childOb = !shallow && observe(val);
|
1029 | Object.defineProperty(obj, key, {
|
1030 | enumerable: true,
|
1031 | configurable: true,
|
1032 | get: function reactiveGetter () {
|
1033 | var value = getter ? getter.call(obj) : val;
|
1034 | if (Dep.target) {
|
1035 | dep.depend();
|
1036 | if (childOb) {
|
1037 | childOb.dep.depend();
|
1038 | if (Array.isArray(value)) {
|
1039 | dependArray(value);
|
1040 | }
|
1041 | }
|
1042 | }
|
1043 | return value
|
1044 | },
|
1045 | set: function reactiveSetter (newVal) {
|
1046 | var value = getter ? getter.call(obj) : val;
|
1047 |
|
1048 | if (newVal === value || (newVal !== newVal && value !== value)) {
|
1049 | return
|
1050 | }
|
1051 |
|
1052 | if (process.env.NODE_ENV !== 'production' && customSetter) {
|
1053 | customSetter();
|
1054 | }
|
1055 |
|
1056 | if (getter && !setter) { return }
|
1057 | if (setter) {
|
1058 | setter.call(obj, newVal);
|
1059 | } else {
|
1060 | val = newVal;
|
1061 | }
|
1062 | childOb = !shallow && observe(newVal);
|
1063 | dep.notify();
|
1064 | }
|
1065 | });
|
1066 | }
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 | function set (target, key, val) {
|
1074 | if (process.env.NODE_ENV !== 'production' &&
|
1075 | (isUndef(target) || isPrimitive(target))
|
1076 | ) {
|
1077 | warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
|
1078 | }
|
1079 | if (Array.isArray(target) && isValidArrayIndex(key)) {
|
1080 | target.length = Math.max(target.length, key);
|
1081 | target.splice(key, 1, val);
|
1082 | return val
|
1083 | }
|
1084 | if (key in target && !(key in Object.prototype)) {
|
1085 | target[key] = val;
|
1086 | return val
|
1087 | }
|
1088 | var ob = (target).__ob__;
|
1089 | if (target._isVue || (ob && ob.vmCount)) {
|
1090 | process.env.NODE_ENV !== 'production' && warn(
|
1091 | 'Avoid adding reactive properties to a Vue instance or its root $data ' +
|
1092 | 'at runtime - declare it upfront in the data option.'
|
1093 | );
|
1094 | return val
|
1095 | }
|
1096 | if (!ob) {
|
1097 | target[key] = val;
|
1098 | return val
|
1099 | }
|
1100 | defineReactive$$1(ob.value, key, val);
|
1101 | ob.dep.notify();
|
1102 | return val
|
1103 | }
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 | function del (target, key) {
|
1109 | if (process.env.NODE_ENV !== 'production' &&
|
1110 | (isUndef(target) || isPrimitive(target))
|
1111 | ) {
|
1112 | warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
|
1113 | }
|
1114 | if (Array.isArray(target) && isValidArrayIndex(key)) {
|
1115 | target.splice(key, 1);
|
1116 | return
|
1117 | }
|
1118 | var ob = (target).__ob__;
|
1119 | if (target._isVue || (ob && ob.vmCount)) {
|
1120 | process.env.NODE_ENV !== 'production' && warn(
|
1121 | 'Avoid deleting properties on a Vue instance or its root $data ' +
|
1122 | '- just set it to null.'
|
1123 | );
|
1124 | return
|
1125 | }
|
1126 | if (!hasOwn(target, key)) {
|
1127 | return
|
1128 | }
|
1129 | delete target[key];
|
1130 | if (!ob) {
|
1131 | return
|
1132 | }
|
1133 | ob.dep.notify();
|
1134 | }
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 | function dependArray (value) {
|
1141 | for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
|
1142 | e = value[i];
|
1143 | e && e.__ob__ && e.__ob__.dep.depend();
|
1144 | if (Array.isArray(e)) {
|
1145 | dependArray(e);
|
1146 | }
|
1147 | }
|
1148 | }
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 | var strats = config.optionMergeStrategies;
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 | if (process.env.NODE_ENV !== 'production') {
|
1163 | strats.el = strats.propsData = function (parent, child, vm, key) {
|
1164 | if (!vm) {
|
1165 | warn(
|
1166 | "option \"" + key + "\" can only be used during instance " +
|
1167 | 'creation with the `new` keyword.'
|
1168 | );
|
1169 | }
|
1170 | return defaultStrat(parent, child)
|
1171 | };
|
1172 | }
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 | function mergeData (to, from) {
|
1178 | if (!from) { return to }
|
1179 | var key, toVal, fromVal;
|
1180 |
|
1181 | var keys = hasSymbol
|
1182 | ? Reflect.ownKeys(from)
|
1183 | : Object.keys(from);
|
1184 |
|
1185 | for (var i = 0; i < keys.length; i++) {
|
1186 | key = keys[i];
|
1187 |
|
1188 | if (key === '__ob__') { continue }
|
1189 | toVal = to[key];
|
1190 | fromVal = from[key];
|
1191 | if (!hasOwn(to, key)) {
|
1192 | set(to, key, fromVal);
|
1193 | } else if (
|
1194 | toVal !== fromVal &&
|
1195 | isPlainObject(toVal) &&
|
1196 | isPlainObject(fromVal)
|
1197 | ) {
|
1198 | mergeData(toVal, fromVal);
|
1199 | }
|
1200 | }
|
1201 | return to
|
1202 | }
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 | function mergeDataOrFn (
|
1208 | parentVal,
|
1209 | childVal,
|
1210 | vm
|
1211 | ) {
|
1212 | if (!vm) {
|
1213 |
|
1214 | if (!childVal) {
|
1215 | return parentVal
|
1216 | }
|
1217 | if (!parentVal) {
|
1218 | return childVal
|
1219 | }
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 | return function mergedDataFn () {
|
1226 | return mergeData(
|
1227 | typeof childVal === 'function' ? childVal.call(this, this) : childVal,
|
1228 | typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
|
1229 | )
|
1230 | }
|
1231 | } else {
|
1232 | return function mergedInstanceDataFn () {
|
1233 |
|
1234 | var instanceData = typeof childVal === 'function'
|
1235 | ? childVal.call(vm, vm)
|
1236 | : childVal;
|
1237 | var defaultData = typeof parentVal === 'function'
|
1238 | ? parentVal.call(vm, vm)
|
1239 | : parentVal;
|
1240 | if (instanceData) {
|
1241 | return mergeData(instanceData, defaultData)
|
1242 | } else {
|
1243 | return defaultData
|
1244 | }
|
1245 | }
|
1246 | }
|
1247 | }
|
1248 |
|
1249 | strats.data = function (
|
1250 | parentVal,
|
1251 | childVal,
|
1252 | vm
|
1253 | ) {
|
1254 | if (!vm) {
|
1255 | if (childVal && typeof childVal !== 'function') {
|
1256 | process.env.NODE_ENV !== 'production' && warn(
|
1257 | 'The "data" option should be a function ' +
|
1258 | 'that returns a per-instance value in component ' +
|
1259 | 'definitions.',
|
1260 | vm
|
1261 | );
|
1262 |
|
1263 | return parentVal
|
1264 | }
|
1265 | return mergeDataOrFn(parentVal, childVal)
|
1266 | }
|
1267 |
|
1268 | return mergeDataOrFn(parentVal, childVal, vm)
|
1269 | };
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 | function mergeHook (
|
1275 | parentVal,
|
1276 | childVal
|
1277 | ) {
|
1278 | var res = childVal
|
1279 | ? parentVal
|
1280 | ? parentVal.concat(childVal)
|
1281 | : Array.isArray(childVal)
|
1282 | ? childVal
|
1283 | : [childVal]
|
1284 | : parentVal;
|
1285 | return res
|
1286 | ? dedupeHooks(res)
|
1287 | : res
|
1288 | }
|
1289 |
|
1290 | function dedupeHooks (hooks) {
|
1291 | var res = [];
|
1292 | for (var i = 0; i < hooks.length; i++) {
|
1293 | if (res.indexOf(hooks[i]) === -1) {
|
1294 | res.push(hooks[i]);
|
1295 | }
|
1296 | }
|
1297 | return res
|
1298 | }
|
1299 |
|
1300 | LIFECYCLE_HOOKS.forEach(function (hook) {
|
1301 | strats[hook] = mergeHook;
|
1302 | });
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 | function mergeAssets (
|
1312 | parentVal,
|
1313 | childVal,
|
1314 | vm,
|
1315 | key
|
1316 | ) {
|
1317 | var res = Object.create(parentVal || null);
|
1318 | if (childVal) {
|
1319 | process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
|
1320 | return extend(res, childVal)
|
1321 | } else {
|
1322 | return res
|
1323 | }
|
1324 | }
|
1325 |
|
1326 | ASSET_TYPES.forEach(function (type) {
|
1327 | strats[type + 's'] = mergeAssets;
|
1328 | });
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 | strats.watch = function (
|
1337 | parentVal,
|
1338 | childVal,
|
1339 | vm,
|
1340 | key
|
1341 | ) {
|
1342 |
|
1343 | if (parentVal === nativeWatch) { parentVal = undefined; }
|
1344 | if (childVal === nativeWatch) { childVal = undefined; }
|
1345 |
|
1346 | if (!childVal) { return Object.create(parentVal || null) }
|
1347 | if (process.env.NODE_ENV !== 'production') {
|
1348 | assertObjectType(key, childVal, vm);
|
1349 | }
|
1350 | if (!parentVal) { return childVal }
|
1351 | var ret = {};
|
1352 | extend(ret, parentVal);
|
1353 | for (var key$1 in childVal) {
|
1354 | var parent = ret[key$1];
|
1355 | var child = childVal[key$1];
|
1356 | if (parent && !Array.isArray(parent)) {
|
1357 | parent = [parent];
|
1358 | }
|
1359 | ret[key$1] = parent
|
1360 | ? parent.concat(child)
|
1361 | : Array.isArray(child) ? child : [child];
|
1362 | }
|
1363 | return ret
|
1364 | };
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 | strats.props =
|
1370 | strats.methods =
|
1371 | strats.inject =
|
1372 | strats.computed = function (
|
1373 | parentVal,
|
1374 | childVal,
|
1375 | vm,
|
1376 | key
|
1377 | ) {
|
1378 | if (childVal && process.env.NODE_ENV !== 'production') {
|
1379 | assertObjectType(key, childVal, vm);
|
1380 | }
|
1381 | if (!parentVal) { return childVal }
|
1382 | var ret = Object.create(null);
|
1383 | extend(ret, parentVal);
|
1384 | if (childVal) { extend(ret, childVal); }
|
1385 | return ret
|
1386 | };
|
1387 | strats.provide = mergeDataOrFn;
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 | var defaultStrat = function (parentVal, childVal) {
|
1393 | return childVal === undefined
|
1394 | ? parentVal
|
1395 | : childVal
|
1396 | };
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 | function checkComponents (options) {
|
1402 | for (var key in options.components) {
|
1403 | validateComponentName(key);
|
1404 | }
|
1405 | }
|
1406 |
|
1407 | function validateComponentName (name) {
|
1408 | if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + unicodeLetters + "]*$")).test(name)) {
|
1409 | warn(
|
1410 | 'Invalid component name: "' + name + '". Component names ' +
|
1411 | 'should conform to valid custom element name in html5 specification.'
|
1412 | );
|
1413 | }
|
1414 | if (isBuiltInTag(name) || config.isReservedTag(name)) {
|
1415 | warn(
|
1416 | 'Do not use built-in or reserved HTML elements as component ' +
|
1417 | 'id: ' + name
|
1418 | );
|
1419 | }
|
1420 | }
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 | function normalizeProps (options, vm) {
|
1427 | var props = options.props;
|
1428 | if (!props) { return }
|
1429 | var res = {};
|
1430 | var i, val, name;
|
1431 | if (Array.isArray(props)) {
|
1432 | i = props.length;
|
1433 | while (i--) {
|
1434 | val = props[i];
|
1435 | if (typeof val === 'string') {
|
1436 | name = camelize(val);
|
1437 | res[name] = { type: null };
|
1438 | } else if (process.env.NODE_ENV !== 'production') {
|
1439 | warn('props must be strings when using array syntax.');
|
1440 | }
|
1441 | }
|
1442 | } else if (isPlainObject(props)) {
|
1443 | for (var key in props) {
|
1444 | val = props[key];
|
1445 | name = camelize(key);
|
1446 | res[name] = isPlainObject(val)
|
1447 | ? val
|
1448 | : { type: val };
|
1449 | }
|
1450 | } else if (process.env.NODE_ENV !== 'production') {
|
1451 | warn(
|
1452 | "Invalid value for option \"props\": expected an Array or an Object, " +
|
1453 | "but got " + (toRawType(props)) + ".",
|
1454 | vm
|
1455 | );
|
1456 | }
|
1457 | options.props = res;
|
1458 | }
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 | function normalizeInject (options, vm) {
|
1464 | var inject = options.inject;
|
1465 | if (!inject) { return }
|
1466 | var normalized = options.inject = {};
|
1467 | if (Array.isArray(inject)) {
|
1468 | for (var i = 0; i < inject.length; i++) {
|
1469 | normalized[inject[i]] = { from: inject[i] };
|
1470 | }
|
1471 | } else if (isPlainObject(inject)) {
|
1472 | for (var key in inject) {
|
1473 | var val = inject[key];
|
1474 | normalized[key] = isPlainObject(val)
|
1475 | ? extend({ from: key }, val)
|
1476 | : { from: val };
|
1477 | }
|
1478 | } else if (process.env.NODE_ENV !== 'production') {
|
1479 | warn(
|
1480 | "Invalid value for option \"inject\": expected an Array or an Object, " +
|
1481 | "but got " + (toRawType(inject)) + ".",
|
1482 | vm
|
1483 | );
|
1484 | }
|
1485 | }
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 | function normalizeDirectives (options) {
|
1491 | var dirs = options.directives;
|
1492 | if (dirs) {
|
1493 | for (var key in dirs) {
|
1494 | var def$$1 = dirs[key];
|
1495 | if (typeof def$$1 === 'function') {
|
1496 | dirs[key] = { bind: def$$1, update: def$$1 };
|
1497 | }
|
1498 | }
|
1499 | }
|
1500 | }
|
1501 |
|
1502 | function assertObjectType (name, value, vm) {
|
1503 | if (!isPlainObject(value)) {
|
1504 | warn(
|
1505 | "Invalid value for option \"" + name + "\": expected an Object, " +
|
1506 | "but got " + (toRawType(value)) + ".",
|
1507 | vm
|
1508 | );
|
1509 | }
|
1510 | }
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 | function mergeOptions (
|
1517 | parent,
|
1518 | child,
|
1519 | vm
|
1520 | ) {
|
1521 | if (process.env.NODE_ENV !== 'production') {
|
1522 | checkComponents(child);
|
1523 | }
|
1524 |
|
1525 | if (typeof child === 'function') {
|
1526 | child = child.options;
|
1527 | }
|
1528 |
|
1529 | normalizeProps(child, vm);
|
1530 | normalizeInject(child, vm);
|
1531 | normalizeDirectives(child);
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 | if (!child._base) {
|
1538 | if (child.extends) {
|
1539 | parent = mergeOptions(parent, child.extends, vm);
|
1540 | }
|
1541 | if (child.mixins) {
|
1542 | for (var i = 0, l = child.mixins.length; i < l; i++) {
|
1543 | parent = mergeOptions(parent, child.mixins[i], vm);
|
1544 | }
|
1545 | }
|
1546 | }
|
1547 |
|
1548 | var options = {};
|
1549 | var key;
|
1550 | for (key in parent) {
|
1551 | mergeField(key);
|
1552 | }
|
1553 | for (key in child) {
|
1554 | if (!hasOwn(parent, key)) {
|
1555 | mergeField(key);
|
1556 | }
|
1557 | }
|
1558 | function mergeField (key) {
|
1559 | var strat = strats[key] || defaultStrat;
|
1560 | options[key] = strat(parent[key], child[key], vm, key);
|
1561 | }
|
1562 | return options
|
1563 | }
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 | function resolveAsset (
|
1571 | options,
|
1572 | type,
|
1573 | id,
|
1574 | warnMissing
|
1575 | ) {
|
1576 |
|
1577 | if (typeof id !== 'string') {
|
1578 | return
|
1579 | }
|
1580 | var assets = options[type];
|
1581 |
|
1582 | if (hasOwn(assets, id)) { return assets[id] }
|
1583 | var camelizedId = camelize(id);
|
1584 | if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
|
1585 | var PascalCaseId = capitalize(camelizedId);
|
1586 | if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
|
1587 |
|
1588 | var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
|
1589 | if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
|
1590 | warn(
|
1591 | 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
|
1592 | options
|
1593 | );
|
1594 | }
|
1595 | return res
|
1596 | }
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 | function validateProp (
|
1603 | key,
|
1604 | propOptions,
|
1605 | propsData,
|
1606 | vm
|
1607 | ) {
|
1608 | var prop = propOptions[key];
|
1609 | var absent = !hasOwn(propsData, key);
|
1610 | var value = propsData[key];
|
1611 |
|
1612 | var booleanIndex = getTypeIndex(Boolean, prop.type);
|
1613 | if (booleanIndex > -1) {
|
1614 | if (absent && !hasOwn(prop, 'default')) {
|
1615 | value = false;
|
1616 | } else if (value === '' || value === hyphenate(key)) {
|
1617 |
|
1618 |
|
1619 | var stringIndex = getTypeIndex(String, prop.type);
|
1620 | if (stringIndex < 0 || booleanIndex < stringIndex) {
|
1621 | value = true;
|
1622 | }
|
1623 | }
|
1624 | }
|
1625 |
|
1626 | if (value === undefined) {
|
1627 | value = getPropDefaultValue(vm, prop, key);
|
1628 |
|
1629 |
|
1630 | var prevShouldObserve = shouldObserve;
|
1631 | toggleObserving(true);
|
1632 | observe(value);
|
1633 | toggleObserving(prevShouldObserve);
|
1634 | }
|
1635 | if (
|
1636 | process.env.NODE_ENV !== 'production' &&
|
1637 |
|
1638 | !(false)
|
1639 | ) {
|
1640 | assertProp(prop, key, value, vm, absent);
|
1641 | }
|
1642 | return value
|
1643 | }
|
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 | function getPropDefaultValue (vm, prop, key) {
|
1649 |
|
1650 | if (!hasOwn(prop, 'default')) {
|
1651 | return undefined
|
1652 | }
|
1653 | var def = prop.default;
|
1654 |
|
1655 | if (process.env.NODE_ENV !== 'production' && isObject(def)) {
|
1656 | warn(
|
1657 | 'Invalid default value for prop "' + key + '": ' +
|
1658 | 'Props with type Object/Array must use a factory function ' +
|
1659 | 'to return the default value.',
|
1660 | vm
|
1661 | );
|
1662 | }
|
1663 |
|
1664 |
|
1665 | if (vm && vm.$options.propsData &&
|
1666 | vm.$options.propsData[key] === undefined &&
|
1667 | vm._props[key] !== undefined
|
1668 | ) {
|
1669 | return vm._props[key]
|
1670 | }
|
1671 |
|
1672 |
|
1673 | return typeof def === 'function' && getType(prop.type) !== 'Function'
|
1674 | ? def.call(vm)
|
1675 | : def
|
1676 | }
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 | function assertProp (
|
1682 | prop,
|
1683 | name,
|
1684 | value,
|
1685 | vm,
|
1686 | absent
|
1687 | ) {
|
1688 | if (prop.required && absent) {
|
1689 | warn(
|
1690 | 'Missing required prop: "' + name + '"',
|
1691 | vm
|
1692 | );
|
1693 | return
|
1694 | }
|
1695 | if (value == null && !prop.required) {
|
1696 | return
|
1697 | }
|
1698 | var type = prop.type;
|
1699 | var valid = !type || type === true;
|
1700 | var expectedTypes = [];
|
1701 | if (type) {
|
1702 | if (!Array.isArray(type)) {
|
1703 | type = [type];
|
1704 | }
|
1705 | for (var i = 0; i < type.length && !valid; i++) {
|
1706 | var assertedType = assertType(value, type[i]);
|
1707 | expectedTypes.push(assertedType.expectedType || '');
|
1708 | valid = assertedType.valid;
|
1709 | }
|
1710 | }
|
1711 |
|
1712 | if (!valid) {
|
1713 | warn(
|
1714 | getInvalidTypeMessage(name, value, expectedTypes),
|
1715 | vm
|
1716 | );
|
1717 | return
|
1718 | }
|
1719 | var validator = prop.validator;
|
1720 | if (validator) {
|
1721 | if (!validator(value)) {
|
1722 | warn(
|
1723 | 'Invalid prop: custom validator check failed for prop "' + name + '".',
|
1724 | vm
|
1725 | );
|
1726 | }
|
1727 | }
|
1728 | }
|
1729 |
|
1730 | var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
|
1731 |
|
1732 | function assertType (value, type) {
|
1733 | var valid;
|
1734 | var expectedType = getType(type);
|
1735 | if (simpleCheckRE.test(expectedType)) {
|
1736 | var t = typeof value;
|
1737 | valid = t === expectedType.toLowerCase();
|
1738 |
|
1739 | if (!valid && t === 'object') {
|
1740 | valid = value instanceof type;
|
1741 | }
|
1742 | } else if (expectedType === 'Object') {
|
1743 | valid = isPlainObject(value);
|
1744 | } else if (expectedType === 'Array') {
|
1745 | valid = Array.isArray(value);
|
1746 | } else {
|
1747 | valid = value instanceof type;
|
1748 | }
|
1749 | return {
|
1750 | valid: valid,
|
1751 | expectedType: expectedType
|
1752 | }
|
1753 | }
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 | function getType (fn) {
|
1761 | var match = fn && fn.toString().match(/^\s*function (\w+)/);
|
1762 | return match ? match[1] : ''
|
1763 | }
|
1764 |
|
1765 | function isSameType (a, b) {
|
1766 | return getType(a) === getType(b)
|
1767 | }
|
1768 |
|
1769 | function getTypeIndex (type, expectedTypes) {
|
1770 | if (!Array.isArray(expectedTypes)) {
|
1771 | return isSameType(expectedTypes, type) ? 0 : -1
|
1772 | }
|
1773 | for (var i = 0, len = expectedTypes.length; i < len; i++) {
|
1774 | if (isSameType(expectedTypes[i], type)) {
|
1775 | return i
|
1776 | }
|
1777 | }
|
1778 | return -1
|
1779 | }
|
1780 |
|
1781 | function getInvalidTypeMessage (name, value, expectedTypes) {
|
1782 | var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
|
1783 | " Expected " + (expectedTypes.map(capitalize).join(', '));
|
1784 | var expectedType = expectedTypes[0];
|
1785 | var receivedType = toRawType(value);
|
1786 | var expectedValue = styleValue(value, expectedType);
|
1787 | var receivedValue = styleValue(value, receivedType);
|
1788 |
|
1789 | if (expectedTypes.length === 1 &&
|
1790 | isExplicable(expectedType) &&
|
1791 | !isBoolean(expectedType, receivedType)) {
|
1792 | message += " with value " + expectedValue;
|
1793 | }
|
1794 | message += ", got " + receivedType + " ";
|
1795 |
|
1796 | if (isExplicable(receivedType)) {
|
1797 | message += "with value " + receivedValue + ".";
|
1798 | }
|
1799 | return message
|
1800 | }
|
1801 |
|
1802 | function styleValue (value, type) {
|
1803 | if (type === 'String') {
|
1804 | return ("\"" + value + "\"")
|
1805 | } else if (type === 'Number') {
|
1806 | return ("" + (Number(value)))
|
1807 | } else {
|
1808 | return ("" + value)
|
1809 | }
|
1810 | }
|
1811 |
|
1812 | function isExplicable (value) {
|
1813 | var explicitTypes = ['string', 'number', 'boolean'];
|
1814 | return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
|
1815 | }
|
1816 |
|
1817 | function isBoolean () {
|
1818 | var args = [], len = arguments.length;
|
1819 | while ( len-- ) args[ len ] = arguments[ len ];
|
1820 |
|
1821 | return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
|
1822 | }
|
1823 |
|
1824 |
|
1825 |
|
1826 | function handleError (err, vm, info) {
|
1827 | if (vm) {
|
1828 | var cur = vm;
|
1829 | while ((cur = cur.$parent)) {
|
1830 | var hooks = cur.$options.errorCaptured;
|
1831 | if (hooks) {
|
1832 | for (var i = 0; i < hooks.length; i++) {
|
1833 | try {
|
1834 | var capture = hooks[i].call(cur, err, vm, info) === false;
|
1835 | if (capture) { return }
|
1836 | } catch (e) {
|
1837 | globalHandleError(e, cur, 'errorCaptured hook');
|
1838 | }
|
1839 | }
|
1840 | }
|
1841 | }
|
1842 | }
|
1843 | globalHandleError(err, vm, info);
|
1844 | }
|
1845 |
|
1846 | function invokeWithErrorHandling (
|
1847 | handler,
|
1848 | context,
|
1849 | args,
|
1850 | vm,
|
1851 | info
|
1852 | ) {
|
1853 | var res;
|
1854 | try {
|
1855 | res = args ? handler.apply(context, args) : handler.call(context);
|
1856 | if (isPromise(res)) {
|
1857 | res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
|
1858 | }
|
1859 | } catch (e) {
|
1860 | handleError(e, vm, info);
|
1861 | }
|
1862 | return res
|
1863 | }
|
1864 |
|
1865 | function globalHandleError (err, vm, info) {
|
1866 | if (config.errorHandler) {
|
1867 | try {
|
1868 | return config.errorHandler.call(null, err, vm, info)
|
1869 | } catch (e) {
|
1870 | logError(e, null, 'config.errorHandler');
|
1871 | }
|
1872 | }
|
1873 | logError(err, vm, info);
|
1874 | }
|
1875 |
|
1876 | function logError (err, vm, info) {
|
1877 | if (process.env.NODE_ENV !== 'production') {
|
1878 | warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
|
1879 | }
|
1880 |
|
1881 | if ((inBrowser || inWeex) && typeof console !== 'undefined') {
|
1882 | console.error(err);
|
1883 | } else {
|
1884 | throw err
|
1885 | }
|
1886 | }
|
1887 |
|
1888 |
|
1889 |
|
1890 | var isUsingMicroTask = false;
|
1891 |
|
1892 | var callbacks = [];
|
1893 | var pending = false;
|
1894 |
|
1895 | function flushCallbacks () {
|
1896 | pending = false;
|
1897 | var copies = callbacks.slice(0);
|
1898 | callbacks.length = 0;
|
1899 | for (var i = 0; i < copies.length; i++) {
|
1900 | copies[i]();
|
1901 | }
|
1902 | }
|
1903 |
|
1904 |
|
1905 |
|
1906 |
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 | var timerFunc;
|
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 |
|
1922 |
|
1923 |
|
1924 | if (typeof Promise !== 'undefined' && isNative(Promise)) {
|
1925 | var p = Promise.resolve();
|
1926 | timerFunc = function () {
|
1927 | p.then(flushCallbacks);
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 | if (isIOS) { setTimeout(noop); }
|
1934 | };
|
1935 | isUsingMicroTask = true;
|
1936 | } else if (!isIE && typeof MutationObserver !== 'undefined' && (
|
1937 | isNative(MutationObserver) ||
|
1938 |
|
1939 | MutationObserver.toString() === '[object MutationObserverConstructor]'
|
1940 | )) {
|
1941 |
|
1942 |
|
1943 |
|
1944 | var counter = 1;
|
1945 | var observer = new MutationObserver(flushCallbacks);
|
1946 | var textNode = document.createTextNode(String(counter));
|
1947 | observer.observe(textNode, {
|
1948 | characterData: true
|
1949 | });
|
1950 | timerFunc = function () {
|
1951 | counter = (counter + 1) % 2;
|
1952 | textNode.data = String(counter);
|
1953 | };
|
1954 | isUsingMicroTask = true;
|
1955 | } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
|
1956 |
|
1957 |
|
1958 |
|
1959 | timerFunc = function () {
|
1960 | setImmediate(flushCallbacks);
|
1961 | };
|
1962 | } else {
|
1963 |
|
1964 | timerFunc = function () {
|
1965 | setTimeout(flushCallbacks, 0);
|
1966 | };
|
1967 | }
|
1968 |
|
1969 | function nextTick (cb, ctx) {
|
1970 | var _resolve;
|
1971 | callbacks.push(function () {
|
1972 | if (cb) {
|
1973 | try {
|
1974 | cb.call(ctx);
|
1975 | } catch (e) {
|
1976 | handleError(e, ctx, 'nextTick');
|
1977 | }
|
1978 | } else if (_resolve) {
|
1979 | _resolve(ctx);
|
1980 | }
|
1981 | });
|
1982 | if (!pending) {
|
1983 | pending = true;
|
1984 | timerFunc();
|
1985 | }
|
1986 |
|
1987 | if (!cb && typeof Promise !== 'undefined') {
|
1988 | return new Promise(function (resolve) {
|
1989 | _resolve = resolve;
|
1990 | })
|
1991 | }
|
1992 | }
|
1993 |
|
1994 |
|
1995 |
|
1996 | var mark;
|
1997 | var measure;
|
1998 |
|
1999 | if (process.env.NODE_ENV !== 'production') {
|
2000 | var perf = inBrowser && window.performance;
|
2001 |
|
2002 | if (
|
2003 | perf &&
|
2004 | perf.mark &&
|
2005 | perf.measure &&
|
2006 | perf.clearMarks &&
|
2007 | perf.clearMeasures
|
2008 | ) {
|
2009 | mark = function (tag) { return perf.mark(tag); };
|
2010 | measure = function (name, startTag, endTag) {
|
2011 | perf.measure(name, startTag, endTag);
|
2012 | perf.clearMarks(startTag);
|
2013 | perf.clearMarks(endTag);
|
2014 |
|
2015 | };
|
2016 | }
|
2017 | }
|
2018 |
|
2019 |
|
2020 |
|
2021 | var initProxy;
|
2022 |
|
2023 | if (process.env.NODE_ENV !== 'production') {
|
2024 | var allowedGlobals = makeMap(
|
2025 | 'Infinity,undefined,NaN,isFinite,isNaN,' +
|
2026 | 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
2027 | 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
|
2028 | 'require'
|
2029 | );
|
2030 |
|
2031 | var warnNonPresent = function (target, key) {
|
2032 | warn(
|
2033 | "Property or method \"" + key + "\" is not defined on the instance but " +
|
2034 | 'referenced during render. Make sure that this property is reactive, ' +
|
2035 | 'either in the data option, or for class-based components, by ' +
|
2036 | 'initializing the property. ' +
|
2037 | 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
|
2038 | target
|
2039 | );
|
2040 | };
|
2041 |
|
2042 | var warnReservedPrefix = function (target, key) {
|
2043 | warn(
|
2044 | "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
|
2045 | 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
|
2046 | 'prevent conflicts with Vue internals' +
|
2047 | 'See: https://vuejs.org/v2/api/#data',
|
2048 | target
|
2049 | );
|
2050 | };
|
2051 |
|
2052 | var hasProxy =
|
2053 | typeof Proxy !== 'undefined' && isNative(Proxy);
|
2054 |
|
2055 | if (hasProxy) {
|
2056 | var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
|
2057 | config.keyCodes = new Proxy(config.keyCodes, {
|
2058 | set: function set (target, key, value) {
|
2059 | if (isBuiltInModifier(key)) {
|
2060 | warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
|
2061 | return false
|
2062 | } else {
|
2063 | target[key] = value;
|
2064 | return true
|
2065 | }
|
2066 | }
|
2067 | });
|
2068 | }
|
2069 |
|
2070 | var hasHandler = {
|
2071 | has: function has (target, key) {
|
2072 | var has = key in target;
|
2073 | var isAllowed = allowedGlobals(key) ||
|
2074 | (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
|
2075 | if (!has && !isAllowed) {
|
2076 | if (key in target.$data) { warnReservedPrefix(target, key); }
|
2077 | else { warnNonPresent(target, key); }
|
2078 | }
|
2079 | return has || !isAllowed
|
2080 | }
|
2081 | };
|
2082 |
|
2083 | var getHandler = {
|
2084 | get: function get (target, key) {
|
2085 | if (typeof key === 'string' && !(key in target)) {
|
2086 | if (key in target.$data) { warnReservedPrefix(target, key); }
|
2087 | else { warnNonPresent(target, key); }
|
2088 | }
|
2089 | return target[key]
|
2090 | }
|
2091 | };
|
2092 |
|
2093 | initProxy = function initProxy (vm) {
|
2094 | if (hasProxy) {
|
2095 |
|
2096 | var options = vm.$options;
|
2097 | var handlers = options.render && options.render._withStripped
|
2098 | ? getHandler
|
2099 | : hasHandler;
|
2100 | vm._renderProxy = new Proxy(vm, handlers);
|
2101 | } else {
|
2102 | vm._renderProxy = vm;
|
2103 | }
|
2104 | };
|
2105 | }
|
2106 |
|
2107 |
|
2108 |
|
2109 | var seenObjects = new _Set();
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 | function traverse (val) {
|
2117 | _traverse(val, seenObjects);
|
2118 | seenObjects.clear();
|
2119 | }
|
2120 |
|
2121 | function _traverse (val, seen) {
|
2122 | var i, keys;
|
2123 | var isA = Array.isArray(val);
|
2124 | if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
|
2125 | return
|
2126 | }
|
2127 | if (val.__ob__) {
|
2128 | var depId = val.__ob__.dep.id;
|
2129 | if (seen.has(depId)) {
|
2130 | return
|
2131 | }
|
2132 | seen.add(depId);
|
2133 | }
|
2134 | if (isA) {
|
2135 | i = val.length;
|
2136 | while (i--) { _traverse(val[i], seen); }
|
2137 | } else {
|
2138 | keys = Object.keys(val);
|
2139 | i = keys.length;
|
2140 | while (i--) { _traverse(val[keys[i]], seen); }
|
2141 | }
|
2142 | }
|
2143 |
|
2144 |
|
2145 |
|
2146 | var normalizeEvent = cached(function (name) {
|
2147 | var passive = name.charAt(0) === '&';
|
2148 | name = passive ? name.slice(1) : name;
|
2149 | var once$$1 = name.charAt(0) === '~';
|
2150 | name = once$$1 ? name.slice(1) : name;
|
2151 | var capture = name.charAt(0) === '!';
|
2152 | name = capture ? name.slice(1) : name;
|
2153 | return {
|
2154 | name: name,
|
2155 | once: once$$1,
|
2156 | capture: capture,
|
2157 | passive: passive
|
2158 | }
|
2159 | });
|
2160 |
|
2161 | function createFnInvoker (fns, vm) {
|
2162 | function invoker () {
|
2163 | var arguments$1 = arguments;
|
2164 |
|
2165 | var fns = invoker.fns;
|
2166 | if (Array.isArray(fns)) {
|
2167 | var cloned = fns.slice();
|
2168 | for (var i = 0; i < cloned.length; i++) {
|
2169 | invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
|
2170 | }
|
2171 | } else {
|
2172 |
|
2173 | return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
|
2174 | }
|
2175 | }
|
2176 | invoker.fns = fns;
|
2177 | return invoker
|
2178 | }
|
2179 |
|
2180 | function updateListeners (
|
2181 | on,
|
2182 | oldOn,
|
2183 | add,
|
2184 | remove$$1,
|
2185 | createOnceHandler,
|
2186 | vm
|
2187 | ) {
|
2188 | var name, def$$1, cur, old, event;
|
2189 | for (name in on) {
|
2190 | def$$1 = cur = on[name];
|
2191 | old = oldOn[name];
|
2192 | event = normalizeEvent(name);
|
2193 | if (isUndef(cur)) {
|
2194 | process.env.NODE_ENV !== 'production' && warn(
|
2195 | "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
|
2196 | vm
|
2197 | );
|
2198 | } else if (isUndef(old)) {
|
2199 | if (isUndef(cur.fns)) {
|
2200 | cur = on[name] = createFnInvoker(cur, vm);
|
2201 | }
|
2202 | if (isTrue(event.once)) {
|
2203 | cur = on[name] = createOnceHandler(event.name, cur, event.capture);
|
2204 | }
|
2205 | add(event.name, cur, event.capture, event.passive, event.params);
|
2206 | } else if (cur !== old) {
|
2207 | old.fns = cur;
|
2208 | on[name] = old;
|
2209 | }
|
2210 | }
|
2211 | for (name in oldOn) {
|
2212 | if (isUndef(on[name])) {
|
2213 | event = normalizeEvent(name);
|
2214 | remove$$1(event.name, oldOn[name], event.capture);
|
2215 | }
|
2216 | }
|
2217 | }
|
2218 |
|
2219 |
|
2220 |
|
2221 | function mergeVNodeHook (def, hookKey, hook) {
|
2222 | if (def instanceof VNode) {
|
2223 | def = def.data.hook || (def.data.hook = {});
|
2224 | }
|
2225 | var invoker;
|
2226 | var oldHook = def[hookKey];
|
2227 |
|
2228 | function wrappedHook () {
|
2229 | hook.apply(this, arguments);
|
2230 |
|
2231 |
|
2232 | remove(invoker.fns, wrappedHook);
|
2233 | }
|
2234 |
|
2235 | if (isUndef(oldHook)) {
|
2236 |
|
2237 | invoker = createFnInvoker([wrappedHook]);
|
2238 | } else {
|
2239 |
|
2240 | if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
|
2241 |
|
2242 | invoker = oldHook;
|
2243 | invoker.fns.push(wrappedHook);
|
2244 | } else {
|
2245 |
|
2246 | invoker = createFnInvoker([oldHook, wrappedHook]);
|
2247 | }
|
2248 | }
|
2249 |
|
2250 | invoker.merged = true;
|
2251 | def[hookKey] = invoker;
|
2252 | }
|
2253 |
|
2254 |
|
2255 |
|
2256 | function extractPropsFromVNodeData (
|
2257 | data,
|
2258 | Ctor,
|
2259 | tag
|
2260 | ) {
|
2261 |
|
2262 |
|
2263 |
|
2264 | var propOptions = Ctor.options.props;
|
2265 | if (isUndef(propOptions)) {
|
2266 | return
|
2267 | }
|
2268 | var res = {};
|
2269 | var attrs = data.attrs;
|
2270 | var props = data.props;
|
2271 | if (isDef(attrs) || isDef(props)) {
|
2272 | for (var key in propOptions) {
|
2273 | var altKey = hyphenate(key);
|
2274 | if (process.env.NODE_ENV !== 'production') {
|
2275 | var keyInLowerCase = key.toLowerCase();
|
2276 | if (
|
2277 | key !== keyInLowerCase &&
|
2278 | attrs && hasOwn(attrs, keyInLowerCase)
|
2279 | ) {
|
2280 | tip(
|
2281 | "Prop \"" + keyInLowerCase + "\" is passed to component " +
|
2282 | (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
|
2283 | " \"" + key + "\". " +
|
2284 | "Note that HTML attributes are case-insensitive and camelCased " +
|
2285 | "props need to use their kebab-case equivalents when using in-DOM " +
|
2286 | "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
|
2287 | );
|
2288 | }
|
2289 | }
|
2290 | checkProp(res, props, key, altKey, true) ||
|
2291 | checkProp(res, attrs, key, altKey, false);
|
2292 | }
|
2293 | }
|
2294 | return res
|
2295 | }
|
2296 |
|
2297 | function checkProp (
|
2298 | res,
|
2299 | hash,
|
2300 | key,
|
2301 | altKey,
|
2302 | preserve
|
2303 | ) {
|
2304 | if (isDef(hash)) {
|
2305 | if (hasOwn(hash, key)) {
|
2306 | res[key] = hash[key];
|
2307 | if (!preserve) {
|
2308 | delete hash[key];
|
2309 | }
|
2310 | return true
|
2311 | } else if (hasOwn(hash, altKey)) {
|
2312 | res[key] = hash[altKey];
|
2313 | if (!preserve) {
|
2314 | delete hash[altKey];
|
2315 | }
|
2316 | return true
|
2317 | }
|
2318 | }
|
2319 | return false
|
2320 | }
|
2321 |
|
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 |
|
2336 | function simpleNormalizeChildren (children) {
|
2337 | for (var i = 0; i < children.length; i++) {
|
2338 | if (Array.isArray(children[i])) {
|
2339 | return Array.prototype.concat.apply([], children)
|
2340 | }
|
2341 | }
|
2342 | return children
|
2343 | }
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 | function normalizeChildren (children) {
|
2350 | return isPrimitive(children)
|
2351 | ? [createTextVNode(children)]
|
2352 | : Array.isArray(children)
|
2353 | ? normalizeArrayChildren(children)
|
2354 | : undefined
|
2355 | }
|
2356 |
|
2357 | function isTextNode (node) {
|
2358 | return isDef(node) && isDef(node.text) && isFalse(node.isComment)
|
2359 | }
|
2360 |
|
2361 | function normalizeArrayChildren (children, nestedIndex) {
|
2362 | var res = [];
|
2363 | var i, c, lastIndex, last;
|
2364 | for (i = 0; i < children.length; i++) {
|
2365 | c = children[i];
|
2366 | if (isUndef(c) || typeof c === 'boolean') { continue }
|
2367 | lastIndex = res.length - 1;
|
2368 | last = res[lastIndex];
|
2369 |
|
2370 | if (Array.isArray(c)) {
|
2371 | if (c.length > 0) {
|
2372 | c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
|
2373 |
|
2374 | if (isTextNode(c[0]) && isTextNode(last)) {
|
2375 | res[lastIndex] = createTextVNode(last.text + (c[0]).text);
|
2376 | c.shift();
|
2377 | }
|
2378 | res.push.apply(res, c);
|
2379 | }
|
2380 | } else if (isPrimitive(c)) {
|
2381 | if (isTextNode(last)) {
|
2382 |
|
2383 |
|
2384 |
|
2385 | res[lastIndex] = createTextVNode(last.text + c);
|
2386 | } else if (c !== '') {
|
2387 |
|
2388 | res.push(createTextVNode(c));
|
2389 | }
|
2390 | } else {
|
2391 | if (isTextNode(c) && isTextNode(last)) {
|
2392 |
|
2393 | res[lastIndex] = createTextVNode(last.text + c.text);
|
2394 | } else {
|
2395 |
|
2396 | if (isTrue(children._isVList) &&
|
2397 | isDef(c.tag) &&
|
2398 | isUndef(c.key) &&
|
2399 | isDef(nestedIndex)) {
|
2400 | c.key = "__vlist" + nestedIndex + "_" + i + "__";
|
2401 | }
|
2402 | res.push(c);
|
2403 | }
|
2404 | }
|
2405 | }
|
2406 | return res
|
2407 | }
|
2408 |
|
2409 |
|
2410 |
|
2411 | function ensureCtor (comp, base) {
|
2412 | if (
|
2413 | comp.__esModule ||
|
2414 | (hasSymbol && comp[Symbol.toStringTag] === 'Module')
|
2415 | ) {
|
2416 | comp = comp.default;
|
2417 | }
|
2418 | return isObject(comp)
|
2419 | ? base.extend(comp)
|
2420 | : comp
|
2421 | }
|
2422 |
|
2423 | function createAsyncPlaceholder (
|
2424 | factory,
|
2425 | data,
|
2426 | context,
|
2427 | children,
|
2428 | tag
|
2429 | ) {
|
2430 | var node = createEmptyVNode();
|
2431 | node.asyncFactory = factory;
|
2432 | node.asyncMeta = { data: data, context: context, children: children, tag: tag };
|
2433 | return node
|
2434 | }
|
2435 |
|
2436 | function resolveAsyncComponent (
|
2437 | factory,
|
2438 | baseCtor,
|
2439 | context
|
2440 | ) {
|
2441 | if (isTrue(factory.error) && isDef(factory.errorComp)) {
|
2442 | return factory.errorComp
|
2443 | }
|
2444 |
|
2445 | if (isDef(factory.resolved)) {
|
2446 | return factory.resolved
|
2447 | }
|
2448 |
|
2449 | if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
|
2450 | return factory.loadingComp
|
2451 | }
|
2452 |
|
2453 | if (isDef(factory.contexts)) {
|
2454 |
|
2455 | factory.contexts.push(context);
|
2456 | } else {
|
2457 | var contexts = factory.contexts = [context];
|
2458 | var sync = true;
|
2459 |
|
2460 | var forceRender = function (renderCompleted) {
|
2461 | for (var i = 0, l = contexts.length; i < l; i++) {
|
2462 | contexts[i].$forceUpdate();
|
2463 | }
|
2464 |
|
2465 | if (renderCompleted) {
|
2466 | contexts.length = 0;
|
2467 | }
|
2468 | };
|
2469 |
|
2470 | var resolve = once(function (res) {
|
2471 |
|
2472 | factory.resolved = ensureCtor(res, baseCtor);
|
2473 |
|
2474 |
|
2475 | if (!sync) {
|
2476 | forceRender(true);
|
2477 | } else {
|
2478 | contexts.length = 0;
|
2479 | }
|
2480 | });
|
2481 |
|
2482 | var reject = once(function (reason) {
|
2483 | process.env.NODE_ENV !== 'production' && warn(
|
2484 | "Failed to resolve async component: " + (String(factory)) +
|
2485 | (reason ? ("\nReason: " + reason) : '')
|
2486 | );
|
2487 | if (isDef(factory.errorComp)) {
|
2488 | factory.error = true;
|
2489 | forceRender(true);
|
2490 | }
|
2491 | });
|
2492 |
|
2493 | var res = factory(resolve, reject);
|
2494 |
|
2495 | if (isObject(res)) {
|
2496 | if (isPromise(res)) {
|
2497 |
|
2498 | if (isUndef(factory.resolved)) {
|
2499 | res.then(resolve, reject);
|
2500 | }
|
2501 | } else if (isPromise(res.component)) {
|
2502 | res.component.then(resolve, reject);
|
2503 |
|
2504 | if (isDef(res.error)) {
|
2505 | factory.errorComp = ensureCtor(res.error, baseCtor);
|
2506 | }
|
2507 |
|
2508 | if (isDef(res.loading)) {
|
2509 | factory.loadingComp = ensureCtor(res.loading, baseCtor);
|
2510 | if (res.delay === 0) {
|
2511 | factory.loading = true;
|
2512 | } else {
|
2513 | setTimeout(function () {
|
2514 | if (isUndef(factory.resolved) && isUndef(factory.error)) {
|
2515 | factory.loading = true;
|
2516 | forceRender(false);
|
2517 | }
|
2518 | }, res.delay || 200);
|
2519 | }
|
2520 | }
|
2521 |
|
2522 | if (isDef(res.timeout)) {
|
2523 | setTimeout(function () {
|
2524 | if (isUndef(factory.resolved)) {
|
2525 | reject(
|
2526 | process.env.NODE_ENV !== 'production'
|
2527 | ? ("timeout (" + (res.timeout) + "ms)")
|
2528 | : null
|
2529 | );
|
2530 | }
|
2531 | }, res.timeout);
|
2532 | }
|
2533 | }
|
2534 | }
|
2535 |
|
2536 | sync = false;
|
2537 |
|
2538 | return factory.loading
|
2539 | ? factory.loadingComp
|
2540 | : factory.resolved
|
2541 | }
|
2542 | }
|
2543 |
|
2544 |
|
2545 |
|
2546 | function isAsyncPlaceholder (node) {
|
2547 | return node.isComment && node.asyncFactory
|
2548 | }
|
2549 |
|
2550 |
|
2551 |
|
2552 | function getFirstComponentChild (children) {
|
2553 | if (Array.isArray(children)) {
|
2554 | for (var i = 0; i < children.length; i++) {
|
2555 | var c = children[i];
|
2556 | if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
|
2557 | return c
|
2558 | }
|
2559 | }
|
2560 | }
|
2561 | }
|
2562 |
|
2563 |
|
2564 |
|
2565 |
|
2566 |
|
2567 | function initEvents (vm) {
|
2568 | vm._events = Object.create(null);
|
2569 | vm._hasHookEvent = false;
|
2570 |
|
2571 | var listeners = vm.$options._parentListeners;
|
2572 | if (listeners) {
|
2573 | updateComponentListeners(vm, listeners);
|
2574 | }
|
2575 | }
|
2576 |
|
2577 | var target;
|
2578 |
|
2579 | function add (event, fn) {
|
2580 | target.$on(event, fn);
|
2581 | }
|
2582 |
|
2583 | function remove$1 (event, fn) {
|
2584 | target.$off(event, fn);
|
2585 | }
|
2586 |
|
2587 | function createOnceHandler (event, fn) {
|
2588 | var _target = target;
|
2589 | return function onceHandler () {
|
2590 | var res = fn.apply(null, arguments);
|
2591 | if (res !== null) {
|
2592 | _target.$off(event, onceHandler);
|
2593 | }
|
2594 | }
|
2595 | }
|
2596 |
|
2597 | function updateComponentListeners (
|
2598 | vm,
|
2599 | listeners,
|
2600 | oldListeners
|
2601 | ) {
|
2602 | target = vm;
|
2603 | updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
|
2604 | target = undefined;
|
2605 | }
|
2606 |
|
2607 | function eventsMixin (Vue) {
|
2608 | var hookRE = /^hook:/;
|
2609 | Vue.prototype.$on = function (event, fn) {
|
2610 | var vm = this;
|
2611 | if (Array.isArray(event)) {
|
2612 | for (var i = 0, l = event.length; i < l; i++) {
|
2613 | vm.$on(event[i], fn);
|
2614 | }
|
2615 | } else {
|
2616 | (vm._events[event] || (vm._events[event] = [])).push(fn);
|
2617 |
|
2618 |
|
2619 | if (hookRE.test(event)) {
|
2620 | vm._hasHookEvent = true;
|
2621 | }
|
2622 | }
|
2623 | return vm
|
2624 | };
|
2625 |
|
2626 | Vue.prototype.$once = function (event, fn) {
|
2627 | var vm = this;
|
2628 | function on () {
|
2629 | vm.$off(event, on);
|
2630 | fn.apply(vm, arguments);
|
2631 | }
|
2632 | on.fn = fn;
|
2633 | vm.$on(event, on);
|
2634 | return vm
|
2635 | };
|
2636 |
|
2637 | Vue.prototype.$off = function (event, fn) {
|
2638 | var vm = this;
|
2639 |
|
2640 | if (!arguments.length) {
|
2641 | vm._events = Object.create(null);
|
2642 | return vm
|
2643 | }
|
2644 |
|
2645 | if (Array.isArray(event)) {
|
2646 | for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
|
2647 | vm.$off(event[i$1], fn);
|
2648 | }
|
2649 | return vm
|
2650 | }
|
2651 |
|
2652 | var cbs = vm._events[event];
|
2653 | if (!cbs) {
|
2654 | return vm
|
2655 | }
|
2656 | if (!fn) {
|
2657 | vm._events[event] = null;
|
2658 | return vm
|
2659 | }
|
2660 |
|
2661 | var cb;
|
2662 | var i = cbs.length;
|
2663 | while (i--) {
|
2664 | cb = cbs[i];
|
2665 | if (cb === fn || cb.fn === fn) {
|
2666 | cbs.splice(i, 1);
|
2667 | break
|
2668 | }
|
2669 | }
|
2670 | return vm
|
2671 | };
|
2672 |
|
2673 | Vue.prototype.$emit = function (event) {
|
2674 | var vm = this;
|
2675 | if (process.env.NODE_ENV !== 'production') {
|
2676 | var lowerCaseEvent = event.toLowerCase();
|
2677 | if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
|
2678 | tip(
|
2679 | "Event \"" + lowerCaseEvent + "\" is emitted in component " +
|
2680 | (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
|
2681 | "Note that HTML attributes are case-insensitive and you cannot use " +
|
2682 | "v-on to listen to camelCase events when using in-DOM templates. " +
|
2683 | "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
|
2684 | );
|
2685 | }
|
2686 | }
|
2687 | var cbs = vm._events[event];
|
2688 | if (cbs) {
|
2689 | cbs = cbs.length > 1 ? toArray(cbs) : cbs;
|
2690 | var args = toArray(arguments, 1);
|
2691 | var info = "event handler for \"" + event + "\"";
|
2692 | for (var i = 0, l = cbs.length; i < l; i++) {
|
2693 | invokeWithErrorHandling(cbs[i], vm, args, vm, info);
|
2694 | }
|
2695 | }
|
2696 | return vm
|
2697 | };
|
2698 | }
|
2699 |
|
2700 |
|
2701 |
|
2702 |
|
2703 |
|
2704 |
|
2705 |
|
2706 |
|
2707 | function resolveSlots (
|
2708 | children,
|
2709 | context
|
2710 | ) {
|
2711 | if (!children || !children.length) {
|
2712 | return {}
|
2713 | }
|
2714 | var slots = {};
|
2715 | for (var i = 0, l = children.length; i < l; i++) {
|
2716 | var child = children[i];
|
2717 | var data = child.data;
|
2718 |
|
2719 | if (data && data.attrs && data.attrs.slot) {
|
2720 | delete data.attrs.slot;
|
2721 | }
|
2722 |
|
2723 |
|
2724 | if ((child.context === context || child.fnContext === context) &&
|
2725 | data && data.slot != null
|
2726 | ) {
|
2727 | var name = data.slot;
|
2728 | var slot = (slots[name] || (slots[name] = []));
|
2729 | if (child.tag === 'template') {
|
2730 | slot.push.apply(slot, child.children || []);
|
2731 | } else {
|
2732 | slot.push(child);
|
2733 | }
|
2734 | } else {
|
2735 | (slots.default || (slots.default = [])).push(child);
|
2736 | }
|
2737 | }
|
2738 |
|
2739 | for (var name$1 in slots) {
|
2740 | if (slots[name$1].every(isWhitespace)) {
|
2741 | delete slots[name$1];
|
2742 | }
|
2743 | }
|
2744 | return slots
|
2745 | }
|
2746 |
|
2747 | function isWhitespace (node) {
|
2748 | return (node.isComment && !node.asyncFactory) || node.text === ' '
|
2749 | }
|
2750 |
|
2751 | function resolveScopedSlots (
|
2752 | fns, // see flow/vnode
|
2753 | hasDynamicKeys,
|
2754 | res
|
2755 | ) {
|
2756 | res = res || { $stable: !hasDynamicKeys };
|
2757 | for (var i = 0; i < fns.length; i++) {
|
2758 | var slot = fns[i];
|
2759 | if (Array.isArray(slot)) {
|
2760 | resolveScopedSlots(slot, hasDynamicKeys, res);
|
2761 | } else if (slot) {
|
2762 | res[slot.key] = slot.fn;
|
2763 | }
|
2764 | }
|
2765 | return res
|
2766 | }
|
2767 |
|
2768 |
|
2769 |
|
2770 | var activeInstance = null;
|
2771 | var isUpdatingChildComponent = false;
|
2772 |
|
2773 | function setActiveInstance(vm) {
|
2774 | var prevActiveInstance = activeInstance;
|
2775 | activeInstance = vm;
|
2776 | return function () {
|
2777 | activeInstance = prevActiveInstance;
|
2778 | }
|
2779 | }
|
2780 |
|
2781 | function initLifecycle (vm) {
|
2782 | var options = vm.$options;
|
2783 |
|
2784 |
|
2785 | var parent = options.parent;
|
2786 | if (parent && !options.abstract) {
|
2787 | while (parent.$options.abstract && parent.$parent) {
|
2788 | parent = parent.$parent;
|
2789 | }
|
2790 | parent.$children.push(vm);
|
2791 | }
|
2792 |
|
2793 | vm.$parent = parent;
|
2794 | vm.$root = parent ? parent.$root : vm;
|
2795 |
|
2796 | vm.$children = [];
|
2797 | vm.$refs = {};
|
2798 |
|
2799 | vm._watcher = null;
|
2800 | vm._inactive = null;
|
2801 | vm._directInactive = false;
|
2802 | vm._isMounted = false;
|
2803 | vm._isDestroyed = false;
|
2804 | vm._isBeingDestroyed = false;
|
2805 | }
|
2806 |
|
2807 | function lifecycleMixin (Vue) {
|
2808 | Vue.prototype._update = function (vnode, hydrating) {
|
2809 | var vm = this;
|
2810 | var prevEl = vm.$el;
|
2811 | var prevVnode = vm._vnode;
|
2812 | var restoreActiveInstance = setActiveInstance(vm);
|
2813 | vm._vnode = vnode;
|
2814 |
|
2815 |
|
2816 | if (!prevVnode) {
|
2817 |
|
2818 | vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false );
|
2819 | } else {
|
2820 |
|
2821 | vm.$el = vm.__patch__(prevVnode, vnode);
|
2822 | }
|
2823 | restoreActiveInstance();
|
2824 |
|
2825 | if (prevEl) {
|
2826 | prevEl.__vue__ = null;
|
2827 | }
|
2828 | if (vm.$el) {
|
2829 | vm.$el.__vue__ = vm;
|
2830 | }
|
2831 |
|
2832 | if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
|
2833 | vm.$parent.$el = vm.$el;
|
2834 | }
|
2835 |
|
2836 |
|
2837 | };
|
2838 |
|
2839 | Vue.prototype.$forceUpdate = function () {
|
2840 | var vm = this;
|
2841 | if (vm._watcher) {
|
2842 | vm._watcher.update();
|
2843 | }
|
2844 | };
|
2845 |
|
2846 | Vue.prototype.$destroy = function () {
|
2847 | var vm = this;
|
2848 | if (vm._isBeingDestroyed) {
|
2849 | return
|
2850 | }
|
2851 | callHook(vm, 'beforeDestroy');
|
2852 | vm._isBeingDestroyed = true;
|
2853 |
|
2854 | var parent = vm.$parent;
|
2855 | if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
|
2856 | remove(parent.$children, vm);
|
2857 | }
|
2858 |
|
2859 | if (vm._watcher) {
|
2860 | vm._watcher.teardown();
|
2861 | }
|
2862 | var i = vm._watchers.length;
|
2863 | while (i--) {
|
2864 | vm._watchers[i].teardown();
|
2865 | }
|
2866 |
|
2867 |
|
2868 | if (vm._data.__ob__) {
|
2869 | vm._data.__ob__.vmCount--;
|
2870 | }
|
2871 |
|
2872 | vm._isDestroyed = true;
|
2873 |
|
2874 | vm.__patch__(vm._vnode, null);
|
2875 |
|
2876 | callHook(vm, 'destroyed');
|
2877 |
|
2878 | vm.$off();
|
2879 |
|
2880 | if (vm.$el) {
|
2881 | vm.$el.__vue__ = null;
|
2882 | }
|
2883 |
|
2884 | if (vm.$vnode) {
|
2885 | vm.$vnode.parent = null;
|
2886 | }
|
2887 | };
|
2888 | }
|
2889 |
|
2890 | function mountComponent (
|
2891 | vm,
|
2892 | el,
|
2893 | hydrating
|
2894 | ) {
|
2895 | vm.$el = el;
|
2896 | if (!vm.$options.render) {
|
2897 | vm.$options.render = createEmptyVNode;
|
2898 | if (process.env.NODE_ENV !== 'production') {
|
2899 |
|
2900 | if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
|
2901 | vm.$options.el || el) {
|
2902 | warn(
|
2903 | 'You are using the runtime-only build of Vue where the template ' +
|
2904 | 'compiler is not available. Either pre-compile the templates into ' +
|
2905 | 'render functions, or use the compiler-included build.',
|
2906 | vm
|
2907 | );
|
2908 | } else {
|
2909 | warn(
|
2910 | 'Failed to mount component: template or render function not defined.',
|
2911 | vm
|
2912 | );
|
2913 | }
|
2914 | }
|
2915 | }
|
2916 | callHook(vm, 'beforeMount');
|
2917 |
|
2918 | var updateComponent;
|
2919 |
|
2920 | if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
|
2921 | updateComponent = function () {
|
2922 | var name = vm._name;
|
2923 | var id = vm._uid;
|
2924 | var startTag = "vue-perf-start:" + id;
|
2925 | var endTag = "vue-perf-end:" + id;
|
2926 |
|
2927 | mark(startTag);
|
2928 | var vnode = vm._render();
|
2929 | mark(endTag);
|
2930 | measure(("vue " + name + " render"), startTag, endTag);
|
2931 |
|
2932 | mark(startTag);
|
2933 | vm._update(vnode, hydrating);
|
2934 | mark(endTag);
|
2935 | measure(("vue " + name + " patch"), startTag, endTag);
|
2936 | };
|
2937 | } else {
|
2938 | updateComponent = function () {
|
2939 | vm._update(vm._render(), hydrating);
|
2940 | };
|
2941 | }
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 | new Watcher(vm, updateComponent, noop, {
|
2947 | before: function before () {
|
2948 | if (vm._isMounted && !vm._isDestroyed) {
|
2949 | callHook(vm, 'beforeUpdate');
|
2950 | }
|
2951 | }
|
2952 | }, true );
|
2953 | hydrating = false;
|
2954 |
|
2955 |
|
2956 |
|
2957 | if (vm.$vnode == null) {
|
2958 | vm._isMounted = true;
|
2959 | callHook(vm, 'mounted');
|
2960 | }
|
2961 | return vm
|
2962 | }
|
2963 |
|
2964 | function updateChildComponent (
|
2965 | vm,
|
2966 | propsData,
|
2967 | listeners,
|
2968 | parentVnode,
|
2969 | renderChildren
|
2970 | ) {
|
2971 | if (process.env.NODE_ENV !== 'production') {
|
2972 | isUpdatingChildComponent = true;
|
2973 | }
|
2974 |
|
2975 |
|
2976 |
|
2977 |
|
2978 |
|
2979 |
|
2980 |
|
2981 | var hasDynamicScopedSlot = !!(
|
2982 | (parentVnode.data.scopedSlots && !parentVnode.data.scopedSlots.$stable) ||
|
2983 | (vm.$scopedSlots !== emptyObject && !vm.$scopedSlots.$stable)
|
2984 | );
|
2985 |
|
2986 |
|
2987 |
|
2988 | var needsForceUpdate = !!(
|
2989 | renderChildren ||
|
2990 | vm.$options._renderChildren ||
|
2991 | hasDynamicScopedSlot
|
2992 | );
|
2993 |
|
2994 | vm.$options._parentVnode = parentVnode;
|
2995 | vm.$vnode = parentVnode;
|
2996 |
|
2997 | if (vm._vnode) {
|
2998 | vm._vnode.parent = parentVnode;
|
2999 | }
|
3000 | vm.$options._renderChildren = renderChildren;
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 | vm.$attrs = parentVnode.data.attrs || emptyObject;
|
3006 | vm.$listeners = listeners || emptyObject;
|
3007 |
|
3008 |
|
3009 | if (propsData && vm.$options.props) {
|
3010 | toggleObserving(false);
|
3011 | var props = vm._props;
|
3012 | var propKeys = vm.$options._propKeys || [];
|
3013 | for (var i = 0; i < propKeys.length; i++) {
|
3014 | var key = propKeys[i];
|
3015 | var propOptions = vm.$options.props;
|
3016 | props[key] = validateProp(key, propOptions, propsData, vm);
|
3017 | }
|
3018 | toggleObserving(true);
|
3019 |
|
3020 | vm.$options.propsData = propsData;
|
3021 | }
|
3022 |
|
3023 |
|
3024 | listeners = listeners || emptyObject;
|
3025 | var oldListeners = vm.$options._parentListeners;
|
3026 | vm.$options._parentListeners = listeners;
|
3027 | updateComponentListeners(vm, listeners, oldListeners);
|
3028 |
|
3029 |
|
3030 | if (needsForceUpdate) {
|
3031 | vm.$slots = resolveSlots(renderChildren, parentVnode.context);
|
3032 | vm.$forceUpdate();
|
3033 | }
|
3034 |
|
3035 | if (process.env.NODE_ENV !== 'production') {
|
3036 | isUpdatingChildComponent = false;
|
3037 | }
|
3038 | }
|
3039 |
|
3040 | function isInInactiveTree (vm) {
|
3041 | while (vm && (vm = vm.$parent)) {
|
3042 | if (vm._inactive) { return true }
|
3043 | }
|
3044 | return false
|
3045 | }
|
3046 |
|
3047 | function activateChildComponent (vm, direct) {
|
3048 | if (direct) {
|
3049 | vm._directInactive = false;
|
3050 | if (isInInactiveTree(vm)) {
|
3051 | return
|
3052 | }
|
3053 | } else if (vm._directInactive) {
|
3054 | return
|
3055 | }
|
3056 | if (vm._inactive || vm._inactive === null) {
|
3057 | vm._inactive = false;
|
3058 | for (var i = 0; i < vm.$children.length; i++) {
|
3059 | activateChildComponent(vm.$children[i]);
|
3060 | }
|
3061 | callHook(vm, 'activated');
|
3062 | }
|
3063 | }
|
3064 |
|
3065 | function deactivateChildComponent (vm, direct) {
|
3066 | if (direct) {
|
3067 | vm._directInactive = true;
|
3068 | if (isInInactiveTree(vm)) {
|
3069 | return
|
3070 | }
|
3071 | }
|
3072 | if (!vm._inactive) {
|
3073 | vm._inactive = true;
|
3074 | for (var i = 0; i < vm.$children.length; i++) {
|
3075 | deactivateChildComponent(vm.$children[i]);
|
3076 | }
|
3077 | callHook(vm, 'deactivated');
|
3078 | }
|
3079 | }
|
3080 |
|
3081 | function callHook (vm, hook) {
|
3082 |
|
3083 | pushTarget();
|
3084 | var handlers = vm.$options[hook];
|
3085 | var info = hook + " hook";
|
3086 | if (handlers) {
|
3087 | for (var i = 0, j = handlers.length; i < j; i++) {
|
3088 | invokeWithErrorHandling(handlers[i], vm, null, vm, info);
|
3089 | }
|
3090 | }
|
3091 | if (vm._hasHookEvent) {
|
3092 | vm.$emit('hook:' + hook);
|
3093 | }
|
3094 | popTarget();
|
3095 | }
|
3096 |
|
3097 |
|
3098 |
|
3099 | var MAX_UPDATE_COUNT = 100;
|
3100 |
|
3101 | var queue = [];
|
3102 | var activatedChildren = [];
|
3103 | var has = {};
|
3104 | var circular = {};
|
3105 | var waiting = false;
|
3106 | var flushing = false;
|
3107 | var index = 0;
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 | function resetSchedulerState () {
|
3113 | index = queue.length = activatedChildren.length = 0;
|
3114 | has = {};
|
3115 | if (process.env.NODE_ENV !== 'production') {
|
3116 | circular = {};
|
3117 | }
|
3118 | waiting = flushing = false;
|
3119 | }
|
3120 |
|
3121 |
|
3122 |
|
3123 |
|
3124 |
|
3125 |
|
3126 | var currentFlushTimestamp = 0;
|
3127 |
|
3128 |
|
3129 | var getNow = Date.now;
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 | if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
|
3136 |
|
3137 |
|
3138 |
|
3139 | getNow = function () { return performance.now(); };
|
3140 | }
|
3141 |
|
3142 |
|
3143 |
|
3144 |
|
3145 | function flushSchedulerQueue () {
|
3146 | currentFlushTimestamp = getNow();
|
3147 | flushing = true;
|
3148 | var watcher, id;
|
3149 |
|
3150 |
|
3151 |
|
3152 |
|
3153 |
|
3154 |
|
3155 |
|
3156 |
|
3157 |
|
3158 | queue.sort(function (a, b) { return a.id - b.id; });
|
3159 |
|
3160 |
|
3161 |
|
3162 | for (index = 0; index < queue.length; index++) {
|
3163 | watcher = queue[index];
|
3164 | if (watcher.before) {
|
3165 | watcher.before();
|
3166 | }
|
3167 | id = watcher.id;
|
3168 | has[id] = null;
|
3169 | watcher.run();
|
3170 |
|
3171 | if (process.env.NODE_ENV !== 'production' && has[id] != null) {
|
3172 | circular[id] = (circular[id] || 0) + 1;
|
3173 | if (circular[id] > MAX_UPDATE_COUNT) {
|
3174 | warn(
|
3175 | 'You may have an infinite update loop ' + (
|
3176 | watcher.user
|
3177 | ? ("in watcher with expression \"" + (watcher.expression) + "\"")
|
3178 | : "in a component render function."
|
3179 | ),
|
3180 | watcher.vm
|
3181 | );
|
3182 | break
|
3183 | }
|
3184 | }
|
3185 | }
|
3186 |
|
3187 |
|
3188 | var activatedQueue = activatedChildren.slice();
|
3189 | var updatedQueue = queue.slice();
|
3190 |
|
3191 | resetSchedulerState();
|
3192 |
|
3193 |
|
3194 | callActivatedHooks(activatedQueue);
|
3195 | callUpdatedHooks(updatedQueue);
|
3196 |
|
3197 |
|
3198 |
|
3199 | if (devtools && config.devtools) {
|
3200 | devtools.emit('flush');
|
3201 | }
|
3202 | }
|
3203 |
|
3204 | function callUpdatedHooks (queue) {
|
3205 | var i = queue.length;
|
3206 | while (i--) {
|
3207 | var watcher = queue[i];
|
3208 | var vm = watcher.vm;
|
3209 | if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
|
3210 | callHook(vm, 'updated');
|
3211 | }
|
3212 | }
|
3213 | }
|
3214 |
|
3215 |
|
3216 |
|
3217 |
|
3218 |
|
3219 | function queueActivatedComponent (vm) {
|
3220 |
|
3221 |
|
3222 | vm._inactive = false;
|
3223 | activatedChildren.push(vm);
|
3224 | }
|
3225 |
|
3226 | function callActivatedHooks (queue) {
|
3227 | for (var i = 0; i < queue.length; i++) {
|
3228 | queue[i]._inactive = true;
|
3229 | activateChildComponent(queue[i], true );
|
3230 | }
|
3231 | }
|
3232 |
|
3233 |
|
3234 |
|
3235 |
|
3236 |
|
3237 |
|
3238 | function queueWatcher (watcher) {
|
3239 | var id = watcher.id;
|
3240 | if (has[id] == null) {
|
3241 | has[id] = true;
|
3242 | if (!flushing) {
|
3243 | queue.push(watcher);
|
3244 | } else {
|
3245 |
|
3246 |
|
3247 | var i = queue.length - 1;
|
3248 | while (i > index && queue[i].id > watcher.id) {
|
3249 | i--;
|
3250 | }
|
3251 | queue.splice(i + 1, 0, watcher);
|
3252 | }
|
3253 |
|
3254 | if (!waiting) {
|
3255 | waiting = true;
|
3256 |
|
3257 | if (process.env.NODE_ENV !== 'production' && !config.async) {
|
3258 | flushSchedulerQueue();
|
3259 | return
|
3260 | }
|
3261 | nextTick(flushSchedulerQueue);
|
3262 | }
|
3263 | }
|
3264 | }
|
3265 |
|
3266 |
|
3267 |
|
3268 |
|
3269 |
|
3270 | var uid$1 = 0;
|
3271 |
|
3272 |
|
3273 |
|
3274 |
|
3275 |
|
3276 |
|
3277 | var Watcher = function Watcher (
|
3278 | vm,
|
3279 | expOrFn,
|
3280 | cb,
|
3281 | options,
|
3282 | isRenderWatcher
|
3283 | ) {
|
3284 | this.vm = vm;
|
3285 | if (isRenderWatcher) {
|
3286 | vm._watcher = this;
|
3287 | }
|
3288 | vm._watchers.push(this);
|
3289 |
|
3290 | if (options) {
|
3291 | this.deep = !!options.deep;
|
3292 | this.user = !!options.user;
|
3293 | this.lazy = !!options.lazy;
|
3294 | this.sync = !!options.sync;
|
3295 | this.before = options.before;
|
3296 | } else {
|
3297 | this.deep = this.user = this.lazy = this.sync = false;
|
3298 | }
|
3299 | this.cb = cb;
|
3300 | this.id = ++uid$1;
|
3301 | this.active = true;
|
3302 | this.dirty = this.lazy;
|
3303 | this.deps = [];
|
3304 | this.newDeps = [];
|
3305 | this.depIds = new _Set();
|
3306 | this.newDepIds = new _Set();
|
3307 | this.expression = process.env.NODE_ENV !== 'production'
|
3308 | ? expOrFn.toString()
|
3309 | : '';
|
3310 |
|
3311 | if (typeof expOrFn === 'function') {
|
3312 | this.getter = expOrFn;
|
3313 | } else {
|
3314 | this.getter = parsePath(expOrFn);
|
3315 | if (!this.getter) {
|
3316 | this.getter = noop;
|
3317 | process.env.NODE_ENV !== 'production' && warn(
|
3318 | "Failed watching path: \"" + expOrFn + "\" " +
|
3319 | 'Watcher only accepts simple dot-delimited paths. ' +
|
3320 | 'For full control, use a function instead.',
|
3321 | vm
|
3322 | );
|
3323 | }
|
3324 | }
|
3325 | this.value = this.lazy
|
3326 | ? undefined
|
3327 | : this.get();
|
3328 | };
|
3329 |
|
3330 |
|
3331 |
|
3332 |
|
3333 | Watcher.prototype.get = function get () {
|
3334 | pushTarget(this);
|
3335 | var value;
|
3336 | var vm = this.vm;
|
3337 | try {
|
3338 | value = this.getter.call(vm, vm);
|
3339 | } catch (e) {
|
3340 | if (this.user) {
|
3341 | handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
|
3342 | } else {
|
3343 | throw e
|
3344 | }
|
3345 | } finally {
|
3346 |
|
3347 |
|
3348 | if (this.deep) {
|
3349 | traverse(value);
|
3350 | }
|
3351 | popTarget();
|
3352 | this.cleanupDeps();
|
3353 | }
|
3354 | return value
|
3355 | };
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 | Watcher.prototype.addDep = function addDep (dep) {
|
3361 | var id = dep.id;
|
3362 | if (!this.newDepIds.has(id)) {
|
3363 | this.newDepIds.add(id);
|
3364 | this.newDeps.push(dep);
|
3365 | if (!this.depIds.has(id)) {
|
3366 | dep.addSub(this);
|
3367 | }
|
3368 | }
|
3369 | };
|
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 | Watcher.prototype.cleanupDeps = function cleanupDeps () {
|
3375 | var i = this.deps.length;
|
3376 | while (i--) {
|
3377 | var dep = this.deps[i];
|
3378 | if (!this.newDepIds.has(dep.id)) {
|
3379 | dep.removeSub(this);
|
3380 | }
|
3381 | }
|
3382 | var tmp = this.depIds;
|
3383 | this.depIds = this.newDepIds;
|
3384 | this.newDepIds = tmp;
|
3385 | this.newDepIds.clear();
|
3386 | tmp = this.deps;
|
3387 | this.deps = this.newDeps;
|
3388 | this.newDeps = tmp;
|
3389 | this.newDeps.length = 0;
|
3390 | };
|
3391 |
|
3392 |
|
3393 |
|
3394 |
|
3395 |
|
3396 | Watcher.prototype.update = function update () {
|
3397 |
|
3398 | if (this.lazy) {
|
3399 | this.dirty = true;
|
3400 | } else if (this.sync) {
|
3401 | this.run();
|
3402 | } else {
|
3403 | queueWatcher(this);
|
3404 | }
|
3405 | };
|
3406 |
|
3407 |
|
3408 |
|
3409 |
|
3410 |
|
3411 | Watcher.prototype.run = function run () {
|
3412 | if (this.active) {
|
3413 | var value = this.get();
|
3414 | if (
|
3415 | value !== this.value ||
|
3416 |
|
3417 |
|
3418 |
|
3419 | isObject(value) ||
|
3420 | this.deep
|
3421 | ) {
|
3422 |
|
3423 | var oldValue = this.value;
|
3424 | this.value = value;
|
3425 | if (this.user) {
|
3426 | try {
|
3427 | this.cb.call(this.vm, value, oldValue);
|
3428 | } catch (e) {
|
3429 | handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
|
3430 | }
|
3431 | } else {
|
3432 | this.cb.call(this.vm, value, oldValue);
|
3433 | }
|
3434 | }
|
3435 | }
|
3436 | };
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 | Watcher.prototype.evaluate = function evaluate () {
|
3443 | this.value = this.get();
|
3444 | this.dirty = false;
|
3445 | };
|
3446 |
|
3447 |
|
3448 |
|
3449 |
|
3450 | Watcher.prototype.depend = function depend () {
|
3451 | var i = this.deps.length;
|
3452 | while (i--) {
|
3453 | this.deps[i].depend();
|
3454 | }
|
3455 | };
|
3456 |
|
3457 |
|
3458 |
|
3459 |
|
3460 | Watcher.prototype.teardown = function teardown () {
|
3461 | if (this.active) {
|
3462 |
|
3463 |
|
3464 |
|
3465 | if (!this.vm._isBeingDestroyed) {
|
3466 | remove(this.vm._watchers, this);
|
3467 | }
|
3468 | var i = this.deps.length;
|
3469 | while (i--) {
|
3470 | this.deps[i].removeSub(this);
|
3471 | }
|
3472 | this.active = false;
|
3473 | }
|
3474 | };
|
3475 |
|
3476 |
|
3477 |
|
3478 | var sharedPropertyDefinition = {
|
3479 | enumerable: true,
|
3480 | configurable: true,
|
3481 | get: noop,
|
3482 | set: noop
|
3483 | };
|
3484 |
|
3485 | function proxy (target, sourceKey, key) {
|
3486 | sharedPropertyDefinition.get = function proxyGetter () {
|
3487 | return this[sourceKey][key]
|
3488 | };
|
3489 | sharedPropertyDefinition.set = function proxySetter (val) {
|
3490 | this[sourceKey][key] = val;
|
3491 | };
|
3492 | Object.defineProperty(target, key, sharedPropertyDefinition);
|
3493 | }
|
3494 |
|
3495 | function initState (vm) {
|
3496 | vm._watchers = [];
|
3497 | var opts = vm.$options;
|
3498 | if (opts.props) { initProps(vm, opts.props); }
|
3499 | if (opts.methods) { initMethods(vm, opts.methods); }
|
3500 | if (opts.data) {
|
3501 | initData(vm);
|
3502 | } else {
|
3503 | observe(vm._data = {}, true );
|
3504 | }
|
3505 | if (opts.computed) { initComputed(vm, opts.computed); }
|
3506 | if (opts.watch && opts.watch !== nativeWatch) {
|
3507 | initWatch(vm, opts.watch);
|
3508 | }
|
3509 | }
|
3510 |
|
3511 | function initProps (vm, propsOptions) {
|
3512 | var propsData = vm.$options.propsData || {};
|
3513 | var props = vm._props = {};
|
3514 |
|
3515 |
|
3516 | var keys = vm.$options._propKeys = [];
|
3517 | var isRoot = !vm.$parent;
|
3518 |
|
3519 | if (!isRoot) {
|
3520 | toggleObserving(false);
|
3521 | }
|
3522 | var loop = function ( key ) {
|
3523 | keys.push(key);
|
3524 | var value = validateProp(key, propsOptions, propsData, vm);
|
3525 |
|
3526 | if (process.env.NODE_ENV !== 'production') {
|
3527 | var hyphenatedKey = hyphenate(key);
|
3528 | if (isReservedAttribute(hyphenatedKey) ||
|
3529 | config.isReservedAttr(hyphenatedKey)) {
|
3530 | warn(
|
3531 | ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
|
3532 | vm
|
3533 | );
|
3534 | }
|
3535 | defineReactive$$1(props, key, value, function () {
|
3536 | if (!isRoot && !isUpdatingChildComponent) {
|
3537 | warn(
|
3538 | "Avoid mutating a prop directly since the value will be " +
|
3539 | "overwritten whenever the parent component re-renders. " +
|
3540 | "Instead, use a data or computed property based on the prop's " +
|
3541 | "value. Prop being mutated: \"" + key + "\"",
|
3542 | vm
|
3543 | );
|
3544 | }
|
3545 | });
|
3546 | } else {
|
3547 | defineReactive$$1(props, key, value);
|
3548 | }
|
3549 |
|
3550 |
|
3551 |
|
3552 | if (!(key in vm)) {
|
3553 | proxy(vm, "_props", key);
|
3554 | }
|
3555 | };
|
3556 |
|
3557 | for (var key in propsOptions) loop( key );
|
3558 | toggleObserving(true);
|
3559 | }
|
3560 |
|
3561 | function initData (vm) {
|
3562 | var data = vm.$options.data;
|
3563 | data = vm._data = typeof data === 'function'
|
3564 | ? getData(data, vm)
|
3565 | : data || {};
|
3566 | if (!isPlainObject(data)) {
|
3567 | data = {};
|
3568 | process.env.NODE_ENV !== 'production' && warn(
|
3569 | 'data functions should return an object:\n' +
|
3570 | 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
|
3571 | vm
|
3572 | );
|
3573 | }
|
3574 |
|
3575 | var keys = Object.keys(data);
|
3576 | var props = vm.$options.props;
|
3577 | var methods = vm.$options.methods;
|
3578 | var i = keys.length;
|
3579 | while (i--) {
|
3580 | var key = keys[i];
|
3581 | if (process.env.NODE_ENV !== 'production') {
|
3582 | if (methods && hasOwn(methods, key)) {
|
3583 | warn(
|
3584 | ("Method \"" + key + "\" has already been defined as a data property."),
|
3585 | vm
|
3586 | );
|
3587 | }
|
3588 | }
|
3589 | if (props && hasOwn(props, key)) {
|
3590 | process.env.NODE_ENV !== 'production' && warn(
|
3591 | "The data property \"" + key + "\" is already declared as a prop. " +
|
3592 | "Use prop default value instead.",
|
3593 | vm
|
3594 | );
|
3595 | } else if (!isReserved(key)) {
|
3596 | proxy(vm, "_data", key);
|
3597 | }
|
3598 | }
|
3599 |
|
3600 | observe(data, true );
|
3601 | }
|
3602 |
|
3603 | function getData (data, vm) {
|
3604 |
|
3605 | pushTarget();
|
3606 | try {
|
3607 | return data.call(vm, vm)
|
3608 | } catch (e) {
|
3609 | handleError(e, vm, "data()");
|
3610 | return {}
|
3611 | } finally {
|
3612 | popTarget();
|
3613 | }
|
3614 | }
|
3615 |
|
3616 | var computedWatcherOptions = { lazy: true };
|
3617 |
|
3618 | function initComputed (vm, computed) {
|
3619 |
|
3620 | var watchers = vm._computedWatchers = Object.create(null);
|
3621 |
|
3622 | var isSSR = isServerRendering();
|
3623 |
|
3624 | for (var key in computed) {
|
3625 | var userDef = computed[key];
|
3626 | var getter = typeof userDef === 'function' ? userDef : userDef.get;
|
3627 | if (process.env.NODE_ENV !== 'production' && getter == null) {
|
3628 | warn(
|
3629 | ("Getter is missing for computed property \"" + key + "\"."),
|
3630 | vm
|
3631 | );
|
3632 | }
|
3633 |
|
3634 | if (!isSSR) {
|
3635 |
|
3636 | watchers[key] = new Watcher(
|
3637 | vm,
|
3638 | getter || noop,
|
3639 | noop,
|
3640 | computedWatcherOptions
|
3641 | );
|
3642 | }
|
3643 |
|
3644 |
|
3645 |
|
3646 |
|
3647 | if (!(key in vm)) {
|
3648 | defineComputed(vm, key, userDef);
|
3649 | } else if (process.env.NODE_ENV !== 'production') {
|
3650 | if (key in vm.$data) {
|
3651 | warn(("The computed property \"" + key + "\" is already defined in data."), vm);
|
3652 | } else if (vm.$options.props && key in vm.$options.props) {
|
3653 | warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
|
3654 | }
|
3655 | }
|
3656 | }
|
3657 | }
|
3658 |
|
3659 | function defineComputed (
|
3660 | target,
|
3661 | key,
|
3662 | userDef
|
3663 | ) {
|
3664 | var shouldCache = !isServerRendering();
|
3665 | if (typeof userDef === 'function') {
|
3666 | sharedPropertyDefinition.get = shouldCache
|
3667 | ? createComputedGetter(key)
|
3668 | : createGetterInvoker(userDef);
|
3669 | sharedPropertyDefinition.set = noop;
|
3670 | } else {
|
3671 | sharedPropertyDefinition.get = userDef.get
|
3672 | ? shouldCache && userDef.cache !== false
|
3673 | ? createComputedGetter(key)
|
3674 | : createGetterInvoker(userDef.get)
|
3675 | : noop;
|
3676 | sharedPropertyDefinition.set = userDef.set || noop;
|
3677 | }
|
3678 | if (process.env.NODE_ENV !== 'production' &&
|
3679 | sharedPropertyDefinition.set === noop) {
|
3680 | sharedPropertyDefinition.set = function () {
|
3681 | warn(
|
3682 | ("Computed property \"" + key + "\" was assigned to but it has no setter."),
|
3683 | this
|
3684 | );
|
3685 | };
|
3686 | }
|
3687 | Object.defineProperty(target, key, sharedPropertyDefinition);
|
3688 | }
|
3689 |
|
3690 | function createComputedGetter (key) {
|
3691 | return function computedGetter () {
|
3692 | var watcher = this._computedWatchers && this._computedWatchers[key];
|
3693 | if (watcher) {
|
3694 | if (watcher.dirty) {
|
3695 | watcher.evaluate();
|
3696 | }
|
3697 | if (Dep.target) {
|
3698 | watcher.depend();
|
3699 | }
|
3700 | return watcher.value
|
3701 | }
|
3702 | }
|
3703 | }
|
3704 |
|
3705 | function createGetterInvoker(fn) {
|
3706 | return function computedGetter () {
|
3707 | return fn.call(this, this)
|
3708 | }
|
3709 | }
|
3710 |
|
3711 | function initMethods (vm, methods) {
|
3712 | var props = vm.$options.props;
|
3713 | for (var key in methods) {
|
3714 | if (process.env.NODE_ENV !== 'production') {
|
3715 | if (typeof methods[key] !== 'function') {
|
3716 | warn(
|
3717 | "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
|
3718 | "Did you reference the function correctly?",
|
3719 | vm
|
3720 | );
|
3721 | }
|
3722 | if (props && hasOwn(props, key)) {
|
3723 | warn(
|
3724 | ("Method \"" + key + "\" has already been defined as a prop."),
|
3725 | vm
|
3726 | );
|
3727 | }
|
3728 | if ((key in vm) && isReserved(key)) {
|
3729 | warn(
|
3730 | "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
|
3731 | "Avoid defining component methods that start with _ or $."
|
3732 | );
|
3733 | }
|
3734 | }
|
3735 | vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
|
3736 | }
|
3737 | }
|
3738 |
|
3739 | function initWatch (vm, watch) {
|
3740 | for (var key in watch) {
|
3741 | var handler = watch[key];
|
3742 | if (Array.isArray(handler)) {
|
3743 | for (var i = 0; i < handler.length; i++) {
|
3744 | createWatcher(vm, key, handler[i]);
|
3745 | }
|
3746 | } else {
|
3747 | createWatcher(vm, key, handler);
|
3748 | }
|
3749 | }
|
3750 | }
|
3751 |
|
3752 | function createWatcher (
|
3753 | vm,
|
3754 | expOrFn,
|
3755 | handler,
|
3756 | options
|
3757 | ) {
|
3758 | if (isPlainObject(handler)) {
|
3759 | options = handler;
|
3760 | handler = handler.handler;
|
3761 | }
|
3762 | if (typeof handler === 'string') {
|
3763 | handler = vm[handler];
|
3764 | }
|
3765 | return vm.$watch(expOrFn, handler, options)
|
3766 | }
|
3767 |
|
3768 | function stateMixin (Vue) {
|
3769 |
|
3770 |
|
3771 |
|
3772 | var dataDef = {};
|
3773 | dataDef.get = function () { return this._data };
|
3774 | var propsDef = {};
|
3775 | propsDef.get = function () { return this._props };
|
3776 | if (process.env.NODE_ENV !== 'production') {
|
3777 | dataDef.set = function () {
|
3778 | warn(
|
3779 | 'Avoid replacing instance root $data. ' +
|
3780 | 'Use nested data properties instead.',
|
3781 | this
|
3782 | );
|
3783 | };
|
3784 | propsDef.set = function () {
|
3785 | warn("$props is readonly.", this);
|
3786 | };
|
3787 | }
|
3788 | Object.defineProperty(Vue.prototype, '$data', dataDef);
|
3789 | Object.defineProperty(Vue.prototype, '$props', propsDef);
|
3790 |
|
3791 | Vue.prototype.$set = set;
|
3792 | Vue.prototype.$delete = del;
|
3793 |
|
3794 | Vue.prototype.$watch = function (
|
3795 | expOrFn,
|
3796 | cb,
|
3797 | options
|
3798 | ) {
|
3799 | var vm = this;
|
3800 | if (isPlainObject(cb)) {
|
3801 | return createWatcher(vm, expOrFn, cb, options)
|
3802 | }
|
3803 | options = options || {};
|
3804 | options.user = true;
|
3805 | var watcher = new Watcher(vm, expOrFn, cb, options);
|
3806 | if (options.immediate) {
|
3807 | try {
|
3808 | cb.call(vm, watcher.value);
|
3809 | } catch (error) {
|
3810 | handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
|
3811 | }
|
3812 | }
|
3813 | return function unwatchFn () {
|
3814 | watcher.teardown();
|
3815 | }
|
3816 | };
|
3817 | }
|
3818 |
|
3819 |
|
3820 |
|
3821 | function initProvide (vm) {
|
3822 | var provide = vm.$options.provide;
|
3823 | if (provide) {
|
3824 | vm._provided = typeof provide === 'function'
|
3825 | ? provide.call(vm)
|
3826 | : provide;
|
3827 | }
|
3828 | }
|
3829 |
|
3830 | function initInjections (vm) {
|
3831 | var result = resolveInject(vm.$options.inject, vm);
|
3832 | if (result) {
|
3833 | toggleObserving(false);
|
3834 | Object.keys(result).forEach(function (key) {
|
3835 |
|
3836 | if (process.env.NODE_ENV !== 'production') {
|
3837 | defineReactive$$1(vm, key, result[key], function () {
|
3838 | warn(
|
3839 | "Avoid mutating an injected value directly since the changes will be " +
|
3840 | "overwritten whenever the provided component re-renders. " +
|
3841 | "injection being mutated: \"" + key + "\"",
|
3842 | vm
|
3843 | );
|
3844 | });
|
3845 | } else {
|
3846 | defineReactive$$1(vm, key, result[key]);
|
3847 | }
|
3848 | });
|
3849 | toggleObserving(true);
|
3850 | }
|
3851 | }
|
3852 |
|
3853 | function resolveInject (inject, vm) {
|
3854 | if (inject) {
|
3855 |
|
3856 | var result = Object.create(null);
|
3857 | var keys = hasSymbol
|
3858 | ? Reflect.ownKeys(inject)
|
3859 | : Object.keys(inject);
|
3860 |
|
3861 | for (var i = 0; i < keys.length; i++) {
|
3862 | var key = keys[i];
|
3863 |
|
3864 | if (key === '__ob__') { continue }
|
3865 | var provideKey = inject[key].from;
|
3866 | var source = vm;
|
3867 | while (source) {
|
3868 | if (source._provided && hasOwn(source._provided, provideKey)) {
|
3869 | result[key] = source._provided[provideKey];
|
3870 | break
|
3871 | }
|
3872 | source = source.$parent;
|
3873 | }
|
3874 | if (!source) {
|
3875 | if ('default' in inject[key]) {
|
3876 | var provideDefault = inject[key].default;
|
3877 | result[key] = typeof provideDefault === 'function'
|
3878 | ? provideDefault.call(vm)
|
3879 | : provideDefault;
|
3880 | } else if (process.env.NODE_ENV !== 'production') {
|
3881 | warn(("Injection \"" + key + "\" not found"), vm);
|
3882 | }
|
3883 | }
|
3884 | }
|
3885 | return result
|
3886 | }
|
3887 | }
|
3888 |
|
3889 |
|
3890 |
|
3891 | function normalizeScopedSlots (
|
3892 | slots,
|
3893 | normalSlots
|
3894 | ) {
|
3895 | var res;
|
3896 | if (!slots) {
|
3897 | res = {};
|
3898 | } else if (slots._normalized) {
|
3899 | return slots
|
3900 | } else {
|
3901 | res = {};
|
3902 | for (var key in slots) {
|
3903 | if (slots[key] && key[0] !== '$') {
|
3904 | res[key] = normalizeScopedSlot(slots[key]);
|
3905 | }
|
3906 | }
|
3907 | }
|
3908 |
|
3909 | for (var key$1 in normalSlots) {
|
3910 | if (!(key$1 in res)) {
|
3911 | res[key$1] = proxyNormalSlot(normalSlots, key$1);
|
3912 | }
|
3913 | }
|
3914 | res._normalized = true;
|
3915 | res.$stable = slots ? slots.$stable : true;
|
3916 | return res
|
3917 | }
|
3918 |
|
3919 | function normalizeScopedSlot(fn) {
|
3920 | return function (scope) {
|
3921 | var res = fn(scope);
|
3922 | return res && typeof res === 'object' && !Array.isArray(res)
|
3923 | ? [res]
|
3924 | : normalizeChildren(res)
|
3925 | }
|
3926 | }
|
3927 |
|
3928 | function proxyNormalSlot(slots, key) {
|
3929 | return function () { return slots[key]; }
|
3930 | }
|
3931 |
|
3932 |
|
3933 |
|
3934 |
|
3935 |
|
3936 |
|
3937 | function renderList (
|
3938 | val,
|
3939 | render
|
3940 | ) {
|
3941 | var ret, i, l, keys, key;
|
3942 | if (Array.isArray(val) || typeof val === 'string') {
|
3943 | ret = new Array(val.length);
|
3944 | for (i = 0, l = val.length; i < l; i++) {
|
3945 | ret[i] = render(val[i], i);
|
3946 | }
|
3947 | } else if (typeof val === 'number') {
|
3948 | ret = new Array(val);
|
3949 | for (i = 0; i < val; i++) {
|
3950 | ret[i] = render(i + 1, i);
|
3951 | }
|
3952 | } else if (isObject(val)) {
|
3953 | if (hasSymbol && val[Symbol.iterator]) {
|
3954 | ret = [];
|
3955 | var iterator = val[Symbol.iterator]();
|
3956 | var result = iterator.next();
|
3957 | while (!result.done) {
|
3958 | ret.push(render(result.value, ret.length));
|
3959 | result = iterator.next();
|
3960 | }
|
3961 | } else {
|
3962 | keys = Object.keys(val);
|
3963 | ret = new Array(keys.length);
|
3964 | for (i = 0, l = keys.length; i < l; i++) {
|
3965 | key = keys[i];
|
3966 | ret[i] = render(val[key], key, i);
|
3967 | }
|
3968 | }
|
3969 | }
|
3970 | if (!isDef(ret)) {
|
3971 | ret = [];
|
3972 | }
|
3973 | (ret)._isVList = true;
|
3974 | return ret
|
3975 | }
|
3976 |
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 | function renderSlot (
|
3983 | name,
|
3984 | fallback,
|
3985 | props,
|
3986 | bindObject
|
3987 | ) {
|
3988 | var scopedSlotFn = this.$scopedSlots[name];
|
3989 | var nodes;
|
3990 | if (scopedSlotFn) {
|
3991 | props = props || {};
|
3992 | if (bindObject) {
|
3993 | if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
|
3994 | warn(
|
3995 | 'slot v-bind without argument expects an Object',
|
3996 | this
|
3997 | );
|
3998 | }
|
3999 | props = extend(extend({}, bindObject), props);
|
4000 | }
|
4001 | nodes = scopedSlotFn(props) || fallback;
|
4002 | } else {
|
4003 | nodes = this.$slots[name] || fallback;
|
4004 | }
|
4005 |
|
4006 | var target = props && props.slot;
|
4007 | if (target) {
|
4008 | return this.$createElement('template', { slot: target }, nodes)
|
4009 | } else {
|
4010 | return nodes
|
4011 | }
|
4012 | }
|
4013 |
|
4014 |
|
4015 |
|
4016 |
|
4017 |
|
4018 |
|
4019 | function resolveFilter (id) {
|
4020 | return resolveAsset(this.$options, 'filters', id, true) || identity
|
4021 | }
|
4022 |
|
4023 |
|
4024 |
|
4025 | function isKeyNotMatch (expect, actual) {
|
4026 | if (Array.isArray(expect)) {
|
4027 | return expect.indexOf(actual) === -1
|
4028 | } else {
|
4029 | return expect !== actual
|
4030 | }
|
4031 | }
|
4032 |
|
4033 |
|
4034 |
|
4035 |
|
4036 |
|
4037 |
|
4038 | function checkKeyCodes (
|
4039 | eventKeyCode,
|
4040 | key,
|
4041 | builtInKeyCode,
|
4042 | eventKeyName,
|
4043 | builtInKeyName
|
4044 | ) {
|
4045 | var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
|
4046 | if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
|
4047 | return isKeyNotMatch(builtInKeyName, eventKeyName)
|
4048 | } else if (mappedKeyCode) {
|
4049 | return isKeyNotMatch(mappedKeyCode, eventKeyCode)
|
4050 | } else if (eventKeyName) {
|
4051 | return hyphenate(eventKeyName) !== key
|
4052 | }
|
4053 | }
|
4054 |
|
4055 |
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 | function bindObjectProps (
|
4061 | data,
|
4062 | tag,
|
4063 | value,
|
4064 | asProp,
|
4065 | isSync
|
4066 | ) {
|
4067 | if (value) {
|
4068 | if (!isObject(value)) {
|
4069 | process.env.NODE_ENV !== 'production' && warn(
|
4070 | 'v-bind without argument expects an Object or Array value',
|
4071 | this
|
4072 | );
|
4073 | } else {
|
4074 | if (Array.isArray(value)) {
|
4075 | value = toObject(value);
|
4076 | }
|
4077 | var hash;
|
4078 | var loop = function ( key ) {
|
4079 | if (
|
4080 | key === 'class' ||
|
4081 | key === 'style' ||
|
4082 | isReservedAttribute(key)
|
4083 | ) {
|
4084 | hash = data;
|
4085 | } else {
|
4086 | var type = data.attrs && data.attrs.type;
|
4087 | hash = asProp || config.mustUseProp(tag, type, key)
|
4088 | ? data.domProps || (data.domProps = {})
|
4089 | : data.attrs || (data.attrs = {});
|
4090 | }
|
4091 | var camelizedKey = camelize(key);
|
4092 | if (!(key in hash) && !(camelizedKey in hash)) {
|
4093 | hash[key] = value[key];
|
4094 |
|
4095 | if (isSync) {
|
4096 | var on = data.on || (data.on = {});
|
4097 | on[("update:" + camelizedKey)] = function ($event) {
|
4098 | value[key] = $event;
|
4099 | };
|
4100 | }
|
4101 | }
|
4102 | };
|
4103 |
|
4104 | for (var key in value) loop( key );
|
4105 | }
|
4106 | }
|
4107 | return data
|
4108 | }
|
4109 |
|
4110 |
|
4111 |
|
4112 |
|
4113 |
|
4114 |
|
4115 | function renderStatic (
|
4116 | index,
|
4117 | isInFor
|
4118 | ) {
|
4119 | var cached = this._staticTrees || (this._staticTrees = []);
|
4120 | var tree = cached[index];
|
4121 |
|
4122 |
|
4123 | if (tree && !isInFor) {
|
4124 | return tree
|
4125 | }
|
4126 |
|
4127 | tree = cached[index] = this.$options.staticRenderFns[index].call(
|
4128 | this._renderProxy,
|
4129 | null,
|
4130 | this
|
4131 | );
|
4132 | markStatic(tree, ("__static__" + index), false);
|
4133 | return tree
|
4134 | }
|
4135 |
|
4136 |
|
4137 |
|
4138 |
|
4139 |
|
4140 | function markOnce (
|
4141 | tree,
|
4142 | index,
|
4143 | key
|
4144 | ) {
|
4145 | markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
|
4146 | return tree
|
4147 | }
|
4148 |
|
4149 | function markStatic (
|
4150 | tree,
|
4151 | key,
|
4152 | isOnce
|
4153 | ) {
|
4154 | if (Array.isArray(tree)) {
|
4155 | for (var i = 0; i < tree.length; i++) {
|
4156 | if (tree[i] && typeof tree[i] !== 'string') {
|
4157 | markStaticNode(tree[i], (key + "_" + i), isOnce);
|
4158 | }
|
4159 | }
|
4160 | } else {
|
4161 | markStaticNode(tree, key, isOnce);
|
4162 | }
|
4163 | }
|
4164 |
|
4165 | function markStaticNode (node, key, isOnce) {
|
4166 | node.isStatic = true;
|
4167 | node.key = key;
|
4168 | node.isOnce = isOnce;
|
4169 | }
|
4170 |
|
4171 |
|
4172 |
|
4173 | function bindObjectListeners (data, value) {
|
4174 | if (value) {
|
4175 | if (!isPlainObject(value)) {
|
4176 | process.env.NODE_ENV !== 'production' && warn(
|
4177 | 'v-on without argument expects an Object value',
|
4178 | this
|
4179 | );
|
4180 | } else {
|
4181 | var on = data.on = data.on ? extend({}, data.on) : {};
|
4182 | for (var key in value) {
|
4183 | var existing = on[key];
|
4184 | var ours = value[key];
|
4185 | on[key] = existing ? [].concat(existing, ours) : ours;
|
4186 | }
|
4187 | }
|
4188 | }
|
4189 | return data
|
4190 | }
|
4191 |
|
4192 |
|
4193 |
|
4194 | function bindDynamicKeys (baseObj, values) {
|
4195 | for (var i = 0; i < values.length; i += 2) {
|
4196 | var key = values[i];
|
4197 | if (typeof key === 'string' && key) {
|
4198 | baseObj[values[i]] = values[i + 1];
|
4199 | } else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
|
4200 |
|
4201 | warn(
|
4202 | ("Invalid value for dynamic directive argument (expected string or null): " + key),
|
4203 | this
|
4204 | );
|
4205 | }
|
4206 | }
|
4207 | return baseObj
|
4208 | }
|
4209 |
|
4210 |
|
4211 |
|
4212 |
|
4213 | function prependModifier (value, symbol) {
|
4214 | return typeof value === 'string' ? symbol + value : value
|
4215 | }
|
4216 |
|
4217 |
|
4218 |
|
4219 | function installRenderHelpers (target) {
|
4220 | target._o = markOnce;
|
4221 | target._n = toNumber;
|
4222 | target._s = toString;
|
4223 | target._l = renderList;
|
4224 | target._t = renderSlot;
|
4225 | target._q = looseEqual;
|
4226 | target._i = looseIndexOf;
|
4227 | target._m = renderStatic;
|
4228 | target._f = resolveFilter;
|
4229 | target._k = checkKeyCodes;
|
4230 | target._b = bindObjectProps;
|
4231 | target._v = createTextVNode;
|
4232 | target._e = createEmptyVNode;
|
4233 | target._u = resolveScopedSlots;
|
4234 | target._g = bindObjectListeners;
|
4235 | target._d = bindDynamicKeys;
|
4236 | target._p = prependModifier;
|
4237 | }
|
4238 |
|
4239 |
|
4240 |
|
4241 | function FunctionalRenderContext (
|
4242 | data,
|
4243 | props,
|
4244 | children,
|
4245 | parent,
|
4246 | Ctor
|
4247 | ) {
|
4248 | var options = Ctor.options;
|
4249 |
|
4250 |
|
4251 | var contextVm;
|
4252 | if (hasOwn(parent, '_uid')) {
|
4253 | contextVm = Object.create(parent);
|
4254 |
|
4255 | contextVm._original = parent;
|
4256 | } else {
|
4257 |
|
4258 |
|
4259 |
|
4260 | contextVm = parent;
|
4261 |
|
4262 | parent = parent._original;
|
4263 | }
|
4264 | var isCompiled = isTrue(options._compiled);
|
4265 | var needNormalization = !isCompiled;
|
4266 |
|
4267 | this.data = data;
|
4268 | this.props = props;
|
4269 | this.children = children;
|
4270 | this.parent = parent;
|
4271 | this.listeners = data.on || emptyObject;
|
4272 | this.injections = resolveInject(options.inject, parent);
|
4273 | this.slots = function () { return resolveSlots(children, parent); };
|
4274 |
|
4275 | Object.defineProperty(this, 'scopedSlots', ({
|
4276 | enumerable: true,
|
4277 | get: function get () {
|
4278 | return normalizeScopedSlots(data.scopedSlots, this.slots())
|
4279 | }
|
4280 | }));
|
4281 |
|
4282 |
|
4283 | if (isCompiled) {
|
4284 |
|
4285 | this.$options = options;
|
4286 |
|
4287 | this.$slots = this.slots();
|
4288 | this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
|
4289 | }
|
4290 |
|
4291 | if (options._scopeId) {
|
4292 | this._c = function (a, b, c, d) {
|
4293 | var vnode = createElement(contextVm, a, b, c, d, needNormalization);
|
4294 | if (vnode && !Array.isArray(vnode)) {
|
4295 | vnode.fnScopeId = options._scopeId;
|
4296 | vnode.fnContext = parent;
|
4297 | }
|
4298 | return vnode
|
4299 | };
|
4300 | } else {
|
4301 | this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
|
4302 | }
|
4303 | }
|
4304 |
|
4305 | installRenderHelpers(FunctionalRenderContext.prototype);
|
4306 |
|
4307 | function createFunctionalComponent (
|
4308 | Ctor,
|
4309 | propsData,
|
4310 | data,
|
4311 | contextVm,
|
4312 | children
|
4313 | ) {
|
4314 | var options = Ctor.options;
|
4315 | var props = {};
|
4316 | var propOptions = options.props;
|
4317 | if (isDef(propOptions)) {
|
4318 | for (var key in propOptions) {
|
4319 | props[key] = validateProp(key, propOptions, propsData || emptyObject);
|
4320 | }
|
4321 | } else {
|
4322 | if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
|
4323 | if (isDef(data.props)) { mergeProps(props, data.props); }
|
4324 | }
|
4325 |
|
4326 | var renderContext = new FunctionalRenderContext(
|
4327 | data,
|
4328 | props,
|
4329 | children,
|
4330 | contextVm,
|
4331 | Ctor
|
4332 | );
|
4333 |
|
4334 | var vnode = options.render.call(null, renderContext._c, renderContext);
|
4335 |
|
4336 | if (vnode instanceof VNode) {
|
4337 | return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
|
4338 | } else if (Array.isArray(vnode)) {
|
4339 | var vnodes = normalizeChildren(vnode) || [];
|
4340 | var res = new Array(vnodes.length);
|
4341 | for (var i = 0; i < vnodes.length; i++) {
|
4342 | res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
|
4343 | }
|
4344 | return res
|
4345 | }
|
4346 | }
|
4347 |
|
4348 | function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
|
4349 |
|
4350 |
|
4351 |
|
4352 | var clone = cloneVNode(vnode);
|
4353 | clone.fnContext = contextVm;
|
4354 | clone.fnOptions = options;
|
4355 | if (process.env.NODE_ENV !== 'production') {
|
4356 | (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
|
4357 | }
|
4358 | if (data.slot) {
|
4359 | (clone.data || (clone.data = {})).slot = data.slot;
|
4360 | }
|
4361 | return clone
|
4362 | }
|
4363 |
|
4364 | function mergeProps (to, from) {
|
4365 | for (var key in from) {
|
4366 | to[camelize(key)] = from[key];
|
4367 | }
|
4368 | }
|
4369 |
|
4370 |
|
4371 |
|
4372 |
|
4373 |
|
4374 |
|
4375 |
|
4376 |
|
4377 |
|
4378 |
|
4379 | var componentVNodeHooks = {
|
4380 | init: function init (vnode, hydrating) {
|
4381 | if (
|
4382 | vnode.componentInstance &&
|
4383 | !vnode.componentInstance._isDestroyed &&
|
4384 | vnode.data.keepAlive
|
4385 | ) {
|
4386 |
|
4387 | var mountedNode = vnode;
|
4388 | componentVNodeHooks.prepatch(mountedNode, mountedNode);
|
4389 | } else {
|
4390 | var child = vnode.componentInstance = createComponentInstanceForVnode(
|
4391 | vnode,
|
4392 | activeInstance
|
4393 | );
|
4394 | child.$mount(hydrating ? vnode.elm : undefined, hydrating);
|
4395 | }
|
4396 | },
|
4397 |
|
4398 | prepatch: function prepatch (oldVnode, vnode) {
|
4399 | var options = vnode.componentOptions;
|
4400 | var child = vnode.componentInstance = oldVnode.componentInstance;
|
4401 | updateChildComponent(
|
4402 | child,
|
4403 | options.propsData,
|
4404 | options.listeners,
|
4405 | vnode,
|
4406 | options.children
|
4407 | );
|
4408 | },
|
4409 |
|
4410 | insert: function insert (vnode) {
|
4411 | var context = vnode.context;
|
4412 | var componentInstance = vnode.componentInstance;
|
4413 | if (!componentInstance._isMounted) {
|
4414 | componentInstance._isMounted = true;
|
4415 | callHook(componentInstance, 'mounted');
|
4416 | }
|
4417 | if (vnode.data.keepAlive) {
|
4418 | if (context._isMounted) {
|
4419 |
|
4420 |
|
4421 |
|
4422 |
|
4423 |
|
4424 | queueActivatedComponent(componentInstance);
|
4425 | } else {
|
4426 | activateChildComponent(componentInstance, true );
|
4427 | }
|
4428 | }
|
4429 | },
|
4430 |
|
4431 | destroy: function destroy (vnode) {
|
4432 | var componentInstance = vnode.componentInstance;
|
4433 | if (!componentInstance._isDestroyed) {
|
4434 | if (!vnode.data.keepAlive) {
|
4435 | componentInstance.$destroy();
|
4436 | } else {
|
4437 | deactivateChildComponent(componentInstance, true );
|
4438 | }
|
4439 | }
|
4440 | }
|
4441 | };
|
4442 |
|
4443 | var hooksToMerge = Object.keys(componentVNodeHooks);
|
4444 |
|
4445 | function createComponent (
|
4446 | Ctor,
|
4447 | data,
|
4448 | context,
|
4449 | children,
|
4450 | tag
|
4451 | ) {
|
4452 | if (isUndef(Ctor)) {
|
4453 | return
|
4454 | }
|
4455 |
|
4456 | var baseCtor = context.$options._base;
|
4457 |
|
4458 |
|
4459 | if (isObject(Ctor)) {
|
4460 | Ctor = baseCtor.extend(Ctor);
|
4461 | }
|
4462 |
|
4463 |
|
4464 |
|
4465 | if (typeof Ctor !== 'function') {
|
4466 | if (process.env.NODE_ENV !== 'production') {
|
4467 | warn(("Invalid Component definition: " + (String(Ctor))), context);
|
4468 | }
|
4469 | return
|
4470 | }
|
4471 |
|
4472 |
|
4473 | var asyncFactory;
|
4474 | if (isUndef(Ctor.cid)) {
|
4475 | asyncFactory = Ctor;
|
4476 | Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
|
4477 | if (Ctor === undefined) {
|
4478 |
|
4479 |
|
4480 |
|
4481 | return createAsyncPlaceholder(
|
4482 | asyncFactory,
|
4483 | data,
|
4484 | context,
|
4485 | children,
|
4486 | tag
|
4487 | )
|
4488 | }
|
4489 | }
|
4490 |
|
4491 | data = data || {};
|
4492 |
|
4493 |
|
4494 |
|
4495 | resolveConstructorOptions(Ctor);
|
4496 |
|
4497 |
|
4498 | if (isDef(data.model)) {
|
4499 | transformModel(Ctor.options, data);
|
4500 | }
|
4501 |
|
4502 |
|
4503 | var propsData = extractPropsFromVNodeData(data, Ctor, tag);
|
4504 |
|
4505 |
|
4506 | if (isTrue(Ctor.options.functional)) {
|
4507 | return createFunctionalComponent(Ctor, propsData, data, context, children)
|
4508 | }
|
4509 |
|
4510 |
|
4511 |
|
4512 | var listeners = data.on;
|
4513 |
|
4514 |
|
4515 | data.on = data.nativeOn;
|
4516 |
|
4517 | if (isTrue(Ctor.options.abstract)) {
|
4518 |
|
4519 |
|
4520 |
|
4521 |
|
4522 | var slot = data.slot;
|
4523 | data = {};
|
4524 | if (slot) {
|
4525 | data.slot = slot;
|
4526 | }
|
4527 | }
|
4528 |
|
4529 |
|
4530 | installComponentHooks(data);
|
4531 |
|
4532 |
|
4533 | var name = Ctor.options.name || tag;
|
4534 | var vnode = new VNode(
|
4535 | ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
|
4536 | data, undefined, undefined, undefined, context,
|
4537 | { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
|
4538 | asyncFactory
|
4539 | );
|
4540 |
|
4541 | return vnode
|
4542 | }
|
4543 |
|
4544 | function createComponentInstanceForVnode (
|
4545 | vnode, // we know it's MountedComponentVNode but flow doesn't
|
4546 | parent // activeInstance in lifecycle state
|
4547 | ) {
|
4548 | var options = {
|
4549 | _isComponent: true,
|
4550 | _parentVnode: vnode,
|
4551 | parent: parent
|
4552 | };
|
4553 |
|
4554 | var inlineTemplate = vnode.data.inlineTemplate;
|
4555 | if (isDef(inlineTemplate)) {
|
4556 | options.render = inlineTemplate.render;
|
4557 | options.staticRenderFns = inlineTemplate.staticRenderFns;
|
4558 | }
|
4559 | return new vnode.componentOptions.Ctor(options)
|
4560 | }
|
4561 |
|
4562 | function installComponentHooks (data) {
|
4563 | var hooks = data.hook || (data.hook = {});
|
4564 | for (var i = 0; i < hooksToMerge.length; i++) {
|
4565 | var key = hooksToMerge[i];
|
4566 | var existing = hooks[key];
|
4567 | var toMerge = componentVNodeHooks[key];
|
4568 | if (existing !== toMerge && !(existing && existing._merged)) {
|
4569 | hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
|
4570 | }
|
4571 | }
|
4572 | }
|
4573 |
|
4574 | function mergeHook$1 (f1, f2) {
|
4575 | var merged = function (a, b) {
|
4576 |
|
4577 | f1(a, b);
|
4578 | f2(a, b);
|
4579 | };
|
4580 | merged._merged = true;
|
4581 | return merged
|
4582 | }
|
4583 |
|
4584 |
|
4585 |
|
4586 | function transformModel (options, data) {
|
4587 | var prop = (options.model && options.model.prop) || 'value';
|
4588 | var event = (options.model && options.model.event) || 'input'
|
4589 | ;(data.props || (data.props = {}))[prop] = data.model.value;
|
4590 | var on = data.on || (data.on = {});
|
4591 | var existing = on[event];
|
4592 | var callback = data.model.callback;
|
4593 | if (isDef(existing)) {
|
4594 | if (
|
4595 | Array.isArray(existing)
|
4596 | ? existing.indexOf(callback) === -1
|
4597 | : existing !== callback
|
4598 | ) {
|
4599 | on[event] = [callback].concat(existing);
|
4600 | }
|
4601 | } else {
|
4602 | on[event] = callback;
|
4603 | }
|
4604 | }
|
4605 |
|
4606 |
|
4607 |
|
4608 | var SIMPLE_NORMALIZE = 1;
|
4609 | var ALWAYS_NORMALIZE = 2;
|
4610 |
|
4611 |
|
4612 |
|
4613 | function createElement (
|
4614 | context,
|
4615 | tag,
|
4616 | data,
|
4617 | children,
|
4618 | normalizationType,
|
4619 | alwaysNormalize
|
4620 | ) {
|
4621 | if (Array.isArray(data) || isPrimitive(data)) {
|
4622 | normalizationType = children;
|
4623 | children = data;
|
4624 | data = undefined;
|
4625 | }
|
4626 | if (isTrue(alwaysNormalize)) {
|
4627 | normalizationType = ALWAYS_NORMALIZE;
|
4628 | }
|
4629 | return _createElement(context, tag, data, children, normalizationType)
|
4630 | }
|
4631 |
|
4632 | function _createElement (
|
4633 | context,
|
4634 | tag,
|
4635 | data,
|
4636 | children,
|
4637 | normalizationType
|
4638 | ) {
|
4639 | if (isDef(data) && isDef((data).__ob__)) {
|
4640 | process.env.NODE_ENV !== 'production' && warn(
|
4641 | "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
|
4642 | 'Always create fresh vnode data objects in each render!',
|
4643 | context
|
4644 | );
|
4645 | return createEmptyVNode()
|
4646 | }
|
4647 |
|
4648 | if (isDef(data) && isDef(data.is)) {
|
4649 | tag = data.is;
|
4650 | }
|
4651 | if (!tag) {
|
4652 |
|
4653 | return createEmptyVNode()
|
4654 | }
|
4655 |
|
4656 | if (process.env.NODE_ENV !== 'production' &&
|
4657 | isDef(data) && isDef(data.key) && !isPrimitive(data.key)
|
4658 | ) {
|
4659 | {
|
4660 | warn(
|
4661 | 'Avoid using non-primitive value as key, ' +
|
4662 | 'use string/number value instead.',
|
4663 | context
|
4664 | );
|
4665 | }
|
4666 | }
|
4667 |
|
4668 | if (Array.isArray(children) &&
|
4669 | typeof children[0] === 'function'
|
4670 | ) {
|
4671 | data = data || {};
|
4672 | data.scopedSlots = { default: children[0] };
|
4673 | children.length = 0;
|
4674 | }
|
4675 | if (normalizationType === ALWAYS_NORMALIZE) {
|
4676 | children = normalizeChildren(children);
|
4677 | } else if (normalizationType === SIMPLE_NORMALIZE) {
|
4678 | children = simpleNormalizeChildren(children);
|
4679 | }
|
4680 | var vnode, ns;
|
4681 | if (typeof tag === 'string') {
|
4682 | var Ctor;
|
4683 | ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
|
4684 | if (config.isReservedTag(tag)) {
|
4685 |
|
4686 | vnode = new VNode(
|
4687 | config.parsePlatformTagName(tag), data, children,
|
4688 | undefined, undefined, context
|
4689 | );
|
4690 | } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
|
4691 |
|
4692 | vnode = createComponent(Ctor, data, context, children, tag);
|
4693 | } else {
|
4694 |
|
4695 |
|
4696 |
|
4697 | vnode = new VNode(
|
4698 | tag, data, children,
|
4699 | undefined, undefined, context
|
4700 | );
|
4701 | }
|
4702 | } else {
|
4703 |
|
4704 | vnode = createComponent(tag, data, context, children);
|
4705 | }
|
4706 | if (Array.isArray(vnode)) {
|
4707 | return vnode
|
4708 | } else if (isDef(vnode)) {
|
4709 | if (isDef(ns)) { applyNS(vnode, ns); }
|
4710 | if (isDef(data)) { registerDeepBindings(data); }
|
4711 | return vnode
|
4712 | } else {
|
4713 | return createEmptyVNode()
|
4714 | }
|
4715 | }
|
4716 |
|
4717 | function applyNS (vnode, ns, force) {
|
4718 | vnode.ns = ns;
|
4719 | if (vnode.tag === 'foreignObject') {
|
4720 |
|
4721 | ns = undefined;
|
4722 | force = true;
|
4723 | }
|
4724 | if (isDef(vnode.children)) {
|
4725 | for (var i = 0, l = vnode.children.length; i < l; i++) {
|
4726 | var child = vnode.children[i];
|
4727 | if (isDef(child.tag) && (
|
4728 | isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
|
4729 | applyNS(child, ns, force);
|
4730 | }
|
4731 | }
|
4732 | }
|
4733 | }
|
4734 |
|
4735 |
|
4736 |
|
4737 |
|
4738 | function registerDeepBindings (data) {
|
4739 | if (isObject(data.style)) {
|
4740 | traverse(data.style);
|
4741 | }
|
4742 | if (isObject(data.class)) {
|
4743 | traverse(data.class);
|
4744 | }
|
4745 | }
|
4746 |
|
4747 |
|
4748 |
|
4749 | function initRender (vm) {
|
4750 | vm._vnode = null;
|
4751 | vm._staticTrees = null;
|
4752 | var options = vm.$options;
|
4753 | var parentVnode = vm.$vnode = options._parentVnode;
|
4754 | var renderContext = parentVnode && parentVnode.context;
|
4755 | vm.$slots = resolveSlots(options._renderChildren, renderContext);
|
4756 | vm.$scopedSlots = emptyObject;
|
4757 |
|
4758 |
|
4759 |
|
4760 |
|
4761 | vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
|
4762 |
|
4763 |
|
4764 | vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
|
4765 |
|
4766 |
|
4767 |
|
4768 | var parentData = parentVnode && parentVnode.data;
|
4769 |
|
4770 |
|
4771 | if (process.env.NODE_ENV !== 'production') {
|
4772 | defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
|
4773 | !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
|
4774 | }, true);
|
4775 | defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
|
4776 | !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
|
4777 | }, true);
|
4778 | } else {
|
4779 | defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
|
4780 | defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true);
|
4781 | }
|
4782 | }
|
4783 |
|
4784 | function renderMixin (Vue) {
|
4785 |
|
4786 | installRenderHelpers(Vue.prototype);
|
4787 |
|
4788 | Vue.prototype.$nextTick = function (fn) {
|
4789 | return nextTick(fn, this)
|
4790 | };
|
4791 |
|
4792 | Vue.prototype._render = function () {
|
4793 | var vm = this;
|
4794 | var ref = vm.$options;
|
4795 | var render = ref.render;
|
4796 | var _parentVnode = ref._parentVnode;
|
4797 |
|
4798 | if (_parentVnode) {
|
4799 | vm.$scopedSlots = normalizeScopedSlots(
|
4800 | _parentVnode.data.scopedSlots,
|
4801 | vm.$slots
|
4802 | );
|
4803 | }
|
4804 |
|
4805 |
|
4806 |
|
4807 | vm.$vnode = _parentVnode;
|
4808 |
|
4809 | var vnode;
|
4810 | try {
|
4811 | vnode = render.call(vm._renderProxy, vm.$createElement);
|
4812 | } catch (e) {
|
4813 | handleError(e, vm, "render");
|
4814 |
|
4815 |
|
4816 |
|
4817 | if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
|
4818 | try {
|
4819 | vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
|
4820 | } catch (e) {
|
4821 | handleError(e, vm, "renderError");
|
4822 | vnode = vm._vnode;
|
4823 | }
|
4824 | } else {
|
4825 | vnode = vm._vnode;
|
4826 | }
|
4827 | }
|
4828 |
|
4829 | if (Array.isArray(vnode) && vnode.length === 1) {
|
4830 | vnode = vnode[0];
|
4831 | }
|
4832 |
|
4833 | if (!(vnode instanceof VNode)) {
|
4834 | if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
|
4835 | warn(
|
4836 | 'Multiple root nodes returned from render function. Render function ' +
|
4837 | 'should return a single root node.',
|
4838 | vm
|
4839 | );
|
4840 | }
|
4841 | vnode = createEmptyVNode();
|
4842 | }
|
4843 |
|
4844 | vnode.parent = _parentVnode;
|
4845 | return vnode
|
4846 | };
|
4847 | }
|
4848 |
|
4849 |
|
4850 |
|
4851 | var uid$3 = 0;
|
4852 |
|
4853 | function initMixin (Vue) {
|
4854 | Vue.prototype._init = function (options) {
|
4855 | var vm = this;
|
4856 |
|
4857 | vm._uid = uid$3++;
|
4858 |
|
4859 | var startTag, endTag;
|
4860 |
|
4861 | if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
|
4862 | startTag = "vue-perf-start:" + (vm._uid);
|
4863 | endTag = "vue-perf-end:" + (vm._uid);
|
4864 | mark(startTag);
|
4865 | }
|
4866 |
|
4867 |
|
4868 | vm._isVue = true;
|
4869 |
|
4870 | if (options && options._isComponent) {
|
4871 |
|
4872 |
|
4873 |
|
4874 | initInternalComponent(vm, options);
|
4875 | } else {
|
4876 | vm.$options = mergeOptions(
|
4877 | resolveConstructorOptions(vm.constructor),
|
4878 | options || {},
|
4879 | vm
|
4880 | );
|
4881 | }
|
4882 |
|
4883 | if (process.env.NODE_ENV !== 'production') {
|
4884 | initProxy(vm);
|
4885 | } else {
|
4886 | vm._renderProxy = vm;
|
4887 | }
|
4888 |
|
4889 | vm._self = vm;
|
4890 | initLifecycle(vm);
|
4891 | initEvents(vm);
|
4892 | initRender(vm);
|
4893 | callHook(vm, 'beforeCreate');
|
4894 | initInjections(vm);
|
4895 | initState(vm);
|
4896 | initProvide(vm);
|
4897 | callHook(vm, 'created');
|
4898 |
|
4899 |
|
4900 | if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
|
4901 | vm._name = formatComponentName(vm, false);
|
4902 | mark(endTag);
|
4903 | measure(("vue " + (vm._name) + " init"), startTag, endTag);
|
4904 | }
|
4905 |
|
4906 | if (vm.$options.el) {
|
4907 | vm.$mount(vm.$options.el);
|
4908 | }
|
4909 | };
|
4910 | }
|
4911 |
|
4912 | function initInternalComponent (vm, options) {
|
4913 | var opts = vm.$options = Object.create(vm.constructor.options);
|
4914 |
|
4915 | var parentVnode = options._parentVnode;
|
4916 | opts.parent = options.parent;
|
4917 | opts._parentVnode = parentVnode;
|
4918 |
|
4919 | var vnodeComponentOptions = parentVnode.componentOptions;
|
4920 | opts.propsData = vnodeComponentOptions.propsData;
|
4921 | opts._parentListeners = vnodeComponentOptions.listeners;
|
4922 | opts._renderChildren = vnodeComponentOptions.children;
|
4923 | opts._componentTag = vnodeComponentOptions.tag;
|
4924 |
|
4925 | if (options.render) {
|
4926 | opts.render = options.render;
|
4927 | opts.staticRenderFns = options.staticRenderFns;
|
4928 | }
|
4929 | }
|
4930 |
|
4931 | function resolveConstructorOptions (Ctor) {
|
4932 | var options = Ctor.options;
|
4933 | if (Ctor.super) {
|
4934 | var superOptions = resolveConstructorOptions(Ctor.super);
|
4935 | var cachedSuperOptions = Ctor.superOptions;
|
4936 | if (superOptions !== cachedSuperOptions) {
|
4937 |
|
4938 |
|
4939 | Ctor.superOptions = superOptions;
|
4940 |
|
4941 | var modifiedOptions = resolveModifiedOptions(Ctor);
|
4942 |
|
4943 | if (modifiedOptions) {
|
4944 | extend(Ctor.extendOptions, modifiedOptions);
|
4945 | }
|
4946 | options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
|
4947 | if (options.name) {
|
4948 | options.components[options.name] = Ctor;
|
4949 | }
|
4950 | }
|
4951 | }
|
4952 | return options
|
4953 | }
|
4954 |
|
4955 | function resolveModifiedOptions (Ctor) {
|
4956 | var modified;
|
4957 | var latest = Ctor.options;
|
4958 | var sealed = Ctor.sealedOptions;
|
4959 | for (var key in latest) {
|
4960 | if (latest[key] !== sealed[key]) {
|
4961 | if (!modified) { modified = {}; }
|
4962 | modified[key] = latest[key];
|
4963 | }
|
4964 | }
|
4965 | return modified
|
4966 | }
|
4967 |
|
4968 | function Vue (options) {
|
4969 | if (process.env.NODE_ENV !== 'production' &&
|
4970 | !(this instanceof Vue)
|
4971 | ) {
|
4972 | warn('Vue is a constructor and should be called with the `new` keyword');
|
4973 | }
|
4974 | this._init(options);
|
4975 | }
|
4976 |
|
4977 | initMixin(Vue);
|
4978 | stateMixin(Vue);
|
4979 | eventsMixin(Vue);
|
4980 | lifecycleMixin(Vue);
|
4981 | renderMixin(Vue);
|
4982 |
|
4983 |
|
4984 |
|
4985 | function initUse (Vue) {
|
4986 | Vue.use = function (plugin) {
|
4987 | var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
|
4988 | if (installedPlugins.indexOf(plugin) > -1) {
|
4989 | return this
|
4990 | }
|
4991 |
|
4992 |
|
4993 | var args = toArray(arguments, 1);
|
4994 | args.unshift(this);
|
4995 | if (typeof plugin.install === 'function') {
|
4996 | plugin.install.apply(plugin, args);
|
4997 | } else if (typeof plugin === 'function') {
|
4998 | plugin.apply(null, args);
|
4999 | }
|
5000 | installedPlugins.push(plugin);
|
5001 | return this
|
5002 | };
|
5003 | }
|
5004 |
|
5005 |
|
5006 |
|
5007 | function initMixin$1 (Vue) {
|
5008 | Vue.mixin = function (mixin) {
|
5009 | this.options = mergeOptions(this.options, mixin);
|
5010 | return this
|
5011 | };
|
5012 | }
|
5013 |
|
5014 |
|
5015 |
|
5016 | function initExtend (Vue) {
|
5017 | |
5018 |
|
5019 |
|
5020 |
|
5021 |
|
5022 | Vue.cid = 0;
|
5023 | var cid = 1;
|
5024 |
|
5025 | |
5026 |
|
5027 |
|
5028 | Vue.extend = function (extendOptions) {
|
5029 | extendOptions = extendOptions || {};
|
5030 | var Super = this;
|
5031 | var SuperId = Super.cid;
|
5032 | var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
|
5033 | if (cachedCtors[SuperId]) {
|
5034 | return cachedCtors[SuperId]
|
5035 | }
|
5036 |
|
5037 | var name = extendOptions.name || Super.options.name;
|
5038 | if (process.env.NODE_ENV !== 'production' && name) {
|
5039 | validateComponentName(name);
|
5040 | }
|
5041 |
|
5042 | var Sub = function VueComponent (options) {
|
5043 | this._init(options);
|
5044 | };
|
5045 | Sub.prototype = Object.create(Super.prototype);
|
5046 | Sub.prototype.constructor = Sub;
|
5047 | Sub.cid = cid++;
|
5048 | Sub.options = mergeOptions(
|
5049 | Super.options,
|
5050 | extendOptions
|
5051 | );
|
5052 | Sub['super'] = Super;
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 | if (Sub.options.props) {
|
5058 | initProps$1(Sub);
|
5059 | }
|
5060 | if (Sub.options.computed) {
|
5061 | initComputed$1(Sub);
|
5062 | }
|
5063 |
|
5064 |
|
5065 | Sub.extend = Super.extend;
|
5066 | Sub.mixin = Super.mixin;
|
5067 | Sub.use = Super.use;
|
5068 |
|
5069 |
|
5070 |
|
5071 | ASSET_TYPES.forEach(function (type) {
|
5072 | Sub[type] = Super[type];
|
5073 | });
|
5074 |
|
5075 | if (name) {
|
5076 | Sub.options.components[name] = Sub;
|
5077 | }
|
5078 |
|
5079 |
|
5080 |
|
5081 |
|
5082 | Sub.superOptions = Super.options;
|
5083 | Sub.extendOptions = extendOptions;
|
5084 | Sub.sealedOptions = extend({}, Sub.options);
|
5085 |
|
5086 |
|
5087 | cachedCtors[SuperId] = Sub;
|
5088 | return Sub
|
5089 | };
|
5090 | }
|
5091 |
|
5092 | function initProps$1 (Comp) {
|
5093 | var props = Comp.options.props;
|
5094 | for (var key in props) {
|
5095 | proxy(Comp.prototype, "_props", key);
|
5096 | }
|
5097 | }
|
5098 |
|
5099 | function initComputed$1 (Comp) {
|
5100 | var computed = Comp.options.computed;
|
5101 | for (var key in computed) {
|
5102 | defineComputed(Comp.prototype, key, computed[key]);
|
5103 | }
|
5104 | }
|
5105 |
|
5106 |
|
5107 |
|
5108 | function initAssetRegisters (Vue) {
|
5109 | |
5110 |
|
5111 |
|
5112 | ASSET_TYPES.forEach(function (type) {
|
5113 | Vue[type] = function (
|
5114 | id,
|
5115 | definition
|
5116 | ) {
|
5117 | if (!definition) {
|
5118 | return this.options[type + 's'][id]
|
5119 | } else {
|
5120 |
|
5121 | if (process.env.NODE_ENV !== 'production' && type === 'component') {
|
5122 | validateComponentName(id);
|
5123 | }
|
5124 | if (type === 'component' && isPlainObject(definition)) {
|
5125 | definition.name = definition.name || id;
|
5126 | definition = this.options._base.extend(definition);
|
5127 | }
|
5128 | if (type === 'directive' && typeof definition === 'function') {
|
5129 | definition = { bind: definition, update: definition };
|
5130 | }
|
5131 | this.options[type + 's'][id] = definition;
|
5132 | return definition
|
5133 | }
|
5134 | };
|
5135 | });
|
5136 | }
|
5137 |
|
5138 |
|
5139 |
|
5140 |
|
5141 |
|
5142 | function getComponentName (opts) {
|
5143 | return opts && (opts.Ctor.options.name || opts.tag)
|
5144 | }
|
5145 |
|
5146 | function matches (pattern, name) {
|
5147 | if (Array.isArray(pattern)) {
|
5148 | return pattern.indexOf(name) > -1
|
5149 | } else if (typeof pattern === 'string') {
|
5150 | return pattern.split(',').indexOf(name) > -1
|
5151 | } else if (isRegExp(pattern)) {
|
5152 | return pattern.test(name)
|
5153 | }
|
5154 |
|
5155 | return false
|
5156 | }
|
5157 |
|
5158 | function pruneCache (keepAliveInstance, filter) {
|
5159 | var cache = keepAliveInstance.cache;
|
5160 | var keys = keepAliveInstance.keys;
|
5161 | var _vnode = keepAliveInstance._vnode;
|
5162 | for (var key in cache) {
|
5163 | var cachedNode = cache[key];
|
5164 | if (cachedNode) {
|
5165 | var name = getComponentName(cachedNode.componentOptions);
|
5166 | if (name && !filter(name)) {
|
5167 | pruneCacheEntry(cache, key, keys, _vnode);
|
5168 | }
|
5169 | }
|
5170 | }
|
5171 | }
|
5172 |
|
5173 | function pruneCacheEntry (
|
5174 | cache,
|
5175 | key,
|
5176 | keys,
|
5177 | current
|
5178 | ) {
|
5179 | var cached$$1 = cache[key];
|
5180 | if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
|
5181 | cached$$1.componentInstance.$destroy();
|
5182 | }
|
5183 | cache[key] = null;
|
5184 | remove(keys, key);
|
5185 | }
|
5186 |
|
5187 | var patternTypes = [String, RegExp, Array];
|
5188 |
|
5189 | var KeepAlive = {
|
5190 | name: 'keep-alive',
|
5191 | abstract: true,
|
5192 |
|
5193 | props: {
|
5194 | include: patternTypes,
|
5195 | exclude: patternTypes,
|
5196 | max: [String, Number]
|
5197 | },
|
5198 |
|
5199 | created: function created () {
|
5200 | this.cache = Object.create(null);
|
5201 | this.keys = [];
|
5202 | },
|
5203 |
|
5204 | destroyed: function destroyed () {
|
5205 | for (var key in this.cache) {
|
5206 | pruneCacheEntry(this.cache, key, this.keys);
|
5207 | }
|
5208 | },
|
5209 |
|
5210 | mounted: function mounted () {
|
5211 | var this$1 = this;
|
5212 |
|
5213 | this.$watch('include', function (val) {
|
5214 | pruneCache(this$1, function (name) { return matches(val, name); });
|
5215 | });
|
5216 | this.$watch('exclude', function (val) {
|
5217 | pruneCache(this$1, function (name) { return !matches(val, name); });
|
5218 | });
|
5219 | },
|
5220 |
|
5221 | render: function render () {
|
5222 | var slot = this.$slots.default;
|
5223 | var vnode = getFirstComponentChild(slot);
|
5224 | var componentOptions = vnode && vnode.componentOptions;
|
5225 | if (componentOptions) {
|
5226 |
|
5227 | var name = getComponentName(componentOptions);
|
5228 | var ref = this;
|
5229 | var include = ref.include;
|
5230 | var exclude = ref.exclude;
|
5231 | if (
|
5232 |
|
5233 | (include && (!name || !matches(include, name))) ||
|
5234 |
|
5235 | (exclude && name && matches(exclude, name))
|
5236 | ) {
|
5237 | return vnode
|
5238 | }
|
5239 |
|
5240 | var ref$1 = this;
|
5241 | var cache = ref$1.cache;
|
5242 | var keys = ref$1.keys;
|
5243 | var key = vnode.key == null
|
5244 |
|
5245 |
|
5246 | ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
|
5247 | : vnode.key;
|
5248 | if (cache[key]) {
|
5249 | vnode.componentInstance = cache[key].componentInstance;
|
5250 |
|
5251 | remove(keys, key);
|
5252 | keys.push(key);
|
5253 | } else {
|
5254 | cache[key] = vnode;
|
5255 | keys.push(key);
|
5256 |
|
5257 | if (this.max && keys.length > parseInt(this.max)) {
|
5258 | pruneCacheEntry(cache, keys[0], keys, this._vnode);
|
5259 | }
|
5260 | }
|
5261 |
|
5262 | vnode.data.keepAlive = true;
|
5263 | }
|
5264 | return vnode || (slot && slot[0])
|
5265 | }
|
5266 | };
|
5267 |
|
5268 | var builtInComponents = {
|
5269 | KeepAlive: KeepAlive
|
5270 | };
|
5271 |
|
5272 |
|
5273 |
|
5274 | function initGlobalAPI (Vue) {
|
5275 |
|
5276 | var configDef = {};
|
5277 | configDef.get = function () { return config; };
|
5278 | if (process.env.NODE_ENV !== 'production') {
|
5279 | configDef.set = function () {
|
5280 | warn(
|
5281 | 'Do not replace the Vue.config object, set individual fields instead.'
|
5282 | );
|
5283 | };
|
5284 | }
|
5285 | Object.defineProperty(Vue, 'config', configDef);
|
5286 |
|
5287 |
|
5288 |
|
5289 |
|
5290 | Vue.util = {
|
5291 | warn: warn,
|
5292 | extend: extend,
|
5293 | mergeOptions: mergeOptions,
|
5294 | defineReactive: defineReactive$$1
|
5295 | };
|
5296 |
|
5297 | Vue.set = set;
|
5298 | Vue.delete = del;
|
5299 | Vue.nextTick = nextTick;
|
5300 |
|
5301 | // 2.6 explicit observable API
|
5302 | Vue.observable = function (obj) {
|
5303 | observe(obj);
|
5304 | return obj
|
5305 | };
|
5306 |
|
5307 | Vue.options = Object.create(null);
|
5308 | ASSET_TYPES.forEach(function (type) {
|
5309 | Vue.options[type + 's'] = Object.create(null);
|
5310 | });
|
5311 |
|
5312 |
|
5313 |
|
5314 | Vue.options._base = Vue;
|
5315 |
|
5316 | extend(Vue.options.components, builtInComponents);
|
5317 |
|
5318 | initUse(Vue);
|
5319 | initMixin$1(Vue);
|
5320 | initExtend(Vue);
|
5321 | initAssetRegisters(Vue);
|
5322 | }
|
5323 |
|
5324 | initGlobalAPI(Vue);
|
5325 |
|
5326 | Object.defineProperty(Vue.prototype, '$isServer', {
|
5327 | get: isServerRendering
|
5328 | });
|
5329 |
|
5330 | Object.defineProperty(Vue.prototype, '$ssrContext', {
|
5331 | get: function get () {
|
5332 |
|
5333 | return this.$vnode && this.$vnode.ssrContext
|
5334 | }
|
5335 | });
|
5336 |
|
5337 |
|
5338 | Object.defineProperty(Vue, 'FunctionalRenderContext', {
|
5339 | value: FunctionalRenderContext
|
5340 | });
|
5341 |
|
5342 | Vue.version = '2.6.0';
|
5343 |
|
5344 |
|
5345 |
|
5346 |
|
5347 |
|
5348 | var isReservedAttr = makeMap('style,class');
|
5349 |
|
5350 |
|
5351 | var acceptValue = makeMap('input,textarea,option,select,progress');
|
5352 | var mustUseProp = function (tag, type, attr) {
|
5353 | return (
|
5354 | (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
|
5355 | (attr === 'selected' && tag === 'option') ||
|
5356 | (attr === 'checked' && tag === 'input') ||
|
5357 | (attr === 'muted' && tag === 'video')
|
5358 | )
|
5359 | };
|
5360 |
|
5361 | var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
|
5362 |
|
5363 | var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
|
5364 |
|
5365 | var convertEnumeratedValue = function (key, value) {
|
5366 | return isFalsyAttrValue(value) || value === 'false'
|
5367 | ? 'false'
|
5368 |
|
5369 | : key === 'contenteditable' && isValidContentEditableValue(value)
|
5370 | ? value
|
5371 | : 'true'
|
5372 | };
|
5373 |
|
5374 | var isBooleanAttr = makeMap(
|
5375 | 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
|
5376 | 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
|
5377 | 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
|
5378 | 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
|
5379 | 'required,reversed,scoped,seamless,selected,sortable,translate,' +
|
5380 | 'truespeed,typemustmatch,visible'
|
5381 | );
|
5382 |
|
5383 | var xlinkNS = 'http://www.w3.org/1999/xlink';
|
5384 |
|
5385 | var isXlink = function (name) {
|
5386 | return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
|
5387 | };
|
5388 |
|
5389 | var getXlinkProp = function (name) {
|
5390 | return isXlink(name) ? name.slice(6, name.length) : ''
|
5391 | };
|
5392 |
|
5393 | var isFalsyAttrValue = function (val) {
|
5394 | return val == null || val === false
|
5395 | };
|
5396 |
|
5397 |
|
5398 |
|
5399 | function genClassForVnode (vnode) {
|
5400 | var data = vnode.data;
|
5401 | var parentNode = vnode;
|
5402 | var childNode = vnode;
|
5403 | while (isDef(childNode.componentInstance)) {
|
5404 | childNode = childNode.componentInstance._vnode;
|
5405 | if (childNode && childNode.data) {
|
5406 | data = mergeClassData(childNode.data, data);
|
5407 | }
|
5408 | }
|
5409 | while (isDef(parentNode = parentNode.parent)) {
|
5410 | if (parentNode && parentNode.data) {
|
5411 | data = mergeClassData(data, parentNode.data);
|
5412 | }
|
5413 | }
|
5414 | return renderClass(data.staticClass, data.class)
|
5415 | }
|
5416 |
|
5417 | function mergeClassData (child, parent) {
|
5418 | return {
|
5419 | staticClass: concat(child.staticClass, parent.staticClass),
|
5420 | class: isDef(child.class)
|
5421 | ? [child.class, parent.class]
|
5422 | : parent.class
|
5423 | }
|
5424 | }
|
5425 |
|
5426 | function renderClass (
|
5427 | staticClass,
|
5428 | dynamicClass
|
5429 | ) {
|
5430 | if (isDef(staticClass) || isDef(dynamicClass)) {
|
5431 | return concat(staticClass, stringifyClass(dynamicClass))
|
5432 | }
|
5433 |
|
5434 | return ''
|
5435 | }
|
5436 |
|
5437 | function concat (a, b) {
|
5438 | return a ? b ? (a + ' ' + b) : a : (b || '')
|
5439 | }
|
5440 |
|
5441 | function stringifyClass (value) {
|
5442 | if (Array.isArray(value)) {
|
5443 | return stringifyArray(value)
|
5444 | }
|
5445 | if (isObject(value)) {
|
5446 | return stringifyObject(value)
|
5447 | }
|
5448 | if (typeof value === 'string') {
|
5449 | return value
|
5450 | }
|
5451 |
|
5452 | return ''
|
5453 | }
|
5454 |
|
5455 | function stringifyArray (value) {
|
5456 | var res = '';
|
5457 | var stringified;
|
5458 | for (var i = 0, l = value.length; i < l; i++) {
|
5459 | if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
|
5460 | if (res) { res += ' '; }
|
5461 | res += stringified;
|
5462 | }
|
5463 | }
|
5464 | return res
|
5465 | }
|
5466 |
|
5467 | function stringifyObject (value) {
|
5468 | var res = '';
|
5469 | for (var key in value) {
|
5470 | if (value[key]) {
|
5471 | if (res) { res += ' '; }
|
5472 | res += key;
|
5473 | }
|
5474 | }
|
5475 | return res
|
5476 | }
|
5477 |
|
5478 |
|
5479 |
|
5480 | var namespaceMap = {
|
5481 | svg: 'http://www.w3.org/2000/svg',
|
5482 | math: 'http://www.w3.org/1998/Math/MathML'
|
5483 | };
|
5484 |
|
5485 | var isHTMLTag = makeMap(
|
5486 | 'html,body,base,head,link,meta,style,title,' +
|
5487 | 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
|
5488 | 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
|
5489 | 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
|
5490 | 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
|
5491 | 'embed,object,param,source,canvas,script,noscript,del,ins,' +
|
5492 | 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
|
5493 | 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
|
5494 | 'output,progress,select,textarea,' +
|
5495 | 'details,dialog,menu,menuitem,summary,' +
|
5496 | 'content,element,shadow,template,blockquote,iframe,tfoot'
|
5497 | );
|
5498 |
|
5499 |
|
5500 |
|
5501 | var isSVG = makeMap(
|
5502 | 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
|
5503 | 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
|
5504 | 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
|
5505 | true
|
5506 | );
|
5507 |
|
5508 | var isPreTag = function (tag) { return tag === 'pre'; };
|
5509 |
|
5510 | var isReservedTag = function (tag) {
|
5511 | return isHTMLTag(tag) || isSVG(tag)
|
5512 | };
|
5513 |
|
5514 | function getTagNamespace (tag) {
|
5515 | if (isSVG(tag)) {
|
5516 | return 'svg'
|
5517 | }
|
5518 |
|
5519 |
|
5520 | if (tag === 'math') {
|
5521 | return 'math'
|
5522 | }
|
5523 | }
|
5524 |
|
5525 | var unknownElementCache = Object.create(null);
|
5526 | function isUnknownElement (tag) {
|
5527 |
|
5528 | if (!inBrowser) {
|
5529 | return true
|
5530 | }
|
5531 | if (isReservedTag(tag)) {
|
5532 | return false
|
5533 | }
|
5534 | tag = tag.toLowerCase();
|
5535 |
|
5536 | if (unknownElementCache[tag] != null) {
|
5537 | return unknownElementCache[tag]
|
5538 | }
|
5539 | var el = document.createElement(tag);
|
5540 | if (tag.indexOf('-') > -1) {
|
5541 |
|
5542 | return (unknownElementCache[tag] = (
|
5543 | el.constructor === window.HTMLUnknownElement ||
|
5544 | el.constructor === window.HTMLElement
|
5545 | ))
|
5546 | } else {
|
5547 | return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
|
5548 | }
|
5549 | }
|
5550 |
|
5551 | var isTextInputType = makeMap('text,number,password,search,email,tel,url');
|
5552 |
|
5553 |
|
5554 |
|
5555 |
|
5556 |
|
5557 |
|
5558 | function query (el) {
|
5559 | if (typeof el === 'string') {
|
5560 | var selected = document.querySelector(el);
|
5561 | if (!selected) {
|
5562 | process.env.NODE_ENV !== 'production' && warn(
|
5563 | 'Cannot find element: ' + el
|
5564 | );
|
5565 | return document.createElement('div')
|
5566 | }
|
5567 | return selected
|
5568 | } else {
|
5569 | return el
|
5570 | }
|
5571 | }
|
5572 |
|
5573 |
|
5574 |
|
5575 | function createElement$1 (tagName, vnode) {
|
5576 | var elm = document.createElement(tagName);
|
5577 | if (tagName !== 'select') {
|
5578 | return elm
|
5579 | }
|
5580 |
|
5581 | if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
|
5582 | elm.setAttribute('multiple', 'multiple');
|
5583 | }
|
5584 | return elm
|
5585 | }
|
5586 |
|
5587 | function createElementNS (namespace, tagName) {
|
5588 | return document.createElementNS(namespaceMap[namespace], tagName)
|
5589 | }
|
5590 |
|
5591 | function createTextNode (text) {
|
5592 | return document.createTextNode(text)
|
5593 | }
|
5594 |
|
5595 | function createComment (text) {
|
5596 | return document.createComment(text)
|
5597 | }
|
5598 |
|
5599 | function insertBefore (parentNode, newNode, referenceNode) {
|
5600 | parentNode.insertBefore(newNode, referenceNode);
|
5601 | }
|
5602 |
|
5603 | function removeChild (node, child) {
|
5604 | node.removeChild(child);
|
5605 | }
|
5606 |
|
5607 | function appendChild (node, child) {
|
5608 | node.appendChild(child);
|
5609 | }
|
5610 |
|
5611 | function parentNode (node) {
|
5612 | return node.parentNode
|
5613 | }
|
5614 |
|
5615 | function nextSibling (node) {
|
5616 | return node.nextSibling
|
5617 | }
|
5618 |
|
5619 | function tagName (node) {
|
5620 | return node.tagName
|
5621 | }
|
5622 |
|
5623 | function setTextContent (node, text) {
|
5624 | node.textContent = text;
|
5625 | }
|
5626 |
|
5627 | function setStyleScope (node, scopeId) {
|
5628 | node.setAttribute(scopeId, '');
|
5629 | }
|
5630 |
|
5631 | var nodeOps = Object.freeze({
|
5632 | createElement: createElement$1,
|
5633 | createElementNS: createElementNS,
|
5634 | createTextNode: createTextNode,
|
5635 | createComment: createComment,
|
5636 | insertBefore: insertBefore,
|
5637 | removeChild: removeChild,
|
5638 | appendChild: appendChild,
|
5639 | parentNode: parentNode,
|
5640 | nextSibling: nextSibling,
|
5641 | tagName: tagName,
|
5642 | setTextContent: setTextContent,
|
5643 | setStyleScope: setStyleScope
|
5644 | });
|
5645 |
|
5646 |
|
5647 |
|
5648 | var ref = {
|
5649 | create: function create (_, vnode) {
|
5650 | registerRef(vnode);
|
5651 | },
|
5652 | update: function update (oldVnode, vnode) {
|
5653 | if (oldVnode.data.ref !== vnode.data.ref) {
|
5654 | registerRef(oldVnode, true);
|
5655 | registerRef(vnode);
|
5656 | }
|
5657 | },
|
5658 | destroy: function destroy (vnode) {
|
5659 | registerRef(vnode, true);
|
5660 | }
|
5661 | };
|
5662 |
|
5663 | function registerRef (vnode, isRemoval) {
|
5664 | var key = vnode.data.ref;
|
5665 | if (!isDef(key)) { return }
|
5666 |
|
5667 | var vm = vnode.context;
|
5668 | var ref = vnode.componentInstance || vnode.elm;
|
5669 | var refs = vm.$refs;
|
5670 | if (isRemoval) {
|
5671 | if (Array.isArray(refs[key])) {
|
5672 | remove(refs[key], ref);
|
5673 | } else if (refs[key] === ref) {
|
5674 | refs[key] = undefined;
|
5675 | }
|
5676 | } else {
|
5677 | if (vnode.data.refInFor) {
|
5678 | if (!Array.isArray(refs[key])) {
|
5679 | refs[key] = [ref];
|
5680 | } else if (refs[key].indexOf(ref) < 0) {
|
5681 |
|
5682 | refs[key].push(ref);
|
5683 | }
|
5684 | } else {
|
5685 | refs[key] = ref;
|
5686 | }
|
5687 | }
|
5688 | }
|
5689 |
|
5690 |
|
5691 |
|
5692 |
|
5693 |
|
5694 |
|
5695 |
|
5696 |
|
5697 |
|
5698 |
|
5699 |
|
5700 |
|
5701 |
|
5702 | var emptyNode = new VNode('', {}, []);
|
5703 |
|
5704 | var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
|
5705 |
|
5706 | function sameVnode (a, b) {
|
5707 | return (
|
5708 | a.key === b.key && (
|
5709 | (
|
5710 | a.tag === b.tag &&
|
5711 | a.isComment === b.isComment &&
|
5712 | isDef(a.data) === isDef(b.data) &&
|
5713 | sameInputType(a, b)
|
5714 | ) || (
|
5715 | isTrue(a.isAsyncPlaceholder) &&
|
5716 | a.asyncFactory === b.asyncFactory &&
|
5717 | isUndef(b.asyncFactory.error)
|
5718 | )
|
5719 | )
|
5720 | )
|
5721 | }
|
5722 |
|
5723 | function sameInputType (a, b) {
|
5724 | if (a.tag !== 'input') { return true }
|
5725 | var i;
|
5726 | var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
|
5727 | var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
|
5728 | return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
|
5729 | }
|
5730 |
|
5731 | function createKeyToOldIdx (children, beginIdx, endIdx) {
|
5732 | var i, key;
|
5733 | var map = {};
|
5734 | for (i = beginIdx; i <= endIdx; ++i) {
|
5735 | key = children[i].key;
|
5736 | if (isDef(key)) { map[key] = i; }
|
5737 | }
|
5738 | return map
|
5739 | }
|
5740 |
|
5741 | function createPatchFunction (backend) {
|
5742 | var i, j;
|
5743 | var cbs = {};
|
5744 |
|
5745 | var modules = backend.modules;
|
5746 | var nodeOps = backend.nodeOps;
|
5747 |
|
5748 | for (i = 0; i < hooks.length; ++i) {
|
5749 | cbs[hooks[i]] = [];
|
5750 | for (j = 0; j < modules.length; ++j) {
|
5751 | if (isDef(modules[j][hooks[i]])) {
|
5752 | cbs[hooks[i]].push(modules[j][hooks[i]]);
|
5753 | }
|
5754 | }
|
5755 | }
|
5756 |
|
5757 | function emptyNodeAt (elm) {
|
5758 | return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
|
5759 | }
|
5760 |
|
5761 | function createRmCb (childElm, listeners) {
|
5762 | function remove$$1 () {
|
5763 | if (--remove$$1.listeners === 0) {
|
5764 | removeNode(childElm);
|
5765 | }
|
5766 | }
|
5767 | remove$$1.listeners = listeners;
|
5768 | return remove$$1
|
5769 | }
|
5770 |
|
5771 | function removeNode (el) {
|
5772 | var parent = nodeOps.parentNode(el);
|
5773 |
|
5774 | if (isDef(parent)) {
|
5775 | nodeOps.removeChild(parent, el);
|
5776 | }
|
5777 | }
|
5778 |
|
5779 | function isUnknownElement$$1 (vnode, inVPre) {
|
5780 | return (
|
5781 | !inVPre &&
|
5782 | !vnode.ns &&
|
5783 | !(
|
5784 | config.ignoredElements.length &&
|
5785 | config.ignoredElements.some(function (ignore) {
|
5786 | return isRegExp(ignore)
|
5787 | ? ignore.test(vnode.tag)
|
5788 | : ignore === vnode.tag
|
5789 | })
|
5790 | ) &&
|
5791 | config.isUnknownElement(vnode.tag)
|
5792 | )
|
5793 | }
|
5794 |
|
5795 | var creatingElmInVPre = 0;
|
5796 |
|
5797 | function createElm (
|
5798 | vnode,
|
5799 | insertedVnodeQueue,
|
5800 | parentElm,
|
5801 | refElm,
|
5802 | nested,
|
5803 | ownerArray,
|
5804 | index
|
5805 | ) {
|
5806 | if (isDef(vnode.elm) && isDef(ownerArray)) {
|
5807 |
|
5808 |
|
5809 |
|
5810 |
|
5811 |
|
5812 | vnode = ownerArray[index] = cloneVNode(vnode);
|
5813 | }
|
5814 |
|
5815 | vnode.isRootInsert = !nested;
|
5816 | if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
|
5817 | return
|
5818 | }
|
5819 |
|
5820 | var data = vnode.data;
|
5821 | var children = vnode.children;
|
5822 | var tag = vnode.tag;
|
5823 | if (isDef(tag)) {
|
5824 | if (process.env.NODE_ENV !== 'production') {
|
5825 | if (data && data.pre) {
|
5826 | creatingElmInVPre++;
|
5827 | }
|
5828 | if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
|
5829 | warn(
|
5830 | 'Unknown custom element: <' + tag + '> - did you ' +
|
5831 | 'register the component correctly? For recursive components, ' +
|
5832 | 'make sure to provide the "name" option.',
|
5833 | vnode.context
|
5834 | );
|
5835 | }
|
5836 | }
|
5837 |
|
5838 | vnode.elm = vnode.ns
|
5839 | ? nodeOps.createElementNS(vnode.ns, tag)
|
5840 | : nodeOps.createElement(tag, vnode);
|
5841 | setScope(vnode);
|
5842 |
|
5843 |
|
5844 | {
|
5845 | createChildren(vnode, children, insertedVnodeQueue);
|
5846 | if (isDef(data)) {
|
5847 | invokeCreateHooks(vnode, insertedVnodeQueue);
|
5848 | }
|
5849 | insert(parentElm, vnode.elm, refElm);
|
5850 | }
|
5851 |
|
5852 | if (process.env.NODE_ENV !== 'production' && data && data.pre) {
|
5853 | creatingElmInVPre--;
|
5854 | }
|
5855 | } else if (isTrue(vnode.isComment)) {
|
5856 | vnode.elm = nodeOps.createComment(vnode.text);
|
5857 | insert(parentElm, vnode.elm, refElm);
|
5858 | } else {
|
5859 | vnode.elm = nodeOps.createTextNode(vnode.text);
|
5860 | insert(parentElm, vnode.elm, refElm);
|
5861 | }
|
5862 | }
|
5863 |
|
5864 | function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
|
5865 | var i = vnode.data;
|
5866 | if (isDef(i)) {
|
5867 | var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
|
5868 | if (isDef(i = i.hook) && isDef(i = i.init)) {
|
5869 | i(vnode, false );
|
5870 | }
|
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 | if (isDef(vnode.componentInstance)) {
|
5876 | initComponent(vnode, insertedVnodeQueue);
|
5877 | insert(parentElm, vnode.elm, refElm);
|
5878 | if (isTrue(isReactivated)) {
|
5879 | reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
|
5880 | }
|
5881 | return true
|
5882 | }
|
5883 | }
|
5884 | }
|
5885 |
|
5886 | function initComponent (vnode, insertedVnodeQueue) {
|
5887 | if (isDef(vnode.data.pendingInsert)) {
|
5888 | insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
|
5889 | vnode.data.pendingInsert = null;
|
5890 | }
|
5891 | vnode.elm = vnode.componentInstance.$el;
|
5892 | if (isPatchable(vnode)) {
|
5893 | invokeCreateHooks(vnode, insertedVnodeQueue);
|
5894 | setScope(vnode);
|
5895 | } else {
|
5896 |
|
5897 |
|
5898 | registerRef(vnode);
|
5899 |
|
5900 | insertedVnodeQueue.push(vnode);
|
5901 | }
|
5902 | }
|
5903 |
|
5904 | function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
|
5905 | var i;
|
5906 |
|
5907 |
|
5908 |
|
5909 |
|
5910 | var innerNode = vnode;
|
5911 | while (innerNode.componentInstance) {
|
5912 | innerNode = innerNode.componentInstance._vnode;
|
5913 | if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
|
5914 | for (i = 0; i < cbs.activate.length; ++i) {
|
5915 | cbs.activate[i](emptyNode, innerNode);
|
5916 | }
|
5917 | insertedVnodeQueue.push(innerNode);
|
5918 | break
|
5919 | }
|
5920 | }
|
5921 |
|
5922 |
|
5923 | insert(parentElm, vnode.elm, refElm);
|
5924 | }
|
5925 |
|
5926 | function insert (parent, elm, ref$$1) {
|
5927 | if (isDef(parent)) {
|
5928 | if (isDef(ref$$1)) {
|
5929 | if (nodeOps.parentNode(ref$$1) === parent) {
|
5930 | nodeOps.insertBefore(parent, elm, ref$$1);
|
5931 | }
|
5932 | } else {
|
5933 | nodeOps.appendChild(parent, elm);
|
5934 | }
|
5935 | }
|
5936 | }
|
5937 |
|
5938 | function createChildren (vnode, children, insertedVnodeQueue) {
|
5939 | if (Array.isArray(children)) {
|
5940 | if (process.env.NODE_ENV !== 'production') {
|
5941 | checkDuplicateKeys(children);
|
5942 | }
|
5943 | for (var i = 0; i < children.length; ++i) {
|
5944 | createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
|
5945 | }
|
5946 | } else if (isPrimitive(vnode.text)) {
|
5947 | nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
|
5948 | }
|
5949 | }
|
5950 |
|
5951 | function isPatchable (vnode) {
|
5952 | while (vnode.componentInstance) {
|
5953 | vnode = vnode.componentInstance._vnode;
|
5954 | }
|
5955 | return isDef(vnode.tag)
|
5956 | }
|
5957 |
|
5958 | function invokeCreateHooks (vnode, insertedVnodeQueue) {
|
5959 | for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
|
5960 | cbs.create[i$1](emptyNode, vnode);
|
5961 | }
|
5962 | i = vnode.data.hook;
|
5963 | if (isDef(i)) {
|
5964 | if (isDef(i.create)) { i.create(emptyNode, vnode); }
|
5965 | if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
|
5966 | }
|
5967 | }
|
5968 |
|
5969 |
|
5970 |
|
5971 |
|
5972 | function setScope (vnode) {
|
5973 | var i;
|
5974 | if (isDef(i = vnode.fnScopeId)) {
|
5975 | nodeOps.setStyleScope(vnode.elm, i);
|
5976 | } else {
|
5977 | var ancestor = vnode;
|
5978 | while (ancestor) {
|
5979 | if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
|
5980 | nodeOps.setStyleScope(vnode.elm, i);
|
5981 | }
|
5982 | ancestor = ancestor.parent;
|
5983 | }
|
5984 | }
|
5985 |
|
5986 | if (isDef(i = activeInstance) &&
|
5987 | i !== vnode.context &&
|
5988 | i !== vnode.fnContext &&
|
5989 | isDef(i = i.$options._scopeId)
|
5990 | ) {
|
5991 | nodeOps.setStyleScope(vnode.elm, i);
|
5992 | }
|
5993 | }
|
5994 |
|
5995 | function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
|
5996 | for (; startIdx <= endIdx; ++startIdx) {
|
5997 | createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
|
5998 | }
|
5999 | }
|
6000 |
|
6001 | function invokeDestroyHook (vnode) {
|
6002 | var i, j;
|
6003 | var data = vnode.data;
|
6004 | if (isDef(data)) {
|
6005 | if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
|
6006 | for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
|
6007 | }
|
6008 | if (isDef(i = vnode.children)) {
|
6009 | for (j = 0; j < vnode.children.length; ++j) {
|
6010 | invokeDestroyHook(vnode.children[j]);
|
6011 | }
|
6012 | }
|
6013 | }
|
6014 |
|
6015 | function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
|
6016 | for (; startIdx <= endIdx; ++startIdx) {
|
6017 | var ch = vnodes[startIdx];
|
6018 | if (isDef(ch)) {
|
6019 | if (isDef(ch.tag)) {
|
6020 | removeAndInvokeRemoveHook(ch);
|
6021 | invokeDestroyHook(ch);
|
6022 | } else {
|
6023 | removeNode(ch.elm);
|
6024 | }
|
6025 | }
|
6026 | }
|
6027 | }
|
6028 |
|
6029 | function removeAndInvokeRemoveHook (vnode, rm) {
|
6030 | if (isDef(rm) || isDef(vnode.data)) {
|
6031 | var i;
|
6032 | var listeners = cbs.remove.length + 1;
|
6033 | if (isDef(rm)) {
|
6034 |
|
6035 |
|
6036 | rm.listeners += listeners;
|
6037 | } else {
|
6038 |
|
6039 | rm = createRmCb(vnode.elm, listeners);
|
6040 | }
|
6041 |
|
6042 | if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
|
6043 | removeAndInvokeRemoveHook(i, rm);
|
6044 | }
|
6045 | for (i = 0; i < cbs.remove.length; ++i) {
|
6046 | cbs.remove[i](vnode, rm);
|
6047 | }
|
6048 | if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
|
6049 | i(vnode, rm);
|
6050 | } else {
|
6051 | rm();
|
6052 | }
|
6053 | } else {
|
6054 | removeNode(vnode.elm);
|
6055 | }
|
6056 | }
|
6057 |
|
6058 | function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
|
6059 | var oldStartIdx = 0;
|
6060 | var newStartIdx = 0;
|
6061 | var oldEndIdx = oldCh.length - 1;
|
6062 | var oldStartVnode = oldCh[0];
|
6063 | var oldEndVnode = oldCh[oldEndIdx];
|
6064 | var newEndIdx = newCh.length - 1;
|
6065 | var newStartVnode = newCh[0];
|
6066 | var newEndVnode = newCh[newEndIdx];
|
6067 | var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
|
6068 |
|
6069 |
|
6070 |
|
6071 |
|
6072 | var canMove = !removeOnly;
|
6073 |
|
6074 | if (process.env.NODE_ENV !== 'production') {
|
6075 | checkDuplicateKeys(newCh);
|
6076 | }
|
6077 |
|
6078 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
6079 | if (isUndef(oldStartVnode)) {
|
6080 | oldStartVnode = oldCh[++oldStartIdx];
|
6081 | } else if (isUndef(oldEndVnode)) {
|
6082 | oldEndVnode = oldCh[--oldEndIdx];
|
6083 | } else if (sameVnode(oldStartVnode, newStartVnode)) {
|
6084 | patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
|
6085 | oldStartVnode = oldCh[++oldStartIdx];
|
6086 | newStartVnode = newCh[++newStartIdx];
|
6087 | } else if (sameVnode(oldEndVnode, newEndVnode)) {
|
6088 | patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
|
6089 | oldEndVnode = oldCh[--oldEndIdx];
|
6090 | newEndVnode = newCh[--newEndIdx];
|
6091 | } else if (sameVnode(oldStartVnode, newEndVnode)) {
|
6092 | patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
|
6093 | canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
|
6094 | oldStartVnode = oldCh[++oldStartIdx];
|
6095 | newEndVnode = newCh[--newEndIdx];
|
6096 | } else if (sameVnode(oldEndVnode, newStartVnode)) {
|
6097 | patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
|
6098 | canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
|
6099 | oldEndVnode = oldCh[--oldEndIdx];
|
6100 | newStartVnode = newCh[++newStartIdx];
|
6101 | } else {
|
6102 | if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
|
6103 | idxInOld = isDef(newStartVnode.key)
|
6104 | ? oldKeyToIdx[newStartVnode.key]
|
6105 | : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
|
6106 | if (isUndef(idxInOld)) {
|
6107 | createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
|
6108 | } else {
|
6109 | vnodeToMove = oldCh[idxInOld];
|
6110 | if (sameVnode(vnodeToMove, newStartVnode)) {
|
6111 | patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
|
6112 | oldCh[idxInOld] = undefined;
|
6113 | canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
|
6114 | } else {
|
6115 |
|
6116 | createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
|
6117 | }
|
6118 | }
|
6119 | newStartVnode = newCh[++newStartIdx];
|
6120 | }
|
6121 | }
|
6122 | if (oldStartIdx > oldEndIdx) {
|
6123 | refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
|
6124 | addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
|
6125 | } else if (newStartIdx > newEndIdx) {
|
6126 | removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
6127 | }
|
6128 | }
|
6129 |
|
6130 | function checkDuplicateKeys (children) {
|
6131 | var seenKeys = {};
|
6132 | for (var i = 0; i < children.length; i++) {
|
6133 | var vnode = children[i];
|
6134 | var key = vnode.key;
|
6135 | if (isDef(key)) {
|
6136 | if (seenKeys[key]) {
|
6137 | warn(
|
6138 | ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
|
6139 | vnode.context
|
6140 | );
|
6141 | } else {
|
6142 | seenKeys[key] = true;
|
6143 | }
|
6144 | }
|
6145 | }
|
6146 | }
|
6147 |
|
6148 | function findIdxInOld (node, oldCh, start, end) {
|
6149 | for (var i = start; i < end; i++) {
|
6150 | var c = oldCh[i];
|
6151 | if (isDef(c) && sameVnode(node, c)) { return i }
|
6152 | }
|
6153 | }
|
6154 |
|
6155 | function patchVnode (
|
6156 | oldVnode,
|
6157 | vnode,
|
6158 | insertedVnodeQueue,
|
6159 | ownerArray,
|
6160 | index,
|
6161 | removeOnly
|
6162 | ) {
|
6163 | if (oldVnode === vnode) {
|
6164 | return
|
6165 | }
|
6166 |
|
6167 | if (isDef(vnode.elm) && isDef(ownerArray)) {
|
6168 |
|
6169 | vnode = ownerArray[index] = cloneVNode(vnode);
|
6170 | }
|
6171 |
|
6172 | var elm = vnode.elm = oldVnode.elm;
|
6173 |
|
6174 | if (isTrue(oldVnode.isAsyncPlaceholder)) {
|
6175 | if (isDef(vnode.asyncFactory.resolved)) {
|
6176 | hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
|
6177 | } else {
|
6178 | vnode.isAsyncPlaceholder = true;
|
6179 | }
|
6180 | return
|
6181 | }
|
6182 |
|
6183 |
|
6184 |
|
6185 |
|
6186 |
|
6187 | if (isTrue(vnode.isStatic) &&
|
6188 | isTrue(oldVnode.isStatic) &&
|
6189 | vnode.key === oldVnode.key &&
|
6190 | (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
|
6191 | ) {
|
6192 | vnode.componentInstance = oldVnode.componentInstance;
|
6193 | return
|
6194 | }
|
6195 |
|
6196 | var i;
|
6197 | var data = vnode.data;
|
6198 | if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
|
6199 | i(oldVnode, vnode);
|
6200 | }
|
6201 |
|
6202 | var oldCh = oldVnode.children;
|
6203 | var ch = vnode.children;
|
6204 | if (isDef(data) && isPatchable(vnode)) {
|
6205 | for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
|
6206 | if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
|
6207 | }
|
6208 | if (isUndef(vnode.text)) {
|
6209 | if (isDef(oldCh) && isDef(ch)) {
|
6210 | if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
|
6211 | } else if (isDef(ch)) {
|
6212 | if (process.env.NODE_ENV !== 'production') {
|
6213 | checkDuplicateKeys(ch);
|
6214 | }
|
6215 | if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
|
6216 | addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
|
6217 | } else if (isDef(oldCh)) {
|
6218 | removeVnodes(elm, oldCh, 0, oldCh.length - 1);
|
6219 | } else if (isDef(oldVnode.text)) {
|
6220 | nodeOps.setTextContent(elm, '');
|
6221 | }
|
6222 | } else if (oldVnode.text !== vnode.text) {
|
6223 | nodeOps.setTextContent(elm, vnode.text);
|
6224 | }
|
6225 | if (isDef(data)) {
|
6226 | if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
|
6227 | }
|
6228 | }
|
6229 |
|
6230 | function invokeInsertHook (vnode, queue, initial) {
|
6231 |
|
6232 |
|
6233 | if (isTrue(initial) && isDef(vnode.parent)) {
|
6234 | vnode.parent.data.pendingInsert = queue;
|
6235 | } else {
|
6236 | for (var i = 0; i < queue.length; ++i) {
|
6237 | queue[i].data.hook.insert(queue[i]);
|
6238 | }
|
6239 | }
|
6240 | }
|
6241 |
|
6242 | var hydrationBailed = false;
|
6243 |
|
6244 |
|
6245 |
|
6246 |
|
6247 | var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
|
6248 |
|
6249 |
|
6250 | function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
|
6251 | var i;
|
6252 | var tag = vnode.tag;
|
6253 | var data = vnode.data;
|
6254 | var children = vnode.children;
|
6255 | inVPre = inVPre || (data && data.pre);
|
6256 | vnode.elm = elm;
|
6257 |
|
6258 | if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
|
6259 | vnode.isAsyncPlaceholder = true;
|
6260 | return true
|
6261 | }
|
6262 |
|
6263 | if (process.env.NODE_ENV !== 'production') {
|
6264 | if (!assertNodeMatch(elm, vnode, inVPre)) {
|
6265 | return false
|
6266 | }
|
6267 | }
|
6268 | if (isDef(data)) {
|
6269 | if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true ); }
|
6270 | if (isDef(i = vnode.componentInstance)) {
|
6271 |
|
6272 | initComponent(vnode, insertedVnodeQueue);
|
6273 | return true
|
6274 | }
|
6275 | }
|
6276 | if (isDef(tag)) {
|
6277 | if (isDef(children)) {
|
6278 |
|
6279 | if (!elm.hasChildNodes()) {
|
6280 | createChildren(vnode, children, insertedVnodeQueue);
|
6281 | } else {
|
6282 |
|
6283 | if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
|
6284 | if (i !== elm.innerHTML) {
|
6285 |
|
6286 | if (process.env.NODE_ENV !== 'production' &&
|
6287 | typeof console !== 'undefined' &&
|
6288 | !hydrationBailed
|
6289 | ) {
|
6290 | hydrationBailed = true;
|
6291 | console.warn('Parent: ', elm);
|
6292 | console.warn('server innerHTML: ', i);
|
6293 | console.warn('client innerHTML: ', elm.innerHTML);
|
6294 | }
|
6295 | return false
|
6296 | }
|
6297 | } else {
|
6298 |
|
6299 | var childrenMatch = true;
|
6300 | var childNode = elm.firstChild;
|
6301 | for (var i$1 = 0; i$1 < children.length; i$1++) {
|
6302 | if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
|
6303 | childrenMatch = false;
|
6304 | break
|
6305 | }
|
6306 | childNode = childNode.nextSibling;
|
6307 | }
|
6308 |
|
6309 |
|
6310 | if (!childrenMatch || childNode) {
|
6311 |
|
6312 | if (process.env.NODE_ENV !== 'production' &&
|
6313 | typeof console !== 'undefined' &&
|
6314 | !hydrationBailed
|
6315 | ) {
|
6316 | hydrationBailed = true;
|
6317 | console.warn('Parent: ', elm);
|
6318 | console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
|
6319 | }
|
6320 | return false
|
6321 | }
|
6322 | }
|
6323 | }
|
6324 | }
|
6325 | if (isDef(data)) {
|
6326 | var fullInvoke = false;
|
6327 | for (var key in data) {
|
6328 | if (!isRenderedModule(key)) {
|
6329 | fullInvoke = true;
|
6330 | invokeCreateHooks(vnode, insertedVnodeQueue);
|
6331 | break
|
6332 | }
|
6333 | }
|
6334 | if (!fullInvoke && data['class']) {
|
6335 |
|
6336 | traverse(data['class']);
|
6337 | }
|
6338 | }
|
6339 | } else if (elm.data !== vnode.text) {
|
6340 | elm.data = vnode.text;
|
6341 | }
|
6342 | return true
|
6343 | }
|
6344 |
|
6345 | function assertNodeMatch (node, vnode, inVPre) {
|
6346 | if (isDef(vnode.tag)) {
|
6347 | return vnode.tag.indexOf('vue-component') === 0 || (
|
6348 | !isUnknownElement$$1(vnode, inVPre) &&
|
6349 | vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
|
6350 | )
|
6351 | } else {
|
6352 | return node.nodeType === (vnode.isComment ? 8 : 3)
|
6353 | }
|
6354 | }
|
6355 |
|
6356 | return function patch (oldVnode, vnode, hydrating, removeOnly) {
|
6357 | if (isUndef(vnode)) {
|
6358 | if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
|
6359 | return
|
6360 | }
|
6361 |
|
6362 | var isInitialPatch = false;
|
6363 | var insertedVnodeQueue = [];
|
6364 |
|
6365 | if (isUndef(oldVnode)) {
|
6366 |
|
6367 | isInitialPatch = true;
|
6368 | createElm(vnode, insertedVnodeQueue);
|
6369 | } else {
|
6370 | var isRealElement = isDef(oldVnode.nodeType);
|
6371 | if (!isRealElement && sameVnode(oldVnode, vnode)) {
|
6372 |
|
6373 | patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
|
6374 | } else {
|
6375 | if (isRealElement) {
|
6376 |
|
6377 |
|
6378 |
|
6379 | if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
|
6380 | oldVnode.removeAttribute(SSR_ATTR);
|
6381 | hydrating = true;
|
6382 | }
|
6383 | if (isTrue(hydrating)) {
|
6384 | if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
|
6385 | invokeInsertHook(vnode, insertedVnodeQueue, true);
|
6386 | return oldVnode
|
6387 | } else if (process.env.NODE_ENV !== 'production') {
|
6388 | warn(
|
6389 | 'The client-side rendered virtual DOM tree is not matching ' +
|
6390 | 'server-rendered content. This is likely caused by incorrect ' +
|
6391 | 'HTML markup, for example nesting block-level elements inside ' +
|
6392 | '<p>, or missing <tbody>. Bailing hydration and performing ' +
|
6393 | 'full client-side render.'
|
6394 | );
|
6395 | }
|
6396 | }
|
6397 |
|
6398 |
|
6399 | oldVnode = emptyNodeAt(oldVnode);
|
6400 | }
|
6401 |
|
6402 |
|
6403 | var oldElm = oldVnode.elm;
|
6404 | var parentElm = nodeOps.parentNode(oldElm);
|
6405 |
|
6406 |
|
6407 | createElm(
|
6408 | vnode,
|
6409 | insertedVnodeQueue,
|
6410 |
|
6411 |
|
6412 |
|
6413 | oldElm._leaveCb ? null : parentElm,
|
6414 | nodeOps.nextSibling(oldElm)
|
6415 | );
|
6416 |
|
6417 |
|
6418 | if (isDef(vnode.parent)) {
|
6419 | var ancestor = vnode.parent;
|
6420 | var patchable = isPatchable(vnode);
|
6421 | while (ancestor) {
|
6422 | for (var i = 0; i < cbs.destroy.length; ++i) {
|
6423 | cbs.destroy[i](ancestor);
|
6424 | }
|
6425 | ancestor.elm = vnode.elm;
|
6426 | if (patchable) {
|
6427 | for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
|
6428 | cbs.create[i$1](emptyNode, ancestor);
|
6429 | }
|
6430 |
|
6431 |
|
6432 |
|
6433 | var insert = ancestor.data.hook.insert;
|
6434 | if (insert.merged) {
|
6435 |
|
6436 | for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
|
6437 | insert.fns[i$2]();
|
6438 | }
|
6439 | }
|
6440 | } else {
|
6441 | registerRef(ancestor);
|
6442 | }
|
6443 | ancestor = ancestor.parent;
|
6444 | }
|
6445 | }
|
6446 |
|
6447 |
|
6448 | if (isDef(parentElm)) {
|
6449 | removeVnodes(parentElm, [oldVnode], 0, 0);
|
6450 | } else if (isDef(oldVnode.tag)) {
|
6451 | invokeDestroyHook(oldVnode);
|
6452 | }
|
6453 | }
|
6454 | }
|
6455 |
|
6456 | invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
|
6457 | return vnode.elm
|
6458 | }
|
6459 | }
|
6460 |
|
6461 |
|
6462 |
|
6463 | var directives = {
|
6464 | create: updateDirectives,
|
6465 | update: updateDirectives,
|
6466 | destroy: function unbindDirectives (vnode) {
|
6467 | updateDirectives(vnode, emptyNode);
|
6468 | }
|
6469 | };
|
6470 |
|
6471 | function updateDirectives (oldVnode, vnode) {
|
6472 | if (oldVnode.data.directives || vnode.data.directives) {
|
6473 | _update(oldVnode, vnode);
|
6474 | }
|
6475 | }
|
6476 |
|
6477 | function _update (oldVnode, vnode) {
|
6478 | var isCreate = oldVnode === emptyNode;
|
6479 | var isDestroy = vnode === emptyNode;
|
6480 | var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
|
6481 | var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
|
6482 |
|
6483 | var dirsWithInsert = [];
|
6484 | var dirsWithPostpatch = [];
|
6485 |
|
6486 | var key, oldDir, dir;
|
6487 | for (key in newDirs) {
|
6488 | oldDir = oldDirs[key];
|
6489 | dir = newDirs[key];
|
6490 | if (!oldDir) {
|
6491 |
|
6492 | callHook$1(dir, 'bind', vnode, oldVnode);
|
6493 | if (dir.def && dir.def.inserted) {
|
6494 | dirsWithInsert.push(dir);
|
6495 | }
|
6496 | } else {
|
6497 |
|
6498 | dir.oldValue = oldDir.value;
|
6499 | dir.oldArg = oldDir.arg;
|
6500 | callHook$1(dir, 'update', vnode, oldVnode);
|
6501 | if (dir.def && dir.def.componentUpdated) {
|
6502 | dirsWithPostpatch.push(dir);
|
6503 | }
|
6504 | }
|
6505 | }
|
6506 |
|
6507 | if (dirsWithInsert.length) {
|
6508 | var callInsert = function () {
|
6509 | for (var i = 0; i < dirsWithInsert.length; i++) {
|
6510 | callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
|
6511 | }
|
6512 | };
|
6513 | if (isCreate) {
|
6514 | mergeVNodeHook(vnode, 'insert', callInsert);
|
6515 | } else {
|
6516 | callInsert();
|
6517 | }
|
6518 | }
|
6519 |
|
6520 | if (dirsWithPostpatch.length) {
|
6521 | mergeVNodeHook(vnode, 'postpatch', function () {
|
6522 | for (var i = 0; i < dirsWithPostpatch.length; i++) {
|
6523 | callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
|
6524 | }
|
6525 | });
|
6526 | }
|
6527 |
|
6528 | if (!isCreate) {
|
6529 | for (key in oldDirs) {
|
6530 | if (!newDirs[key]) {
|
6531 |
|
6532 | callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
|
6533 | }
|
6534 | }
|
6535 | }
|
6536 | }
|
6537 |
|
6538 | var emptyModifiers = Object.create(null);
|
6539 |
|
6540 | function normalizeDirectives$1 (
|
6541 | dirs,
|
6542 | vm
|
6543 | ) {
|
6544 | var res = Object.create(null);
|
6545 | if (!dirs) {
|
6546 |
|
6547 | return res
|
6548 | }
|
6549 | var i, dir;
|
6550 | for (i = 0; i < dirs.length; i++) {
|
6551 | dir = dirs[i];
|
6552 | if (!dir.modifiers) {
|
6553 |
|
6554 | dir.modifiers = emptyModifiers;
|
6555 | }
|
6556 | res[getRawDirName(dir)] = dir;
|
6557 | dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
|
6558 | }
|
6559 |
|
6560 | return res
|
6561 | }
|
6562 |
|
6563 | function getRawDirName (dir) {
|
6564 | return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
|
6565 | }
|
6566 |
|
6567 | function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
|
6568 | var fn = dir.def && dir.def[hook];
|
6569 | if (fn) {
|
6570 | try {
|
6571 | fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
|
6572 | } catch (e) {
|
6573 | handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
|
6574 | }
|
6575 | }
|
6576 | }
|
6577 |
|
6578 | var baseModules = [
|
6579 | ref,
|
6580 | directives
|
6581 | ];
|
6582 |
|
6583 |
|
6584 |
|
6585 | function updateAttrs (oldVnode, vnode) {
|
6586 | var opts = vnode.componentOptions;
|
6587 | if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
|
6588 | return
|
6589 | }
|
6590 | if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
|
6591 | return
|
6592 | }
|
6593 | var key, cur, old;
|
6594 | var elm = vnode.elm;
|
6595 | var oldAttrs = oldVnode.data.attrs || {};
|
6596 | var attrs = vnode.data.attrs || {};
|
6597 |
|
6598 | if (isDef(attrs.__ob__)) {
|
6599 | attrs = vnode.data.attrs = extend({}, attrs);
|
6600 | }
|
6601 |
|
6602 | for (key in attrs) {
|
6603 | cur = attrs[key];
|
6604 | old = oldAttrs[key];
|
6605 | if (old !== cur) {
|
6606 | setAttr(elm, key, cur);
|
6607 | }
|
6608 | }
|
6609 |
|
6610 |
|
6611 |
|
6612 | if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
|
6613 | setAttr(elm, 'value', attrs.value);
|
6614 | }
|
6615 | for (key in oldAttrs) {
|
6616 | if (isUndef(attrs[key])) {
|
6617 | if (isXlink(key)) {
|
6618 | elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
|
6619 | } else if (!isEnumeratedAttr(key)) {
|
6620 | elm.removeAttribute(key);
|
6621 | }
|
6622 | }
|
6623 | }
|
6624 | }
|
6625 |
|
6626 | function setAttr (el, key, value) {
|
6627 | if (el.tagName.indexOf('-') > -1) {
|
6628 | baseSetAttr(el, key, value);
|
6629 | } else if (isBooleanAttr(key)) {
|
6630 |
|
6631 |
|
6632 | if (isFalsyAttrValue(value)) {
|
6633 | el.removeAttribute(key);
|
6634 | } else {
|
6635 |
|
6636 |
|
6637 | value = key === 'allowfullscreen' && el.tagName === 'EMBED'
|
6638 | ? 'true'
|
6639 | : key;
|
6640 | el.setAttribute(key, value);
|
6641 | }
|
6642 | } else if (isEnumeratedAttr(key)) {
|
6643 | el.setAttribute(key, convertEnumeratedValue(key, value));
|
6644 | } else if (isXlink(key)) {
|
6645 | if (isFalsyAttrValue(value)) {
|
6646 | el.removeAttributeNS(xlinkNS, getXlinkProp(key));
|
6647 | } else {
|
6648 | el.setAttributeNS(xlinkNS, key, value);
|
6649 | }
|
6650 | } else {
|
6651 | baseSetAttr(el, key, value);
|
6652 | }
|
6653 | }
|
6654 |
|
6655 | function baseSetAttr (el, key, value) {
|
6656 | if (isFalsyAttrValue(value)) {
|
6657 | el.removeAttribute(key);
|
6658 | } else {
|
6659 |
|
6660 |
|
6661 |
|
6662 |
|
6663 | if (
|
6664 | isIE && !isIE9 &&
|
6665 | (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') &&
|
6666 | key === 'placeholder' && !el.__ieph
|
6667 | ) {
|
6668 | var blocker = function (e) {
|
6669 | e.stopImmediatePropagation();
|
6670 | el.removeEventListener('input', blocker);
|
6671 | };
|
6672 | el.addEventListener('input', blocker);
|
6673 |
|
6674 | el.__ieph = true;
|
6675 | }
|
6676 | el.setAttribute(key, value);
|
6677 | }
|
6678 | }
|
6679 |
|
6680 | var attrs = {
|
6681 | create: updateAttrs,
|
6682 | update: updateAttrs
|
6683 | };
|
6684 |
|
6685 |
|
6686 |
|
6687 | function updateClass (oldVnode, vnode) {
|
6688 | var el = vnode.elm;
|
6689 | var data = vnode.data;
|
6690 | var oldData = oldVnode.data;
|
6691 | if (
|
6692 | isUndef(data.staticClass) &&
|
6693 | isUndef(data.class) && (
|
6694 | isUndef(oldData) || (
|
6695 | isUndef(oldData.staticClass) &&
|
6696 | isUndef(oldData.class)
|
6697 | )
|
6698 | )
|
6699 | ) {
|
6700 | return
|
6701 | }
|
6702 |
|
6703 | var cls = genClassForVnode(vnode);
|
6704 |
|
6705 |
|
6706 | var transitionClass = el._transitionClasses;
|
6707 | if (isDef(transitionClass)) {
|
6708 | cls = concat(cls, stringifyClass(transitionClass));
|
6709 | }
|
6710 |
|
6711 |
|
6712 | if (cls !== el._prevClass) {
|
6713 | el.setAttribute('class', cls);
|
6714 | el._prevClass = cls;
|
6715 | }
|
6716 | }
|
6717 |
|
6718 | var klass = {
|
6719 | create: updateClass,
|
6720 | update: updateClass
|
6721 | };
|
6722 |
|
6723 |
|
6724 |
|
6725 | var validDivisionCharRE = /[\w).+\-_$\]]/;
|
6726 |
|
6727 | function parseFilters (exp) {
|
6728 | var inSingle = false;
|
6729 | var inDouble = false;
|
6730 | var inTemplateString = false;
|
6731 | var inRegex = false;
|
6732 | var curly = 0;
|
6733 | var square = 0;
|
6734 | var paren = 0;
|
6735 | var lastFilterIndex = 0;
|
6736 | var c, prev, i, expression, filters;
|
6737 |
|
6738 | for (i = 0; i < exp.length; i++) {
|
6739 | prev = c;
|
6740 | c = exp.charCodeAt(i);
|
6741 | if (inSingle) {
|
6742 | if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
|
6743 | } else if (inDouble) {
|
6744 | if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
|
6745 | } else if (inTemplateString) {
|
6746 | if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
|
6747 | } else if (inRegex) {
|
6748 | if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
|
6749 | } else if (
|
6750 | c === 0x7C &&
|
6751 | exp.charCodeAt(i + 1) !== 0x7C &&
|
6752 | exp.charCodeAt(i - 1) !== 0x7C &&
|
6753 | !curly && !square && !paren
|
6754 | ) {
|
6755 | if (expression === undefined) {
|
6756 |
|
6757 | lastFilterIndex = i + 1;
|
6758 | expression = exp.slice(0, i).trim();
|
6759 | } else {
|
6760 | pushFilter();
|
6761 | }
|
6762 | } else {
|
6763 | switch (c) {
|
6764 | case 0x22: inDouble = true; break
|
6765 | case 0x27: inSingle = true; break
|
6766 | case 0x60: inTemplateString = true; break
|
6767 | case 0x28: paren++; break
|
6768 | case 0x29: paren--; break
|
6769 | case 0x5B: square++; break
|
6770 | case 0x5D: square--; break
|
6771 | case 0x7B: curly++; break
|
6772 | case 0x7D: curly--; break
|
6773 | }
|
6774 | if (c === 0x2f) {
|
6775 | var j = i - 1;
|
6776 | var p = (void 0);
|
6777 |
|
6778 | for (; j >= 0; j--) {
|
6779 | p = exp.charAt(j);
|
6780 | if (p !== ' ') { break }
|
6781 | }
|
6782 | if (!p || !validDivisionCharRE.test(p)) {
|
6783 | inRegex = true;
|
6784 | }
|
6785 | }
|
6786 | }
|
6787 | }
|
6788 |
|
6789 | if (expression === undefined) {
|
6790 | expression = exp.slice(0, i).trim();
|
6791 | } else if (lastFilterIndex !== 0) {
|
6792 | pushFilter();
|
6793 | }
|
6794 |
|
6795 | function pushFilter () {
|
6796 | (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
|
6797 | lastFilterIndex = i + 1;
|
6798 | }
|
6799 |
|
6800 | if (filters) {
|
6801 | for (i = 0; i < filters.length; i++) {
|
6802 | expression = wrapFilter(expression, filters[i]);
|
6803 | }
|
6804 | }
|
6805 |
|
6806 | return expression
|
6807 | }
|
6808 |
|
6809 | function wrapFilter (exp, filter) {
|
6810 | var i = filter.indexOf('(');
|
6811 | if (i < 0) {
|
6812 |
|
6813 | return ("_f(\"" + filter + "\")(" + exp + ")")
|
6814 | } else {
|
6815 | var name = filter.slice(0, i);
|
6816 | var args = filter.slice(i + 1);
|
6817 | return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
|
6818 | }
|
6819 | }
|
6820 |
|
6821 |
|
6822 |
|
6823 |
|
6824 |
|
6825 |
|
6826 | function baseWarn (msg, range) {
|
6827 | console.error(("[Vue compiler]: " + msg));
|
6828 | }
|
6829 |
|
6830 |
|
6831 | function pluckModuleFunction (
|
6832 | modules,
|
6833 | key
|
6834 | ) {
|
6835 | return modules
|
6836 | ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
|
6837 | : []
|
6838 | }
|
6839 |
|
6840 | function addProp (el, name, value, range, dynamic) {
|
6841 | (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
|
6842 | el.plain = false;
|
6843 | }
|
6844 |
|
6845 | function addAttr (el, name, value, range, dynamic) {
|
6846 | var attrs = dynamic
|
6847 | ? (el.dynamicAttrs || (el.dynamicAttrs = []))
|
6848 | : (el.attrs || (el.attrs = []));
|
6849 | attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
|
6850 | el.plain = false;
|
6851 | }
|
6852 |
|
6853 |
|
6854 | function addRawAttr (el, name, value, range) {
|
6855 | el.attrsMap[name] = value;
|
6856 | el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
|
6857 | }
|
6858 |
|
6859 | function addDirective (
|
6860 | el,
|
6861 | name,
|
6862 | rawName,
|
6863 | value,
|
6864 | arg,
|
6865 | isDynamicArg,
|
6866 | modifiers,
|
6867 | range
|
6868 | ) {
|
6869 | (el.directives || (el.directives = [])).push(rangeSetItem({
|
6870 | name: name,
|
6871 | rawName: rawName,
|
6872 | value: value,
|
6873 | arg: arg,
|
6874 | isDynamicArg: isDynamicArg,
|
6875 | modifiers: modifiers
|
6876 | }, range));
|
6877 | el.plain = false;
|
6878 | }
|
6879 |
|
6880 | function prependModifierMarker (symbol, name, dynamic) {
|
6881 | return dynamic
|
6882 | ? ("_p(" + name + ",\"" + symbol + "\")")
|
6883 | : symbol + name
|
6884 | }
|
6885 |
|
6886 | function addHandler (
|
6887 | el,
|
6888 | name,
|
6889 | value,
|
6890 | modifiers,
|
6891 | important,
|
6892 | warn,
|
6893 | range,
|
6894 | dynamic
|
6895 | ) {
|
6896 | modifiers = modifiers || emptyObject;
|
6897 |
|
6898 |
|
6899 | if (
|
6900 | process.env.NODE_ENV !== 'production' && warn &&
|
6901 | modifiers.prevent && modifiers.passive
|
6902 | ) {
|
6903 | warn(
|
6904 | 'passive and prevent can\'t be used together. ' +
|
6905 | 'Passive handler can\'t prevent default event.',
|
6906 | range
|
6907 | );
|
6908 | }
|
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 | if (modifiers.right) {
|
6914 | if (dynamic) {
|
6915 | name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
|
6916 | } else if (name === 'click') {
|
6917 | name = 'contextmenu';
|
6918 | delete modifiers.right;
|
6919 | }
|
6920 | } else if (modifiers.middle) {
|
6921 | if (dynamic) {
|
6922 | name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
|
6923 | } else if (name === 'click') {
|
6924 | name = 'mouseup';
|
6925 | }
|
6926 | }
|
6927 |
|
6928 |
|
6929 | if (modifiers.capture) {
|
6930 | delete modifiers.capture;
|
6931 | name = prependModifierMarker('!', name, dynamic);
|
6932 | }
|
6933 | if (modifiers.once) {
|
6934 | delete modifiers.once;
|
6935 | name = prependModifierMarker('~', name, dynamic);
|
6936 | }
|
6937 |
|
6938 | if (modifiers.passive) {
|
6939 | delete modifiers.passive;
|
6940 | name = prependModifierMarker('&', name, dynamic);
|
6941 | }
|
6942 |
|
6943 | var events;
|
6944 | if (modifiers.native) {
|
6945 | delete modifiers.native;
|
6946 | events = el.nativeEvents || (el.nativeEvents = {});
|
6947 | } else {
|
6948 | events = el.events || (el.events = {});
|
6949 | }
|
6950 |
|
6951 | var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
|
6952 | if (modifiers !== emptyObject) {
|
6953 | newHandler.modifiers = modifiers;
|
6954 | }
|
6955 |
|
6956 | var handlers = events[name];
|
6957 |
|
6958 | if (Array.isArray(handlers)) {
|
6959 | important ? handlers.unshift(newHandler) : handlers.push(newHandler);
|
6960 | } else if (handlers) {
|
6961 | events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
|
6962 | } else {
|
6963 | events[name] = newHandler;
|
6964 | }
|
6965 |
|
6966 | el.plain = false;
|
6967 | }
|
6968 |
|
6969 | function getRawBindingAttr (
|
6970 | el,
|
6971 | name
|
6972 | ) {
|
6973 | return el.rawAttrsMap[':' + name] ||
|
6974 | el.rawAttrsMap['v-bind:' + name] ||
|
6975 | el.rawAttrsMap[name]
|
6976 | }
|
6977 |
|
6978 | function getBindingAttr (
|
6979 | el,
|
6980 | name,
|
6981 | getStatic
|
6982 | ) {
|
6983 | var dynamicValue =
|
6984 | getAndRemoveAttr(el, ':' + name) ||
|
6985 | getAndRemoveAttr(el, 'v-bind:' + name);
|
6986 | if (dynamicValue != null) {
|
6987 | return parseFilters(dynamicValue)
|
6988 | } else if (getStatic !== false) {
|
6989 | var staticValue = getAndRemoveAttr(el, name);
|
6990 | if (staticValue != null) {
|
6991 | return JSON.stringify(staticValue)
|
6992 | }
|
6993 | }
|
6994 | }
|
6995 |
|
6996 |
|
6997 |
|
6998 |
|
6999 |
|
7000 | function getAndRemoveAttr (
|
7001 | el,
|
7002 | name,
|
7003 | removeFromMap
|
7004 | ) {
|
7005 | var val;
|
7006 | if ((val = el.attrsMap[name]) != null) {
|
7007 | var list = el.attrsList;
|
7008 | for (var i = 0, l = list.length; i < l; i++) {
|
7009 | if (list[i].name === name) {
|
7010 | list.splice(i, 1);
|
7011 | break
|
7012 | }
|
7013 | }
|
7014 | }
|
7015 | if (removeFromMap) {
|
7016 | delete el.attrsMap[name];
|
7017 | }
|
7018 | return val
|
7019 | }
|
7020 |
|
7021 | function getAndRemoveAttrByRegex (
|
7022 | el,
|
7023 | name
|
7024 | ) {
|
7025 | var list = el.attrsList;
|
7026 | for (var i = 0, l = list.length; i < l; i++) {
|
7027 | var attr = list[i];
|
7028 | if (name.test(attr.name)) {
|
7029 | list.splice(i, 1);
|
7030 | return attr
|
7031 | }
|
7032 | }
|
7033 | }
|
7034 |
|
7035 | function rangeSetItem (
|
7036 | item,
|
7037 | range
|
7038 | ) {
|
7039 | if (range) {
|
7040 | if (range.start != null) {
|
7041 | item.start = range.start;
|
7042 | }
|
7043 | if (range.end != null) {
|
7044 | item.end = range.end;
|
7045 | }
|
7046 | }
|
7047 | return item
|
7048 | }
|
7049 |
|
7050 |
|
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 | function genComponentModel (
|
7056 | el,
|
7057 | value,
|
7058 | modifiers
|
7059 | ) {
|
7060 | var ref = modifiers || {};
|
7061 | var number = ref.number;
|
7062 | var trim = ref.trim;
|
7063 |
|
7064 | var baseValueExpression = '$$v';
|
7065 | var valueExpression = baseValueExpression;
|
7066 | if (trim) {
|
7067 | valueExpression =
|
7068 | "(typeof " + baseValueExpression + " === 'string'" +
|
7069 | "? " + baseValueExpression + ".trim()" +
|
7070 | ": " + baseValueExpression + ")";
|
7071 | }
|
7072 | if (number) {
|
7073 | valueExpression = "_n(" + valueExpression + ")";
|
7074 | }
|
7075 | var assignment = genAssignmentCode(value, valueExpression);
|
7076 |
|
7077 | el.model = {
|
7078 | value: ("(" + value + ")"),
|
7079 | expression: JSON.stringify(value),
|
7080 | callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
|
7081 | };
|
7082 | }
|
7083 |
|
7084 |
|
7085 |
|
7086 |
|
7087 | function genAssignmentCode (
|
7088 | value,
|
7089 | assignment
|
7090 | ) {
|
7091 | var res = parseModel(value);
|
7092 | if (res.key === null) {
|
7093 | return (value + "=" + assignment)
|
7094 | } else {
|
7095 | return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
|
7096 | }
|
7097 | }
|
7098 |
|
7099 |
|
7100 |
|
7101 |
|
7102 |
|
7103 |
|
7104 |
|
7105 |
|
7106 |
|
7107 |
|
7108 |
|
7109 |
|
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 | var len, str, chr, index$1, expressionPos, expressionEndPos;
|
7115 |
|
7116 |
|
7117 |
|
7118 | function parseModel (val) {
|
7119 |
|
7120 |
|
7121 | val = val.trim();
|
7122 | len = val.length;
|
7123 |
|
7124 | if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
|
7125 | index$1 = val.lastIndexOf('.');
|
7126 | if (index$1 > -1) {
|
7127 | return {
|
7128 | exp: val.slice(0, index$1),
|
7129 | key: '"' + val.slice(index$1 + 1) + '"'
|
7130 | }
|
7131 | } else {
|
7132 | return {
|
7133 | exp: val,
|
7134 | key: null
|
7135 | }
|
7136 | }
|
7137 | }
|
7138 |
|
7139 | str = val;
|
7140 | index$1 = expressionPos = expressionEndPos = 0;
|
7141 |
|
7142 | while (!eof()) {
|
7143 | chr = next();
|
7144 |
|
7145 | if (isStringStart(chr)) {
|
7146 | parseString(chr);
|
7147 | } else if (chr === 0x5B) {
|
7148 | parseBracket(chr);
|
7149 | }
|
7150 | }
|
7151 |
|
7152 | return {
|
7153 | exp: val.slice(0, expressionPos),
|
7154 | key: val.slice(expressionPos + 1, expressionEndPos)
|
7155 | }
|
7156 | }
|
7157 |
|
7158 | function next () {
|
7159 | return str.charCodeAt(++index$1)
|
7160 | }
|
7161 |
|
7162 | function eof () {
|
7163 | return index$1 >= len
|
7164 | }
|
7165 |
|
7166 | function isStringStart (chr) {
|
7167 | return chr === 0x22 || chr === 0x27
|
7168 | }
|
7169 |
|
7170 | function parseBracket (chr) {
|
7171 | var inBracket = 1;
|
7172 | expressionPos = index$1;
|
7173 | while (!eof()) {
|
7174 | chr = next();
|
7175 | if (isStringStart(chr)) {
|
7176 | parseString(chr);
|
7177 | continue
|
7178 | }
|
7179 | if (chr === 0x5B) { inBracket++; }
|
7180 | if (chr === 0x5D) { inBracket--; }
|
7181 | if (inBracket === 0) {
|
7182 | expressionEndPos = index$1;
|
7183 | break
|
7184 | }
|
7185 | }
|
7186 | }
|
7187 |
|
7188 | function parseString (chr) {
|
7189 | var stringQuote = chr;
|
7190 | while (!eof()) {
|
7191 | chr = next();
|
7192 | if (chr === stringQuote) {
|
7193 | break
|
7194 | }
|
7195 | }
|
7196 | }
|
7197 |
|
7198 |
|
7199 |
|
7200 | var warn$1;
|
7201 |
|
7202 |
|
7203 |
|
7204 | var RANGE_TOKEN = '__r';
|
7205 | var CHECKBOX_RADIO_TOKEN = '__c';
|
7206 |
|
7207 | function model (
|
7208 | el,
|
7209 | dir,
|
7210 | _warn
|
7211 | ) {
|
7212 | warn$1 = _warn;
|
7213 | var value = dir.value;
|
7214 | var modifiers = dir.modifiers;
|
7215 | var tag = el.tag;
|
7216 | var type = el.attrsMap.type;
|
7217 |
|
7218 | if (process.env.NODE_ENV !== 'production') {
|
7219 |
|
7220 |
|
7221 | if (tag === 'input' && type === 'file') {
|
7222 | warn$1(
|
7223 | "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
|
7224 | "File inputs are read only. Use a v-on:change listener instead.",
|
7225 | el.rawAttrsMap['v-model']
|
7226 | );
|
7227 | }
|
7228 | }
|
7229 |
|
7230 | if (el.component) {
|
7231 | genComponentModel(el, value, modifiers);
|
7232 |
|
7233 | return false
|
7234 | } else if (tag === 'select') {
|
7235 | genSelect(el, value, modifiers);
|
7236 | } else if (tag === 'input' && type === 'checkbox') {
|
7237 | genCheckboxModel(el, value, modifiers);
|
7238 | } else if (tag === 'input' && type === 'radio') {
|
7239 | genRadioModel(el, value, modifiers);
|
7240 | } else if (tag === 'input' || tag === 'textarea') {
|
7241 | genDefaultModel(el, value, modifiers);
|
7242 | } else if (!config.isReservedTag(tag)) {
|
7243 | genComponentModel(el, value, modifiers);
|
7244 |
|
7245 | return false
|
7246 | } else if (process.env.NODE_ENV !== 'production') {
|
7247 | warn$1(
|
7248 | "<" + (el.tag) + " v-model=\"" + value + "\">: " +
|
7249 | "v-model is not supported on this element type. " +
|
7250 | 'If you are working with contenteditable, it\'s recommended to ' +
|
7251 | 'wrap a library dedicated for that purpose inside a custom component.',
|
7252 | el.rawAttrsMap['v-model']
|
7253 | );
|
7254 | }
|
7255 |
|
7256 |
|
7257 | return true
|
7258 | }
|
7259 |
|
7260 | function genCheckboxModel (
|
7261 | el,
|
7262 | value,
|
7263 | modifiers
|
7264 | ) {
|
7265 | var number = modifiers && modifiers.number;
|
7266 | var valueBinding = getBindingAttr(el, 'value') || 'null';
|
7267 | var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
|
7268 | var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
|
7269 | addProp(el, 'checked',
|
7270 | "Array.isArray(" + value + ")" +
|
7271 | "?_i(" + value + "," + valueBinding + ")>-1" + (
|
7272 | trueValueBinding === 'true'
|
7273 | ? (":(" + value + ")")
|
7274 | : (":_q(" + value + "," + trueValueBinding + ")")
|
7275 | )
|
7276 | );
|
7277 | addHandler(el, 'change',
|
7278 | "var $$a=" + value + "," +
|
7279 | '$$el=$event.target,' +
|
7280 | "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
|
7281 | 'if(Array.isArray($$a)){' +
|
7282 | "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
|
7283 | '$$i=_i($$a,$$v);' +
|
7284 | "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
|
7285 | "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
|
7286 | "}else{" + (genAssignmentCode(value, '$$c')) + "}",
|
7287 | null, true
|
7288 | );
|
7289 | }
|
7290 |
|
7291 | function genRadioModel (
|
7292 | el,
|
7293 | value,
|
7294 | modifiers
|
7295 | ) {
|
7296 | var number = modifiers && modifiers.number;
|
7297 | var valueBinding = getBindingAttr(el, 'value') || 'null';
|
7298 | valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
|
7299 | addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
|
7300 | addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
|
7301 | }
|
7302 |
|
7303 | function genSelect (
|
7304 | el,
|
7305 | value,
|
7306 | modifiers
|
7307 | ) {
|
7308 | var number = modifiers && modifiers.number;
|
7309 | var selectedVal = "Array.prototype.filter" +
|
7310 | ".call($event.target.options,function(o){return o.selected})" +
|
7311 | ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
|
7312 | "return " + (number ? '_n(val)' : 'val') + "})";
|
7313 |
|
7314 | var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
|
7315 | var code = "var $$selectedVal = " + selectedVal + ";";
|
7316 | code = code + " " + (genAssignmentCode(value, assignment));
|
7317 | addHandler(el, 'change', code, null, true);
|
7318 | }
|
7319 |
|
7320 | function genDefaultModel (
|
7321 | el,
|
7322 | value,
|
7323 | modifiers
|
7324 | ) {
|
7325 | var type = el.attrsMap.type;
|
7326 |
|
7327 |
|
7328 |
|
7329 | if (process.env.NODE_ENV !== 'production') {
|
7330 | var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
|
7331 | var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
|
7332 | if (value$1 && !typeBinding) {
|
7333 | var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
|
7334 | warn$1(
|
7335 | binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
|
7336 | 'because the latter already expands to a value binding internally',
|
7337 | el.rawAttrsMap[binding]
|
7338 | );
|
7339 | }
|
7340 | }
|
7341 |
|
7342 | var ref = modifiers || {};
|
7343 | var lazy = ref.lazy;
|
7344 | var number = ref.number;
|
7345 | var trim = ref.trim;
|
7346 | var needCompositionGuard = !lazy && type !== 'range';
|
7347 | var event = lazy
|
7348 | ? 'change'
|
7349 | : type === 'range'
|
7350 | ? RANGE_TOKEN
|
7351 | : 'input';
|
7352 |
|
7353 | var valueExpression = '$event.target.value';
|
7354 | if (trim) {
|
7355 | valueExpression = "$event.target.value.trim()";
|
7356 | }
|
7357 | if (number) {
|
7358 | valueExpression = "_n(" + valueExpression + ")";
|
7359 | }
|
7360 |
|
7361 | var code = genAssignmentCode(value, valueExpression);
|
7362 | if (needCompositionGuard) {
|
7363 | code = "if($event.target.composing)return;" + code;
|
7364 | }
|
7365 |
|
7366 | addProp(el, 'value', ("(" + value + ")"));
|
7367 | addHandler(el, event, code, null, true);
|
7368 | if (trim || number) {
|
7369 | addHandler(el, 'blur', '$forceUpdate()');
|
7370 | }
|
7371 | }
|
7372 |
|
7373 |
|
7374 |
|
7375 |
|
7376 |
|
7377 |
|
7378 |
|
7379 | function normalizeEvents (on) {
|
7380 |
|
7381 | if (isDef(on[RANGE_TOKEN])) {
|
7382 |
|
7383 | var event = isIE ? 'change' : 'input';
|
7384 | on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
|
7385 | delete on[RANGE_TOKEN];
|
7386 | }
|
7387 |
|
7388 |
|
7389 |
|
7390 | if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
|
7391 | on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
|
7392 | delete on[CHECKBOX_RADIO_TOKEN];
|
7393 | }
|
7394 | }
|
7395 |
|
7396 | var target$1;
|
7397 |
|
7398 | function createOnceHandler$1 (event, handler, capture) {
|
7399 | var _target = target$1;
|
7400 | return function onceHandler () {
|
7401 | var res = handler.apply(null, arguments);
|
7402 | if (res !== null) {
|
7403 | remove$2(event, onceHandler, capture, _target);
|
7404 | }
|
7405 | }
|
7406 | }
|
7407 |
|
7408 | function add$1 (
|
7409 | name,
|
7410 | handler,
|
7411 | capture,
|
7412 | passive
|
7413 | ) {
|
7414 |
|
7415 |
|
7416 |
|
7417 |
|
7418 |
|
7419 |
|
7420 | if (isUsingMicroTask) {
|
7421 | var attachedTimestamp = currentFlushTimestamp;
|
7422 | var original = handler;
|
7423 | handler = original._wrapper = function (e) {
|
7424 | if (e.timeStamp >= attachedTimestamp) {
|
7425 | return original.apply(this, arguments)
|
7426 | }
|
7427 | };
|
7428 | }
|
7429 | target$1.addEventListener(
|
7430 | name,
|
7431 | handler,
|
7432 | supportsPassive
|
7433 | ? { capture: capture, passive: passive }
|
7434 | : capture
|
7435 | );
|
7436 | }
|
7437 |
|
7438 | function remove$2 (
|
7439 | name,
|
7440 | handler,
|
7441 | capture,
|
7442 | _target
|
7443 | ) {
|
7444 | (_target || target$1).removeEventListener(
|
7445 | name,
|
7446 | handler._wrapper || handler,
|
7447 | capture
|
7448 | );
|
7449 | }
|
7450 |
|
7451 | function updateDOMListeners (oldVnode, vnode) {
|
7452 | if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
|
7453 | return
|
7454 | }
|
7455 | var on = vnode.data.on || {};
|
7456 | var oldOn = oldVnode.data.on || {};
|
7457 | target$1 = vnode.elm;
|
7458 | normalizeEvents(on);
|
7459 | updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
|
7460 | target$1 = undefined;
|
7461 | }
|
7462 |
|
7463 | var events = {
|
7464 | create: updateDOMListeners,
|
7465 | update: updateDOMListeners
|
7466 | };
|
7467 |
|
7468 |
|
7469 |
|
7470 | var svgContainer;
|
7471 |
|
7472 | function updateDOMProps (oldVnode, vnode) {
|
7473 | if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
|
7474 | return
|
7475 | }
|
7476 | var key, cur;
|
7477 | var elm = vnode.elm;
|
7478 | var oldProps = oldVnode.data.domProps || {};
|
7479 | var props = vnode.data.domProps || {};
|
7480 |
|
7481 | if (isDef(props.__ob__)) {
|
7482 | props = vnode.data.domProps = extend({}, props);
|
7483 | }
|
7484 |
|
7485 | for (key in oldProps) {
|
7486 | if (isUndef(props[key])) {
|
7487 | elm[key] = '';
|
7488 | }
|
7489 | }
|
7490 | for (key in props) {
|
7491 | cur = props[key];
|
7492 |
|
7493 |
|
7494 |
|
7495 | if (key === 'textContent' || key === 'innerHTML') {
|
7496 | if (vnode.children) { vnode.children.length = 0; }
|
7497 | if (cur === oldProps[key]) { continue }
|
7498 |
|
7499 |
|
7500 | if (elm.childNodes.length === 1) {
|
7501 | elm.removeChild(elm.childNodes[0]);
|
7502 | }
|
7503 | }
|
7504 |
|
7505 |
|
7506 |
|
7507 |
|
7508 |
|
7509 | if (key !== 'value' && cur === oldProps[key]) {
|
7510 | continue
|
7511 | }
|
7512 |
|
7513 | if (key === 'value') {
|
7514 |
|
7515 |
|
7516 | elm._value = cur;
|
7517 |
|
7518 | var strCur = isUndef(cur) ? '' : String(cur);
|
7519 | if (shouldUpdateValue(elm, strCur)) {
|
7520 | elm.value = strCur;
|
7521 | }
|
7522 | } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
|
7523 |
|
7524 | svgContainer = svgContainer || document.createElement('div');
|
7525 | svgContainer.innerHTML = "<svg>" + cur + "</svg>";
|
7526 | var svg = svgContainer.firstChild;
|
7527 | while (elm.firstChild) {
|
7528 | elm.removeChild(elm.firstChild);
|
7529 | }
|
7530 | while (svg.firstChild) {
|
7531 | elm.appendChild(svg.firstChild);
|
7532 | }
|
7533 | } else {
|
7534 | elm[key] = cur;
|
7535 | }
|
7536 | }
|
7537 | }
|
7538 |
|
7539 |
|
7540 |
|
7541 |
|
7542 | function shouldUpdateValue (elm, checkVal) {
|
7543 | return (!elm.composing && (
|
7544 | elm.tagName === 'OPTION' ||
|
7545 | isNotInFocusAndDirty(elm, checkVal) ||
|
7546 | isDirtyWithModifiers(elm, checkVal)
|
7547 | ))
|
7548 | }
|
7549 |
|
7550 | function isNotInFocusAndDirty (elm, checkVal) {
|
7551 |
|
7552 |
|
7553 | var notInFocus = true;
|
7554 |
|
7555 |
|
7556 | try { notInFocus = document.activeElement !== elm; } catch (e) {}
|
7557 | return notInFocus && elm.value !== checkVal
|
7558 | }
|
7559 |
|
7560 | function isDirtyWithModifiers (elm, newVal) {
|
7561 | var value = elm.value;
|
7562 | var modifiers = elm._vModifiers;
|
7563 | if (isDef(modifiers)) {
|
7564 | if (modifiers.number) {
|
7565 | return toNumber(value) !== toNumber(newVal)
|
7566 | }
|
7567 | if (modifiers.trim) {
|
7568 | return value.trim() !== newVal.trim()
|
7569 | }
|
7570 | }
|
7571 | return value !== newVal
|
7572 | }
|
7573 |
|
7574 | var domProps = {
|
7575 | create: updateDOMProps,
|
7576 | update: updateDOMProps
|
7577 | };
|
7578 |
|
7579 |
|
7580 |
|
7581 | var parseStyleText = cached(function (cssText) {
|
7582 | var res = {};
|
7583 | var listDelimiter = /;(?![^(]*\))/g;
|
7584 | var propertyDelimiter = /:(.+)/;
|
7585 | cssText.split(listDelimiter).forEach(function (item) {
|
7586 | if (item) {
|
7587 | var tmp = item.split(propertyDelimiter);
|
7588 | tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
7589 | }
|
7590 | });
|
7591 | return res
|
7592 | });
|
7593 |
|
7594 |
|
7595 | function normalizeStyleData (data) {
|
7596 | var style = normalizeStyleBinding(data.style);
|
7597 |
|
7598 |
|
7599 | return data.staticStyle
|
7600 | ? extend(data.staticStyle, style)
|
7601 | : style
|
7602 | }
|
7603 |
|
7604 |
|
7605 | function normalizeStyleBinding (bindingStyle) {
|
7606 | if (Array.isArray(bindingStyle)) {
|
7607 | return toObject(bindingStyle)
|
7608 | }
|
7609 | if (typeof bindingStyle === 'string') {
|
7610 | return parseStyleText(bindingStyle)
|
7611 | }
|
7612 | return bindingStyle
|
7613 | }
|
7614 |
|
7615 |
|
7616 |
|
7617 |
|
7618 |
|
7619 | function getStyle (vnode, checkChild) {
|
7620 | var res = {};
|
7621 | var styleData;
|
7622 |
|
7623 | if (checkChild) {
|
7624 | var childNode = vnode;
|
7625 | while (childNode.componentInstance) {
|
7626 | childNode = childNode.componentInstance._vnode;
|
7627 | if (
|
7628 | childNode && childNode.data &&
|
7629 | (styleData = normalizeStyleData(childNode.data))
|
7630 | ) {
|
7631 | extend(res, styleData);
|
7632 | }
|
7633 | }
|
7634 | }
|
7635 |
|
7636 | if ((styleData = normalizeStyleData(vnode.data))) {
|
7637 | extend(res, styleData);
|
7638 | }
|
7639 |
|
7640 | var parentNode = vnode;
|
7641 | while ((parentNode = parentNode.parent)) {
|
7642 | if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
|
7643 | extend(res, styleData);
|
7644 | }
|
7645 | }
|
7646 | return res
|
7647 | }
|
7648 |
|
7649 |
|
7650 |
|
7651 | var cssVarRE = /^--/;
|
7652 | var importantRE = /\s*!important$/;
|
7653 | var setProp = function (el, name, val) {
|
7654 |
|
7655 | if (cssVarRE.test(name)) {
|
7656 | el.style.setProperty(name, val);
|
7657 | } else if (importantRE.test(val)) {
|
7658 | el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
|
7659 | } else {
|
7660 | var normalizedName = normalize(name);
|
7661 | if (Array.isArray(val)) {
|
7662 |
|
7663 |
|
7664 |
|
7665 | for (var i = 0, len = val.length; i < len; i++) {
|
7666 | el.style[normalizedName] = val[i];
|
7667 | }
|
7668 | } else {
|
7669 | el.style[normalizedName] = val;
|
7670 | }
|
7671 | }
|
7672 | };
|
7673 |
|
7674 | var vendorNames = ['Webkit', 'Moz', 'ms'];
|
7675 |
|
7676 | var emptyStyle;
|
7677 | var normalize = cached(function (prop) {
|
7678 | emptyStyle = emptyStyle || document.createElement('div').style;
|
7679 | prop = camelize(prop);
|
7680 | if (prop !== 'filter' && (prop in emptyStyle)) {
|
7681 | return prop
|
7682 | }
|
7683 | var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
|
7684 | for (var i = 0; i < vendorNames.length; i++) {
|
7685 | var name = vendorNames[i] + capName;
|
7686 | if (name in emptyStyle) {
|
7687 | return name
|
7688 | }
|
7689 | }
|
7690 | });
|
7691 |
|
7692 | function updateStyle (oldVnode, vnode) {
|
7693 | var data = vnode.data;
|
7694 | var oldData = oldVnode.data;
|
7695 |
|
7696 | if (isUndef(data.staticStyle) && isUndef(data.style) &&
|
7697 | isUndef(oldData.staticStyle) && isUndef(oldData.style)
|
7698 | ) {
|
7699 | return
|
7700 | }
|
7701 |
|
7702 | var cur, name;
|
7703 | var el = vnode.elm;
|
7704 | var oldStaticStyle = oldData.staticStyle;
|
7705 | var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
|
7706 |
|
7707 |
|
7708 | var oldStyle = oldStaticStyle || oldStyleBinding;
|
7709 |
|
7710 | var style = normalizeStyleBinding(vnode.data.style) || {};
|
7711 |
|
7712 |
|
7713 |
|
7714 |
|
7715 | vnode.data.normalizedStyle = isDef(style.__ob__)
|
7716 | ? extend({}, style)
|
7717 | : style;
|
7718 |
|
7719 | var newStyle = getStyle(vnode, true);
|
7720 |
|
7721 | for (name in oldStyle) {
|
7722 | if (isUndef(newStyle[name])) {
|
7723 | setProp(el, name, '');
|
7724 | }
|
7725 | }
|
7726 | for (name in newStyle) {
|
7727 | cur = newStyle[name];
|
7728 | if (cur !== oldStyle[name]) {
|
7729 |
|
7730 | setProp(el, name, cur == null ? '' : cur);
|
7731 | }
|
7732 | }
|
7733 | }
|
7734 |
|
7735 | var style = {
|
7736 | create: updateStyle,
|
7737 | update: updateStyle
|
7738 | };
|
7739 |
|
7740 |
|
7741 |
|
7742 | var whitespaceRE = /\s+/;
|
7743 |
|
7744 |
|
7745 |
|
7746 |
|
7747 |
|
7748 | function addClass (el, cls) {
|
7749 |
|
7750 | if (!cls || !(cls = cls.trim())) {
|
7751 | return
|
7752 | }
|
7753 |
|
7754 |
|
7755 | if (el.classList) {
|
7756 | if (cls.indexOf(' ') > -1) {
|
7757 | cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
|
7758 | } else {
|
7759 | el.classList.add(cls);
|
7760 | }
|
7761 | } else {
|
7762 | var cur = " " + (el.getAttribute('class') || '') + " ";
|
7763 | if (cur.indexOf(' ' + cls + ' ') < 0) {
|
7764 | el.setAttribute('class', (cur + cls).trim());
|
7765 | }
|
7766 | }
|
7767 | }
|
7768 |
|
7769 |
|
7770 |
|
7771 |
|
7772 |
|
7773 | function removeClass (el, cls) {
|
7774 |
|
7775 | if (!cls || !(cls = cls.trim())) {
|
7776 | return
|
7777 | }
|
7778 |
|
7779 |
|
7780 | if (el.classList) {
|
7781 | if (cls.indexOf(' ') > -1) {
|
7782 | cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
|
7783 | } else {
|
7784 | el.classList.remove(cls);
|
7785 | }
|
7786 | if (!el.classList.length) {
|
7787 | el.removeAttribute('class');
|
7788 | }
|
7789 | } else {
|
7790 | var cur = " " + (el.getAttribute('class') || '') + " ";
|
7791 | var tar = ' ' + cls + ' ';
|
7792 | while (cur.indexOf(tar) >= 0) {
|
7793 | cur = cur.replace(tar, ' ');
|
7794 | }
|
7795 | cur = cur.trim();
|
7796 | if (cur) {
|
7797 | el.setAttribute('class', cur);
|
7798 | } else {
|
7799 | el.removeAttribute('class');
|
7800 | }
|
7801 | }
|
7802 | }
|
7803 |
|
7804 |
|
7805 |
|
7806 | function resolveTransition (def$$1) {
|
7807 | if (!def$$1) {
|
7808 | return
|
7809 | }
|
7810 |
|
7811 | if (typeof def$$1 === 'object') {
|
7812 | var res = {};
|
7813 | if (def$$1.css !== false) {
|
7814 | extend(res, autoCssTransition(def$$1.name || 'v'));
|
7815 | }
|
7816 | extend(res, def$$1);
|
7817 | return res
|
7818 | } else if (typeof def$$1 === 'string') {
|
7819 | return autoCssTransition(def$$1)
|
7820 | }
|
7821 | }
|
7822 |
|
7823 | var autoCssTransition = cached(function (name) {
|
7824 | return {
|
7825 | enterClass: (name + "-enter"),
|
7826 | enterToClass: (name + "-enter-to"),
|
7827 | enterActiveClass: (name + "-enter-active"),
|
7828 | leaveClass: (name + "-leave"),
|
7829 | leaveToClass: (name + "-leave-to"),
|
7830 | leaveActiveClass: (name + "-leave-active")
|
7831 | }
|
7832 | });
|
7833 |
|
7834 | var hasTransition = inBrowser && !isIE9;
|
7835 | var TRANSITION = 'transition';
|
7836 | var ANIMATION = 'animation';
|
7837 |
|
7838 |
|
7839 | var transitionProp = 'transition';
|
7840 | var transitionEndEvent = 'transitionend';
|
7841 | var animationProp = 'animation';
|
7842 | var animationEndEvent = 'animationend';
|
7843 | if (hasTransition) {
|
7844 |
|
7845 | if (window.ontransitionend === undefined &&
|
7846 | window.onwebkittransitionend !== undefined
|
7847 | ) {
|
7848 | transitionProp = 'WebkitTransition';
|
7849 | transitionEndEvent = 'webkitTransitionEnd';
|
7850 | }
|
7851 | if (window.onanimationend === undefined &&
|
7852 | window.onwebkitanimationend !== undefined
|
7853 | ) {
|
7854 | animationProp = 'WebkitAnimation';
|
7855 | animationEndEvent = 'webkitAnimationEnd';
|
7856 | }
|
7857 | }
|
7858 |
|
7859 |
|
7860 | var raf = inBrowser
|
7861 | ? window.requestAnimationFrame
|
7862 | ? window.requestAnimationFrame.bind(window)
|
7863 | : setTimeout
|
7864 | : function (fn) { return fn(); };
|
7865 |
|
7866 | function nextFrame (fn) {
|
7867 | raf(function () {
|
7868 | raf(fn);
|
7869 | });
|
7870 | }
|
7871 |
|
7872 | function addTransitionClass (el, cls) {
|
7873 | var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
|
7874 | if (transitionClasses.indexOf(cls) < 0) {
|
7875 | transitionClasses.push(cls);
|
7876 | addClass(el, cls);
|
7877 | }
|
7878 | }
|
7879 |
|
7880 | function removeTransitionClass (el, cls) {
|
7881 | if (el._transitionClasses) {
|
7882 | remove(el._transitionClasses, cls);
|
7883 | }
|
7884 | removeClass(el, cls);
|
7885 | }
|
7886 |
|
7887 | function whenTransitionEnds (
|
7888 | el,
|
7889 | expectedType,
|
7890 | cb
|
7891 | ) {
|
7892 | var ref = getTransitionInfo(el, expectedType);
|
7893 | var type = ref.type;
|
7894 | var timeout = ref.timeout;
|
7895 | var propCount = ref.propCount;
|
7896 | if (!type) { return cb() }
|
7897 | var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
|
7898 | var ended = 0;
|
7899 | var end = function () {
|
7900 | el.removeEventListener(event, onEnd);
|
7901 | cb();
|
7902 | };
|
7903 | var onEnd = function (e) {
|
7904 | if (e.target === el) {
|
7905 | if (++ended >= propCount) {
|
7906 | end();
|
7907 | }
|
7908 | }
|
7909 | };
|
7910 | setTimeout(function () {
|
7911 | if (ended < propCount) {
|
7912 | end();
|
7913 | }
|
7914 | }, timeout + 1);
|
7915 | el.addEventListener(event, onEnd);
|
7916 | }
|
7917 |
|
7918 | var transformRE = /\b(transform|all)(,|$)/;
|
7919 |
|
7920 | function getTransitionInfo (el, expectedType) {
|
7921 | var styles = window.getComputedStyle(el);
|
7922 |
|
7923 | var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
|
7924 | var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
|
7925 | var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
7926 | var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
|
7927 | var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
|
7928 | var animationTimeout = getTimeout(animationDelays, animationDurations);
|
7929 |
|
7930 | var type;
|
7931 | var timeout = 0;
|
7932 | var propCount = 0;
|
7933 |
|
7934 | if (expectedType === TRANSITION) {
|
7935 | if (transitionTimeout > 0) {
|
7936 | type = TRANSITION;
|
7937 | timeout = transitionTimeout;
|
7938 | propCount = transitionDurations.length;
|
7939 | }
|
7940 | } else if (expectedType === ANIMATION) {
|
7941 | if (animationTimeout > 0) {
|
7942 | type = ANIMATION;
|
7943 | timeout = animationTimeout;
|
7944 | propCount = animationDurations.length;
|
7945 | }
|
7946 | } else {
|
7947 | timeout = Math.max(transitionTimeout, animationTimeout);
|
7948 | type = timeout > 0
|
7949 | ? transitionTimeout > animationTimeout
|
7950 | ? TRANSITION
|
7951 | : ANIMATION
|
7952 | : null;
|
7953 | propCount = type
|
7954 | ? type === TRANSITION
|
7955 | ? transitionDurations.length
|
7956 | : animationDurations.length
|
7957 | : 0;
|
7958 | }
|
7959 | var hasTransform =
|
7960 | type === TRANSITION &&
|
7961 | transformRE.test(styles[transitionProp + 'Property']);
|
7962 | return {
|
7963 | type: type,
|
7964 | timeout: timeout,
|
7965 | propCount: propCount,
|
7966 | hasTransform: hasTransform
|
7967 | }
|
7968 | }
|
7969 |
|
7970 | function getTimeout (delays, durations) {
|
7971 |
|
7972 | while (delays.length < durations.length) {
|
7973 | delays = delays.concat(delays);
|
7974 | }
|
7975 |
|
7976 | return Math.max.apply(null, durations.map(function (d, i) {
|
7977 | return toMs(d) + toMs(delays[i])
|
7978 | }))
|
7979 | }
|
7980 |
|
7981 |
|
7982 |
|
7983 |
|
7984 |
|
7985 | function toMs (s) {
|
7986 | return Number(s.slice(0, -1).replace(',', '.')) * 1000
|
7987 | }
|
7988 |
|
7989 |
|
7990 |
|
7991 | function enter (vnode, toggleDisplay) {
|
7992 | var el = vnode.elm;
|
7993 |
|
7994 |
|
7995 | if (isDef(el._leaveCb)) {
|
7996 | el._leaveCb.cancelled = true;
|
7997 | el._leaveCb();
|
7998 | }
|
7999 |
|
8000 | var data = resolveTransition(vnode.data.transition);
|
8001 | if (isUndef(data)) {
|
8002 | return
|
8003 | }
|
8004 |
|
8005 |
|
8006 | if (isDef(el._enterCb) || el.nodeType !== 1) {
|
8007 | return
|
8008 | }
|
8009 |
|
8010 | var css = data.css;
|
8011 | var type = data.type;
|
8012 | var enterClass = data.enterClass;
|
8013 | var enterToClass = data.enterToClass;
|
8014 | var enterActiveClass = data.enterActiveClass;
|
8015 | var appearClass = data.appearClass;
|
8016 | var appearToClass = data.appearToClass;
|
8017 | var appearActiveClass = data.appearActiveClass;
|
8018 | var beforeEnter = data.beforeEnter;
|
8019 | var enter = data.enter;
|
8020 | var afterEnter = data.afterEnter;
|
8021 | var enterCancelled = data.enterCancelled;
|
8022 | var beforeAppear = data.beforeAppear;
|
8023 | var appear = data.appear;
|
8024 | var afterAppear = data.afterAppear;
|
8025 | var appearCancelled = data.appearCancelled;
|
8026 | var duration = data.duration;
|
8027 |
|
8028 |
|
8029 |
|
8030 |
|
8031 |
|
8032 | var context = activeInstance;
|
8033 | var transitionNode = activeInstance.$vnode;
|
8034 | while (transitionNode && transitionNode.parent) {
|
8035 | transitionNode = transitionNode.parent;
|
8036 | context = transitionNode.context;
|
8037 | }
|
8038 |
|
8039 | var isAppear = !context._isMounted || !vnode.isRootInsert;
|
8040 |
|
8041 | if (isAppear && !appear && appear !== '') {
|
8042 | return
|
8043 | }
|
8044 |
|
8045 | var startClass = isAppear && appearClass
|
8046 | ? appearClass
|
8047 | : enterClass;
|
8048 | var activeClass = isAppear && appearActiveClass
|
8049 | ? appearActiveClass
|
8050 | : enterActiveClass;
|
8051 | var toClass = isAppear && appearToClass
|
8052 | ? appearToClass
|
8053 | : enterToClass;
|
8054 |
|
8055 | var beforeEnterHook = isAppear
|
8056 | ? (beforeAppear || beforeEnter)
|
8057 | : beforeEnter;
|
8058 | var enterHook = isAppear
|
8059 | ? (typeof appear === 'function' ? appear : enter)
|
8060 | : enter;
|
8061 | var afterEnterHook = isAppear
|
8062 | ? (afterAppear || afterEnter)
|
8063 | : afterEnter;
|
8064 | var enterCancelledHook = isAppear
|
8065 | ? (appearCancelled || enterCancelled)
|
8066 | : enterCancelled;
|
8067 |
|
8068 | var explicitEnterDuration = toNumber(
|
8069 | isObject(duration)
|
8070 | ? duration.enter
|
8071 | : duration
|
8072 | );
|
8073 |
|
8074 | if (process.env.NODE_ENV !== 'production' && explicitEnterDuration != null) {
|
8075 | checkDuration(explicitEnterDuration, 'enter', vnode);
|
8076 | }
|
8077 |
|
8078 | var expectsCSS = css !== false && !isIE9;
|
8079 | var userWantsControl = getHookArgumentsLength(enterHook);
|
8080 |
|
8081 | var cb = el._enterCb = once(function () {
|
8082 | if (expectsCSS) {
|
8083 | removeTransitionClass(el, toClass);
|
8084 | removeTransitionClass(el, activeClass);
|
8085 | }
|
8086 | if (cb.cancelled) {
|
8087 | if (expectsCSS) {
|
8088 | removeTransitionClass(el, startClass);
|
8089 | }
|
8090 | enterCancelledHook && enterCancelledHook(el);
|
8091 | } else {
|
8092 | afterEnterHook && afterEnterHook(el);
|
8093 | }
|
8094 | el._enterCb = null;
|
8095 | });
|
8096 |
|
8097 | if (!vnode.data.show) {
|
8098 |
|
8099 | mergeVNodeHook(vnode, 'insert', function () {
|
8100 | var parent = el.parentNode;
|
8101 | var pendingNode = parent && parent._pending && parent._pending[vnode.key];
|
8102 | if (pendingNode &&
|
8103 | pendingNode.tag === vnode.tag &&
|
8104 | pendingNode.elm._leaveCb
|
8105 | ) {
|
8106 | pendingNode.elm._leaveCb();
|
8107 | }
|
8108 | enterHook && enterHook(el, cb);
|
8109 | });
|
8110 | }
|
8111 |
|
8112 |
|
8113 | beforeEnterHook && beforeEnterHook(el);
|
8114 | if (expectsCSS) {
|
8115 | addTransitionClass(el, startClass);
|
8116 | addTransitionClass(el, activeClass);
|
8117 | nextFrame(function () {
|
8118 | removeTransitionClass(el, startClass);
|
8119 | if (!cb.cancelled) {
|
8120 | addTransitionClass(el, toClass);
|
8121 | if (!userWantsControl) {
|
8122 | if (isValidDuration(explicitEnterDuration)) {
|
8123 | setTimeout(cb, explicitEnterDuration);
|
8124 | } else {
|
8125 | whenTransitionEnds(el, type, cb);
|
8126 | }
|
8127 | }
|
8128 | }
|
8129 | });
|
8130 | }
|
8131 |
|
8132 | if (vnode.data.show) {
|
8133 | toggleDisplay && toggleDisplay();
|
8134 | enterHook && enterHook(el, cb);
|
8135 | }
|
8136 |
|
8137 | if (!expectsCSS && !userWantsControl) {
|
8138 | cb();
|
8139 | }
|
8140 | }
|
8141 |
|
8142 | function leave (vnode, rm) {
|
8143 | var el = vnode.elm;
|
8144 |
|
8145 |
|
8146 | if (isDef(el._enterCb)) {
|
8147 | el._enterCb.cancelled = true;
|
8148 | el._enterCb();
|
8149 | }
|
8150 |
|
8151 | var data = resolveTransition(vnode.data.transition);
|
8152 | if (isUndef(data) || el.nodeType !== 1) {
|
8153 | return rm()
|
8154 | }
|
8155 |
|
8156 |
|
8157 | if (isDef(el._leaveCb)) {
|
8158 | return
|
8159 | }
|
8160 |
|
8161 | var css = data.css;
|
8162 | var type = data.type;
|
8163 | var leaveClass = data.leaveClass;
|
8164 | var leaveToClass = data.leaveToClass;
|
8165 | var leaveActiveClass = data.leaveActiveClass;
|
8166 | var beforeLeave = data.beforeLeave;
|
8167 | var leave = data.leave;
|
8168 | var afterLeave = data.afterLeave;
|
8169 | var leaveCancelled = data.leaveCancelled;
|
8170 | var delayLeave = data.delayLeave;
|
8171 | var duration = data.duration;
|
8172 |
|
8173 | var expectsCSS = css !== false && !isIE9;
|
8174 | var userWantsControl = getHookArgumentsLength(leave);
|
8175 |
|
8176 | var explicitLeaveDuration = toNumber(
|
8177 | isObject(duration)
|
8178 | ? duration.leave
|
8179 | : duration
|
8180 | );
|
8181 |
|
8182 | if (process.env.NODE_ENV !== 'production' && isDef(explicitLeaveDuration)) {
|
8183 | checkDuration(explicitLeaveDuration, 'leave', vnode);
|
8184 | }
|
8185 |
|
8186 | var cb = el._leaveCb = once(function () {
|
8187 | if (el.parentNode && el.parentNode._pending) {
|
8188 | el.parentNode._pending[vnode.key] = null;
|
8189 | }
|
8190 | if (expectsCSS) {
|
8191 | removeTransitionClass(el, leaveToClass);
|
8192 | removeTransitionClass(el, leaveActiveClass);
|
8193 | }
|
8194 | if (cb.cancelled) {
|
8195 | if (expectsCSS) {
|
8196 | removeTransitionClass(el, leaveClass);
|
8197 | }
|
8198 | leaveCancelled && leaveCancelled(el);
|
8199 | } else {
|
8200 | rm();
|
8201 | afterLeave && afterLeave(el);
|
8202 | }
|
8203 | el._leaveCb = null;
|
8204 | });
|
8205 |
|
8206 | if (delayLeave) {
|
8207 | delayLeave(performLeave);
|
8208 | } else {
|
8209 | performLeave();
|
8210 | }
|
8211 |
|
8212 | function performLeave () {
|
8213 |
|
8214 | if (cb.cancelled) {
|
8215 | return
|
8216 | }
|
8217 |
|
8218 | if (!vnode.data.show && el.parentNode) {
|
8219 | (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
|
8220 | }
|
8221 | beforeLeave && beforeLeave(el);
|
8222 | if (expectsCSS) {
|
8223 | addTransitionClass(el, leaveClass);
|
8224 | addTransitionClass(el, leaveActiveClass);
|
8225 | nextFrame(function () {
|
8226 | removeTransitionClass(el, leaveClass);
|
8227 | if (!cb.cancelled) {
|
8228 | addTransitionClass(el, leaveToClass);
|
8229 | if (!userWantsControl) {
|
8230 | if (isValidDuration(explicitLeaveDuration)) {
|
8231 | setTimeout(cb, explicitLeaveDuration);
|
8232 | } else {
|
8233 | whenTransitionEnds(el, type, cb);
|
8234 | }
|
8235 | }
|
8236 | }
|
8237 | });
|
8238 | }
|
8239 | leave && leave(el, cb);
|
8240 | if (!expectsCSS && !userWantsControl) {
|
8241 | cb();
|
8242 | }
|
8243 | }
|
8244 | }
|
8245 |
|
8246 |
|
8247 | function checkDuration (val, name, vnode) {
|
8248 | if (typeof val !== 'number') {
|
8249 | warn(
|
8250 | "<transition> explicit " + name + " duration is not a valid number - " +
|
8251 | "got " + (JSON.stringify(val)) + ".",
|
8252 | vnode.context
|
8253 | );
|
8254 | } else if (isNaN(val)) {
|
8255 | warn(
|
8256 | "<transition> explicit " + name + " duration is NaN - " +
|
8257 | 'the duration expression might be incorrect.',
|
8258 | vnode.context
|
8259 | );
|
8260 | }
|
8261 | }
|
8262 |
|
8263 | function isValidDuration (val) {
|
8264 | return typeof val === 'number' && !isNaN(val)
|
8265 | }
|
8266 |
|
8267 |
|
8268 |
|
8269 |
|
8270 |
|
8271 |
|
8272 |
|
8273 | function getHookArgumentsLength (fn) {
|
8274 | if (isUndef(fn)) {
|
8275 | return false
|
8276 | }
|
8277 | var invokerFns = fn.fns;
|
8278 | if (isDef(invokerFns)) {
|
8279 |
|
8280 | return getHookArgumentsLength(
|
8281 | Array.isArray(invokerFns)
|
8282 | ? invokerFns[0]
|
8283 | : invokerFns
|
8284 | )
|
8285 | } else {
|
8286 | return (fn._length || fn.length) > 1
|
8287 | }
|
8288 | }
|
8289 |
|
8290 | function _enter (_, vnode) {
|
8291 | if (vnode.data.show !== true) {
|
8292 | enter(vnode);
|
8293 | }
|
8294 | }
|
8295 |
|
8296 | var transition = inBrowser ? {
|
8297 | create: _enter,
|
8298 | activate: _enter,
|
8299 | remove: function remove$$1 (vnode, rm) {
|
8300 |
|
8301 | if (vnode.data.show !== true) {
|
8302 | leave(vnode, rm);
|
8303 | } else {
|
8304 | rm();
|
8305 | }
|
8306 | }
|
8307 | } : {};
|
8308 |
|
8309 | var platformModules = [
|
8310 | attrs,
|
8311 | klass,
|
8312 | events,
|
8313 | domProps,
|
8314 | style,
|
8315 | transition
|
8316 | ];
|
8317 |
|
8318 |
|
8319 |
|
8320 |
|
8321 |
|
8322 | var modules = platformModules.concat(baseModules);
|
8323 |
|
8324 | var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
|
8325 |
|
8326 |
|
8327 |
|
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 | if (isIE9) {
|
8333 |
|
8334 | document.addEventListener('selectionchange', function () {
|
8335 | var el = document.activeElement;
|
8336 | if (el && el.vmodel) {
|
8337 | trigger(el, 'input');
|
8338 | }
|
8339 | });
|
8340 | }
|
8341 |
|
8342 | var directive = {
|
8343 | inserted: function inserted (el, binding, vnode, oldVnode) {
|
8344 | if (vnode.tag === 'select') {
|
8345 |
|
8346 | if (oldVnode.elm && !oldVnode.elm._vOptions) {
|
8347 | mergeVNodeHook(vnode, 'postpatch', function () {
|
8348 | directive.componentUpdated(el, binding, vnode);
|
8349 | });
|
8350 | } else {
|
8351 | setSelected(el, binding, vnode.context);
|
8352 | }
|
8353 | el._vOptions = [].map.call(el.options, getValue);
|
8354 | } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
|
8355 | el._vModifiers = binding.modifiers;
|
8356 | if (!binding.modifiers.lazy) {
|
8357 | el.addEventListener('compositionstart', onCompositionStart);
|
8358 | el.addEventListener('compositionend', onCompositionEnd);
|
8359 |
|
8360 |
|
8361 |
|
8362 |
|
8363 | el.addEventListener('change', onCompositionEnd);
|
8364 |
|
8365 | if (isIE9) {
|
8366 | el.vmodel = true;
|
8367 | }
|
8368 | }
|
8369 | }
|
8370 | },
|
8371 |
|
8372 | componentUpdated: function componentUpdated (el, binding, vnode) {
|
8373 | if (vnode.tag === 'select') {
|
8374 | setSelected(el, binding, vnode.context);
|
8375 |
|
8376 |
|
8377 |
|
8378 |
|
8379 | var prevOptions = el._vOptions;
|
8380 | var curOptions = el._vOptions = [].map.call(el.options, getValue);
|
8381 | if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
|
8382 |
|
8383 |
|
8384 | var needReset = el.multiple
|
8385 | ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
|
8386 | : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
|
8387 | if (needReset) {
|
8388 | trigger(el, 'change');
|
8389 | }
|
8390 | }
|
8391 | }
|
8392 | }
|
8393 | };
|
8394 |
|
8395 | function setSelected (el, binding, vm) {
|
8396 | actuallySetSelected(el, binding, vm);
|
8397 |
|
8398 | if (isIE || isEdge) {
|
8399 | setTimeout(function () {
|
8400 | actuallySetSelected(el, binding, vm);
|
8401 | }, 0);
|
8402 | }
|
8403 | }
|
8404 |
|
8405 | function actuallySetSelected (el, binding, vm) {
|
8406 | var value = binding.value;
|
8407 | var isMultiple = el.multiple;
|
8408 | if (isMultiple && !Array.isArray(value)) {
|
8409 | process.env.NODE_ENV !== 'production' && warn(
|
8410 | "<select multiple v-model=\"" + (binding.expression) + "\"> " +
|
8411 | "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
|
8412 | vm
|
8413 | );
|
8414 | return
|
8415 | }
|
8416 | var selected, option;
|
8417 | for (var i = 0, l = el.options.length; i < l; i++) {
|
8418 | option = el.options[i];
|
8419 | if (isMultiple) {
|
8420 | selected = looseIndexOf(value, getValue(option)) > -1;
|
8421 | if (option.selected !== selected) {
|
8422 | option.selected = selected;
|
8423 | }
|
8424 | } else {
|
8425 | if (looseEqual(getValue(option), value)) {
|
8426 | if (el.selectedIndex !== i) {
|
8427 | el.selectedIndex = i;
|
8428 | }
|
8429 | return
|
8430 | }
|
8431 | }
|
8432 | }
|
8433 | if (!isMultiple) {
|
8434 | el.selectedIndex = -1;
|
8435 | }
|
8436 | }
|
8437 |
|
8438 | function hasNoMatchingOption (value, options) {
|
8439 | return options.every(function (o) { return !looseEqual(o, value); })
|
8440 | }
|
8441 |
|
8442 | function getValue (option) {
|
8443 | return '_value' in option
|
8444 | ? option._value
|
8445 | : option.value
|
8446 | }
|
8447 |
|
8448 | function onCompositionStart (e) {
|
8449 | e.target.composing = true;
|
8450 | }
|
8451 |
|
8452 | function onCompositionEnd (e) {
|
8453 |
|
8454 | if (!e.target.composing) { return }
|
8455 | e.target.composing = false;
|
8456 | trigger(e.target, 'input');
|
8457 | }
|
8458 |
|
8459 | function trigger (el, type) {
|
8460 | var e = document.createEvent('HTMLEvents');
|
8461 | e.initEvent(type, true, true);
|
8462 | el.dispatchEvent(e);
|
8463 | }
|
8464 |
|
8465 |
|
8466 |
|
8467 |
|
8468 | function locateNode (vnode) {
|
8469 | return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
|
8470 | ? locateNode(vnode.componentInstance._vnode)
|
8471 | : vnode
|
8472 | }
|
8473 |
|
8474 | var show = {
|
8475 | bind: function bind (el, ref, vnode) {
|
8476 | var value = ref.value;
|
8477 |
|
8478 | vnode = locateNode(vnode);
|
8479 | var transition$$1 = vnode.data && vnode.data.transition;
|
8480 | var originalDisplay = el.__vOriginalDisplay =
|
8481 | el.style.display === 'none' ? '' : el.style.display;
|
8482 | if (value && transition$$1) {
|
8483 | vnode.data.show = true;
|
8484 | enter(vnode, function () {
|
8485 | el.style.display = originalDisplay;
|
8486 | });
|
8487 | } else {
|
8488 | el.style.display = value ? originalDisplay : 'none';
|
8489 | }
|
8490 | },
|
8491 |
|
8492 | update: function update (el, ref, vnode) {
|
8493 | var value = ref.value;
|
8494 | var oldValue = ref.oldValue;
|
8495 |
|
8496 |
|
8497 | if (!value === !oldValue) { return }
|
8498 | vnode = locateNode(vnode);
|
8499 | var transition$$1 = vnode.data && vnode.data.transition;
|
8500 | if (transition$$1) {
|
8501 | vnode.data.show = true;
|
8502 | if (value) {
|
8503 | enter(vnode, function () {
|
8504 | el.style.display = el.__vOriginalDisplay;
|
8505 | });
|
8506 | } else {
|
8507 | leave(vnode, function () {
|
8508 | el.style.display = 'none';
|
8509 | });
|
8510 | }
|
8511 | } else {
|
8512 | el.style.display = value ? el.__vOriginalDisplay : 'none';
|
8513 | }
|
8514 | },
|
8515 |
|
8516 | unbind: function unbind (
|
8517 | el,
|
8518 | binding,
|
8519 | vnode,
|
8520 | oldVnode,
|
8521 | isDestroy
|
8522 | ) {
|
8523 | if (!isDestroy) {
|
8524 | el.style.display = el.__vOriginalDisplay;
|
8525 | }
|
8526 | }
|
8527 | };
|
8528 |
|
8529 | var platformDirectives = {
|
8530 | model: directive,
|
8531 | show: show
|
8532 | };
|
8533 |
|
8534 |
|
8535 |
|
8536 | var transitionProps = {
|
8537 | name: String,
|
8538 | appear: Boolean,
|
8539 | css: Boolean,
|
8540 | mode: String,
|
8541 | type: String,
|
8542 | enterClass: String,
|
8543 | leaveClass: String,
|
8544 | enterToClass: String,
|
8545 | leaveToClass: String,
|
8546 | enterActiveClass: String,
|
8547 | leaveActiveClass: String,
|
8548 | appearClass: String,
|
8549 | appearActiveClass: String,
|
8550 | appearToClass: String,
|
8551 | duration: [Number, String, Object]
|
8552 | };
|
8553 |
|
8554 |
|
8555 |
|
8556 | function getRealChild (vnode) {
|
8557 | var compOptions = vnode && vnode.componentOptions;
|
8558 | if (compOptions && compOptions.Ctor.options.abstract) {
|
8559 | return getRealChild(getFirstComponentChild(compOptions.children))
|
8560 | } else {
|
8561 | return vnode
|
8562 | }
|
8563 | }
|
8564 |
|
8565 | function extractTransitionData (comp) {
|
8566 | var data = {};
|
8567 | var options = comp.$options;
|
8568 |
|
8569 | for (var key in options.propsData) {
|
8570 | data[key] = comp[key];
|
8571 | }
|
8572 |
|
8573 |
|
8574 | var listeners = options._parentListeners;
|
8575 | for (var key$1 in listeners) {
|
8576 | data[camelize(key$1)] = listeners[key$1];
|
8577 | }
|
8578 | return data
|
8579 | }
|
8580 |
|
8581 | function placeholder (h, rawChild) {
|
8582 | if (/\d-keep-alive$/.test(rawChild.tag)) {
|
8583 | return h('keep-alive', {
|
8584 | props: rawChild.componentOptions.propsData
|
8585 | })
|
8586 | }
|
8587 | }
|
8588 |
|
8589 | function hasParentTransition (vnode) {
|
8590 | while ((vnode = vnode.parent)) {
|
8591 | if (vnode.data.transition) {
|
8592 | return true
|
8593 | }
|
8594 | }
|
8595 | }
|
8596 |
|
8597 | function isSameChild (child, oldChild) {
|
8598 | return oldChild.key === child.key && oldChild.tag === child.tag
|
8599 | }
|
8600 |
|
8601 | var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
|
8602 |
|
8603 | var isVShowDirective = function (d) { return d.name === 'show'; };
|
8604 |
|
8605 | var Transition = {
|
8606 | name: 'transition',
|
8607 | props: transitionProps,
|
8608 | abstract: true,
|
8609 |
|
8610 | render: function render (h) {
|
8611 | var this$1 = this;
|
8612 |
|
8613 | var children = this.$slots.default;
|
8614 | if (!children) {
|
8615 | return
|
8616 | }
|
8617 |
|
8618 |
|
8619 | children = children.filter(isNotTextNode);
|
8620 |
|
8621 | if (!children.length) {
|
8622 | return
|
8623 | }
|
8624 |
|
8625 |
|
8626 | if (process.env.NODE_ENV !== 'production' && children.length > 1) {
|
8627 | warn(
|
8628 | '<transition> can only be used on a single element. Use ' +
|
8629 | '<transition-group> for lists.',
|
8630 | this.$parent
|
8631 | );
|
8632 | }
|
8633 |
|
8634 | var mode = this.mode;
|
8635 |
|
8636 |
|
8637 | if (process.env.NODE_ENV !== 'production' &&
|
8638 | mode && mode !== 'in-out' && mode !== 'out-in'
|
8639 | ) {
|
8640 | warn(
|
8641 | 'invalid <transition> mode: ' + mode,
|
8642 | this.$parent
|
8643 | );
|
8644 | }
|
8645 |
|
8646 | var rawChild = children[0];
|
8647 |
|
8648 |
|
8649 |
|
8650 | if (hasParentTransition(this.$vnode)) {
|
8651 | return rawChild
|
8652 | }
|
8653 |
|
8654 |
|
8655 |
|
8656 | var child = getRealChild(rawChild);
|
8657 |
|
8658 | if (!child) {
|
8659 | return rawChild
|
8660 | }
|
8661 |
|
8662 | if (this._leaving) {
|
8663 | return placeholder(h, rawChild)
|
8664 | }
|
8665 |
|
8666 |
|
8667 |
|
8668 |
|
8669 | var id = "__transition-" + (this._uid) + "-";
|
8670 | child.key = child.key == null
|
8671 | ? child.isComment
|
8672 | ? id + 'comment'
|
8673 | : id + child.tag
|
8674 | : isPrimitive(child.key)
|
8675 | ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
|
8676 | : child.key;
|
8677 |
|
8678 | var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
|
8679 | var oldRawChild = this._vnode;
|
8680 | var oldChild = getRealChild(oldRawChild);
|
8681 |
|
8682 |
|
8683 |
|
8684 | if (child.data.directives && child.data.directives.some(isVShowDirective)) {
|
8685 | child.data.show = true;
|
8686 | }
|
8687 |
|
8688 | if (
|
8689 | oldChild &&
|
8690 | oldChild.data &&
|
8691 | !isSameChild(child, oldChild) &&
|
8692 | !isAsyncPlaceholder(oldChild) &&
|
8693 |
|
8694 | !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
|
8695 | ) {
|
8696 |
|
8697 |
|
8698 | var oldData = oldChild.data.transition = extend({}, data);
|
8699 |
|
8700 | if (mode === 'out-in') {
|
8701 |
|
8702 | this._leaving = true;
|
8703 | mergeVNodeHook(oldData, 'afterLeave', function () {
|
8704 | this$1._leaving = false;
|
8705 | this$1.$forceUpdate();
|
8706 | });
|
8707 | return placeholder(h, rawChild)
|
8708 | } else if (mode === 'in-out') {
|
8709 | if (isAsyncPlaceholder(child)) {
|
8710 | return oldRawChild
|
8711 | }
|
8712 | var delayedLeave;
|
8713 | var performLeave = function () { delayedLeave(); };
|
8714 | mergeVNodeHook(data, 'afterEnter', performLeave);
|
8715 | mergeVNodeHook(data, 'enterCancelled', performLeave);
|
8716 | mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
|
8717 | }
|
8718 | }
|
8719 |
|
8720 | return rawChild
|
8721 | }
|
8722 | };
|
8723 |
|
8724 |
|
8725 |
|
8726 | var props = extend({
|
8727 | tag: String,
|
8728 | moveClass: String
|
8729 | }, transitionProps);
|
8730 |
|
8731 | delete props.mode;
|
8732 |
|
8733 | var TransitionGroup = {
|
8734 | props: props,
|
8735 |
|
8736 | beforeMount: function beforeMount () {
|
8737 | var this$1 = this;
|
8738 |
|
8739 | var update = this._update;
|
8740 | this._update = function (vnode, hydrating) {
|
8741 | var restoreActiveInstance = setActiveInstance(this$1);
|
8742 |
|
8743 | this$1.__patch__(
|
8744 | this$1._vnode,
|
8745 | this$1.kept,
|
8746 | false,
|
8747 | true
|
8748 | );
|
8749 | this$1._vnode = this$1.kept;
|
8750 | restoreActiveInstance();
|
8751 | update.call(this$1, vnode, hydrating);
|
8752 | };
|
8753 | },
|
8754 |
|
8755 | render: function render (h) {
|
8756 | var tag = this.tag || this.$vnode.data.tag || 'span';
|
8757 | var map = Object.create(null);
|
8758 | var prevChildren = this.prevChildren = this.children;
|
8759 | var rawChildren = this.$slots.default || [];
|
8760 | var children = this.children = [];
|
8761 | var transitionData = extractTransitionData(this);
|
8762 |
|
8763 | for (var i = 0; i < rawChildren.length; i++) {
|
8764 | var c = rawChildren[i];
|
8765 | if (c.tag) {
|
8766 | if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
|
8767 | children.push(c);
|
8768 | map[c.key] = c
|
8769 | ;(c.data || (c.data = {})).transition = transitionData;
|
8770 | } else if (process.env.NODE_ENV !== 'production') {
|
8771 | var opts = c.componentOptions;
|
8772 | var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
|
8773 | warn(("<transition-group> children must be keyed: <" + name + ">"));
|
8774 | }
|
8775 | }
|
8776 | }
|
8777 |
|
8778 | if (prevChildren) {
|
8779 | var kept = [];
|
8780 | var removed = [];
|
8781 | for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
|
8782 | var c$1 = prevChildren[i$1];
|
8783 | c$1.data.transition = transitionData;
|
8784 | c$1.data.pos = c$1.elm.getBoundingClientRect();
|
8785 | if (map[c$1.key]) {
|
8786 | kept.push(c$1);
|
8787 | } else {
|
8788 | removed.push(c$1);
|
8789 | }
|
8790 | }
|
8791 | this.kept = h(tag, null, kept);
|
8792 | this.removed = removed;
|
8793 | }
|
8794 |
|
8795 | return h(tag, null, children)
|
8796 | },
|
8797 |
|
8798 | updated: function updated () {
|
8799 | var children = this.prevChildren;
|
8800 | var moveClass = this.moveClass || ((this.name || 'v') + '-move');
|
8801 | if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
|
8802 | return
|
8803 | }
|
8804 |
|
8805 |
|
8806 |
|
8807 | children.forEach(callPendingCbs);
|
8808 | children.forEach(recordPosition);
|
8809 | children.forEach(applyTranslation);
|
8810 |
|
8811 |
|
8812 |
|
8813 |
|
8814 | this._reflow = document.body.offsetHeight;
|
8815 |
|
8816 | children.forEach(function (c) {
|
8817 | if (c.data.moved) {
|
8818 | var el = c.elm;
|
8819 | var s = el.style;
|
8820 | addTransitionClass(el, moveClass);
|
8821 | s.transform = s.WebkitTransform = s.transitionDuration = '';
|
8822 | el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
|
8823 | if (e && e.target !== el) {
|
8824 | return
|
8825 | }
|
8826 | if (!e || /transform$/.test(e.propertyName)) {
|
8827 | el.removeEventListener(transitionEndEvent, cb);
|
8828 | el._moveCb = null;
|
8829 | removeTransitionClass(el, moveClass);
|
8830 | }
|
8831 | });
|
8832 | }
|
8833 | });
|
8834 | },
|
8835 |
|
8836 | methods: {
|
8837 | hasMove: function hasMove (el, moveClass) {
|
8838 |
|
8839 | if (!hasTransition) {
|
8840 | return false
|
8841 | }
|
8842 |
|
8843 | if (this._hasMove) {
|
8844 | return this._hasMove
|
8845 | }
|
8846 |
|
8847 |
|
8848 |
|
8849 |
|
8850 |
|
8851 | var clone = el.cloneNode();
|
8852 | if (el._transitionClasses) {
|
8853 | el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
|
8854 | }
|
8855 | addClass(clone, moveClass);
|
8856 | clone.style.display = 'none';
|
8857 | this.$el.appendChild(clone);
|
8858 | var info = getTransitionInfo(clone);
|
8859 | this.$el.removeChild(clone);
|
8860 | return (this._hasMove = info.hasTransform)
|
8861 | }
|
8862 | }
|
8863 | };
|
8864 |
|
8865 | function callPendingCbs (c) {
|
8866 |
|
8867 | if (c.elm._moveCb) {
|
8868 | c.elm._moveCb();
|
8869 | }
|
8870 |
|
8871 | if (c.elm._enterCb) {
|
8872 | c.elm._enterCb();
|
8873 | }
|
8874 | }
|
8875 |
|
8876 | function recordPosition (c) {
|
8877 | c.data.newPos = c.elm.getBoundingClientRect();
|
8878 | }
|
8879 |
|
8880 | function applyTranslation (c) {
|
8881 | var oldPos = c.data.pos;
|
8882 | var newPos = c.data.newPos;
|
8883 | var dx = oldPos.left - newPos.left;
|
8884 | var dy = oldPos.top - newPos.top;
|
8885 | if (dx || dy) {
|
8886 | c.data.moved = true;
|
8887 | var s = c.elm.style;
|
8888 | s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
|
8889 | s.transitionDuration = '0s';
|
8890 | }
|
8891 | }
|
8892 |
|
8893 | var platformComponents = {
|
8894 | Transition: Transition,
|
8895 | TransitionGroup: TransitionGroup
|
8896 | };
|
8897 |
|
8898 |
|
8899 |
|
8900 |
|
8901 | Vue.config.mustUseProp = mustUseProp;
|
8902 | Vue.config.isReservedTag = isReservedTag;
|
8903 | Vue.config.isReservedAttr = isReservedAttr;
|
8904 | Vue.config.getTagNamespace = getTagNamespace;
|
8905 | Vue.config.isUnknownElement = isUnknownElement;
|
8906 |
|
8907 |
|
8908 | extend(Vue.options.directives, platformDirectives);
|
8909 | extend(Vue.options.components, platformComponents);
|
8910 |
|
8911 |
|
8912 | Vue.prototype.__patch__ = inBrowser ? patch : noop;
|
8913 |
|
8914 |
|
8915 | Vue.prototype.$mount = function (
|
8916 | el,
|
8917 | hydrating
|
8918 | ) {
|
8919 | el = el && inBrowser ? query(el) : undefined;
|
8920 | return mountComponent(this, el, hydrating)
|
8921 | };
|
8922 |
|
8923 |
|
8924 |
|
8925 | if (inBrowser) {
|
8926 | setTimeout(function () {
|
8927 | if (config.devtools) {
|
8928 | if (devtools) {
|
8929 | devtools.emit('init', Vue);
|
8930 | } else if (
|
8931 | process.env.NODE_ENV !== 'production' &&
|
8932 | process.env.NODE_ENV !== 'test'
|
8933 | ) {
|
8934 | console[console.info ? 'info' : 'log'](
|
8935 | 'Download the Vue Devtools extension for a better development experience:\n' +
|
8936 | 'https://github.com/vuejs/vue-devtools'
|
8937 | );
|
8938 | }
|
8939 | }
|
8940 | if (process.env.NODE_ENV !== 'production' &&
|
8941 | process.env.NODE_ENV !== 'test' &&
|
8942 | config.productionTip !== false &&
|
8943 | typeof console !== 'undefined'
|
8944 | ) {
|
8945 | console[console.info ? 'info' : 'log'](
|
8946 | "You are running Vue in development mode.\n" +
|
8947 | "Make sure to turn on production mode when deploying for production.\n" +
|
8948 | "See more tips at https://vuejs.org/guide/deployment.html"
|
8949 | );
|
8950 | }
|
8951 | }, 0);
|
8952 | }
|
8953 |
|
8954 |
|
8955 |
|
8956 | var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
|
8957 | var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
|
8958 |
|
8959 | var buildRegex = cached(function (delimiters) {
|
8960 | var open = delimiters[0].replace(regexEscapeRE, '\\$&');
|
8961 | var close = delimiters[1].replace(regexEscapeRE, '\\$&');
|
8962 | return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
|
8963 | });
|
8964 |
|
8965 |
|
8966 |
|
8967 | function parseText (
|
8968 | text,
|
8969 | delimiters
|
8970 | ) {
|
8971 | var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
|
8972 | if (!tagRE.test(text)) {
|
8973 | return
|
8974 | }
|
8975 | var tokens = [];
|
8976 | var rawTokens = [];
|
8977 | var lastIndex = tagRE.lastIndex = 0;
|
8978 | var match, index, tokenValue;
|
8979 | while ((match = tagRE.exec(text))) {
|
8980 | index = match.index;
|
8981 |
|
8982 | if (index > lastIndex) {
|
8983 | rawTokens.push(tokenValue = text.slice(lastIndex, index));
|
8984 | tokens.push(JSON.stringify(tokenValue));
|
8985 | }
|
8986 |
|
8987 | var exp = parseFilters(match[1].trim());
|
8988 | tokens.push(("_s(" + exp + ")"));
|
8989 | rawTokens.push({ '@binding': exp });
|
8990 | lastIndex = index + match[0].length;
|
8991 | }
|
8992 | if (lastIndex < text.length) {
|
8993 | rawTokens.push(tokenValue = text.slice(lastIndex));
|
8994 | tokens.push(JSON.stringify(tokenValue));
|
8995 | }
|
8996 | return {
|
8997 | expression: tokens.join('+'),
|
8998 | tokens: rawTokens
|
8999 | }
|
9000 | }
|
9001 |
|
9002 |
|
9003 |
|
9004 | function transformNode (el, options) {
|
9005 | var warn = options.warn || baseWarn;
|
9006 | var staticClass = getAndRemoveAttr(el, 'class');
|
9007 | if (process.env.NODE_ENV !== 'production' && staticClass) {
|
9008 | var res = parseText(staticClass, options.delimiters);
|
9009 | if (res) {
|
9010 | warn(
|
9011 | "class=\"" + staticClass + "\": " +
|
9012 | 'Interpolation inside attributes has been removed. ' +
|
9013 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
9014 | 'instead of <div class="{{ val }}">, use <div :class="val">.',
|
9015 | el.rawAttrsMap['class']
|
9016 | );
|
9017 | }
|
9018 | }
|
9019 | if (staticClass) {
|
9020 | el.staticClass = JSON.stringify(staticClass);
|
9021 | }
|
9022 | var classBinding = getBindingAttr(el, 'class', false );
|
9023 | if (classBinding) {
|
9024 | el.classBinding = classBinding;
|
9025 | }
|
9026 | }
|
9027 |
|
9028 | function genData (el) {
|
9029 | var data = '';
|
9030 | if (el.staticClass) {
|
9031 | data += "staticClass:" + (el.staticClass) + ",";
|
9032 | }
|
9033 | if (el.classBinding) {
|
9034 | data += "class:" + (el.classBinding) + ",";
|
9035 | }
|
9036 | return data
|
9037 | }
|
9038 |
|
9039 | var klass$1 = {
|
9040 | staticKeys: ['staticClass'],
|
9041 | transformNode: transformNode,
|
9042 | genData: genData
|
9043 | };
|
9044 |
|
9045 |
|
9046 |
|
9047 | function transformNode$1 (el, options) {
|
9048 | var warn = options.warn || baseWarn;
|
9049 | var staticStyle = getAndRemoveAttr(el, 'style');
|
9050 | if (staticStyle) {
|
9051 |
|
9052 | if (process.env.NODE_ENV !== 'production') {
|
9053 | var res = parseText(staticStyle, options.delimiters);
|
9054 | if (res) {
|
9055 | warn(
|
9056 | "style=\"" + staticStyle + "\": " +
|
9057 | 'Interpolation inside attributes has been removed. ' +
|
9058 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
9059 | 'instead of <div style="{{ val }}">, use <div :style="val">.',
|
9060 | el.rawAttrsMap['style']
|
9061 | );
|
9062 | }
|
9063 | }
|
9064 | el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
|
9065 | }
|
9066 |
|
9067 | var styleBinding = getBindingAttr(el, 'style', false );
|
9068 | if (styleBinding) {
|
9069 | el.styleBinding = styleBinding;
|
9070 | }
|
9071 | }
|
9072 |
|
9073 | function genData$1 (el) {
|
9074 | var data = '';
|
9075 | if (el.staticStyle) {
|
9076 | data += "staticStyle:" + (el.staticStyle) + ",";
|
9077 | }
|
9078 | if (el.styleBinding) {
|
9079 | data += "style:(" + (el.styleBinding) + "),";
|
9080 | }
|
9081 | return data
|
9082 | }
|
9083 |
|
9084 | var style$1 = {
|
9085 | staticKeys: ['staticStyle'],
|
9086 | transformNode: transformNode$1,
|
9087 | genData: genData$1
|
9088 | };
|
9089 |
|
9090 |
|
9091 |
|
9092 | var decoder;
|
9093 |
|
9094 | var he = {
|
9095 | decode: function decode (html) {
|
9096 | decoder = decoder || document.createElement('div');
|
9097 | decoder.innerHTML = html;
|
9098 | return decoder.textContent
|
9099 | }
|
9100 | };
|
9101 |
|
9102 |
|
9103 |
|
9104 | var isUnaryTag = makeMap(
|
9105 | 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
|
9106 | 'link,meta,param,source,track,wbr'
|
9107 | );
|
9108 |
|
9109 |
|
9110 |
|
9111 | var canBeLeftOpenTag = makeMap(
|
9112 | 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
|
9113 | );
|
9114 |
|
9115 |
|
9116 |
|
9117 | var isNonPhrasingTag = makeMap(
|
9118 | 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
|
9119 | 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
|
9120 | 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
|
9121 | 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
|
9122 | 'title,tr,track'
|
9123 | );
|
9124 |
|
9125 |
|
9126 |
|
9127 |
|
9128 |
|
9129 |
|
9130 | var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
9131 | var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
9132 | var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + unicodeLetters + "]*";
|
9133 | var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
|
9134 | var startTagOpen = new RegExp(("^<" + qnameCapture));
|
9135 | var startTagClose = /^\s*(\/?)>/;
|
9136 | var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
|
9137 | var doctype = /^<!DOCTYPE [^>]+>/i;
|
9138 |
|
9139 | var comment = /^<!\--/;
|
9140 | var conditionalComment = /^<!\[/;
|
9141 |
|
9142 |
|
9143 | var isPlainTextElement = makeMap('script,style,textarea', true);
|
9144 | var reCache = {};
|
9145 |
|
9146 | var decodingMap = {
|
9147 | '<': '<',
|
9148 | '>': '>',
|
9149 | '"': '"',
|
9150 | '&': '&',
|
9151 | ' ': '\n',
|
9152 | '	': '\t'
|
9153 | };
|
9154 | var encodedAttr = /&(?:lt|gt|quot|amp);/g;
|
9155 | var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g;
|
9156 |
|
9157 |
|
9158 | var isIgnoreNewlineTag = makeMap('pre,textarea', true);
|
9159 | var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
|
9160 |
|
9161 | function decodeAttr (value, shouldDecodeNewlines) {
|
9162 | var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
|
9163 | return value.replace(re, function (match) { return decodingMap[match]; })
|
9164 | }
|
9165 |
|
9166 | function parseHTML (html, options) {
|
9167 | var stack = [];
|
9168 | var expectHTML = options.expectHTML;
|
9169 | var isUnaryTag$$1 = options.isUnaryTag || no;
|
9170 | var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
|
9171 | var index = 0;
|
9172 | var last, lastTag;
|
9173 | while (html) {
|
9174 | last = html;
|
9175 |
|
9176 | if (!lastTag || !isPlainTextElement(lastTag)) {
|
9177 | var textEnd = html.indexOf('<');
|
9178 | if (textEnd === 0) {
|
9179 |
|
9180 | if (comment.test(html)) {
|
9181 | var commentEnd = html.indexOf('-->');
|
9182 |
|
9183 | if (commentEnd >= 0) {
|
9184 | if (options.shouldKeepComment) {
|
9185 | options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
|
9186 | }
|
9187 | advance(commentEnd + 3);
|
9188 | continue
|
9189 | }
|
9190 | }
|
9191 |
|
9192 |
|
9193 | if (conditionalComment.test(html)) {
|
9194 | var conditionalEnd = html.indexOf(']>');
|
9195 |
|
9196 | if (conditionalEnd >= 0) {
|
9197 | advance(conditionalEnd + 2);
|
9198 | continue
|
9199 | }
|
9200 | }
|
9201 |
|
9202 |
|
9203 | var doctypeMatch = html.match(doctype);
|
9204 | if (doctypeMatch) {
|
9205 | advance(doctypeMatch[0].length);
|
9206 | continue
|
9207 | }
|
9208 |
|
9209 |
|
9210 | var endTagMatch = html.match(endTag);
|
9211 | if (endTagMatch) {
|
9212 | var curIndex = index;
|
9213 | advance(endTagMatch[0].length);
|
9214 | parseEndTag(endTagMatch[1], curIndex, index);
|
9215 | continue
|
9216 | }
|
9217 |
|
9218 |
|
9219 | var startTagMatch = parseStartTag();
|
9220 | if (startTagMatch) {
|
9221 | handleStartTag(startTagMatch);
|
9222 | if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
|
9223 | advance(1);
|
9224 | }
|
9225 | continue
|
9226 | }
|
9227 | }
|
9228 |
|
9229 | var text = (void 0), rest = (void 0), next = (void 0);
|
9230 | if (textEnd >= 0) {
|
9231 | rest = html.slice(textEnd);
|
9232 | while (
|
9233 | !endTag.test(rest) &&
|
9234 | !startTagOpen.test(rest) &&
|
9235 | !comment.test(rest) &&
|
9236 | !conditionalComment.test(rest)
|
9237 | ) {
|
9238 |
|
9239 | next = rest.indexOf('<', 1);
|
9240 | if (next < 0) { break }
|
9241 | textEnd += next;
|
9242 | rest = html.slice(textEnd);
|
9243 | }
|
9244 | text = html.substring(0, textEnd);
|
9245 | }
|
9246 |
|
9247 | if (textEnd < 0) {
|
9248 | text = html;
|
9249 | }
|
9250 |
|
9251 | if (text) {
|
9252 | advance(text.length);
|
9253 | }
|
9254 |
|
9255 | if (options.chars && text) {
|
9256 | options.chars(text, index - text.length, index);
|
9257 | }
|
9258 | } else {
|
9259 | var endTagLength = 0;
|
9260 | var stackedTag = lastTag.toLowerCase();
|
9261 | var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
|
9262 | var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
|
9263 | endTagLength = endTag.length;
|
9264 | if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
|
9265 | text = text
|
9266 | .replace(/<!\--([\s\S]*?)-->/g, '$1')
|
9267 | .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
|
9268 | }
|
9269 | if (shouldIgnoreFirstNewline(stackedTag, text)) {
|
9270 | text = text.slice(1);
|
9271 | }
|
9272 | if (options.chars) {
|
9273 | options.chars(text);
|
9274 | }
|
9275 | return ''
|
9276 | });
|
9277 | index += html.length - rest$1.length;
|
9278 | html = rest$1;
|
9279 | parseEndTag(stackedTag, index - endTagLength, index);
|
9280 | }
|
9281 |
|
9282 | if (html === last) {
|
9283 | options.chars && options.chars(html);
|
9284 | if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
|
9285 | options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
|
9286 | }
|
9287 | break
|
9288 | }
|
9289 | }
|
9290 |
|
9291 |
|
9292 | parseEndTag();
|
9293 |
|
9294 | function advance (n) {
|
9295 | index += n;
|
9296 | html = html.substring(n);
|
9297 | }
|
9298 |
|
9299 | function parseStartTag () {
|
9300 | var start = html.match(startTagOpen);
|
9301 | if (start) {
|
9302 | var match = {
|
9303 | tagName: start[1],
|
9304 | attrs: [],
|
9305 | start: index
|
9306 | };
|
9307 | advance(start[0].length);
|
9308 | var end, attr;
|
9309 | while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
|
9310 | attr.start = index;
|
9311 | advance(attr[0].length);
|
9312 | attr.end = index;
|
9313 | match.attrs.push(attr);
|
9314 | }
|
9315 | if (end) {
|
9316 | match.unarySlash = end[1];
|
9317 | advance(end[0].length);
|
9318 | match.end = index;
|
9319 | return match
|
9320 | }
|
9321 | }
|
9322 | }
|
9323 |
|
9324 | function handleStartTag (match) {
|
9325 | var tagName = match.tagName;
|
9326 | var unarySlash = match.unarySlash;
|
9327 |
|
9328 | if (expectHTML) {
|
9329 | if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
|
9330 | parseEndTag(lastTag);
|
9331 | }
|
9332 | if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
|
9333 | parseEndTag(tagName);
|
9334 | }
|
9335 | }
|
9336 |
|
9337 | var unary = isUnaryTag$$1(tagName) || !!unarySlash;
|
9338 |
|
9339 | var l = match.attrs.length;
|
9340 | var attrs = new Array(l);
|
9341 | for (var i = 0; i < l; i++) {
|
9342 | var args = match.attrs[i];
|
9343 | var value = args[3] || args[4] || args[5] || '';
|
9344 | var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
|
9345 | ? options.shouldDecodeNewlinesForHref
|
9346 | : options.shouldDecodeNewlines;
|
9347 | attrs[i] = {
|
9348 | name: args[1],
|
9349 | value: decodeAttr(value, shouldDecodeNewlines)
|
9350 | };
|
9351 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
9352 | attrs[i].start = args.start + args[0].match(/^\s*/).length;
|
9353 | attrs[i].end = args.end;
|
9354 | }
|
9355 | }
|
9356 |
|
9357 | if (!unary) {
|
9358 | stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
|
9359 | lastTag = tagName;
|
9360 | }
|
9361 |
|
9362 | if (options.start) {
|
9363 | options.start(tagName, attrs, unary, match.start, match.end);
|
9364 | }
|
9365 | }
|
9366 |
|
9367 | function parseEndTag (tagName, start, end) {
|
9368 | var pos, lowerCasedTagName;
|
9369 | if (start == null) { start = index; }
|
9370 | if (end == null) { end = index; }
|
9371 |
|
9372 |
|
9373 | if (tagName) {
|
9374 | lowerCasedTagName = tagName.toLowerCase();
|
9375 | for (pos = stack.length - 1; pos >= 0; pos--) {
|
9376 | if (stack[pos].lowerCasedTag === lowerCasedTagName) {
|
9377 | break
|
9378 | }
|
9379 | }
|
9380 | } else {
|
9381 |
|
9382 | pos = 0;
|
9383 | }
|
9384 |
|
9385 | if (pos >= 0) {
|
9386 |
|
9387 | for (var i = stack.length - 1; i >= pos; i--) {
|
9388 | if (process.env.NODE_ENV !== 'production' &&
|
9389 | (i > pos || !tagName) &&
|
9390 | options.warn
|
9391 | ) {
|
9392 | options.warn(
|
9393 | ("tag <" + (stack[i].tag) + "> has no matching end tag."),
|
9394 | { start: stack[i].start }
|
9395 | );
|
9396 | }
|
9397 | if (options.end) {
|
9398 | options.end(stack[i].tag, start, end);
|
9399 | }
|
9400 | }
|
9401 |
|
9402 |
|
9403 | stack.length = pos;
|
9404 | lastTag = pos && stack[pos - 1].tag;
|
9405 | } else if (lowerCasedTagName === 'br') {
|
9406 | if (options.start) {
|
9407 | options.start(tagName, [], true, start, end);
|
9408 | }
|
9409 | } else if (lowerCasedTagName === 'p') {
|
9410 | if (options.start) {
|
9411 | options.start(tagName, [], false, start, end);
|
9412 | }
|
9413 | if (options.end) {
|
9414 | options.end(tagName, start, end);
|
9415 | }
|
9416 | }
|
9417 | }
|
9418 | }
|
9419 |
|
9420 |
|
9421 |
|
9422 | var onRE = /^@|^v-on:/;
|
9423 | var dirRE = /^v-|^@|^:/;
|
9424 | var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
9425 | var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
9426 | var stripParensRE = /^\(|\)$/g;
|
9427 | var dynamicArgRE = /^\[.*\]$/;
|
9428 |
|
9429 | var argRE = /:(.*)$/;
|
9430 | var bindRE = /^:|^\.|^v-bind:/;
|
9431 | var modifierRE = /\.[^.]+/g;
|
9432 |
|
9433 | var slotRE = /^v-slot(:|$)|^#/;
|
9434 |
|
9435 | var lineBreakRE = /[\r\n]/;
|
9436 | var whitespaceRE$1 = /\s+/g;
|
9437 |
|
9438 | var invalidAttributeRE = /[\s"'<>\/=]/;
|
9439 |
|
9440 | var decodeHTMLCached = cached(he.decode);
|
9441 |
|
9442 |
|
9443 | var warn$2;
|
9444 | var delimiters;
|
9445 | var transforms;
|
9446 | var preTransforms;
|
9447 | var postTransforms;
|
9448 | var platformIsPreTag;
|
9449 | var platformMustUseProp;
|
9450 | var platformGetTagNamespace;
|
9451 | var maybeComponent;
|
9452 |
|
9453 | function createASTElement (
|
9454 | tag,
|
9455 | attrs,
|
9456 | parent
|
9457 | ) {
|
9458 | return {
|
9459 | type: 1,
|
9460 | tag: tag,
|
9461 | attrsList: attrs,
|
9462 | attrsMap: makeAttrsMap(attrs),
|
9463 | rawAttrsMap: {},
|
9464 | parent: parent,
|
9465 | children: []
|
9466 | }
|
9467 | }
|
9468 |
|
9469 |
|
9470 |
|
9471 |
|
9472 | function parse (
|
9473 | template,
|
9474 | options
|
9475 | ) {
|
9476 | warn$2 = options.warn || baseWarn;
|
9477 |
|
9478 | platformIsPreTag = options.isPreTag || no;
|
9479 | platformMustUseProp = options.mustUseProp || no;
|
9480 | platformGetTagNamespace = options.getTagNamespace || no;
|
9481 | var isReservedTag = options.isReservedTag || no;
|
9482 | maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
|
9483 |
|
9484 | transforms = pluckModuleFunction(options.modules, 'transformNode');
|
9485 | preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
|
9486 | postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
|
9487 |
|
9488 | delimiters = options.delimiters;
|
9489 |
|
9490 | var stack = [];
|
9491 | var preserveWhitespace = options.preserveWhitespace !== false;
|
9492 | var whitespaceOption = options.whitespace;
|
9493 | var root;
|
9494 | var currentParent;
|
9495 | var inVPre = false;
|
9496 | var inPre = false;
|
9497 | var warned = false;
|
9498 |
|
9499 | function warnOnce (msg, range) {
|
9500 | if (!warned) {
|
9501 | warned = true;
|
9502 | warn$2(msg, range);
|
9503 | }
|
9504 | }
|
9505 |
|
9506 | function closeElement (element) {
|
9507 | trimEndingWhitespace(element);
|
9508 | if (!inVPre && !element.processed) {
|
9509 | element = processElement(element, options);
|
9510 | }
|
9511 |
|
9512 | if (!stack.length && element !== root) {
|
9513 |
|
9514 | if (root.if && (element.elseif || element.else)) {
|
9515 | if (process.env.NODE_ENV !== 'production') {
|
9516 | checkRootConstraints(element);
|
9517 | }
|
9518 | addIfCondition(root, {
|
9519 | exp: element.elseif,
|
9520 | block: element
|
9521 | });
|
9522 | } else if (process.env.NODE_ENV !== 'production') {
|
9523 | warnOnce(
|
9524 | "Component template should contain exactly one root element. " +
|
9525 | "If you are using v-if on multiple elements, " +
|
9526 | "use v-else-if to chain them instead.",
|
9527 | { start: element.start }
|
9528 | );
|
9529 | }
|
9530 | }
|
9531 | if (currentParent && !element.forbidden) {
|
9532 | if (element.elseif || element.else) {
|
9533 | processIfConditions(element, currentParent);
|
9534 | } else {
|
9535 | if (element.slotScope) {
|
9536 |
|
9537 |
|
9538 |
|
9539 | var name = element.slotTarget || '"default"'
|
9540 | ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
|
9541 | }
|
9542 | currentParent.children.push(element);
|
9543 | element.parent = currentParent;
|
9544 | }
|
9545 | }
|
9546 |
|
9547 |
|
9548 |
|
9549 | element.children = element.children.filter(function (c) { return !(c).slotScope; });
|
9550 |
|
9551 | trimEndingWhitespace(element);
|
9552 |
|
9553 |
|
9554 | if (element.pre) {
|
9555 | inVPre = false;
|
9556 | }
|
9557 | if (platformIsPreTag(element.tag)) {
|
9558 | inPre = false;
|
9559 | }
|
9560 |
|
9561 | for (var i = 0; i < postTransforms.length; i++) {
|
9562 | postTransforms[i](element, options);
|
9563 | }
|
9564 | }
|
9565 |
|
9566 | function trimEndingWhitespace (el) {
|
9567 |
|
9568 | if (!inPre) {
|
9569 | var lastNode;
|
9570 | while (
|
9571 | (lastNode = el.children[el.children.length - 1]) &&
|
9572 | lastNode.type === 3 &&
|
9573 | lastNode.text === ' '
|
9574 | ) {
|
9575 | el.children.pop();
|
9576 | }
|
9577 | }
|
9578 | }
|
9579 |
|
9580 | function checkRootConstraints (el) {
|
9581 | if (el.tag === 'slot' || el.tag === 'template') {
|
9582 | warnOnce(
|
9583 | "Cannot use <" + (el.tag) + "> as component root element because it may " +
|
9584 | 'contain multiple nodes.',
|
9585 | { start: el.start }
|
9586 | );
|
9587 | }
|
9588 | if (el.attrsMap.hasOwnProperty('v-for')) {
|
9589 | warnOnce(
|
9590 | 'Cannot use v-for on stateful component root element because ' +
|
9591 | 'it renders multiple elements.',
|
9592 | el.rawAttrsMap['v-for']
|
9593 | );
|
9594 | }
|
9595 | }
|
9596 |
|
9597 | parseHTML(template, {
|
9598 | warn: warn$2,
|
9599 | expectHTML: options.expectHTML,
|
9600 | isUnaryTag: options.isUnaryTag,
|
9601 | canBeLeftOpenTag: options.canBeLeftOpenTag,
|
9602 | shouldDecodeNewlines: options.shouldDecodeNewlines,
|
9603 | shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
|
9604 | shouldKeepComment: options.comments,
|
9605 | outputSourceRange: options.outputSourceRange,
|
9606 | start: function start (tag, attrs, unary, start$1) {
|
9607 |
|
9608 |
|
9609 | var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
|
9610 |
|
9611 |
|
9612 |
|
9613 | if (isIE && ns === 'svg') {
|
9614 | attrs = guardIESVGBug(attrs);
|
9615 | }
|
9616 |
|
9617 | var element = createASTElement(tag, attrs, currentParent);
|
9618 | if (ns) {
|
9619 | element.ns = ns;
|
9620 | }
|
9621 |
|
9622 | if (process.env.NODE_ENV !== 'production') {
|
9623 | if (options.outputSourceRange) {
|
9624 | element.start = start$1;
|
9625 | element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
|
9626 | cumulated[attr.name] = attr;
|
9627 | return cumulated
|
9628 | }, {});
|
9629 | }
|
9630 | attrs.forEach(function (attr) {
|
9631 | if (invalidAttributeRE.test(attr.name)) {
|
9632 | warn$2(
|
9633 | "Invalid dynamic argument expression: attribute names cannot contain " +
|
9634 | "spaces, quotes, <, >, / or =.",
|
9635 | {
|
9636 | start: attr.start + attr.name.indexOf("["),
|
9637 | end: attr.start + attr.name.length
|
9638 | }
|
9639 | );
|
9640 | }
|
9641 | });
|
9642 | }
|
9643 |
|
9644 | if (isForbiddenTag(element) && !isServerRendering()) {
|
9645 | element.forbidden = true;
|
9646 | process.env.NODE_ENV !== 'production' && warn$2(
|
9647 | 'Templates should only be responsible for mapping the state to the ' +
|
9648 | 'UI. Avoid placing tags with side-effects in your templates, such as ' +
|
9649 | "<" + tag + ">" + ', as they will not be parsed.',
|
9650 | { start: element.start }
|
9651 | );
|
9652 | }
|
9653 |
|
9654 |
|
9655 | for (var i = 0; i < preTransforms.length; i++) {
|
9656 | element = preTransforms[i](element, options) || element;
|
9657 | }
|
9658 |
|
9659 | if (!inVPre) {
|
9660 | processPre(element);
|
9661 | if (element.pre) {
|
9662 | inVPre = true;
|
9663 | }
|
9664 | }
|
9665 | if (platformIsPreTag(element.tag)) {
|
9666 | inPre = true;
|
9667 | }
|
9668 | if (inVPre) {
|
9669 | processRawAttrs(element);
|
9670 | } else if (!element.processed) {
|
9671 |
|
9672 | processFor(element);
|
9673 | processIf(element);
|
9674 | processOnce(element);
|
9675 | }
|
9676 |
|
9677 | if (!root) {
|
9678 | root = element;
|
9679 | if (process.env.NODE_ENV !== 'production') {
|
9680 | checkRootConstraints(root);
|
9681 | }
|
9682 | }
|
9683 |
|
9684 | if (!unary) {
|
9685 | currentParent = element;
|
9686 | stack.push(element);
|
9687 | } else {
|
9688 | closeElement(element);
|
9689 | }
|
9690 | },
|
9691 |
|
9692 | end: function end (tag, start, end$1) {
|
9693 | var element = stack[stack.length - 1];
|
9694 |
|
9695 | stack.length -= 1;
|
9696 | currentParent = stack[stack.length - 1];
|
9697 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
9698 | element.end = end$1;
|
9699 | }
|
9700 | closeElement(element);
|
9701 | },
|
9702 |
|
9703 | chars: function chars (text, start, end) {
|
9704 | if (!currentParent) {
|
9705 | if (process.env.NODE_ENV !== 'production') {
|
9706 | if (text === template) {
|
9707 | warnOnce(
|
9708 | 'Component template requires a root element, rather than just text.',
|
9709 | { start: start }
|
9710 | );
|
9711 | } else if ((text = text.trim())) {
|
9712 | warnOnce(
|
9713 | ("text \"" + text + "\" outside root element will be ignored."),
|
9714 | { start: start }
|
9715 | );
|
9716 | }
|
9717 | }
|
9718 | return
|
9719 | }
|
9720 |
|
9721 |
|
9722 | if (isIE &&
|
9723 | currentParent.tag === 'textarea' &&
|
9724 | currentParent.attrsMap.placeholder === text
|
9725 | ) {
|
9726 | return
|
9727 | }
|
9728 | var children = currentParent.children;
|
9729 | if (inPre || text.trim()) {
|
9730 | text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
|
9731 | } else if (!children.length) {
|
9732 |
|
9733 | text = '';
|
9734 | } else if (whitespaceOption) {
|
9735 | if (whitespaceOption === 'condense') {
|
9736 |
|
9737 |
|
9738 | text = lineBreakRE.test(text) ? '' : ' ';
|
9739 | } else {
|
9740 | text = ' ';
|
9741 | }
|
9742 | } else {
|
9743 | text = preserveWhitespace ? ' ' : '';
|
9744 | }
|
9745 | if (text) {
|
9746 | if (whitespaceOption === 'condense') {
|
9747 |
|
9748 | text = text.replace(whitespaceRE$1, ' ');
|
9749 | }
|
9750 | var res;
|
9751 | var child;
|
9752 | if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
|
9753 | child = {
|
9754 | type: 2,
|
9755 | expression: res.expression,
|
9756 | tokens: res.tokens,
|
9757 | text: text
|
9758 | };
|
9759 | } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
|
9760 | child = {
|
9761 | type: 3,
|
9762 | text: text
|
9763 | };
|
9764 | }
|
9765 | if (child) {
|
9766 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
9767 | child.start = start;
|
9768 | child.end = end;
|
9769 | }
|
9770 | children.push(child);
|
9771 | }
|
9772 | }
|
9773 | },
|
9774 | comment: function comment (text, start, end) {
|
9775 | var child = {
|
9776 | type: 3,
|
9777 | text: text,
|
9778 | isComment: true
|
9779 | };
|
9780 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
9781 | child.start = start;
|
9782 | child.end = end;
|
9783 | }
|
9784 | currentParent.children.push(child);
|
9785 | }
|
9786 | });
|
9787 | return root
|
9788 | }
|
9789 |
|
9790 | function processPre (el) {
|
9791 | if (getAndRemoveAttr(el, 'v-pre') != null) {
|
9792 | el.pre = true;
|
9793 | }
|
9794 | }
|
9795 |
|
9796 | function processRawAttrs (el) {
|
9797 | var list = el.attrsList;
|
9798 | var len = list.length;
|
9799 | if (len) {
|
9800 | var attrs = el.attrs = new Array(len);
|
9801 | for (var i = 0; i < len; i++) {
|
9802 | attrs[i] = {
|
9803 | name: list[i].name,
|
9804 | value: JSON.stringify(list[i].value)
|
9805 | };
|
9806 | if (list[i].start != null) {
|
9807 | attrs[i].start = list[i].start;
|
9808 | attrs[i].end = list[i].end;
|
9809 | }
|
9810 | }
|
9811 | } else if (!el.pre) {
|
9812 |
|
9813 | el.plain = true;
|
9814 | }
|
9815 | }
|
9816 |
|
9817 | function processElement (
|
9818 | element,
|
9819 | options
|
9820 | ) {
|
9821 | processKey(element);
|
9822 |
|
9823 |
|
9824 |
|
9825 | element.plain = (
|
9826 | !element.key &&
|
9827 | !element.scopedSlots &&
|
9828 | !element.attrsList.length
|
9829 | );
|
9830 |
|
9831 | processRef(element);
|
9832 | processSlotContent(element);
|
9833 | processSlotOutlet(element);
|
9834 | processComponent(element);
|
9835 | for (var i = 0; i < transforms.length; i++) {
|
9836 | element = transforms[i](element, options) || element;
|
9837 | }
|
9838 | processAttrs(element);
|
9839 | return element
|
9840 | }
|
9841 |
|
9842 | function processKey (el) {
|
9843 | var exp = getBindingAttr(el, 'key');
|
9844 | if (exp) {
|
9845 | if (process.env.NODE_ENV !== 'production') {
|
9846 | if (el.tag === 'template') {
|
9847 | warn$2(
|
9848 | "<template> cannot be keyed. Place the key on real elements instead.",
|
9849 | getRawBindingAttr(el, 'key')
|
9850 | );
|
9851 | }
|
9852 | if (el.for) {
|
9853 | var iterator = el.iterator2 || el.iterator1;
|
9854 | var parent = el.parent;
|
9855 | if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
|
9856 | warn$2(
|
9857 | "Do not use v-for index as key on <transition-group> children, " +
|
9858 | "this is the same as not using keys.",
|
9859 | getRawBindingAttr(el, 'key'),
|
9860 | true
|
9861 | );
|
9862 | }
|
9863 | }
|
9864 | }
|
9865 | el.key = exp;
|
9866 | }
|
9867 | }
|
9868 |
|
9869 | function processRef (el) {
|
9870 | var ref = getBindingAttr(el, 'ref');
|
9871 | if (ref) {
|
9872 | el.ref = ref;
|
9873 | el.refInFor = checkInFor(el);
|
9874 | }
|
9875 | }
|
9876 |
|
9877 | function processFor (el) {
|
9878 | var exp;
|
9879 | if ((exp = getAndRemoveAttr(el, 'v-for'))) {
|
9880 | var res = parseFor(exp);
|
9881 | if (res) {
|
9882 | extend(el, res);
|
9883 | } else if (process.env.NODE_ENV !== 'production') {
|
9884 | warn$2(
|
9885 | ("Invalid v-for expression: " + exp),
|
9886 | el.rawAttrsMap['v-for']
|
9887 | );
|
9888 | }
|
9889 | }
|
9890 | }
|
9891 |
|
9892 |
|
9893 |
|
9894 | function parseFor (exp) {
|
9895 | var inMatch = exp.match(forAliasRE);
|
9896 | if (!inMatch) { return }
|
9897 | var res = {};
|
9898 | res.for = inMatch[2].trim();
|
9899 | var alias = inMatch[1].trim().replace(stripParensRE, '');
|
9900 | var iteratorMatch = alias.match(forIteratorRE);
|
9901 | if (iteratorMatch) {
|
9902 | res.alias = alias.replace(forIteratorRE, '').trim();
|
9903 | res.iterator1 = iteratorMatch[1].trim();
|
9904 | if (iteratorMatch[2]) {
|
9905 | res.iterator2 = iteratorMatch[2].trim();
|
9906 | }
|
9907 | } else {
|
9908 | res.alias = alias;
|
9909 | }
|
9910 | return res
|
9911 | }
|
9912 |
|
9913 | function processIf (el) {
|
9914 | var exp = getAndRemoveAttr(el, 'v-if');
|
9915 | if (exp) {
|
9916 | el.if = exp;
|
9917 | addIfCondition(el, {
|
9918 | exp: exp,
|
9919 | block: el
|
9920 | });
|
9921 | } else {
|
9922 | if (getAndRemoveAttr(el, 'v-else') != null) {
|
9923 | el.else = true;
|
9924 | }
|
9925 | var elseif = getAndRemoveAttr(el, 'v-else-if');
|
9926 | if (elseif) {
|
9927 | el.elseif = elseif;
|
9928 | }
|
9929 | }
|
9930 | }
|
9931 |
|
9932 | function processIfConditions (el, parent) {
|
9933 | var prev = findPrevElement(parent.children);
|
9934 | if (prev && prev.if) {
|
9935 | addIfCondition(prev, {
|
9936 | exp: el.elseif,
|
9937 | block: el
|
9938 | });
|
9939 | } else if (process.env.NODE_ENV !== 'production') {
|
9940 | warn$2(
|
9941 | "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
|
9942 | "used on element <" + (el.tag) + "> without corresponding v-if.",
|
9943 | el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
|
9944 | );
|
9945 | }
|
9946 | }
|
9947 |
|
9948 | function findPrevElement (children) {
|
9949 | var i = children.length;
|
9950 | while (i--) {
|
9951 | if (children[i].type === 1) {
|
9952 | return children[i]
|
9953 | } else {
|
9954 | if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
|
9955 | warn$2(
|
9956 | "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
|
9957 | "will be ignored.",
|
9958 | children[i]
|
9959 | );
|
9960 | }
|
9961 | children.pop();
|
9962 | }
|
9963 | }
|
9964 | }
|
9965 |
|
9966 | function addIfCondition (el, condition) {
|
9967 | if (!el.ifConditions) {
|
9968 | el.ifConditions = [];
|
9969 | }
|
9970 | el.ifConditions.push(condition);
|
9971 | }
|
9972 |
|
9973 | function processOnce (el) {
|
9974 | var once$$1 = getAndRemoveAttr(el, 'v-once');
|
9975 | if (once$$1 != null) {
|
9976 | el.once = true;
|
9977 | }
|
9978 | }
|
9979 |
|
9980 |
|
9981 |
|
9982 | function processSlotContent (el) {
|
9983 | var slotScope;
|
9984 | if (el.tag === 'template') {
|
9985 | slotScope = getAndRemoveAttr(el, 'scope');
|
9986 |
|
9987 | if (process.env.NODE_ENV !== 'production' && slotScope) {
|
9988 | warn$2(
|
9989 | "the \"scope\" attribute for scoped slots have been deprecated and " +
|
9990 | "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
|
9991 | "can also be used on plain elements in addition to <template> to " +
|
9992 | "denote scoped slots.",
|
9993 | el.rawAttrsMap['scope'],
|
9994 | true
|
9995 | );
|
9996 | }
|
9997 | el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
|
9998 | } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
|
9999 |
|
10000 | if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
|
10001 | warn$2(
|
10002 | "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
|
10003 | "(v-for takes higher priority). Use a wrapper <template> for the " +
|
10004 | "scoped slot to make it clearer.",
|
10005 | el.rawAttrsMap['slot-scope'],
|
10006 | true
|
10007 | );
|
10008 | }
|
10009 | el.slotScope = slotScope;
|
10010 | }
|
10011 |
|
10012 |
|
10013 | var slotTarget = getBindingAttr(el, 'slot');
|
10014 | if (slotTarget) {
|
10015 | el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
|
10016 | el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
|
10017 |
|
10018 |
|
10019 | if (el.tag !== 'template' && !el.slotScope) {
|
10020 | addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
|
10021 | }
|
10022 | }
|
10023 |
|
10024 |
|
10025 | {
|
10026 | if (el.tag === 'template') {
|
10027 |
|
10028 | var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
|
10029 | if (slotBinding) {
|
10030 | if (process.env.NODE_ENV !== 'production') {
|
10031 | if (el.slotTarget || el.slotScope) {
|
10032 | warn$2(
|
10033 | "Unexpected mixed usage of different slot syntaxes.",
|
10034 | el
|
10035 | );
|
10036 | }
|
10037 | if (el.parent && !maybeComponent(el.parent)) {
|
10038 | warn$2(
|
10039 | "<template v-slot> can only appear at the root level inside " +
|
10040 | "the receiving the component",
|
10041 | el
|
10042 | );
|
10043 | }
|
10044 | }
|
10045 | var ref = getSlotName(slotBinding);
|
10046 | var name = ref.name;
|
10047 | var dynamic = ref.dynamic;
|
10048 | el.slotTarget = name;
|
10049 | el.slotTargetDynamic = dynamic;
|
10050 | el.slotScope = slotBinding.value || "_";
|
10051 | }
|
10052 | } else {
|
10053 |
|
10054 | var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
|
10055 | if (slotBinding$1) {
|
10056 | if (process.env.NODE_ENV !== 'production') {
|
10057 | if (!maybeComponent(el)) {
|
10058 | warn$2(
|
10059 | "v-slot can only be used on components or <template>.",
|
10060 | slotBinding$1
|
10061 | );
|
10062 | }
|
10063 | if (el.slotScope || el.slotTarget) {
|
10064 | warn$2(
|
10065 | "Unexpected mixed usage of different slot syntaxes.",
|
10066 | el
|
10067 | );
|
10068 | }
|
10069 | if (el.scopedSlots) {
|
10070 | warn$2(
|
10071 | "To avoid scope ambiguity, the default slot should also use " +
|
10072 | "<template> syntax when there are other named slots.",
|
10073 | slotBinding$1
|
10074 | );
|
10075 | }
|
10076 | }
|
10077 |
|
10078 | var slots = el.scopedSlots || (el.scopedSlots = {});
|
10079 | var ref$1 = getSlotName(slotBinding$1);
|
10080 | var name$1 = ref$1.name;
|
10081 | var dynamic$1 = ref$1.dynamic;
|
10082 | var slotContainer = slots[name$1] = createASTElement('template', [], el);
|
10083 | slotContainer.slotTarget = name$1;
|
10084 | slotContainer.slotTargetDynamic = dynamic$1;
|
10085 | slotContainer.children = el.children.filter(function (c) { return !(c).slotScope; });
|
10086 | slotContainer.slotScope = slotBinding$1.value || "_";
|
10087 |
|
10088 | el.children = [];
|
10089 |
|
10090 | el.plain = false;
|
10091 | }
|
10092 | }
|
10093 | }
|
10094 | }
|
10095 |
|
10096 | function getSlotName (binding) {
|
10097 | var name = binding.name.replace(slotRE, '');
|
10098 | if (!name) {
|
10099 | if (binding.name[0] !== '#') {
|
10100 | name = 'default';
|
10101 | } else if (process.env.NODE_ENV !== 'production') {
|
10102 | warn$2(
|
10103 | "v-slot shorthand syntax requires a slot name.",
|
10104 | binding
|
10105 | );
|
10106 | }
|
10107 | }
|
10108 | return dynamicArgRE.test(name)
|
10109 |
|
10110 | ? { name: name.slice(1, -1), dynamic: true }
|
10111 |
|
10112 | : { name: ("\"" + name + "\""), dynamic: false }
|
10113 | }
|
10114 |
|
10115 |
|
10116 | function processSlotOutlet (el) {
|
10117 | if (el.tag === 'slot') {
|
10118 | el.slotName = getBindingAttr(el, 'name');
|
10119 | if (process.env.NODE_ENV !== 'production' && el.key) {
|
10120 | warn$2(
|
10121 | "`key` does not work on <slot> because slots are abstract outlets " +
|
10122 | "and can possibly expand into multiple elements. " +
|
10123 | "Use the key on a wrapping element instead.",
|
10124 | getRawBindingAttr(el, 'key')
|
10125 | );
|
10126 | }
|
10127 | }
|
10128 | }
|
10129 |
|
10130 | function processComponent (el) {
|
10131 | var binding;
|
10132 | if ((binding = getBindingAttr(el, 'is'))) {
|
10133 | el.component = binding;
|
10134 | }
|
10135 | if (getAndRemoveAttr(el, 'inline-template') != null) {
|
10136 | el.inlineTemplate = true;
|
10137 | }
|
10138 | }
|
10139 |
|
10140 | function processAttrs (el) {
|
10141 | var list = el.attrsList;
|
10142 | var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
|
10143 | for (i = 0, l = list.length; i < l; i++) {
|
10144 | name = rawName = list[i].name;
|
10145 | value = list[i].value;
|
10146 | if (dirRE.test(name)) {
|
10147 |
|
10148 | el.hasBindings = true;
|
10149 |
|
10150 | modifiers = parseModifiers(name.replace(dirRE, ''));
|
10151 |
|
10152 | if (modifiers) {
|
10153 | name = name.replace(modifierRE, '');
|
10154 | }
|
10155 | if (bindRE.test(name)) {
|
10156 | name = name.replace(bindRE, '');
|
10157 | value = parseFilters(value);
|
10158 | isDynamic = dynamicArgRE.test(name);
|
10159 | if (isDynamic) {
|
10160 | name = name.slice(1, -1);
|
10161 | }
|
10162 | if (
|
10163 | process.env.NODE_ENV !== 'production' &&
|
10164 | value.trim().length === 0
|
10165 | ) {
|
10166 | warn$2(
|
10167 | ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
|
10168 | );
|
10169 | }
|
10170 | if (modifiers) {
|
10171 | if (modifiers.prop && !isDynamic) {
|
10172 | name = camelize(name);
|
10173 | if (name === 'innerHtml') { name = 'innerHTML'; }
|
10174 | }
|
10175 | if (modifiers.camel && !isDynamic) {
|
10176 | name = camelize(name);
|
10177 | }
|
10178 | if (modifiers.sync) {
|
10179 | syncGen = genAssignmentCode(value, "$event");
|
10180 | if (!isDynamic) {
|
10181 | addHandler(
|
10182 | el,
|
10183 | ("update:" + (camelize(name))),
|
10184 | syncGen,
|
10185 | null,
|
10186 | false,
|
10187 | warn$2,
|
10188 | list[i]
|
10189 | );
|
10190 | if (hyphenate(name) !== camelize(name)) {
|
10191 | addHandler(
|
10192 | el,
|
10193 | ("update:" + (hyphenate(name))),
|
10194 | syncGen,
|
10195 | null,
|
10196 | false,
|
10197 | warn$2,
|
10198 | list[i]
|
10199 | );
|
10200 | }
|
10201 | } else {
|
10202 |
|
10203 | addHandler(
|
10204 | el,
|
10205 | ("\"update:\"+(" + name + ")"),
|
10206 | syncGen,
|
10207 | null,
|
10208 | false,
|
10209 | warn$2,
|
10210 | list[i],
|
10211 | true
|
10212 | );
|
10213 | }
|
10214 | }
|
10215 | }
|
10216 | if ((modifiers && modifiers.prop) || (
|
10217 | !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
|
10218 | )) {
|
10219 | addProp(el, name, value, list[i], isDynamic);
|
10220 | } else {
|
10221 | addAttr(el, name, value, list[i], isDynamic);
|
10222 | }
|
10223 | } else if (onRE.test(name)) {
|
10224 | name = name.replace(onRE, '');
|
10225 | isDynamic = dynamicArgRE.test(name);
|
10226 | if (isDynamic) {
|
10227 | name = name.slice(1, -1);
|
10228 | }
|
10229 | addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
|
10230 | } else {
|
10231 | name = name.replace(dirRE, '');
|
10232 |
|
10233 | var argMatch = name.match(argRE);
|
10234 | var arg = argMatch && argMatch[1];
|
10235 | isDynamic = false;
|
10236 | if (arg) {
|
10237 | name = name.slice(0, -(arg.length + 1));
|
10238 | if (dynamicArgRE.test(arg)) {
|
10239 | arg = arg.slice(1, -1);
|
10240 | isDynamic = true;
|
10241 | }
|
10242 | }
|
10243 | addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
|
10244 | if (process.env.NODE_ENV !== 'production' && name === 'model') {
|
10245 | checkForAliasModel(el, value);
|
10246 | }
|
10247 | }
|
10248 | } else {
|
10249 |
|
10250 | if (process.env.NODE_ENV !== 'production') {
|
10251 | var res = parseText(value, delimiters);
|
10252 | if (res) {
|
10253 | warn$2(
|
10254 | name + "=\"" + value + "\": " +
|
10255 | 'Interpolation inside attributes has been removed. ' +
|
10256 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
10257 | 'instead of <div id="{{ val }}">, use <div :id="val">.',
|
10258 | list[i]
|
10259 | );
|
10260 | }
|
10261 | }
|
10262 | addAttr(el, name, JSON.stringify(value), list[i]);
|
10263 |
|
10264 |
|
10265 | if (!el.component &&
|
10266 | name === 'muted' &&
|
10267 | platformMustUseProp(el.tag, el.attrsMap.type, name)) {
|
10268 | addProp(el, name, 'true', list[i]);
|
10269 | }
|
10270 | }
|
10271 | }
|
10272 | }
|
10273 |
|
10274 | function checkInFor (el) {
|
10275 | var parent = el;
|
10276 | while (parent) {
|
10277 | if (parent.for !== undefined) {
|
10278 | return true
|
10279 | }
|
10280 | parent = parent.parent;
|
10281 | }
|
10282 | return false
|
10283 | }
|
10284 |
|
10285 | function parseModifiers (name) {
|
10286 | var match = name.match(modifierRE);
|
10287 | if (match) {
|
10288 | var ret = {};
|
10289 | match.forEach(function (m) { ret[m.slice(1)] = true; });
|
10290 | return ret
|
10291 | }
|
10292 | }
|
10293 |
|
10294 | function makeAttrsMap (attrs) {
|
10295 | var map = {};
|
10296 | for (var i = 0, l = attrs.length; i < l; i++) {
|
10297 | if (
|
10298 | process.env.NODE_ENV !== 'production' &&
|
10299 | map[attrs[i].name] && !isIE && !isEdge
|
10300 | ) {
|
10301 | warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
|
10302 | }
|
10303 | map[attrs[i].name] = attrs[i].value;
|
10304 | }
|
10305 | return map
|
10306 | }
|
10307 |
|
10308 |
|
10309 | function isTextTag (el) {
|
10310 | return el.tag === 'script' || el.tag === 'style'
|
10311 | }
|
10312 |
|
10313 | function isForbiddenTag (el) {
|
10314 | return (
|
10315 | el.tag === 'style' ||
|
10316 | (el.tag === 'script' && (
|
10317 | !el.attrsMap.type ||
|
10318 | el.attrsMap.type === 'text/javascript'
|
10319 | ))
|
10320 | )
|
10321 | }
|
10322 |
|
10323 | var ieNSBug = /^xmlns:NS\d+/;
|
10324 | var ieNSPrefix = /^NS\d+:/;
|
10325 |
|
10326 |
|
10327 | function guardIESVGBug (attrs) {
|
10328 | var res = [];
|
10329 | for (var i = 0; i < attrs.length; i++) {
|
10330 | var attr = attrs[i];
|
10331 | if (!ieNSBug.test(attr.name)) {
|
10332 | attr.name = attr.name.replace(ieNSPrefix, '');
|
10333 | res.push(attr);
|
10334 | }
|
10335 | }
|
10336 | return res
|
10337 | }
|
10338 |
|
10339 | function checkForAliasModel (el, value) {
|
10340 | var _el = el;
|
10341 | while (_el) {
|
10342 | if (_el.for && _el.alias === value) {
|
10343 | warn$2(
|
10344 | "<" + (el.tag) + " v-model=\"" + value + "\">: " +
|
10345 | "You are binding v-model directly to a v-for iteration alias. " +
|
10346 | "This will not be able to modify the v-for source array because " +
|
10347 | "writing to the alias is like modifying a function local variable. " +
|
10348 | "Consider using an array of objects and use v-model on an object property instead.",
|
10349 | el.rawAttrsMap['v-model']
|
10350 | );
|
10351 | }
|
10352 | _el = _el.parent;
|
10353 | }
|
10354 | }
|
10355 |
|
10356 |
|
10357 |
|
10358 | function preTransformNode (el, options) {
|
10359 | if (el.tag === 'input') {
|
10360 | var map = el.attrsMap;
|
10361 | if (!map['v-model']) {
|
10362 | return
|
10363 | }
|
10364 |
|
10365 | var typeBinding;
|
10366 | if (map[':type'] || map['v-bind:type']) {
|
10367 | typeBinding = getBindingAttr(el, 'type');
|
10368 | }
|
10369 | if (!map.type && !typeBinding && map['v-bind']) {
|
10370 | typeBinding = "(" + (map['v-bind']) + ").type";
|
10371 | }
|
10372 |
|
10373 | if (typeBinding) {
|
10374 | var ifCondition = getAndRemoveAttr(el, 'v-if', true);
|
10375 | var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
|
10376 | var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
|
10377 | var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
|
10378 |
|
10379 | var branch0 = cloneASTElement(el);
|
10380 |
|
10381 | processFor(branch0);
|
10382 | addRawAttr(branch0, 'type', 'checkbox');
|
10383 | processElement(branch0, options);
|
10384 | branch0.processed = true;
|
10385 | branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
|
10386 | addIfCondition(branch0, {
|
10387 | exp: branch0.if,
|
10388 | block: branch0
|
10389 | });
|
10390 |
|
10391 | var branch1 = cloneASTElement(el);
|
10392 | getAndRemoveAttr(branch1, 'v-for', true);
|
10393 | addRawAttr(branch1, 'type', 'radio');
|
10394 | processElement(branch1, options);
|
10395 | addIfCondition(branch0, {
|
10396 | exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
|
10397 | block: branch1
|
10398 | });
|
10399 |
|
10400 | var branch2 = cloneASTElement(el);
|
10401 | getAndRemoveAttr(branch2, 'v-for', true);
|
10402 | addRawAttr(branch2, ':type', typeBinding);
|
10403 | processElement(branch2, options);
|
10404 | addIfCondition(branch0, {
|
10405 | exp: ifCondition,
|
10406 | block: branch2
|
10407 | });
|
10408 |
|
10409 | if (hasElse) {
|
10410 | branch0.else = true;
|
10411 | } else if (elseIfCondition) {
|
10412 | branch0.elseif = elseIfCondition;
|
10413 | }
|
10414 |
|
10415 | return branch0
|
10416 | }
|
10417 | }
|
10418 | }
|
10419 |
|
10420 | function cloneASTElement (el) {
|
10421 | return createASTElement(el.tag, el.attrsList.slice(), el.parent)
|
10422 | }
|
10423 |
|
10424 | var model$1 = {
|
10425 | preTransformNode: preTransformNode
|
10426 | };
|
10427 |
|
10428 | var modules$1 = [
|
10429 | klass$1,
|
10430 | style$1,
|
10431 | model$1
|
10432 | ];
|
10433 |
|
10434 |
|
10435 |
|
10436 | function text (el, dir) {
|
10437 | if (dir.value) {
|
10438 | addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
|
10439 | }
|
10440 | }
|
10441 |
|
10442 |
|
10443 |
|
10444 | function html (el, dir) {
|
10445 | if (dir.value) {
|
10446 | addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
|
10447 | }
|
10448 | }
|
10449 |
|
10450 | var directives$1 = {
|
10451 | model: model,
|
10452 | text: text,
|
10453 | html: html
|
10454 | };
|
10455 |
|
10456 |
|
10457 |
|
10458 | var baseOptions = {
|
10459 | expectHTML: true,
|
10460 | modules: modules$1,
|
10461 | directives: directives$1,
|
10462 | isPreTag: isPreTag,
|
10463 | isUnaryTag: isUnaryTag,
|
10464 | mustUseProp: mustUseProp,
|
10465 | canBeLeftOpenTag: canBeLeftOpenTag,
|
10466 | isReservedTag: isReservedTag,
|
10467 | getTagNamespace: getTagNamespace,
|
10468 | staticKeys: genStaticKeys(modules$1)
|
10469 | };
|
10470 |
|
10471 |
|
10472 |
|
10473 | var isStaticKey;
|
10474 | var isPlatformReservedTag;
|
10475 |
|
10476 | var genStaticKeysCached = cached(genStaticKeys$1);
|
10477 |
|
10478 |
|
10479 |
|
10480 |
|
10481 |
|
10482 |
|
10483 |
|
10484 |
|
10485 |
|
10486 |
|
10487 |
|
10488 |
|
10489 | function optimize (root, options) {
|
10490 | if (!root) { return }
|
10491 | isStaticKey = genStaticKeysCached(options.staticKeys || '');
|
10492 | isPlatformReservedTag = options.isReservedTag || no;
|
10493 |
|
10494 | markStatic$1(root);
|
10495 |
|
10496 | markStaticRoots(root, false);
|
10497 | }
|
10498 |
|
10499 | function genStaticKeys$1 (keys) {
|
10500 | return makeMap(
|
10501 | 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
|
10502 | (keys ? ',' + keys : '')
|
10503 | )
|
10504 | }
|
10505 |
|
10506 | function markStatic$1 (node) {
|
10507 | node.static = isStatic(node);
|
10508 | if (node.type === 1) {
|
10509 |
|
10510 |
|
10511 |
|
10512 | if (
|
10513 | !isPlatformReservedTag(node.tag) &&
|
10514 | node.tag !== 'slot' &&
|
10515 | node.attrsMap['inline-template'] == null
|
10516 | ) {
|
10517 | return
|
10518 | }
|
10519 | for (var i = 0, l = node.children.length; i < l; i++) {
|
10520 | var child = node.children[i];
|
10521 | markStatic$1(child);
|
10522 | if (!child.static) {
|
10523 | node.static = false;
|
10524 | }
|
10525 | }
|
10526 | if (node.ifConditions) {
|
10527 | for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
10528 | var block = node.ifConditions[i$1].block;
|
10529 | markStatic$1(block);
|
10530 | if (!block.static) {
|
10531 | node.static = false;
|
10532 | }
|
10533 | }
|
10534 | }
|
10535 | }
|
10536 | }
|
10537 |
|
10538 | function markStaticRoots (node, isInFor) {
|
10539 | if (node.type === 1) {
|
10540 | if (node.static || node.once) {
|
10541 | node.staticInFor = isInFor;
|
10542 | }
|
10543 |
|
10544 |
|
10545 |
|
10546 | if (node.static && node.children.length && !(
|
10547 | node.children.length === 1 &&
|
10548 | node.children[0].type === 3
|
10549 | )) {
|
10550 | node.staticRoot = true;
|
10551 | return
|
10552 | } else {
|
10553 | node.staticRoot = false;
|
10554 | }
|
10555 | if (node.children) {
|
10556 | for (var i = 0, l = node.children.length; i < l; i++) {
|
10557 | markStaticRoots(node.children[i], isInFor || !!node.for);
|
10558 | }
|
10559 | }
|
10560 | if (node.ifConditions) {
|
10561 | for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
10562 | markStaticRoots(node.ifConditions[i$1].block, isInFor);
|
10563 | }
|
10564 | }
|
10565 | }
|
10566 | }
|
10567 |
|
10568 | function isStatic (node) {
|
10569 | if (node.type === 2) {
|
10570 | return false
|
10571 | }
|
10572 | if (node.type === 3) {
|
10573 | return true
|
10574 | }
|
10575 | return !!(node.pre || (
|
10576 | !node.hasBindings &&
|
10577 | !node.if && !node.for &&
|
10578 | !isBuiltInTag(node.tag) &&
|
10579 | isPlatformReservedTag(node.tag) &&
|
10580 | !isDirectChildOfTemplateFor(node) &&
|
10581 | Object.keys(node).every(isStaticKey)
|
10582 | ))
|
10583 | }
|
10584 |
|
10585 | function isDirectChildOfTemplateFor (node) {
|
10586 | while (node.parent) {
|
10587 | node = node.parent;
|
10588 | if (node.tag !== 'template') {
|
10589 | return false
|
10590 | }
|
10591 | if (node.for) {
|
10592 | return true
|
10593 | }
|
10594 | }
|
10595 | return false
|
10596 | }
|
10597 |
|
10598 |
|
10599 |
|
10600 | var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
|
10601 | var fnInvokeRE = /\([^)]*?\);*$/;
|
10602 | var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
10603 |
|
10604 |
|
10605 | var keyCodes = {
|
10606 | esc: 27,
|
10607 | tab: 9,
|
10608 | enter: 13,
|
10609 | space: 32,
|
10610 | up: 38,
|
10611 | left: 37,
|
10612 | right: 39,
|
10613 | down: 40,
|
10614 | 'delete': [8, 46]
|
10615 | };
|
10616 |
|
10617 |
|
10618 | var keyNames = {
|
10619 |
|
10620 | esc: ['Esc', 'Escape'],
|
10621 | tab: 'Tab',
|
10622 | enter: 'Enter',
|
10623 |
|
10624 | space: [' ', 'Spacebar'],
|
10625 |
|
10626 | up: ['Up', 'ArrowUp'],
|
10627 | left: ['Left', 'ArrowLeft'],
|
10628 | right: ['Right', 'ArrowRight'],
|
10629 | down: ['Down', 'ArrowDown'],
|
10630 |
|
10631 | 'delete': ['Backspace', 'Delete', 'Del']
|
10632 | };
|
10633 |
|
10634 |
|
10635 |
|
10636 |
|
10637 | var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
|
10638 |
|
10639 | var modifierCode = {
|
10640 | stop: '$event.stopPropagation();',
|
10641 | prevent: '$event.preventDefault();',
|
10642 | self: genGuard("$event.target !== $event.currentTarget"),
|
10643 | ctrl: genGuard("!$event.ctrlKey"),
|
10644 | shift: genGuard("!$event.shiftKey"),
|
10645 | alt: genGuard("!$event.altKey"),
|
10646 | meta: genGuard("!$event.metaKey"),
|
10647 | left: genGuard("'button' in $event && $event.button !== 0"),
|
10648 | middle: genGuard("'button' in $event && $event.button !== 1"),
|
10649 | right: genGuard("'button' in $event && $event.button !== 2")
|
10650 | };
|
10651 |
|
10652 | function genHandlers (
|
10653 | events,
|
10654 | isNative
|
10655 | ) {
|
10656 | var prefix = isNative ? 'nativeOn:' : 'on:';
|
10657 | var staticHandlers = "";
|
10658 | var dynamicHandlers = "";
|
10659 | for (var name in events) {
|
10660 | var handlerCode = genHandler(events[name]);
|
10661 | if (events[name] && events[name].dynamic) {
|
10662 | dynamicHandlers += name + "," + handlerCode + ",";
|
10663 | } else {
|
10664 | staticHandlers += "\"" + name + "\":" + handlerCode + ",";
|
10665 | }
|
10666 | }
|
10667 | staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
|
10668 | if (dynamicHandlers) {
|
10669 | return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
|
10670 | } else {
|
10671 | return prefix + staticHandlers
|
10672 | }
|
10673 | }
|
10674 |
|
10675 | function genHandler (handler) {
|
10676 | if (!handler) {
|
10677 | return 'function(){}'
|
10678 | }
|
10679 |
|
10680 | if (Array.isArray(handler)) {
|
10681 | return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
|
10682 | }
|
10683 |
|
10684 | var isMethodPath = simplePathRE.test(handler.value);
|
10685 | var isFunctionExpression = fnExpRE.test(handler.value);
|
10686 | var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
|
10687 |
|
10688 | if (!handler.modifiers) {
|
10689 | if (isMethodPath || isFunctionExpression) {
|
10690 | return handler.value
|
10691 | }
|
10692 | return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}")
|
10693 | } else {
|
10694 | var code = '';
|
10695 | var genModifierCode = '';
|
10696 | var keys = [];
|
10697 | for (var key in handler.modifiers) {
|
10698 | if (modifierCode[key]) {
|
10699 | genModifierCode += modifierCode[key];
|
10700 |
|
10701 | if (keyCodes[key]) {
|
10702 | keys.push(key);
|
10703 | }
|
10704 | } else if (key === 'exact') {
|
10705 | var modifiers = (handler.modifiers);
|
10706 | genModifierCode += genGuard(
|
10707 | ['ctrl', 'shift', 'alt', 'meta']
|
10708 | .filter(function (keyModifier) { return !modifiers[keyModifier]; })
|
10709 | .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
|
10710 | .join('||')
|
10711 | );
|
10712 | } else {
|
10713 | keys.push(key);
|
10714 | }
|
10715 | }
|
10716 | if (keys.length) {
|
10717 | code += genKeyFilter(keys);
|
10718 | }
|
10719 |
|
10720 | if (genModifierCode) {
|
10721 | code += genModifierCode;
|
10722 | }
|
10723 | var handlerCode = isMethodPath
|
10724 | ? ("return " + (handler.value) + "($event)")
|
10725 | : isFunctionExpression
|
10726 | ? ("return (" + (handler.value) + ")($event)")
|
10727 | : isFunctionInvocation
|
10728 | ? ("return " + (handler.value))
|
10729 | : handler.value;
|
10730 | return ("function($event){" + code + handlerCode + "}")
|
10731 | }
|
10732 | }
|
10733 |
|
10734 | function genKeyFilter (keys) {
|
10735 | return ("if(('keyCode' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
|
10736 | }
|
10737 |
|
10738 | function genFilterCode (key) {
|
10739 | var keyVal = parseInt(key, 10);
|
10740 | if (keyVal) {
|
10741 | return ("$event.keyCode!==" + keyVal)
|
10742 | }
|
10743 | var keyCode = keyCodes[key];
|
10744 | var keyName = keyNames[key];
|
10745 | return (
|
10746 | "_k($event.keyCode," +
|
10747 | (JSON.stringify(key)) + "," +
|
10748 | (JSON.stringify(keyCode)) + "," +
|
10749 | "$event.key," +
|
10750 | "" + (JSON.stringify(keyName)) +
|
10751 | ")"
|
10752 | )
|
10753 | }
|
10754 |
|
10755 |
|
10756 |
|
10757 | function on (el, dir) {
|
10758 | if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
|
10759 | warn("v-on without argument does not support modifiers.");
|
10760 | }
|
10761 | el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
|
10762 | }
|
10763 |
|
10764 |
|
10765 |
|
10766 | function bind$1 (el, dir) {
|
10767 | el.wrapData = function (code) {
|
10768 | return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
|
10769 | };
|
10770 | }
|
10771 |
|
10772 |
|
10773 |
|
10774 | var baseDirectives = {
|
10775 | on: on,
|
10776 | bind: bind$1,
|
10777 | cloak: noop
|
10778 | };
|
10779 |
|
10780 |
|
10781 |
|
10782 |
|
10783 |
|
10784 |
|
10785 |
|
10786 | var CodegenState = function CodegenState (options) {
|
10787 | this.options = options;
|
10788 | this.warn = options.warn || baseWarn;
|
10789 | this.transforms = pluckModuleFunction(options.modules, 'transformCode');
|
10790 | this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
10791 | this.directives = extend(extend({}, baseDirectives), options.directives);
|
10792 | var isReservedTag = options.isReservedTag || no;
|
10793 | this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
|
10794 | this.onceId = 0;
|
10795 | this.staticRenderFns = [];
|
10796 | this.pre = false;
|
10797 | };
|
10798 |
|
10799 |
|
10800 |
|
10801 | function generate (
|
10802 | ast,
|
10803 | options
|
10804 | ) {
|
10805 | var state = new CodegenState(options);
|
10806 | var code = ast ? genElement(ast, state) : '_c("div")';
|
10807 | return {
|
10808 | render: ("with(this){return " + code + "}"),
|
10809 | staticRenderFns: state.staticRenderFns
|
10810 | }
|
10811 | }
|
10812 |
|
10813 | function genElement (el, state) {
|
10814 | if (el.parent) {
|
10815 | el.pre = el.pre || el.parent.pre;
|
10816 | }
|
10817 |
|
10818 | if (el.staticRoot && !el.staticProcessed) {
|
10819 | return genStatic(el, state)
|
10820 | } else if (el.once && !el.onceProcessed) {
|
10821 | return genOnce(el, state)
|
10822 | } else if (el.for && !el.forProcessed) {
|
10823 | return genFor(el, state)
|
10824 | } else if (el.if && !el.ifProcessed) {
|
10825 | return genIf(el, state)
|
10826 | } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
|
10827 | return genChildren(el, state) || 'void 0'
|
10828 | } else if (el.tag === 'slot') {
|
10829 | return genSlot(el, state)
|
10830 | } else {
|
10831 |
|
10832 | var code;
|
10833 | if (el.component) {
|
10834 | code = genComponent(el.component, el, state);
|
10835 | } else {
|
10836 | var data;
|
10837 | if (!el.plain || (el.pre && state.maybeComponent(el))) {
|
10838 | data = genData$2(el, state);
|
10839 | }
|
10840 |
|
10841 | var children = el.inlineTemplate ? null : genChildren(el, state, true);
|
10842 | code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
|
10843 | }
|
10844 |
|
10845 | for (var i = 0; i < state.transforms.length; i++) {
|
10846 | code = state.transforms[i](el, code);
|
10847 | }
|
10848 | return code
|
10849 | }
|
10850 | }
|
10851 |
|
10852 |
|
10853 | function genStatic (el, state) {
|
10854 | el.staticProcessed = true;
|
10855 |
|
10856 |
|
10857 |
|
10858 | var originalPreState = state.pre;
|
10859 | if (el.pre) {
|
10860 | state.pre = el.pre;
|
10861 | }
|
10862 | state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
|
10863 | state.pre = originalPreState;
|
10864 | return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
|
10865 | }
|
10866 |
|
10867 |
|
10868 | function genOnce (el, state) {
|
10869 | el.onceProcessed = true;
|
10870 | if (el.if && !el.ifProcessed) {
|
10871 | return genIf(el, state)
|
10872 | } else if (el.staticInFor) {
|
10873 | var key = '';
|
10874 | var parent = el.parent;
|
10875 | while (parent) {
|
10876 | if (parent.for) {
|
10877 | key = parent.key;
|
10878 | break
|
10879 | }
|
10880 | parent = parent.parent;
|
10881 | }
|
10882 | if (!key) {
|
10883 | process.env.NODE_ENV !== 'production' && state.warn(
|
10884 | "v-once can only be used inside v-for that is keyed. ",
|
10885 | el.rawAttrsMap['v-once']
|
10886 | );
|
10887 | return genElement(el, state)
|
10888 | }
|
10889 | return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
|
10890 | } else {
|
10891 | return genStatic(el, state)
|
10892 | }
|
10893 | }
|
10894 |
|
10895 | function genIf (
|
10896 | el,
|
10897 | state,
|
10898 | altGen,
|
10899 | altEmpty
|
10900 | ) {
|
10901 | el.ifProcessed = true;
|
10902 | return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
|
10903 | }
|
10904 |
|
10905 | function genIfConditions (
|
10906 | conditions,
|
10907 | state,
|
10908 | altGen,
|
10909 | altEmpty
|
10910 | ) {
|
10911 | if (!conditions.length) {
|
10912 | return altEmpty || '_e()'
|
10913 | }
|
10914 |
|
10915 | var condition = conditions.shift();
|
10916 | if (condition.exp) {
|
10917 | return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
|
10918 | } else {
|
10919 | return ("" + (genTernaryExp(condition.block)))
|
10920 | }
|
10921 |
|
10922 |
|
10923 | function genTernaryExp (el) {
|
10924 | return altGen
|
10925 | ? altGen(el, state)
|
10926 | : el.once
|
10927 | ? genOnce(el, state)
|
10928 | : genElement(el, state)
|
10929 | }
|
10930 | }
|
10931 |
|
10932 | function genFor (
|
10933 | el,
|
10934 | state,
|
10935 | altGen,
|
10936 | altHelper
|
10937 | ) {
|
10938 | var exp = el.for;
|
10939 | var alias = el.alias;
|
10940 | var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
|
10941 | var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
|
10942 |
|
10943 | if (process.env.NODE_ENV !== 'production' &&
|
10944 | state.maybeComponent(el) &&
|
10945 | el.tag !== 'slot' &&
|
10946 | el.tag !== 'template' &&
|
10947 | !el.key
|
10948 | ) {
|
10949 | state.warn(
|
10950 | "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
|
10951 | "v-for should have explicit keys. " +
|
10952 | "See https://vuejs.org/guide/list.html#key for more info.",
|
10953 | el.rawAttrsMap['v-for'],
|
10954 | true
|
10955 | );
|
10956 | }
|
10957 |
|
10958 | el.forProcessed = true;
|
10959 | return (altHelper || '_l') + "((" + exp + ")," +
|
10960 | "function(" + alias + iterator1 + iterator2 + "){" +
|
10961 | "return " + ((altGen || genElement)(el, state)) +
|
10962 | '})'
|
10963 | }
|
10964 |
|
10965 | function genData$2 (el, state) {
|
10966 | var data = '{';
|
10967 |
|
10968 |
|
10969 |
|
10970 | var dirs = genDirectives(el, state);
|
10971 | if (dirs) { data += dirs + ','; }
|
10972 |
|
10973 |
|
10974 | if (el.key) {
|
10975 | data += "key:" + (el.key) + ",";
|
10976 | }
|
10977 |
|
10978 | if (el.ref) {
|
10979 | data += "ref:" + (el.ref) + ",";
|
10980 | }
|
10981 | if (el.refInFor) {
|
10982 | data += "refInFor:true,";
|
10983 | }
|
10984 |
|
10985 | if (el.pre) {
|
10986 | data += "pre:true,";
|
10987 | }
|
10988 |
|
10989 | if (el.component) {
|
10990 | data += "tag:\"" + (el.tag) + "\",";
|
10991 | }
|
10992 |
|
10993 | for (var i = 0; i < state.dataGenFns.length; i++) {
|
10994 | data += state.dataGenFns[i](el);
|
10995 | }
|
10996 |
|
10997 | if (el.attrs) {
|
10998 | data += "attrs:" + (genProps(el.attrs)) + ",";
|
10999 | }
|
11000 |
|
11001 | if (el.props) {
|
11002 | data += "domProps:" + (genProps(el.props)) + ",";
|
11003 | }
|
11004 |
|
11005 | if (el.events) {
|
11006 | data += (genHandlers(el.events, false)) + ",";
|
11007 | }
|
11008 | if (el.nativeEvents) {
|
11009 | data += (genHandlers(el.nativeEvents, true)) + ",";
|
11010 | }
|
11011 |
|
11012 |
|
11013 | if (el.slotTarget && !el.slotScope) {
|
11014 | data += "slot:" + (el.slotTarget) + ",";
|
11015 | }
|
11016 |
|
11017 | if (el.scopedSlots) {
|
11018 | data += (genScopedSlots(el.scopedSlots, state)) + ",";
|
11019 | }
|
11020 |
|
11021 | if (el.model) {
|
11022 | data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
|
11023 | }
|
11024 |
|
11025 | if (el.inlineTemplate) {
|
11026 | var inlineTemplate = genInlineTemplate(el, state);
|
11027 | if (inlineTemplate) {
|
11028 | data += inlineTemplate + ",";
|
11029 | }
|
11030 | }
|
11031 | data = data.replace(/,$/, '') + '}';
|
11032 |
|
11033 |
|
11034 |
|
11035 | if (el.dynamicAttrs) {
|
11036 | data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
|
11037 | }
|
11038 |
|
11039 | if (el.wrapData) {
|
11040 | data = el.wrapData(data);
|
11041 | }
|
11042 |
|
11043 | if (el.wrapListeners) {
|
11044 | data = el.wrapListeners(data);
|
11045 | }
|
11046 | return data
|
11047 | }
|
11048 |
|
11049 | function genDirectives (el, state) {
|
11050 | var dirs = el.directives;
|
11051 | if (!dirs) { return }
|
11052 | var res = 'directives:[';
|
11053 | var hasRuntime = false;
|
11054 | var i, l, dir, needRuntime;
|
11055 | for (i = 0, l = dirs.length; i < l; i++) {
|
11056 | dir = dirs[i];
|
11057 | needRuntime = true;
|
11058 | var gen = state.directives[dir.name];
|
11059 | if (gen) {
|
11060 |
|
11061 |
|
11062 | needRuntime = !!gen(el, dir, state.warn);
|
11063 | }
|
11064 | if (needRuntime) {
|
11065 | hasRuntime = true;
|
11066 | 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))) : '') + "},";
|
11067 | }
|
11068 | }
|
11069 | if (hasRuntime) {
|
11070 | return res.slice(0, -1) + ']'
|
11071 | }
|
11072 | }
|
11073 |
|
11074 | function genInlineTemplate (el, state) {
|
11075 | var ast = el.children[0];
|
11076 | if (process.env.NODE_ENV !== 'production' && (
|
11077 | el.children.length !== 1 || ast.type !== 1
|
11078 | )) {
|
11079 | state.warn(
|
11080 | 'Inline-template components must have exactly one child element.',
|
11081 | { start: el.start }
|
11082 | );
|
11083 | }
|
11084 | if (ast.type === 1) {
|
11085 | var inlineRenderFns = generate(ast, state.options);
|
11086 | return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
|
11087 | }
|
11088 | }
|
11089 |
|
11090 | function genScopedSlots (
|
11091 | slots,
|
11092 | state
|
11093 | ) {
|
11094 | var hasDynamicKeys = Object.keys(slots).some(function (key) {
|
11095 | var slot = slots[key];
|
11096 | return slot.slotTargetDynamic || slot.if || slot.for
|
11097 | });
|
11098 | return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
|
11099 | return genScopedSlot(slots[key], state)
|
11100 | }).join(',')) + "]" + (hasDynamicKeys ? ",true" : "") + ")")
|
11101 | }
|
11102 |
|
11103 | function genScopedSlot (
|
11104 | el,
|
11105 | state
|
11106 | ) {
|
11107 | if (el.if && !el.ifProcessed) {
|
11108 | return genIf(el, state, genScopedSlot, "null")
|
11109 | }
|
11110 | if (el.for && !el.forProcessed) {
|
11111 | return genFor(el, state, genScopedSlot)
|
11112 | }
|
11113 | var fn = "function(" + (String(el.slotScope)) + "){" +
|
11114 | "return " + (el.tag === 'template'
|
11115 | ? genChildren(el, state) || 'undefined'
|
11116 | : genElement(el, state)) + "}";
|
11117 | return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + "}")
|
11118 | }
|
11119 |
|
11120 | function genChildren (
|
11121 | el,
|
11122 | state,
|
11123 | checkSkip,
|
11124 | altGenElement,
|
11125 | altGenNode
|
11126 | ) {
|
11127 | var children = el.children;
|
11128 | if (children.length) {
|
11129 | var el$1 = children[0];
|
11130 |
|
11131 | if (children.length === 1 &&
|
11132 | el$1.for &&
|
11133 | el$1.tag !== 'template' &&
|
11134 | el$1.tag !== 'slot'
|
11135 | ) {
|
11136 | var normalizationType = checkSkip
|
11137 | ? state.maybeComponent(el$1) ? ",1" : ",0"
|
11138 | : "";
|
11139 | return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
|
11140 | }
|
11141 | var normalizationType$1 = checkSkip
|
11142 | ? getNormalizationType(children, state.maybeComponent)
|
11143 | : 0;
|
11144 | var gen = altGenNode || genNode;
|
11145 | return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
|
11146 | }
|
11147 | }
|
11148 |
|
11149 |
|
11150 |
|
11151 |
|
11152 |
|
11153 | function getNormalizationType (
|
11154 | children,
|
11155 | maybeComponent
|
11156 | ) {
|
11157 | var res = 0;
|
11158 | for (var i = 0; i < children.length; i++) {
|
11159 | var el = children[i];
|
11160 | if (el.type !== 1) {
|
11161 | continue
|
11162 | }
|
11163 | if (needsNormalization(el) ||
|
11164 | (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
|
11165 | res = 2;
|
11166 | break
|
11167 | }
|
11168 | if (maybeComponent(el) ||
|
11169 | (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
|
11170 | res = 1;
|
11171 | }
|
11172 | }
|
11173 | return res
|
11174 | }
|
11175 |
|
11176 | function needsNormalization (el) {
|
11177 | return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
|
11178 | }
|
11179 |
|
11180 | function genNode (node, state) {
|
11181 | if (node.type === 1) {
|
11182 | return genElement(node, state)
|
11183 | } else if (node.type === 3 && node.isComment) {
|
11184 | return genComment(node)
|
11185 | } else {
|
11186 | return genText(node)
|
11187 | }
|
11188 | }
|
11189 |
|
11190 | function genText (text) {
|
11191 | return ("_v(" + (text.type === 2
|
11192 | ? text.expression
|
11193 | : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
|
11194 | }
|
11195 |
|
11196 | function genComment (comment) {
|
11197 | return ("_e(" + (JSON.stringify(comment.text)) + ")")
|
11198 | }
|
11199 |
|
11200 | function genSlot (el, state) {
|
11201 | var slotName = el.slotName || '"default"';
|
11202 | var children = genChildren(el, state);
|
11203 | var res = "_t(" + slotName + (children ? ("," + children) : '');
|
11204 | var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
|
11205 | var bind$$1 = el.attrsMap['v-bind'];
|
11206 | if ((attrs || bind$$1) && !children) {
|
11207 | res += ",null";
|
11208 | }
|
11209 | if (attrs) {
|
11210 | res += "," + attrs;
|
11211 | }
|
11212 | if (bind$$1) {
|
11213 | res += (attrs ? '' : ',null') + "," + bind$$1;
|
11214 | }
|
11215 | return res + ')'
|
11216 | }
|
11217 |
|
11218 |
|
11219 | function genComponent (
|
11220 | componentName,
|
11221 | el,
|
11222 | state
|
11223 | ) {
|
11224 | var children = el.inlineTemplate ? null : genChildren(el, state, true);
|
11225 | return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
|
11226 | }
|
11227 |
|
11228 | function genProps (props) {
|
11229 | var staticProps = "";
|
11230 | var dynamicProps = "";
|
11231 | for (var i = 0; i < props.length; i++) {
|
11232 | var prop = props[i];
|
11233 | var value = transformSpecialNewlines(prop.value);
|
11234 | if (prop.dynamic) {
|
11235 | dynamicProps += (prop.name) + "," + value + ",";
|
11236 | } else {
|
11237 | staticProps += "\"" + (prop.name) + "\":" + value + ",";
|
11238 | }
|
11239 | }
|
11240 | staticProps = "{" + (staticProps.slice(0, -1)) + "}";
|
11241 | if (dynamicProps) {
|
11242 | return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
|
11243 | } else {
|
11244 | return staticProps
|
11245 | }
|
11246 | }
|
11247 |
|
11248 |
|
11249 | function transformSpecialNewlines (text) {
|
11250 | return text
|
11251 | .replace(/\u2028/g, '\\u2028')
|
11252 | .replace(/\u2029/g, '\\u2029')
|
11253 | }
|
11254 |
|
11255 |
|
11256 |
|
11257 |
|
11258 |
|
11259 |
|
11260 |
|
11261 | var prohibitedKeywordRE = new RegExp('\\b' + (
|
11262 | 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
11263 | 'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
11264 | 'extends,finally,continue,debugger,function,arguments'
|
11265 | ).split(',').join('\\b|\\b') + '\\b');
|
11266 |
|
11267 |
|
11268 | var unaryOperatorsRE = new RegExp('\\b' + (
|
11269 | 'delete,typeof,void'
|
11270 | ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
|
11271 |
|
11272 |
|
11273 | var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
11274 |
|
11275 |
|
11276 | function detectErrors (ast, warn) {
|
11277 | if (ast) {
|
11278 | checkNode(ast, warn);
|
11279 | }
|
11280 | }
|
11281 |
|
11282 | function checkNode (node, warn) {
|
11283 | if (node.type === 1) {
|
11284 | for (var name in node.attrsMap) {
|
11285 | if (dirRE.test(name)) {
|
11286 | var value = node.attrsMap[name];
|
11287 | if (value) {
|
11288 | var range = node.rawAttrsMap[name];
|
11289 | if (name === 'v-for') {
|
11290 | checkFor(node, ("v-for=\"" + value + "\""), warn, range);
|
11291 | } else if (onRE.test(name)) {
|
11292 | checkEvent(value, (name + "=\"" + value + "\""), warn, range);
|
11293 | } else {
|
11294 | checkExpression(value, (name + "=\"" + value + "\""), warn, range);
|
11295 | }
|
11296 | }
|
11297 | }
|
11298 | }
|
11299 | if (node.children) {
|
11300 | for (var i = 0; i < node.children.length; i++) {
|
11301 | checkNode(node.children[i], warn);
|
11302 | }
|
11303 | }
|
11304 | } else if (node.type === 2) {
|
11305 | checkExpression(node.expression, node.text, warn, node);
|
11306 | }
|
11307 | }
|
11308 |
|
11309 | function checkEvent (exp, text, warn, range) {
|
11310 | var stipped = exp.replace(stripStringRE, '');
|
11311 | var keywordMatch = stipped.match(unaryOperatorsRE);
|
11312 | if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
|
11313 | warn(
|
11314 | "avoid using JavaScript unary operator as property name: " +
|
11315 | "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
|
11316 | range
|
11317 | );
|
11318 | }
|
11319 | checkExpression(exp, text, warn, range);
|
11320 | }
|
11321 |
|
11322 | function checkFor (node, text, warn, range) {
|
11323 | checkExpression(node.for || '', text, warn, range);
|
11324 | checkIdentifier(node.alias, 'v-for alias', text, warn, range);
|
11325 | checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
|
11326 | checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
|
11327 | }
|
11328 |
|
11329 | function checkIdentifier (
|
11330 | ident,
|
11331 | type,
|
11332 | text,
|
11333 | warn,
|
11334 | range
|
11335 | ) {
|
11336 | if (typeof ident === 'string') {
|
11337 | try {
|
11338 | new Function(("var " + ident + "=_"));
|
11339 | } catch (e) {
|
11340 | warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
|
11341 | }
|
11342 | }
|
11343 | }
|
11344 |
|
11345 | function checkExpression (exp, text, warn, range) {
|
11346 | try {
|
11347 | new Function(("return " + exp));
|
11348 | } catch (e) {
|
11349 | var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
|
11350 | if (keywordMatch) {
|
11351 | warn(
|
11352 | "avoid using JavaScript keyword as property name: " +
|
11353 | "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
|
11354 | range
|
11355 | );
|
11356 | } else {
|
11357 | warn(
|
11358 | "invalid expression: " + (e.message) + " in\n\n" +
|
11359 | " " + exp + "\n\n" +
|
11360 | " Raw expression: " + (text.trim()) + "\n",
|
11361 | range
|
11362 | );
|
11363 | }
|
11364 | }
|
11365 | }
|
11366 |
|
11367 |
|
11368 |
|
11369 | var range = 2;
|
11370 |
|
11371 | function generateCodeFrame (
|
11372 | source,
|
11373 | start,
|
11374 | end
|
11375 | ) {
|
11376 | if ( start === void 0 ) start = 0;
|
11377 | if ( end === void 0 ) end = source.length;
|
11378 |
|
11379 | var lines = source.split(/\r?\n/);
|
11380 | var count = 0;
|
11381 | var res = [];
|
11382 | for (var i = 0; i < lines.length; i++) {
|
11383 | count += lines[i].length + 1;
|
11384 | if (count >= start) {
|
11385 | for (var j = i - range; j <= i + range || end > count; j++) {
|
11386 | if (j < 0 || j >= lines.length) { continue }
|
11387 | res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
|
11388 | var lineLength = lines[j].length;
|
11389 | if (j === i) {
|
11390 |
|
11391 | var pad = start - (count - lineLength) + 1;
|
11392 | var length = end > count ? lineLength - pad : end - start;
|
11393 | res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
|
11394 | } else if (j > i) {
|
11395 | if (end > count) {
|
11396 | var length$1 = Math.min(end - count, lineLength);
|
11397 | res.push(" | " + repeat$1("^", length$1));
|
11398 | }
|
11399 | count += lineLength + 1;
|
11400 | }
|
11401 | }
|
11402 | break
|
11403 | }
|
11404 | }
|
11405 | return res.join('\n')
|
11406 | }
|
11407 |
|
11408 | function repeat$1 (str, n) {
|
11409 | var result = '';
|
11410 | while (true) {
|
11411 | if (n & 1) { result += str; }
|
11412 | n >>>= 1;
|
11413 | if (n <= 0) { break }
|
11414 | str += str;
|
11415 | }
|
11416 | return result
|
11417 | }
|
11418 |
|
11419 |
|
11420 |
|
11421 |
|
11422 |
|
11423 | function createFunction (code, errors) {
|
11424 | try {
|
11425 | return new Function(code)
|
11426 | } catch (err) {
|
11427 | errors.push({ err: err, code: code });
|
11428 | return noop
|
11429 | }
|
11430 | }
|
11431 |
|
11432 | function createCompileToFunctionFn (compile) {
|
11433 | var cache = Object.create(null);
|
11434 |
|
11435 | return function compileToFunctions (
|
11436 | template,
|
11437 | options,
|
11438 | vm
|
11439 | ) {
|
11440 | options = extend({}, options);
|
11441 | var warn$$1 = options.warn || warn;
|
11442 | delete options.warn;
|
11443 |
|
11444 |
|
11445 | if (process.env.NODE_ENV !== 'production') {
|
11446 |
|
11447 | try {
|
11448 | new Function('return 1');
|
11449 | } catch (e) {
|
11450 | if (e.toString().match(/unsafe-eval|CSP/)) {
|
11451 | warn$$1(
|
11452 | 'It seems you are using the standalone build of Vue.js in an ' +
|
11453 | 'environment with Content Security Policy that prohibits unsafe-eval. ' +
|
11454 | 'The template compiler cannot work in this environment. Consider ' +
|
11455 | 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
|
11456 | 'templates into render functions.'
|
11457 | );
|
11458 | }
|
11459 | }
|
11460 | }
|
11461 |
|
11462 |
|
11463 | var key = options.delimiters
|
11464 | ? String(options.delimiters) + template
|
11465 | : template;
|
11466 | if (cache[key]) {
|
11467 | return cache[key]
|
11468 | }
|
11469 |
|
11470 |
|
11471 | var compiled = compile(template, options);
|
11472 |
|
11473 |
|
11474 | if (process.env.NODE_ENV !== 'production') {
|
11475 | if (compiled.errors && compiled.errors.length) {
|
11476 | if (options.outputSourceRange) {
|
11477 | compiled.errors.forEach(function (e) {
|
11478 | warn$$1(
|
11479 | "Error compiling template:\n\n" + (e.msg) + "\n\n" +
|
11480 | generateCodeFrame(template, e.start, e.end),
|
11481 | vm
|
11482 | );
|
11483 | });
|
11484 | } else {
|
11485 | warn$$1(
|
11486 | "Error compiling template:\n\n" + template + "\n\n" +
|
11487 | compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
|
11488 | vm
|
11489 | );
|
11490 | }
|
11491 | }
|
11492 | if (compiled.tips && compiled.tips.length) {
|
11493 | if (options.outputSourceRange) {
|
11494 | compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
|
11495 | } else {
|
11496 | compiled.tips.forEach(function (msg) { return tip(msg, vm); });
|
11497 | }
|
11498 | }
|
11499 | }
|
11500 |
|
11501 |
|
11502 | var res = {};
|
11503 | var fnGenErrors = [];
|
11504 | res.render = createFunction(compiled.render, fnGenErrors);
|
11505 | res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
|
11506 | return createFunction(code, fnGenErrors)
|
11507 | });
|
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 |
|
11513 | if (process.env.NODE_ENV !== 'production') {
|
11514 | if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
|
11515 | warn$$1(
|
11516 | "Failed to generate render function:\n\n" +
|
11517 | fnGenErrors.map(function (ref) {
|
11518 | var err = ref.err;
|
11519 | var code = ref.code;
|
11520 |
|
11521 | return ((err.toString()) + " in\n\n" + code + "\n");
|
11522 | }).join('\n'),
|
11523 | vm
|
11524 | );
|
11525 | }
|
11526 | }
|
11527 |
|
11528 | return (cache[key] = res)
|
11529 | }
|
11530 | }
|
11531 |
|
11532 |
|
11533 |
|
11534 | function createCompilerCreator (baseCompile) {
|
11535 | return function createCompiler (baseOptions) {
|
11536 | function compile (
|
11537 | template,
|
11538 | options
|
11539 | ) {
|
11540 | var finalOptions = Object.create(baseOptions);
|
11541 | var errors = [];
|
11542 | var tips = [];
|
11543 |
|
11544 | var warn = function (msg, range, tip) {
|
11545 | (tip ? tips : errors).push(msg);
|
11546 | };
|
11547 |
|
11548 | if (options) {
|
11549 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
11550 |
|
11551 | var leadingSpaceLength = template.match(/^\s*/)[0].length;
|
11552 |
|
11553 | warn = function (msg, range, tip) {
|
11554 | var data = { msg: msg };
|
11555 | if (range) {
|
11556 | if (range.start != null) {
|
11557 | data.start = range.start + leadingSpaceLength;
|
11558 | }
|
11559 | if (range.end != null) {
|
11560 | data.end = range.end + leadingSpaceLength;
|
11561 | }
|
11562 | }
|
11563 | (tip ? tips : errors).push(data);
|
11564 | };
|
11565 | }
|
11566 |
|
11567 | if (options.modules) {
|
11568 | finalOptions.modules =
|
11569 | (baseOptions.modules || []).concat(options.modules);
|
11570 | }
|
11571 |
|
11572 | if (options.directives) {
|
11573 | finalOptions.directives = extend(
|
11574 | Object.create(baseOptions.directives || null),
|
11575 | options.directives
|
11576 | );
|
11577 | }
|
11578 |
|
11579 | for (var key in options) {
|
11580 | if (key !== 'modules' && key !== 'directives') {
|
11581 | finalOptions[key] = options[key];
|
11582 | }
|
11583 | }
|
11584 | }
|
11585 |
|
11586 | finalOptions.warn = warn;
|
11587 |
|
11588 | var compiled = baseCompile(template.trim(), finalOptions);
|
11589 | if (process.env.NODE_ENV !== 'production') {
|
11590 | detectErrors(compiled.ast, warn);
|
11591 | }
|
11592 | compiled.errors = errors;
|
11593 | compiled.tips = tips;
|
11594 | return compiled
|
11595 | }
|
11596 |
|
11597 | return {
|
11598 | compile: compile,
|
11599 | compileToFunctions: createCompileToFunctionFn(compile)
|
11600 | }
|
11601 | }
|
11602 | }
|
11603 |
|
11604 |
|
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 | var createCompiler = createCompilerCreator(function baseCompile (
|
11610 | template,
|
11611 | options
|
11612 | ) {
|
11613 | var ast = parse(template.trim(), options);
|
11614 | if (options.optimize !== false) {
|
11615 | optimize(ast, options);
|
11616 | }
|
11617 | var code = generate(ast, options);
|
11618 | return {
|
11619 | ast: ast,
|
11620 | render: code.render,
|
11621 | staticRenderFns: code.staticRenderFns
|
11622 | }
|
11623 | });
|
11624 |
|
11625 |
|
11626 |
|
11627 | var ref$1 = createCompiler(baseOptions);
|
11628 | var compile = ref$1.compile;
|
11629 | var compileToFunctions = ref$1.compileToFunctions;
|
11630 |
|
11631 |
|
11632 |
|
11633 |
|
11634 | var div;
|
11635 | function getShouldDecode (href) {
|
11636 | div = div || document.createElement('div');
|
11637 | div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
|
11638 | return div.innerHTML.indexOf(' ') > 0
|
11639 | }
|
11640 |
|
11641 |
|
11642 | var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
|
11643 |
|
11644 | var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
|
11645 |
|
11646 |
|
11647 |
|
11648 | var idToTemplate = cached(function (id) {
|
11649 | var el = query(id);
|
11650 | return el && el.innerHTML
|
11651 | });
|
11652 |
|
11653 | var mount = Vue.prototype.$mount;
|
11654 | Vue.prototype.$mount = function (
|
11655 | el,
|
11656 | hydrating
|
11657 | ) {
|
11658 | el = el && query(el);
|
11659 |
|
11660 |
|
11661 | if (el === document.body || el === document.documentElement) {
|
11662 | process.env.NODE_ENV !== 'production' && warn(
|
11663 | "Do not mount Vue to <html> or <body> - mount to normal elements instead."
|
11664 | );
|
11665 | return this
|
11666 | }
|
11667 |
|
11668 | var options = this.$options;
|
11669 |
|
11670 | if (!options.render) {
|
11671 | var template = options.template;
|
11672 | if (template) {
|
11673 | if (typeof template === 'string') {
|
11674 | if (template.charAt(0) === '#') {
|
11675 | template = idToTemplate(template);
|
11676 |
|
11677 | if (process.env.NODE_ENV !== 'production' && !template) {
|
11678 | warn(
|
11679 | ("Template element not found or is empty: " + (options.template)),
|
11680 | this
|
11681 | );
|
11682 | }
|
11683 | }
|
11684 | } else if (template.nodeType) {
|
11685 | template = template.innerHTML;
|
11686 | } else {
|
11687 | if (process.env.NODE_ENV !== 'production') {
|
11688 | warn('invalid template option:' + template, this);
|
11689 | }
|
11690 | return this
|
11691 | }
|
11692 | } else if (el) {
|
11693 | template = getOuterHTML(el);
|
11694 | }
|
11695 | if (template) {
|
11696 |
|
11697 | if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
|
11698 | mark('compile');
|
11699 | }
|
11700 |
|
11701 | var ref = compileToFunctions(template, {
|
11702 | outputSourceRange: process.env.NODE_ENV !== 'production',
|
11703 | shouldDecodeNewlines: shouldDecodeNewlines,
|
11704 | shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
|
11705 | delimiters: options.delimiters,
|
11706 | comments: options.comments
|
11707 | }, this);
|
11708 | var render = ref.render;
|
11709 | var staticRenderFns = ref.staticRenderFns;
|
11710 | options.render = render;
|
11711 | options.staticRenderFns = staticRenderFns;
|
11712 |
|
11713 |
|
11714 | if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
|
11715 | mark('compile end');
|
11716 | measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
|
11717 | }
|
11718 | }
|
11719 | }
|
11720 | return mount.call(this, el, hydrating)
|
11721 | };
|
11722 |
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 | function getOuterHTML (el) {
|
11728 | if (el.outerHTML) {
|
11729 | return el.outerHTML
|
11730 | } else {
|
11731 | var container = document.createElement('div');
|
11732 | container.appendChild(el.cloneNode(true));
|
11733 | return container.innerHTML
|
11734 | }
|
11735 | }
|
11736 |
|
11737 | Vue.compile = compileToFunctions;
|
11738 |
|
11739 | export default Vue;
|