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