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