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