1/*! 2 * Vue.js v2.7.14 3 * (c) 2014-2022 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 = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Vue = factory()); 10})(this, (function () { 'use strict'; 11 12 var emptyObject = Object.freeze({}); 13 var isArray = Array.isArray; 14 // These helpers produce better VM code in JS engines due to their 15 // explicitness and function inlining. 16 function isUndef(v) { 17 return v === undefined || v === null; 18 } 19 function isDef(v) { 20 return v !== undefined && v !== null; 21 } 22 function isTrue(v) { 23 return v === true; 24 } 25 function isFalse(v) { 26 return v === false; 27 } 28 /** 29 * Check if value is primitive. 30 */ 31 function isPrimitive(value) { 32 return (typeof value === 'string' || 33 typeof value === 'number' || 34 // $flow-disable-line 35 typeof value === 'symbol' || 36 typeof value === 'boolean'); 37 } 38 function isFunction(value) { 39 return typeof value === 'function'; 40 } 41 /** 42 * Quick object check - this is primarily used to tell 43 * objects from primitive values when we know the value 44 * is a JSON-compliant type. 45 */ 46 function isObject(obj) { 47 return obj !== null && typeof obj === 'object'; 48 } 49 /** 50 * Get the raw type string of a value, e.g., [object Object]. 51 */ 52 var _toString = Object.prototype.toString; 53 function toRawType(value) { 54 return _toString.call(value).slice(8, -1); 55 } 56 /** 57 * Strict object type check. Only returns true 58 * for plain JavaScript objects. 59 */ 60 function isPlainObject(obj) { 61 return _toString.call(obj) === '[object Object]'; 62 } 63 function isRegExp(v) { 64 return _toString.call(v) === '[object RegExp]'; 65 } 66 /** 67 * Check if val is a valid array index. 68 */ 69 function isValidArrayIndex(val) { 70 var n = parseFloat(String(val)); 71 return n >= 0 && Math.floor(n) === n && isFinite(val); 72 } 73 function isPromise(val) { 74 return (isDef(val) && 75 typeof val.then === 'function' && 76 typeof val.catch === 'function'); 77 } 78 /** 79 * Convert a value to a string that is actually rendered. 80 */ 81 function toString(val) { 82 return val == null 83 ? '' 84 : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString) 85 ? JSON.stringify(val, null, 2) 86 : String(val); 87 } 88 /** 89 * Convert an input value to a number for persistence. 90 * If the conversion fails, return original string. 91 */ 92 function toNumber(val) { 93 var n = parseFloat(val); 94 return isNaN(n) ? val : n; 95 } 96 /** 97 * Make a map and return a function for checking if a key 98 * is in that map. 99 */ 100 function makeMap(str, expectsLowerCase) { 101 var map = Object.create(null); 102 var list = str.split(','); 103 for (var i = 0; i < list.length; i++) { 104 map[list[i]] = true; 105 } 106 return expectsLowerCase ? function (val) { return map[val.toLowerCase()]; } : function (val) { return map[val]; }; 107 } 108 /** 109 * Check if a tag is a built-in tag. 110 */ 111 var isBuiltInTag = makeMap('slot,component', true); 112 /** 113 * Check if an attribute is a reserved attribute. 114 */ 115 var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); 116 /** 117 * Remove an item from an array. 118 */ 119 function remove$2(arr, item) { 120 var len = arr.length; 121 if (len) { 122 // fast path for the only / last item 123 if (item === arr[len - 1]) { 124 arr.length = len - 1; 125 return; 126 } 127 var index = arr.indexOf(item); 128 if (index > -1) { 129 return arr.splice(index, 1); 130 } 131 } 132 } 133 /** 134 * Check whether an object has the property. 135 */ 136 var hasOwnProperty = Object.prototype.hasOwnProperty; 137 function hasOwn(obj, key) { 138 return hasOwnProperty.call(obj, key); 139 } 140 /** 141 * Create a cached version of a pure function. 142 */ 143 function cached(fn) { 144 var cache = Object.create(null); 145 return function cachedFn(str) { 146 var hit = cache[str]; 147 return hit || (cache[str] = fn(str)); 148 }; 149 } 150 /** 151 * Camelize a hyphen-delimited string. 152 */ 153 var camelizeRE = /-(\w)/g; 154 var camelize = cached(function (str) { 155 return str.replace(camelizeRE, function (_, c) { return (c ? c.toUpperCase() : ''); }); 156 }); 157 /** 158 * Capitalize a string. 159 */ 160 var capitalize = cached(function (str) { 161 return str.charAt(0).toUpperCase() + str.slice(1); 162 }); 163 /** 164 * Hyphenate a camelCase string. 165 */ 166 var hyphenateRE = /\B([A-Z])/g; 167 var hyphenate = cached(function (str) { 168 return str.replace(hyphenateRE, '-$1').toLowerCase(); 169 }); 170 /** 171 * Simple bind polyfill for environments that do not support it, 172 * e.g., PhantomJS 1.x. Technically, we don't need this anymore 173 * since native bind is now performant enough in most browsers.
174 * But removing it would mean breaking code that was able to run in 175 * PhantomJS 1.x, so this must be kept for backward compatibility. 176 */ 177 /* istanbul ignore next */ 178 function polyfillBind(fn, ctx) { 179 function boundFn(a) { 180 var l = arguments.length; 181 return l 182 ? l > 1 183 ? fn.apply(ctx, arguments) 184 : fn.call(ctx, a) 185 : fn.call(ctx); 186 } 187 boundFn._length = fn.length; 188 return boundFn; 189 } 190 function nativeBind(fn, ctx) { 191 return fn.bind(ctx); 192 } 193 // @ts-expect-error bind cannot be `undefined` 194 var bind$1 = Function.prototype.bind ? nativeBind : polyfillBind; 195 /** 196 * Convert an Array-like object to a real Array. 197 */ 198 function toArray(list, start) { 199 start = start || 0; 200 var i = list.length - start; 201 var ret = new Array(i); 202 while (i--) { 203 ret[i] = list[i + start]; 204 } 205 return ret; 206 } 207 /** 208 * Mix properties into target object. 209 */ 210 function extend(to, _from) { 211 for (var key in _from) { 212 to[key] = _from[key]; 213 } 214 return to; 215 } 216 /** 217 * Merge an Array of Objects into a single Object. 218 */ 219 function toObject(arr) { 220 var res = {}; 221 for (var i = 0; i < arr.length; i++) { 222 if (arr[i]) { 223 extend(res, arr[i]); 224 } 225 } 226 return res; 227 } 228 /* eslint-disable no-unused-vars */ 229 /** 230 * Perform no operation. 231 * Stubbing args to make Flow happy without leaving useless transpiled code 232 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). 233 */ 234 function noop(a, b, c) { } 235 /** 236 * Always return false. 237 */ 238 var no = function (a, b, c) { return false; }; 239 /* eslint-enable no-unused-vars */ 240 /** 241 * Return the same value. 242 */ 243 var identity = function (_) { return _; }; 244 /** 245 * Generate a string containing static keys from compiler modules. 246 */ 247 function genStaticKeys$1(modules) { 248 return modules 249 .reduce(function (keys, m) { 250 return keys.concat(m.staticKeys || []); 251 }, []) 252 .join(','); 253 } 254 /** 255 * Check if two values are loosely equal - that is, 256 * if they are plain objects, do they have the same shape? 257 */ 258 function looseEqual(a, b) { 259 if (a === b) 260 return true; 261 var isObjectA = isObject(a); 262 var isObjectB = isObject(b); 263 if (isObjectA && isObjectB) { 264 try { 265 var isArrayA = Array.isArray(a); 266 var isArrayB = Array.isArray(b); 267 if (isArrayA && isArrayB) { 268 return (a.length === b.length && 269 a.every(function (e, i) { 270 return looseEqual(e, b[i]); 271 })); 272 } 273 else if (a instanceof Date && b instanceof Date) { 274 return a.getTime() === b.getTime(); 275 } 276 else if (!isArrayA && !isArrayB) { 277 var keysA = Object.keys(a); 278 var keysB = Object.keys(b); 279 return (keysA.length === keysB.length && 280 keysA.every(function (key) { 281 return looseEqual(a[key], b[key]); 282 })); 283 } 284 else { 285 /* istanbul ignore next */ 286 return false; 287 } 288 } 289 catch (e) { 290 /* istanbul ignore next */ 291 return false; 292 } 293 } 294 else if (!isObjectA && !isObjectB) { 295 return String(a) === String(b); 296 } 297 else { 298 return false; 299 } 300 } 301 /** 302 * Return the first index at which a loosely equal value can be 303 * found in the array (if value is a plain object, the array must 304 * contain an object of the same shape), or -1 if it is not present. 305 */ 306 function looseIndexOf(arr, val) { 307 for (var i = 0; i < arr.length; i++) { 308 if (looseEqual(arr[i], val)) 309 return i; 310 } 311 return -1; 312 } 313 /** 314 * Ensure a function is called only once. 315 */ 316 function once(fn) { 317 var called = false;
318 return function () { 319 if (!called) { 320 called = true; 321 fn.apply(this, arguments); 322 } 323 }; 324 } 325 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill 326 function hasChanged(x, y) { 327 if (x === y) { 328 return x === 0 && 1 / x !== 1 / y; 329 } 330 else { 331 return x === x || y === y; 332 } 333 } 334 335 var SSR_ATTR = 'data-server-rendered'; 336 var ASSET_TYPES = ['component', 'directive', 'filter']; 337 var LIFECYCLE_HOOKS = [ 338 'beforeCreate', 339 'created', 340 'beforeMount', 341 'mounted', 342 'beforeUpdate', 343 'updated', 344 'beforeDestroy', 345 'destroyed', 346 'activated', 347 'deactivated', 348 'errorCaptured', 349 'serverPrefetch', 350 'renderTracked', 351 'renderTriggered' 352 ]; 353 354 var config = { 355 /** 356 * Option merge strategies (used in core/util/options) 357 */ 358 // $flow-disable-line 359 optionMergeStrategies: Object.create(null), 360 /** 361 * Whether to suppress warnings. 362 */ 363 silent: false, 364 /** 365 * Show production mode tip message on boot? 366 */ 367 productionTip: true, 368 /** 369 * Whether to enable devtools 370 */ 371 devtools: true, 372 /** 373 * Whether to record perf 374 */ 375 performance: false, 376 /** 377 * Error handler for watcher errors 378 */ 379 errorHandler: null, 380 /** 381 * Warn handler for watcher warns 382 */ 383 warnHandler: null, 384 /** 385 * Ignore certain custom elements 386 */ 387 ignoredElements: [], 388 /** 389 * Custom user key aliases for v-on 390 */ 391 // $flow-disable-line 392 keyCodes: Object.create(null), 393 /** 394 * Check if a tag is reserved so that it cannot be registered as a 395 * component. This is platform-dependent and may be overwritten. 396 */ 397 isReservedTag: no, 398 /** 399 * Check if an attribute is reserved so that it cannot be used as a component 400 * prop. This is platform-dependent and may be overwritten. 401 */ 402 isReservedAttr: no, 403 /** 404 * Check if a tag is an unknown element. 405 * Platform-dependent. 406 */ 407 isUnknownElement: no, 408 /** 409 * Get the namespace of an element 410 */ 411 getTagNamespace: noop, 412 /** 413 * Parse the real tag name for the specific platform. 414 */ 415 parsePlatformTagName: identity, 416 /** 417 * Check if an attribute must be bound using property, e.g. value 418 * Platform-dependent. 419 */ 420 mustUseProp: no, 421 /** 422 * Perform updates asynchronously. Intended to be used by Vue Test Utils 423 * This will significantly reduce performance if set to false. 424 */ 425 async: true, 426 /** 427 * Exposed for legacy reasons 428 */ 429 _lifecycleHooks: LIFECYCLE_HOOKS 430 }; 431 432 /** 433 * unicode letters used for parsing html tags, component names and property paths. 434 * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname 435 * skipping \u10000-\uEFFFF due to it freezing up PhantomJS 436 */ 437 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/; 438 /** 439 * Check if a string starts with $ or _ 440 */ 441 function isReserved(str) { 442 var c = (str + '').charCodeAt(0); 443 return c === 0x24 || c === 0x5f; 444 } 445 /** 446 * Define a property. 447 */ 448 function def(obj, key, val, enumerable) { 449 Object.defineProperty(obj, key, { 450 value: val, 451 enumerable: !!enumerable, 452 writable: true, 453 configurable: true 454 }); 455 } 456 /** 457 * Parse simple path. 458 */ 459 var bailRE = new RegExp("[^".concat(unicodeRegExp.source, ".$_\\d]")); 460 function parsePath(path) { 461 if (bailRE.test(path)) { 462 return; 463 } 464 var segments = path.split('.'); 465 return function (obj) { 466 for (var i = 0; i < segments.length; i++) { 467 if (!obj) 468 return; 469 obj = obj[segments[i]]; 470 } 471 return obj; 472 }; 473 } 474 475 // can we use __proto__? 476 var hasProto = '__proto__' in {}; 477 // Browser environment sniffing 478 var inBrowser = typeof window !== 'undefined'; 479 var UA = inBrowser && window.navigator.userAgent.toLowerCase(); 480 var isIE = UA && /msie|trident/.test(UA); 481 var isIE9 = UA && UA.indexOf('msie 9.0') > 0; 482 var isEdge = UA && UA.indexOf('edge/') > 0; 483 UA && UA.indexOf('android') > 0; 484 var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); 485 UA && /chrome\/\d+/.test(UA) && !isEdge; 486 UA && /phantomjs/.test(UA); 487 var isFF = UA && UA.match(/firefox\/(\d+)/);
488 // Firefox has a "watch" function on Object.prototype... 489 // @ts-expect-error firebox support 490 var nativeWatch = {}.watch; 491 var supportsPassive = false; 492 if (inBrowser) { 493 try { 494 var opts = {}; 495 Object.defineProperty(opts, 'passive', { 496 get: function () { 497 /* istanbul ignore next */ 498 supportsPassive = true; 499 } 500 }); // https://github.com/facebook/flow/issues/285 501 window.addEventListener('test-passive', null, opts); 502 } 503 catch (e) { } 504 } 505 // this needs to be lazy-evaled because vue may be required before 506 // vue-server-renderer can set VUE_ENV 507 var _isServer; 508 var isServerRendering = function () { 509 if (_isServer === undefined) { 510 /* istanbul ignore if */ 511 if (!inBrowser && typeof global !== 'undefined') { 512 // detect presence of vue-server-renderer and avoid 513 // Webpack shimming the process 514 _isServer = 515 global['process'] && global['process'].env.VUE_ENV === 'server'; 516 } 517 else { 518 _isServer = false; 519 } 520 } 521 return _isServer; 522 }; 523 // detect devtools 524 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; 525 /* istanbul ignore next */ 526 function isNative(Ctor) { 527 return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); 528 } 529 var hasSymbol = typeof Symbol !== 'undefined' && 530 isNative(Symbol) && 531 typeof Reflect !== 'undefined' && 532 isNative(Reflect.ownKeys); 533 var _Set; // $flow-disable-line 534 /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) { 535 // use native Set when available. 536 _Set = Set; 537 } 538 else { 539 // a non-standard Set polyfill that only works with primitive keys. 540 _Set = /** @class */ (function () { 541 function Set() { 542 this.set = Object.create(null); 543 } 544 Set.prototype.has = function (key) { 545 return this.set[key] === true; 546 }; 547 Set.prototype.add = function (key) { 548 this.set[key] = true; 549 }; 550 Set.prototype.clear = function () { 551 this.set = Object.create(null); 552 }; 553 return Set; 554 }()); 555 } 556 557 var currentInstance = null; 558 /** 559 * This is exposed for compatibility with v3 (e.g. some functions in VueUse 560 * relies on it). Do not use this internally, just use `currentInstance`. 561 * 562 * @internal this function needs manual type declaration because it relies 563 * on previously manually authored types from Vue 2 564 */ 565 function getCurrentInstance() { 566 return currentInstance && { proxy: currentInstance }; 567 } 568 /** 569 * @internal 570 */ 571 function setCurrentInstance(vm) { 572 if (vm === void 0) { vm = null; } 573 if (!vm) 574 currentInstance && currentInstance._scope.off(); 575 currentInstance = vm; 576 vm && vm._scope.on(); 577 } 578 579 /** 580 * @internal 581 */ 582 var VNode = /** @class */ (function () { 583 function VNode(tag, data, children, text, elm, context, componentOptions, asyncFactory) { 584 this.tag = tag; 585 this.data = data; 586 this.children = children; 587 this.text = text; 588 this.elm = elm; 589 this.ns = undefined; 590 this.context = context; 591 this.fnContext = undefined; 592 this.fnOptions = undefined; 593 this.fnScopeId = undefined; 594 this.key = data && data.key; 595 this.componentOptions = componentOptions; 596 this.componentInstance = undefined; 597 this.parent = undefined; 598 this.raw = false; 599 this.isStatic = false; 600 this.isRootInsert = true; 601 this.isComment = false; 602 this.isCloned = false; 603 this.isOnce = false; 604 this.asyncFactory = asyncFactory; 605 this.asyncMeta = undefined; 606 this.isAsyncPlaceholder = false; 607 } 608 Object.defineProperty(VNode.prototype, "child", { 609 // DEPRECATED: alias for componentInstance for backwards compat. 610 /* istanbul ignore next */ 611 get: function () { 612 return this.componentInstance; 613 }, 614 enumerable: false, 615 configurable: true 616 }); 617 return VNode; 618 }()); 619 var createEmptyVNode = function (text) { 620 if (text === void 0) { text = ''; } 621 var node = new VNode(); 622 node.text = text; 623 node.isComment = true; 624 return node; 625 }; 626 function createTextVNode(val) { 627 return new VNode(undefined, undefined, undefined, String(val)); 628 } 629 // optimized shallow clone
630 // used for static nodes and slot nodes because they may be reused across 631 // multiple renders, cloning them avoids errors when DOM manipulations rely 632 // on their elm reference. 633 function cloneVNode(vnode) { 634 var cloned = new VNode(vnode.tag, vnode.data, 635 // #7975 636 // clone children array to avoid mutating original in case of cloning 637 // a child. 638 vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory); 639 cloned.ns = vnode.ns; 640 cloned.isStatic = vnode.isStatic; 641 cloned.key = vnode.key; 642 cloned.isComment = vnode.isComment; 643 cloned.fnContext = vnode.fnContext; 644 cloned.fnOptions = vnode.fnOptions; 645 cloned.fnScopeId = vnode.fnScopeId; 646 cloned.asyncMeta = vnode.asyncMeta; 647 cloned.isCloned = true; 648 return cloned; 649 } 650 651 /* not type checking this file because flow doesn't play well with Proxy */ 652 var initProxy; 653 { 654 var allowedGlobals_1 = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 655 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 656 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' + 657 'require' // for Webpack/Browserify 658 ); 659 var warnNonPresent_1 = function (target, key) { 660 warn$2("Property or method \"".concat(key, "\" is not defined on the instance but ") + 661 'referenced during render. Make sure that this property is reactive, ' + 662 'either in the data option, or for class-based components, by ' + 663 'initializing the property. ' + 664 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target); 665 }; 666 var warnReservedPrefix_1 = function (target, key) { 667 warn$2("Property \"".concat(key, "\" must be accessed with \"$data.").concat(key, "\" because ") + 668 'properties starting with "$" or "_" are not proxied in the Vue instance to ' + 669 'prevent conflicts with Vue internals. ' + 670 'See: https://v2.vuejs.org/v2/api/#data', target); 671 }; 672 var hasProxy_1 = typeof Proxy !== 'undefined' && isNative(Proxy); 673 if (hasProxy_1) { 674 var isBuiltInModifier_1 = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); 675 config.keyCodes = new Proxy(config.keyCodes, { 676 set: function (target, key, value) { 677 if (isBuiltInModifier_1(key)) { 678 warn$2("Avoid overwriting built-in modifier in config.keyCodes: .".concat(key)); 679 return false; 680 } 681 else { 682 target[key] = value; 683 return true; 684 } 685 } 686 }); 687 } 688 var hasHandler_1 = { 689 has: function (target, key) { 690 var has = key in target; 691 var isAllowed = allowedGlobals_1(key) || 692 (typeof key === 'string' && 693 key.charAt(0) === '_' && 694 !(key in target.$data)); 695 if (!has && !isAllowed) { 696 if (key in target.$data) 697 warnReservedPrefix_1(target, key); 698 else 699 warnNonPresent_1(target, key); 700 } 701 return has || !isAllowed; 702 } 703 }; 704 var getHandler_1 = { 705 get: function (target, key) { 706 if (typeof key === 'string' && !(key in target)) { 707 if (key in target.$data) 708 warnReservedPrefix_1(target, key); 709 else 710 warnNonPresent_1(target, key); 711 } 712 return target[key]; 713 } 714 }; 715 initProxy = function initProxy(vm) { 716 if (hasProxy_1) { 717 // determine which proxy handler to use 718 var options = vm.$options; 719 var handlers = options.render && options.render._withStripped ? getHandler_1 : hasHandler_1; 720 vm._renderProxy = new Proxy(vm, handlers); 721 } 722 else { 723 vm._renderProxy = vm; 724 } 725 }; 726 } 727 728 /****************************************************************************** 729 Copyright (c) Microsoft Corporation. 730 731 Permission to use, copy, modify, and/or distribute this software for any 732 purpose with or without fee is hereby granted. 733 734 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 735 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 736 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
737 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 738 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 739 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 740 PERFORMANCE OF THIS SOFTWARE. 741 ***************************************************************************** */ 742 743 var __assign = function() { 744 __assign = Object.assign || function __assign(t) { 745 for (var s, i = 1, n = arguments.length; i < n; i++) { 746 s = arguments[i]; 747 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 748 } 749 return t; 750 }; 751 return __assign.apply(this, arguments); 752 }; 753 754 var uid$2 = 0; 755 var pendingCleanupDeps = []; 756 var cleanupDeps = function () { 757 for (var i = 0; i < pendingCleanupDeps.length; i++) { 758 var dep = pendingCleanupDeps[i]; 759 dep.subs = dep.subs.filter(function (s) { return s; }); 760 dep._pending = false; 761 } 762 pendingCleanupDeps.length = 0; 763 }; 764 /** 765 * A dep is an observable that can have multiple 766 * directives subscribing to it. 767 * @internal 768 */ 769 var Dep = /** @class */ (function () { 770 function Dep() { 771 // pending subs cleanup 772 this._pending = false; 773 this.id = uid$2++; 774 this.subs = []; 775 } 776 Dep.prototype.addSub = function (sub) { 777 this.subs.push(sub); 778 }; 779 Dep.prototype.removeSub = function (sub) { 780 // #12696 deps with massive amount of subscribers are extremely slow to 781 // clean up in Chromium 782 // to workaround this, we unset the sub for now, and clear them on 783 // next scheduler flush. 784 this.subs[this.subs.indexOf(sub)] = null; 785 if (!this._pending) { 786 this._pending = true; 787 pendingCleanupDeps.push(this); 788 } 789 };
790 Dep.prototype.depend = function (info) { 791 if (Dep.target) { 792 Dep.target.addDep(this); 793 if (info && Dep.target.onTrack) { 794 Dep.target.onTrack(__assign({ effect: Dep.target }, info)); 795 } 796 } 797 }; 798 Dep.prototype.notify = function (info) { 799 // stabilize the subscriber list first 800 var subs = this.subs.filter(function (s) { return s; }); 801 if (!config.async) { 802 // subs aren't sorted in scheduler if not running async 803 // we need to sort them now to make sure they fire in correct 804 // order 805 subs.sort(function (a, b) { return a.id - b.id; }); 806 } 807 for (var i = 0, l = subs.length; i < l; i++) { 808 var sub = subs[i]; 809 if (info) { 810 sub.onTrigger && 811 sub.onTrigger(__assign({ effect: subs[i] }, info)); 812 } 813 sub.update(); 814 } 815 }; 816 return Dep; 817 }()); 818 // The current target watcher being evaluated. 819 // This is globally unique because only one watcher 820 // can be evaluated at a time. 821 Dep.target = null; 822 var targetStack = []; 823 function pushTarget(target) { 824 targetStack.push(target); 825 Dep.target = target; 826 } 827 function popTarget() { 828 targetStack.pop(); 829 Dep.target = targetStack[targetStack.length - 1]; 830 } 831 832 /* 833 * not type checking this file because flow doesn't play well with 834 * dynamically accessing methods on Array prototype 835 */ 836 var arrayProto = Array.prototype; 837 var arrayMethods = Object.create(arrayProto); 838 var methodsToPatch = [ 839 'push', 840 'pop', 841 'shift', 842 'unshift', 843 'splice', 844 'sort', 845 'reverse' 846 ]; 847 /** 848 * Intercept mutating methods and emit events 849 */ 850 methodsToPatch.forEach(function (method) { 851 // cache original method 852 var original = arrayProto[method]; 853 def(arrayMethods, method, function mutator() { 854 var args = []; 855 for (var _i = 0; _i < arguments.length; _i++) { 856 args[_i] = arguments[_i]; 857 } 858 var result = original.apply(this, args); 859 var ob = this.__ob__; 860 var inserted; 861 switch (method) { 862 case 'push': 863 case 'unshift': 864 inserted = args; 865 break; 866 case 'splice': 867 inserted = args.slice(2); 868 break; 869 } 870 if (inserted) 871 ob.observeArray(inserted); 872 // notify change 873 { 874 ob.dep.notify({ 875 type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */, 876 target: this, 877 key: method 878 }); 879 } 880 return result; 881 }); 882 }); 883 884 var arrayKeys = Object.getOwnPropertyNames(arrayMethods); 885 var NO_INIITIAL_VALUE = {}; 886 /** 887 * In some cases we may want to disable observation inside a component's 888 * update computation. 889 */ 890 var shouldObserve = true; 891 function toggleObserving(value) { 892 shouldObserve = value; 893 } 894 // ssr mock dep 895 var mockDep = { 896 notify: noop, 897 depend: noop, 898 addSub: noop, 899 removeSub: noop 900 }; 901 /** 902 * Observer class that is attached to each observed 903 * object. Once attached, the observer converts the target 904 * object's property keys into getter/setters that 905 * collect dependencies and dispatch updates. 906 */ 907 var Observer = /** @class */ (function () { 908 function Observer(value, shallow, mock) { 909 if (shallow === void 0) { shallow = false; } 910 if (mock === void 0) { mock = false; } 911 this.value = value; 912 this.shallow = shallow; 913 this.mock = mock; 914 // this.value = value 915 this.dep = mock ? mockDep : new Dep(); 916 this.vmCount = 0; 917 def(value, '__ob__', this); 918 if (isArray(value)) { 919 if (!mock) { 920 if (hasProto) { 921 value.__proto__ = arrayMethods; 922 /* eslint-enable no-proto */ 923 } 924 else { 925 for (var i = 0, l = arrayKeys.length; i < l; i++) { 926 var key = arrayKeys[i]; 927 def(value, key, arrayMethods[key]); 928 } 929 } 930 } 931 if (!shallow) { 932 this.observeArray(value); 933 } 934 } 935 else { 936 /** 937 * Walk through all properties and convert them into 938 * getter/setters. This method should only be called when 939 * value type is Object. 940 */ 941 var keys = Object.keys(value); 942 for (var i = 0; i < keys.length; i++) { 943 var key = keys[i]; 944 defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock); 945 } 946 } 947 } 948 /** 949 * Observe a list of Array items. 950 */ 951 Observer.prototype.observeArray = function (value) { 952 for (var i = 0, l = value.length; i < l; i++) { 953 observe(value[i], false, this.mock); 954 } 955 }; 956 return Observer; 957 }()); 958 // helpers 959 /** 960 * Attempt to create an observer instance for a value, 961 * returns the new observer if successfully observed, 962 * or the existing observer if the value already has one. 963 */ 964 function observe(value, shallow, ssrMockReactivity) { 965 if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { 966 return value.__ob__; 967 } 968 if (shouldObserve && 969 (ssrMockReactivity || !isServerRendering()) && 970 (isArray(value) || isPlainObject(value)) && 971 Object.isExtensible(value) && 972 !value.__v_skip /* ReactiveFlags.SKIP */ && 973 !isRef(value) && 974 !(value instanceof VNode)) { 975 return new Observer(value, shallow, ssrMockReactivity); 976 } 977 } 978 /** 979 * Define a reactive property on an Object. 980 */ 981 function defineReactive(obj, key, val, customSetter, shallow, mock) { 982 var dep = new Dep(); 983 var property = Object.getOwnPropertyDescriptor(obj, key); 984 if (property && property.configurable === false) { 985 return; 986 } 987 // cater for pre-defined getter/setters 988 var getter = property && property.get; 989 var setter = property && property.set; 990 if ((!getter || setter) && 991 (val === NO_INIITIAL_VALUE || arguments.length === 2)) { 992 val = obj[key]; 993 } 994 var childOb = !shallow && observe(val, false, mock); 995 Object.defineProperty(obj, key, { 996 enumerable: true, 997 configurable: true, 998 get: function reactiveGetter() { 999 var value = getter ? getter.call(obj) : val; 1000 if (Dep.target) { 1001 { 1002 dep.depend({ 1003 target: obj, 1004 type: "get" /* TrackOpTypes.GET */, 1005 key: key 1006 }); 1007 } 1008 if (childOb) { 1009 childOb.dep.depend(); 1010 if (isArray(value)) { 1011 dependArray(value); 1012 } 1013 } 1014 } 1015 return isRef(value) && !shallow ? value.value : value; 1016 }, 1017 set: function reactiveSetter(newVal) { 1018 var value = getter ? getter.call(obj) : val; 1019 if (!hasChanged(value, newVal)) { 1020 return; 1021 } 1022 if (customSetter) { 1023 customSetter(); 1024 } 1025 if (setter) { 1026 setter.call(obj, newVal); 1027 } 1028 else if (getter) { 1029 // #7981: for accessor properties without setter 1030 return; 1031 } 1032 else if (!shallow && isRef(value) && !isRef(newVal)) { 1033 value.value = newVal; 1034 return; 1035 } 1036 else { 1037 val = newVal; 1038 } 1039 childOb = !shallow && observe(newVal, false, mock); 1040 { 1041 dep.notify({ 1042 type: "set" /* TriggerOpTypes.SET */, 1043 target: obj, 1044 key: key, 1045 newValue: newVal, 1046 oldValue: value 1047 }); 1048 } 1049 } 1050 }); 1051 return dep; 1052 } 1053 function set(target, key, val) { 1054 if ((isUndef(target) || isPrimitive(target))) { 1055 warn$2("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); 1056 } 1057 if (isReadonly(target)) { 1058 warn$2("Set operation on key \"".concat(key, "\" failed: target is readonly.")); 1059 return; 1060 } 1061 var ob = target.__ob__; 1062 if (isArray(target) && isValidArrayIndex(key)) { 1063 target.length = Math.max(target.length, key); 1064 target.splice(key, 1, val); 1065 // when mocking for SSR, array methods are not hijacked 1066 if (ob && !ob.shallow && ob.mock) { 1067 observe(val, false, true); 1068 } 1069 return val; 1070 } 1071 if (key in target && !(key in Object.prototype)) { 1072 target[key] = val; 1073 return val; 1074 } 1075 if (target._isVue || (ob && ob.vmCount)) { 1076 warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' + 1077 'at runtime - declare it upfront in the data option.'); 1078 return val; 1079 } 1080 if (!ob) { 1081 target[key] = val; 1082 return val; 1083 } 1084 defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock); 1085 { 1086 ob.dep.notify({ 1087 type: "add" /* TriggerOpTypes.ADD */, 1088 target: target, 1089 key: key, 1090 newValue: val, 1091 oldValue: undefined 1092 }); 1093 } 1094 return val; 1095 } 1096 function del(target, key) { 1097 if ((isUndef(target) || isPrimitive(target))) { 1098 warn$2("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); 1099 } 1100 if (isArray(target) && isValidArrayIndex(key)) { 1101 target.splice(key, 1); 1102 return; 1103 } 1104 var ob = target.__ob__; 1105 if (target._isVue || (ob && ob.vmCount)) { 1106 warn$2('Avoid deleting properties on a Vue instance or its root $data ' +
1107 '- just set it to null.'); 1108 return; 1109 } 1110 if (isReadonly(target)) { 1111 warn$2("Delete operation on key \"".concat(key, "\" failed: target is readonly.")); 1112 return; 1113 } 1114 if (!hasOwn(target, key)) { 1115 return; 1116 } 1117 delete target[key]; 1118 if (!ob) { 1119 return; 1120 } 1121 { 1122 ob.dep.notify({ 1123 type: "delete" /* TriggerOpTypes.DELETE */, 1124 target: target, 1125 key: key 1126 }); 1127 } 1128 } 1129 /** 1130 * Collect dependencies on array elements when the array is touched, since 1131 * we cannot intercept array element access like property getters. 1132 */ 1133 function dependArray(value) { 1134 for (var e = void 0, i = 0, l = value.length; i < l; i++) { 1135 e = value[i]; 1136 if (e && e.__ob__) { 1137 e.__ob__.dep.depend(); 1138 } 1139 if (isArray(e)) { 1140 dependArray(e); 1141 } 1142 } 1143 } 1144 1145 function reactive(target) { 1146 makeReactive(target, false); 1147 return target; 1148 } 1149 /** 1150 * Return a shallowly-reactive copy of the original object, where only the root 1151 * level properties are reactive. It also does not auto-unwrap refs (even at the 1152 * root level). 1153 */ 1154 function shallowReactive(target) { 1155 makeReactive(target, true); 1156 def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true); 1157 return target; 1158 } 1159 function makeReactive(target, shallow) { 1160 // if trying to observe a readonly proxy, return the readonly version. 1161 if (!isReadonly(target)) { 1162 { 1163 if (isArray(target)) { 1164 warn$2("Avoid using Array as root value for ".concat(shallow ? "shallowReactive()" : "reactive()", " as it cannot be tracked in watch() or watchEffect(). Use ").concat(shallow ? "shallowRef()" : "ref()", " instead. This is a Vue-2-only limitation.")); 1165 } 1166 var existingOb = target && target.__ob__; 1167 if (existingOb && existingOb.shallow !== shallow) { 1168 warn$2("Target is already a ".concat(existingOb.shallow ? "" : "non-", "shallow reactive object, and cannot be converted to ").concat(shallow ? "" : "non-", "shallow.")); 1169 } 1170 } 1171 var ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */); 1172 if (!ob) { 1173 if (target == null || isPrimitive(target)) { 1174 warn$2("value cannot be made reactive: ".concat(String(target))); 1175 } 1176 if (isCollectionType(target)) { 1177 warn$2("Vue 2 does not support reactive collection types such as Map or Set."); 1178 } 1179 } 1180 } 1181 } 1182 function isReactive(value) { 1183 if (isReadonly(value)) { 1184 return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]); 1185 } 1186 return !!(value && value.__ob__); 1187 } 1188 function isShallow(value) { 1189 return !!(value && value.__v_isShallow); 1190 } 1191 function isReadonly(value) { 1192 return !!(value && value.__v_isReadonly); 1193 } 1194 function isProxy(value) { 1195 return isReactive(value) || isReadonly(value); 1196 } 1197 function toRaw(observed) { 1198 var raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */]; 1199 return raw ? toRaw(raw) : observed; 1200 } 1201 function markRaw(value) { 1202 // non-extensible objects won't be observed anyway 1203 if (Object.isExtensible(value)) { 1204 def(value, "__v_skip" /* ReactiveFlags.SKIP */, true); 1205 } 1206 return value; 1207 } 1208 /** 1209 * @internal 1210 */ 1211 function isCollectionType(value) { 1212 var type = toRawType(value); 1213 return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet'); 1214 } 1215 1216 /** 1217 * @internal 1218 */ 1219 var RefFlag = "__v_isRef"; 1220 function isRef(r) { 1221 return !!(r && r.__v_isRef === true); 1222 } 1223 function ref$1(value) { 1224 return createRef(value, false); 1225 } 1226 function shallowRef(value) { 1227 return createRef(value, true); 1228 } 1229 function createRef(rawValue, shallow) { 1230 if (isRef(rawValue)) { 1231 return rawValue; 1232 } 1233 var ref = {}; 1234 def(ref, RefFlag, true); 1235 def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow); 1236 def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering())); 1237 return ref; 1238 } 1239 function triggerRef(ref) { 1240 if (!ref.dep) { 1241 warn$2("received object is not a triggerable ref."); 1242 } 1243 { 1244 ref.dep && 1245 ref.dep.notify({ 1246 type: "set" /* TriggerOpTypes.SET */, 1247 target: ref, 1248 key: 'value' 1249 }); 1250 } 1251 } 1252 function unref(ref) { 1253 return isRef(ref) ? ref.value : ref; 1254 } 1255 function proxyRefs(objectWithRefs) { 1256 if (isReactive(objectWithRefs)) { 1257 return objectWithRefs; 1258 } 1259 var proxy = {}; 1260 var keys = Object.keys(objectWithRefs); 1261 for (var i = 0; i < keys.length; i++) { 1262 proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]); 1263 } 1264 return proxy; 1265 } 1266 function proxyWithRefUnwrap(target, source, key) { 1267 Object.defineProperty(target, key, { 1268 enumerable: true, 1269 configurable: true, 1270 get: function () { 1271 var val = source[key]; 1272 if (isRef(val)) { 1273 return val.value; 1274 } 1275 else { 1276 var ob = val && val.__ob__; 1277 if (ob) 1278 ob.dep.depend(); 1279 return val; 1280 } 1281 }, 1282 set: function (value) { 1283 var oldValue = source[key]; 1284 if (isRef(oldValue) && !isRef(value)) { 1285 oldValue.value = value; 1286 } 1287 else { 1288 source[key] = value; 1289 } 1290 } 1291 }); 1292 } 1293 function customRef(factory) { 1294 var dep = new Dep(); 1295 var _a = factory(function () { 1296 { 1297 dep.depend({ 1298 target: ref, 1299 type: "get" /* TrackOpTypes.GET */, 1300 key: 'value' 1301 }); 1302 } 1303 }, function () { 1304 { 1305 dep.notify({ 1306 target: ref, 1307 type: "set" /* TriggerOpTypes.SET */, 1308 key: 'value' 1309 }); 1310 } 1311 }), get = _a.get, set = _a.set; 1312 var ref = { 1313 get value() { 1314 return get(); 1315 }, 1316 set value(newVal) { 1317 set(newVal); 1318 } 1319 }; 1320 def(ref, RefFlag, true); 1321 return ref; 1322 } 1323 function toRefs(object) { 1324 if (!isReactive(object)) { 1325 warn$2("toRefs() expects a reactive object but received a plain one."); 1326 } 1327 var ret = isArray(object) ? new Array(object.length) : {}; 1328 for (var key in object) { 1329 ret[key] = toRef(object, key); 1330 } 1331 return ret; 1332 } 1333 function toRef(object, key, defaultValue) { 1334 var val = object[key]; 1335 if (isRef(val)) { 1336 return val; 1337 } 1338 var ref = { 1339 get value() { 1340 var val = object[key]; 1341 return val === undefined ? defaultValue : val; 1342 }, 1343 set value(newVal) { 1344 object[key] = newVal; 1345 } 1346 }; 1347 def(ref, RefFlag, true); 1348 return ref; 1349 } 1350 1351 var rawToReadonlyFlag = "__v_rawToReadonly"; 1352 var rawToShallowReadonlyFlag = "__v_rawToShallowReadonly"; 1353 function readonly(target) { 1354 return createReadonly(target, false); 1355 } 1356 function createReadonly(target, shallow) { 1357 if (!isPlainObject(target)) { 1358 { 1359 if (isArray(target)) { 1360 warn$2("Vue 2 does not support readonly arrays."); 1361 } 1362 else if (isCollectionType(target)) { 1363 warn$2("Vue 2 does not support readonly collection types such as Map or Set."); 1364 } 1365 else { 1366 warn$2("value cannot be made readonly: ".concat(typeof target)); 1367 } 1368 } 1369 return target; 1370 } 1371 if (!Object.isExtensible(target)) { 1372 warn$2("Vue 2 does not support creating readonly proxy for non-extensible object."); 1373 } 1374 // already a readonly object 1375 if (isReadonly(target)) { 1376 return target; 1377 } 1378 // already has a readonly proxy 1379 var existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag; 1380 var existingProxy = target[existingFlag]; 1381 if (existingProxy) { 1382 return existingProxy; 1383 } 1384 var proxy = Object.create(Object.getPrototypeOf(target)); 1385 def(target, existingFlag, proxy); 1386 def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true); 1387 def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target); 1388 if (isRef(target)) { 1389 def(proxy, RefFlag, true); 1390 } 1391 if (shallow || isShallow(target)) { 1392 def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true); 1393 } 1394 var keys = Object.keys(target); 1395 for (var i = 0; i < keys.length; i++) { 1396 defineReadonlyProperty(proxy, target, keys[i], shallow); 1397 } 1398 return proxy; 1399 } 1400 function defineReadonlyProperty(proxy, target, key, shallow) { 1401 Object.defineProperty(proxy, key, { 1402 enumerable: true, 1403 configurable: true, 1404 get: function () { 1405 var val = target[key]; 1406 return shallow || !isPlainObject(val) ? val : readonly(val); 1407 }, 1408 set: function () { 1409 warn$2("Set operation on key \"".concat(key, "\" failed: target is readonly.")); 1410 } 1411 }); 1412 } 1413 /** 1414 * Returns a reactive-copy of the original object, where only the root level 1415 * properties are readonly, and does NOT unwrap refs nor recursively convert 1416 * returned properties. 1417 * This is used for creating the props proxy object for stateful components. 1418 */ 1419 function shallowReadonly(target) { 1420 return createReadonly(target, true); 1421 } 1422 1423 function computed(getterOrOptions, debugOptions) { 1424 var getter; 1425 var setter; 1426 var onlyGetter = isFunction(getterOrOptions); 1427 if (onlyGetter) { 1428 getter = getterOrOptions; 1429 setter = function () { 1430 warn$2('Write operation failed: computed value is readonly'); 1431 } 1432 ; 1433 } 1434 else { 1435 getter = getterOrOptions.get; 1436 setter = getterOrOptions.set; 1437 } 1438 var watcher = isServerRendering() 1439 ? null 1440 : new Watcher(currentInstance, getter, noop, { lazy: true }); 1441 if (watcher && debugOptions) { 1442 watcher.onTrack = debugOptions.onTrack; 1443 watcher.onTrigger = debugOptions.onTrigger; 1444 } 1445 var ref = { 1446 // some libs rely on the presence effect for checking computed refs 1447 // from normal refs, but the implementation doesn't matter 1448 effect: watcher, 1449 get value() { 1450 if (watcher) { 1451 if (watcher.dirty) { 1452 watcher.evaluate(); 1453 } 1454 if (Dep.target) { 1455 if (Dep.target.onTrack) { 1456 Dep.target.onTrack({ 1457 effect: Dep.target, 1458 target: ref, 1459 type: "get" /* TrackOpTypes.GET */, 1460 key: 'value' 1461 }); 1462 }
1463 watcher.depend(); 1464 } 1465 return watcher.value; 1466 } 1467 else { 1468 return getter(); 1469 } 1470 }, 1471 set value(newVal) { 1472 setter(newVal); 1473 } 1474 }; 1475 def(ref, RefFlag, true); 1476 def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter); 1477 return ref; 1478 } 1479 1480 var mark; 1481 var measure; 1482 { 1483 var perf_1 = inBrowser && window.performance; 1484 /* istanbul ignore if */ 1485 if (perf_1 && 1486 // @ts-ignore 1487 perf_1.mark && 1488 // @ts-ignore 1489 perf_1.measure && 1490 // @ts-ignore 1491 perf_1.clearMarks && 1492 // @ts-ignore 1493 perf_1.clearMeasures) { 1494 mark = function (tag) { return perf_1.mark(tag); }; 1495 measure = function (name, startTag, endTag) { 1496 perf_1.measure(name, startTag, endTag); 1497 perf_1.clearMarks(startTag); 1498 perf_1.clearMarks(endTag); 1499 // perf.clearMeasures(name) 1500 }; 1501 } 1502 } 1503 1504 var normalizeEvent = cached(function (name) { 1505 var passive = name.charAt(0) === '&'; 1506 name = passive ? name.slice(1) : name; 1507 var once = name.charAt(0) === '~'; // Prefixed last, checked first 1508 name = once ? name.slice(1) : name; 1509 var capture = name.charAt(0) === '!'; 1510 name = capture ? name.slice(1) : name; 1511 return { 1512 name: name, 1513 once: once, 1514 capture: capture, 1515 passive: passive 1516 }; 1517 }); 1518 function createFnInvoker(fns, vm) { 1519 function invoker() { 1520 var fns = invoker.fns; 1521 if (isArray(fns)) { 1522 var cloned = fns.slice(); 1523 for (var i = 0; i < cloned.length; i++) { 1524 invokeWithErrorHandling(cloned[i], null, arguments, vm, "v-on handler"); 1525 } 1526 } 1527 else { 1528 // return handler return value for single handlers 1529 return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler"); 1530 } 1531 } 1532 invoker.fns = fns; 1533 return invoker; 1534 } 1535 function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) { 1536 var name, cur, old, event; 1537 for (name in on) { 1538 cur = on[name]; 1539 old = oldOn[name]; 1540 event = normalizeEvent(name); 1541 if (isUndef(cur)) { 1542 warn$2("Invalid handler for event \"".concat(event.name, "\": got ") + String(cur), vm); 1543 } 1544 else if (isUndef(old)) { 1545 if (isUndef(cur.fns)) { 1546 cur = on[name] = createFnInvoker(cur, vm); 1547 } 1548 if (isTrue(event.once)) { 1549 cur = on[name] = createOnceHandler(event.name, cur, event.capture); 1550 } 1551 add(event.name, cur, event.capture, event.passive, event.params); 1552 } 1553 else if (cur !== old) { 1554 old.fns = cur; 1555 on[name] = old; 1556 } 1557 } 1558 for (name in oldOn) { 1559 if (isUndef(on[name])) { 1560 event = normalizeEvent(name); 1561 remove(event.name, oldOn[name], event.capture); 1562 } 1563 } 1564 } 1565 1566 function mergeVNodeHook(def, hookKey, hook) { 1567 if (def instanceof VNode) { 1568 def = def.data.hook || (def.data.hook = {}); 1569 } 1570 var invoker; 1571 var oldHook = def[hookKey]; 1572 function wrappedHook() { 1573 hook.apply(this, arguments); 1574 // important: remove merged hook to ensure it's called only once 1575 // and prevent memory leak 1576 remove$2(invoker.fns, wrappedHook); 1577 } 1578 if (isUndef(oldHook)) { 1579 // no existing hook 1580 invoker = createFnInvoker([wrappedHook]); 1581 } 1582 else { 1583 /* istanbul ignore if */ 1584 if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { 1585 // already a merged invoker 1586 invoker = oldHook; 1587 invoker.fns.push(wrappedHook); 1588 } 1589 else { 1590 // existing plain hook 1591 invoker = createFnInvoker([oldHook, wrappedHook]); 1592 } 1593 } 1594 invoker.merged = true; 1595 def[hookKey] = invoker; 1596 } 1597 1598 function extractPropsFromVNodeData(data, Ctor, tag) { 1599 // we are only extracting raw values here. 1600 // validation and default values are handled in the child 1601 // component itself. 1602 var propOptions = Ctor.options.props; 1603 if (isUndef(propOptions)) { 1604 return; 1605 } 1606 var res = {}; 1607 var attrs = data.attrs, props = data.props; 1608 if (isDef(attrs) || isDef(props)) { 1609 for (var key in propOptions) { 1610 var altKey = hyphenate(key); 1611 { 1612 var keyInLowerCase = key.toLowerCase(); 1613 if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) { 1614 tip("Prop \"".concat(keyInLowerCase, "\" is passed to component ") + 1615 "".concat(formatComponentName( 1616 // @ts-expect-error tag is string 1617 tag || Ctor), ", but the declared prop name is") + 1618 " \"".concat(key, "\". ") + 1619 "Note that HTML attributes are case-insensitive and camelCased " + 1620 "props need to use their kebab-case equivalents when using in-DOM " + 1621 "templates. You should probably use \"".concat(altKey, "\" instead of \"").concat(key, "\".")); 1622 } 1623 } 1624 checkProp(res, props, key, altKey, true) || 1625 checkProp(res, attrs, key, altKey, false); 1626 } 1627 } 1628 return res; 1629 } 1630 function checkProp(res, hash, key, altKey, preserve) {
1631 if (isDef(hash)) { 1632 if (hasOwn(hash, key)) { 1633 res[key] = hash[key]; 1634 if (!preserve) { 1635 delete hash[key]; 1636 } 1637 return true; 1638 } 1639 else if (hasOwn(hash, altKey)) { 1640 res[key] = hash[altKey]; 1641 if (!preserve) { 1642 delete hash[altKey]; 1643 } 1644 return true; 1645 } 1646 } 1647 return false; 1648 } 1649 1650 // The template compiler attempts to minimize the need for normalization by 1651 // statically analyzing the template at compile time. 1652 // 1653 // For plain HTML markup, normalization can be completely skipped because the 1654 // generated render function is guaranteed to return Array<VNode>. There are 1655 // two cases where extra normalization is needed: 1656 // 1. When the children contains components - because a functional component 1657 // may return an Array instead of a single root. In this case, just a simple 1658 // normalization is needed - if any child is an Array, we flatten the whole 1659 // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep 1660 // because functional components already normalize their own children. 1661 function simpleNormalizeChildren(children) { 1662 for (var i = 0; i < children.length; i++) { 1663 if (isArray(children[i])) { 1664 return Array.prototype.concat.apply([], children); 1665 } 1666 } 1667 return children; 1668 } 1669 // 2. When the children contains constructs that always generated nested Arrays, 1670 // e.g. <template>, <slot>, v-for, or when the children is provided by user 1671 // with hand-written render functions / JSX. In such cases a full normalization 1672 // is needed to cater to all possible types of children values. 1673 function normalizeChildren(children) { 1674 return isPrimitive(children) 1675 ? [createTextVNode(children)] 1676 : isArray(children) 1677 ? normalizeArrayChildren(children) 1678 : undefined; 1679 } 1680 function isTextNode(node) { 1681 return isDef(node) && isDef(node.text) && isFalse(node.isComment); 1682 } 1683 function normalizeArrayChildren(children, nestedIndex) { 1684 var res = []; 1685 var i, c, lastIndex, last; 1686 for (i = 0; i < children.length; i++) { 1687 c = children[i]; 1688 if (isUndef(c) || typeof c === 'boolean') 1689 continue; 1690 lastIndex = res.length - 1; 1691 last = res[lastIndex]; 1692 // nested 1693 if (isArray(c)) { 1694 if (c.length > 0) { 1695 c = normalizeArrayChildren(c, "".concat(nestedIndex || '', "_").concat(i)); 1696 // merge adjacent text nodes 1697 if (isTextNode(c[0]) && isTextNode(last)) { 1698 res[lastIndex] = createTextVNode(last.text + c[0].text); 1699 c.shift(); 1700 } 1701 res.push.apply(res, c); 1702 } 1703 } 1704 else if (isPrimitive(c)) { 1705 if (isTextNode(last)) { 1706 // merge adjacent text nodes 1707 // this is necessary for SSR hydration because text nodes are 1708 // essentially merged when rendered to HTML strings 1709 res[lastIndex] = createTextVNode(last.text + c); 1710 } 1711 else if (c !== '') { 1712 // convert primitive to vnode 1713 res.push(createTextVNode(c)); 1714 } 1715 } 1716 else { 1717 if (isTextNode(c) && isTextNode(last)) { 1718 // merge adjacent text nodes 1719 res[lastIndex] = createTextVNode(last.text + c.text); 1720 } 1721 else { 1722 // default key for nested array children (likely generated by v-for) 1723 if (isTrue(children._isVList) && 1724 isDef(c.tag) && 1725 isUndef(c.key) && 1726 isDef(nestedIndex)) { 1727 c.key = "__vlist".concat(nestedIndex, "_").concat(i, "__"); 1728 } 1729 res.push(c); 1730 } 1731 } 1732 } 1733 return res; 1734 } 1735 1736 var SIMPLE_NORMALIZE = 1; 1737 var ALWAYS_NORMALIZE = 2; 1738 // wrapper function for providing a more flexible interface 1739 // without getting yelled at by flow 1740 function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) { 1741 if (isArray(data) || isPrimitive(data)) { 1742 normalizationType = children; 1743 children = data; 1744 data = undefined; 1745 } 1746 if (isTrue(alwaysNormalize)) { 1747 normalizationType = ALWAYS_NORMALIZE; 1748 } 1749 return _createElement(context, tag, data, children, normalizationType); 1750 } 1751 function _createElement(context, tag, data, children, normalizationType) { 1752 if (isDef(data) && isDef(data.__ob__)) { 1753 warn$2("Avoid using observed data object as vnode data: ".concat(JSON.stringify(data), "\n") + 'Always create fresh vnode data objects in each render!', context); 1754 return createEmptyVNode(); 1755 } 1756 // object syntax in v-bind 1757 if (isDef(data) && isDef(data.is)) { 1758 tag = data.is; 1759 } 1760 if (!tag) { 1761 // in case of component :is set to falsy value 1762 return createEmptyVNode(); 1763 } 1764 // warn against non-primitive key 1765 if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) { 1766 warn$2('Avoid using non-primitive value as key, ' + 1767 'use string/number value instead.', context); 1768 } 1769 // support single function children as default scoped slot 1770 if (isArray(children) && isFunction(children[0])) { 1771 data = data || {}; 1772 data.scopedSlots = { default: children[0] }; 1773 children.length = 0; 1774 } 1775 if (normalizationType === ALWAYS_NORMALIZE) { 1776 children = normalizeChildren(children); 1777 } 1778 else if (normalizationType === SIMPLE_NORMALIZE) { 1779 children = simpleNormalizeChildren(children); 1780 } 1781 var vnode, ns; 1782 if (typeof tag === 'string') { 1783 var Ctor = void 0; 1784 ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag); 1785 if (config.isReservedTag(tag)) { 1786 // platform built-in elements 1787 if (isDef(data) && 1788 isDef(data.nativeOn) && 1789 data.tag !== 'component') { 1790 warn$2("The .native modifier for v-on is only valid on components but it was used on <".concat(tag, ">."), context); 1791 } 1792 vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, c
1792ontext); 1793 } 1794 else if ((!data || !data.pre) && 1795 isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) { 1796 // component 1797 vnode = createComponent(Ctor, data, context, children, tag); 1798 } 1799 else { 1800 // unknown or unlisted namespaced elements 1801 // check at runtime because it may get assigned a namespace when its 1802 // parent normalizes children 1803 vnode = new VNode(tag, data, children, undefined, undefined, context); 1804 } 1805 } 1806 else { 1807 // direct component options / constructor 1808 vnode = createComponent(tag, data, context, children); 1809 } 1810 if (isArray(vnode)) { 1811 return vnode; 1812 } 1813 else if (isDef(vnode)) { 1814 if (isDef(ns)) 1815 applyNS(vnode, ns); 1816 if (isDef(data)) 1817 registerDeepBindings(data); 1818 return vnode; 1819 } 1820 else { 1821 return createEmptyVNode(); 1822 } 1823 } 1824 function applyNS(vnode, ns, force) { 1825 vnode.ns = ns; 1826 if (vnode.tag === 'foreignObject') { 1827 // use default namespace inside foreignObject 1828 ns = undefined; 1829 force = true; 1830 }
vendor: 1,997 bytes, lines 1831-1898
1831 if (isDef(vnode.children)) { 1832 for (var i = 0, l = vnode.children.length; i < l; i++) { 1833 var child = vnode.children[i]; 1834 if (isDef(child.tag) && 1835 (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) { 1836 applyNS(child, ns, force); 1837 } 1838 } 1839 } 1840 } 1841 // ref #5318 1842 // necessary to ensure parent re-render when deep bindings like :style and 1843 // :class are used on slot nodes 1844 function registerDeepBindings(data) { 1845 if (isObject(data.style)) { 1846 traverse(data.style); 1847 } 1848 if (isObject(data.class)) { 1849 traverse(data.class); 1850 } 1851 } 1852 1853 /** 1854 * Runtime helper for rendering v-for lists. 1855 */ 1856 function renderList(val, render) { 1857 var ret = null, i, l, keys, key; 1858 if (isArray(val) || typeof val === 'string') { 1859 ret = new Array(val.length); 1860 for (i = 0, l = val.length; i < l; i++) { 1861 ret[i] = render(val[i], i); 1862 } 1863 } 1864 else if (typeof val === 'number') { 1865 ret = new Array(val); 1866 for (i = 0; i < val; i++) { 1867 ret[i] = render(i + 1, i); 1868 } 1869 } 1870 else if (isObject(val)) { 1871 if (hasSymbol && val[Symbol.iterator]) { 1872 ret = []; 1873 var iterator = val[Symbol.iterator](); 1874 var result = iterator.next(); 1875 while (!result.done) { 1876 ret.push(render(result.value, ret.length)); 1877 result = iterator.next(); 1878 } 1879 } 1880 else { 1881 keys = Object.keys(val); 1882 ret = new Array(keys.length); 1883 for (i = 0, l = keys.length; i < l; i++) { 1884 key = keys[i]; 1885 ret[i] = render(val[key], key, i); 1886 } 1887 } 1888 } 1889 if (!isDef(ret)) { 1890 ret = []; 1891 } 1892 ret._isVList = true; 1893 return ret; 1894 } 1895 1896 /** 1897 * Runtime helper for rendering <slot> 1898 */
1899 function renderSlot(name, fallbackRender, props, bindObject) { 1900 var scopedSlotFn = this.$scopedSlots[name]; 1901 var nodes; 1902 if (scopedSlotFn) { 1903 // scoped slot 1904 props = props || {}; 1905 if (bindObject) { 1906 if (!isObject(bindObject)) { 1907 warn$2('slot v-bind without argument expects an Object', this); 1908 } 1909 props = extend(extend({}, bindObject), props); 1910 } 1911 nodes = 1912 scopedSlotFn(props) || 1913 (isFunction(fallbackRender) ? fallbackRender() : fallbackRender); 1914 } 1915 else { 1916 nodes = 1917 this.$slots[name] || 1918 (isFunction(fallbackRender) ? fallbackRender() : fallbackRender); 1919 } 1920 var target = props && props.slot; 1921 if (target) { 1922 return this.$createElement('template', { slot: target }, nodes); 1923 } 1924 else { 1925 return nodes; 1926 } 1927 } 1928 1929 /** 1930 * Runtime helper for resolving filters 1931 */ 1932 function resolveFilter(id) { 1933 return resolveAsset(this.$options, 'filters', id, true) || identity; 1934 } 1935 1936 function isKeyNotMatch(expect, actual) { 1937 if (isArray(expect)) { 1938 return expect.indexOf(actual) === -1; 1939 } 1940 else { 1941 return expect !== actual; 1942 } 1943 } 1944 /** 1945 * Runtime helper for checking keyCodes from config. 1946 * exposed as Vue.prototype._k 1947 * passing in eventKeyName as last argument separately for backwards compat 1948 */ 1949 function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) { 1950 var mappedKeyCode = config.keyCodes[key] || builtInKeyCode; 1951 if (builtInKeyName && eventKeyName && !config.keyCodes[key]) { 1952 return isKeyNotMatch(builtInKeyName, eventKeyName); 1953 } 1954 else if (mappedKeyCode) { 1955 return isKeyNotMatch(mappedKeyCode, eventKeyCode); 1956 } 1957 else if (eventKeyName) { 1958 return hyphenate(eventKeyName) !== key; 1959 }
1960 return eventKeyCode === undefined; 1961 } 1962 1963 /** 1964 * Runtime helper for merging v-bind="object" into a VNode's data. 1965 */ 1966 function bindObjectProps(data, tag, value, asProp, isSync) { 1967 if (value) { 1968 if (!isObject(value)) { 1969 warn$2('v-bind without argument expects an Object or Array value', this); 1970 } 1971 else { 1972 if (isArray(value)) { 1973 value = toObject(value); 1974 } 1975 var hash = void 0; 1976 var _loop_1 = function (key) { 1977 if (key === 'class' || key === 'style' || isReservedAttribute(key)) { 1978 hash = data; 1979 } 1980 else { 1981 var type = data.attrs && data.attrs.type; 1982 hash = 1983 asProp || config.mustUseProp(tag, type, key) 1984 ? data.domProps || (data.domProps = {}) 1985 : data.attrs || (data.attrs = {}); 1986 } 1987 var camelizedKey = camelize(key); 1988 var hyphenatedKey = hyphenate(key); 1989 if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) { 1990 hash[key] = value[key]; 1991 if (isSync) { 1992 var on = data.on || (data.on = {}); 1993 on["update:".concat(key)] = function ($event) { 1994 value[key] = $event; 1995 }; 1996 } 1997 } 1998 }; 1999 for (var key in value) { 2000 _loop_1(key); 2001 } 2002 } 2003 } 2004 return data; 2005 } 2006 2007 /** 2008 * Runtime helper for rendering static trees. 2009 */
2010 function renderStatic(index, isInFor) { 2011 var cached = this._staticTrees || (this._staticTrees = []); 2012 var tree = cached[index]; 2013 // if has already-rendered static tree and not inside v-for, 2014 // we can reuse the same tree. 2015 if (tree && !isInFor) { 2016 return tree; 2017 } 2018 // otherwise, render a fresh tree. 2019 tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates 2020 ); 2021 markStatic$1(tree, "__static__".concat(index), false); 2022 return tree; 2023 } 2024 /** 2025 * Runtime helper for v-once. 2026 * Effectively it means marking the node as static with a unique key. 2027 */ 2028 function markOnce(tree, index, key) { 2029 markStatic$1(tree, "__once__".concat(index).concat(key ? "_".concat(key) : ""), true); 2030 return tree; 2031 } 2032 function markStatic$1(tree, key, isOnce) { 2033 if (isArray(tree)) { 2034 for (var i = 0; i < tree.length; i++) { 2035 if (tree[i] && typeof tree[i] !== 'string') { 2036 markStaticNode(tree[i], "".concat(key, "_").concat(i), isOnce); 2037 } 2038 } 2039 } 2040 else { 2041 markStaticNode(tree, key, isOnce); 2042 } 2043 } 2044 function markStaticNode(node, key, isOnce) { 2045 node.isStatic = true; 2046 node.key = key; 2047 node.isOnce = isOnce; 2048 } 2049 2050 function bindObjectListeners(data, value) { 2051 if (value) { 2052 if (!isPlainObject(value)) { 2053 warn$2('v-on without argument expects an Object value', this); 2054 } 2055 else { 2056 var on = (data.on = data.on ? extend({}, data.on) : {}); 2057 for (var key in value) { 2058 var existing = on[key]; 2059 var ours = value[key]; 2060 on[key] = existing ? [].concat(existing, ours) : ours; 2061 } 2062 } 2063 } 2064 return data; 2065 } 2066 2067 function resolveScopedSlots(fns, res, 2068 // the following are added in 2.6 2069 hasDynamicKeys, contentHashKey) { 2070 res = res || { $stable: !hasDynamicKeys }; 2071 for (var i = 0; i < fns.length; i++) { 2072 var slot = fns[i]; 2073 if (isArray(slot)) { 2074 resolveScopedSlots(slot, res, hasDynamicKeys); 2075 } 2076 else if (slot) { 2077 // marker for reverse proxying v-slot without scope on this.$slots 2078 // @ts-expect-error 2079 if (slot.proxy) { 2080 // @ts-expect-error 2081 slot.fn.proxy = true; 2082 } 2083 res[slot.key] = slot.fn; 2084 } 2085 } 2086 if (contentHashKey) { 2087 res.$key = contentHashKey; 2088 } 2089 return res; 2090 } 2091 2092 // helper to process dynamic keys for dynamic arguments in v-bind and v-on. 2093 function bindDynamicKeys(baseObj, values) { 2094 for (var i = 0; i < values.length; i += 2) { 2095 var key = values[i]; 2096 if (typeof key === 'string' && key) { 2097 baseObj[values[i]] = values[i + 1]; 2098 } 2099 else if (key !== '' && key !== null) { 2100 // null is a special value for explicitly removing a binding 2101 warn$2("Invalid value for dynamic directive argument (expected string or null): ".concat(key), this); 2102 } 2103 } 2104 return baseObj; 2105 } 2106 // helper to dynamically append modifier runtime markers to event names. 2107 // ensure only append when value is already string, otherwise it will be cast 2108 // to string and cause the type check to miss. 2109 function prependModifier(value, symbol) { 2110 return typeof value === 'string' ? symbol + value : value; 2111 } 2112 2113 function installRenderHelpers(target) { 2114 target._o = markOnce; 2115 target._n = toNumber; 2116 target._s = toString; 2117 target._l = renderList; 2118 target._t = renderSlot; 2119 target._q = looseEqual; 2120 target._i = looseIndexOf; 2121 target._m = renderStatic; 2122 target._f = resolveFilter; 2123 target._k = checkKeyCodes; 2124 target._b = bindObjectProps; 2125 target._v = createTextVNode; 2126 target._e = createEmptyVNode; 2127 target._u = resolveScopedSlots;
2128 target._g = bindObjectListeners; 2129 target._d = bindDynamicKeys; 2130 target._p = prependModifier; 2131 } 2132 2133 /** 2134 * Runtime helper for resolving raw children VNodes into a slot object. 2135 */ 2136 function resolveSlots(children, context) { 2137 if (!children || !children.length) { 2138 return {}; 2139 } 2140 var slots = {}; 2141 for (var i = 0, l = children.length; i < l; i++) { 2142 var child = children[i]; 2143 var data = child.data; 2144 // remove slot attribute if the node is resolved as a Vue slot node 2145 if (data && data.attrs && data.attrs.slot) { 2146 delete data.attrs.slot; 2147 } 2148 // named slots should only be respected if the vnode was rendered in the 2149 // same context. 2150 if ((child.context === context || child.fnContext === context) && 2151 data && 2152 data.slot != null) { 2153 var name_1 = data.slot; 2154 var slot = slots[name_1] || (slots[name_1] = []); 2155 if (child.tag === 'template') { 2156 slot.push.apply(slot, child.children || []); 2157 } 2158 else { 2159 slot.push(child); 2160 } 2161 } 2162 else { 2163 (slots.default || (slots.default = [])).push(child); 2164 } 2165 } 2166 // ignore slots that contains only whitespace 2167 for (var name_2 in slots) { 2168 if (slots[name_2].every(isWhitespace)) { 2169 delete slots[name_2]; 2170 } 2171 } 2172 return slots; 2173 } 2174 function isWhitespace(node) { 2175 return (node.isComment && !node.asyncFactory) || node.text === ' '; 2176 } 2177 2178 function isAsyncPlaceholder(node) { 2179 // @ts-expect-error not really boolean type 2180 return node.isComment && node.asyncFactory; 2181 } 2182 2183 function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) { 2184 var res; 2185 var hasNormalSlots = Object.keys(normalSlots).length > 0; 2186 var isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots; 2187 var key = scopedSlots && scopedSlots.$key; 2188 if (!scopedSlots) { 2189 res = {}; 2190 } 2191 else if (scopedSlots._normalized) { 2192 // fast path 1: child component re-render only, parent did not change 2193 return scopedSlots._normalized; 2194 } 2195 else if (isStable && 2196 prevScopedSlots && 2197 prevScopedSlots !== emptyObject && 2198 key === prevScopedSlots.$key && 2199 !hasNormalSlots && 2200 !prevScopedSlots.$hasNormal) { 2201 // fast path 2: stable scoped slots w/ no normal slots to proxy, 2202 // only need to normalize once 2203 return prevScopedSlots; 2204 } 2205 else { 2206 res = {}; 2207 for (var key_1 in scopedSlots) { 2208 if (scopedSlots[key_1] && key_1[0] !== '$') { 2209 res[key_1] = normalizeScopedSlot(ownerVm, normalSlots, key_1, scopedSlots[key_1]); 2210 } 2211 } 2212 } 2213 // expose normal slots on scopedSlots 2214 for (var key_2 in normalSlots) { 2215 if (!(key_2 in res)) { 2216 res[key_2] = proxyNormalSlot(normalSlots, key_2); 2217 } 2218 } 2219 // avoriaz seems to mock a non-extensible $scopedSlots object 2220 // and when that is passed down this would cause an error 2221 if (scopedSlots && Object.isExtensible(scopedSlots)) { 2222 scopedSlots._normalized = res; 2223 } 2224 def(res, '$stable', isStable); 2225 def(res, '$key', key); 2226 def(res, '$hasNormal', hasNormalSlots); 2227 return res; 2228 } 2229 function normalizeScopedSlot(vm, normalSlots, key, fn) { 2230 var normalized = function () { 2231 var cur = currentInstance; 2232 setCurrentInstance(vm); 2233 var res = arguments.length ? fn.apply(null, arguments) : fn({}); 2234 res = 2235 res && typeof res === 'object' && !isArray(res) 2236 ? [res] // single vnode 2237 : normalizeChildren(res); 2238 var vnode = res && res[0]; 2239 setCurrentInstance(cur); 2240 return res && 2241 (!vnode || 2242 (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391 2243 ? undefined 2244 : res; 2245 }; 2246 // this is a slot using the new v-slot syntax without scope. although it is 2247 // compiled as a scoped slot, render fn users would expect it to be present 2248 // on this.$slots because the usage is semantically a normal slot. 2249 if (fn.proxy) { 2250 Object.defineProperty(normalSlots, key, { 2251 get: normalized, 2252 enumerable: true, 2253 configurable: true 2254 }); 2255 } 2256 return normalized; 2257 } 2258 function proxyNormalSlot(slots, key) { 2259 return function () { return slots[key]; }; 2260 } 2261 2262 function initSetup(vm) { 2263 var options = vm.$options; 2264 var setup = options.setup; 2265 if (setup) { 2266 var ctx = (vm._setupContext = createSetupContext(vm)); 2267 setCurrentInstance(vm); 2268 pushTarget(); 2269 var setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, "setup"); 2270 popTarget(); 2271 setCurrentInstance(); 2272 if (isFunction(setupResult)) { 2273 // render function 2274 // @ts-ignore 2275 options.render = setupResult; 2276 } 2277 else if (isObject(setupResult)) { 2278 // bindings 2279 if (setupResult instanceof VNode) { 2280 warn$2("setup() should not return VNodes directly - " + 2281 "return a render function instead."); 2282 } 2283 vm._setupState = setupResult; 2284 // __sfc indicates compiled bindings from <script setup> 2285 if (!setupResult.__sfc) { 2286 for (var key in setupResult) { 2287 if (!isReserved(key)) { 2288 proxyWithRefUnwrap(vm, setupResult, key); 2289 } 2290 else { 2291 warn$2("Avoid using variables that start with _ or $ in setup()."); 2292 } 2293 } 2294 } 2295 else {
2296 // exposed for compiled render fn 2297 var proxy = (vm._setupProxy = {}); 2298 for (var key in setupResult) { 2299 if (key !== '__sfc') { 2300 proxyWithRefUnwrap(proxy, setupResult, key); 2301 } 2302 } 2303 } 2304 } 2305 else if (setupResult !== undefined) { 2306 warn$2("setup() should return an object. Received: ".concat(setupResult === null ? 'null' : typeof setupResult)); 2307 } 2308 } 2309 } 2310 function createSetupContext(vm) { 2311 var exposeCalled = false; 2312 return { 2313 get attrs() { 2314 if (!vm._attrsProxy) { 2315 var proxy = (vm._attrsProxy = {}); 2316 def(proxy, '_v_attr_proxy', true); 2317 syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs'); 2318 } 2319 return vm._attrsProxy; 2320 }, 2321 get listeners() { 2322 if (!vm._listenersProxy) { 2323 var proxy = (vm._listenersProxy = {}); 2324 syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners'); 2325 } 2326 return vm._listenersProxy; 2327 }, 2328 get slots() { 2329 return initSlotsProxy(vm); 2330 }, 2331 emit: bind$1(vm.$emit, vm), 2332 expose: function (exposed) { 2333 { 2334 if (exposeCalled) { 2335 warn$2("expose() should be called only once per setup().", vm); 2336 } 2337 exposeCalled = true; 2338 } 2339 if (exposed) { 2340 Object.keys(exposed).forEach(function (key) { 2341 return proxyWithRefUnwrap(vm, exposed, key); 2342 }); 2343 } 2344 } 2345 }; 2346 } 2347 function syncSetupProxy(to, from, prev, instance, type) { 2348 var changed = false; 2349 for (var key in from) { 2350 if (!(key in to)) { 2351 changed = true; 2352 defineProxyAttr(to, key, instance, type); 2353 } 2354 else if (from[key] !== prev[key]) { 2355 changed = true; 2356 } 2357 } 2358 for (var key in to) { 2359 if (!(key in from)) { 2360 changed = true; 2361 delete to[key]; 2362 } 2363 } 2364 return changed; 2365 } 2366 function defineProxyAttr(proxy, key, instance, type) { 2367 Object.defineProperty(proxy, key, { 2368 enumerable: true, 2369 configurable: true, 2370 get: function () { 2371 return instance[type][key]; 2372 } 2373 }); 2374 } 2375 function initSlotsProxy(vm) { 2376 if (!vm._slotsProxy) { 2377 syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots); 2378 } 2379 return vm._slotsProxy; 2380 } 2381 function syncSetupSlots(to, from) { 2382 for (var key in from) { 2383 to[key] = from[key]; 2384 } 2385 for (var key in to) { 2386 if (!(key in from)) { 2387 delete to[key]; 2388 } 2389 } 2390 } 2391 /** 2392 * @internal use manual type def because public setup context type relies on 2393 * legacy VNode types 2394 */ 2395 function useSlots() { 2396 return getContext().slots; 2397 } 2398 /** 2399 * @internal use manual type def because public setup context type relies on 2400 * legacy VNode types 2401 */ 2402 function useAttrs() { 2403 return getContext().attrs; 2404 } 2405 /** 2406 * Vue 2 only 2407 * @internal use manual type def because public setup context type relies on 2408 * legacy VNode types 2409 */ 2410 function useListeners() { 2411 return getContext().listeners; 2412 } 2413 function getContext() { 2414 if (!currentInstance) { 2415 warn$2("useContext() called without active instance."); 2416 } 2417 var vm = currentInstance; 2418 return vm._setupContext || (vm._setupContext = createSetupContext(vm)); 2419 } 2420 /** 2421 * Runtime helper for merging default declarations. Imported by compiled code 2422 * only. 2423 * @internal 2424 */ 2425 function mergeDefaults(raw, defaults) { 2426 var props = isArray(raw) 2427 ? raw.reduce(function (normalized, p) { return ((normalized[p] = {}), normalized); }, {}) 2428 : raw; 2429 for (var key in defaults) { 2430 var opt = props[key]; 2431 if (opt) { 2432 if (isArray(opt) || isFunction(opt)) { 2433 props[key] = { type: opt, default: defaults[key] }; 2434 } 2435 else { 2436 opt.default = defaults[key]; 2437 } 2438 } 2439 else if (opt === null) { 2440 props[key] = { default: defaults[key] }; 2441 } 2442 else { 2443 warn$2("props default key \"".concat(key, "\" has no corresponding declaration.")); 2444 } 2445 } 2446 return props; 2447 } 2448 2449 function initRender(vm) { 2450 vm._vnode = null; // the root of the child tree 2451 vm._staticTrees = null; // v-once cached trees 2452 var options = vm.$options; 2453 var parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree 2454 var renderContext = parentVnode && parentVnode.context; 2455 vm.$slots = resolveSlots(options._renderChildren, renderContext); 2456 vm.$scopedSlots = parentVnode 2457 ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots) 2458 : emptyObject; 2459 // bind the createElement fn to this instance 2460 // so that we get proper render context inside it. 2461 // args order: tag, data, children, normalizationType, alwaysNormalize 2462 // internal version is used by render functions compiled from templates 2463 // @ts-expect-error 2464 vm._c = function (a, b, c, d) { return createElement$1(vm, a, b, c, d, false); }; 2465 // normalization is always applied for the public version, used in 2466 // user-written render functions. 2467 // @ts-expect-error 2468 vm.$createElement = function (a, b, c, d) { return createElement$1(vm, a, b, c, d, true); }; 2469 // $attrs & $listeners are exposed for easier HOC creation. 2470 // they need to be reactive so that HOCs using them are always updated 2471 var parentData = parentVnode && parentVnode.data; 2472 /* istanbul ignore else */ 2473 { 2474 defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, function () { 2475 !isUpdatingChildComponent && warn$2("$attrs is readonly.", vm); 2476 }, true); 2477 defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function () { 2478 !isUpdatingChildComponent && warn$2("$listeners is readonly.", vm); 2479 }, true); 2480 } 2481 } 2482 var currentRenderingInstance = null; 2483 function renderMixin(Vue) { 2484 // install runtime convenience helpers 2485 installRenderHelpers(Vue.prototype); 2486 Vue.prototype.$nextTick = function (fn) { 2487 return nextTick(fn, this); 2488 }; 2489 Vue.prototype._render = function () { 2490 var vm = this; 2491 var _a = vm.$options, render = _a.render, _parentVnode = _a._parentVnode; 2492 if (_parentVnode && vm._isMounted) { 2493 vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots); 2494 if (vm._slotsProxy) { 2495 syncSetupSlots(vm._slotsProxy, vm.$scopedSlots); 2496 } 2497 } 2498 // set parent vnode. this allows render functions to have access 2499 // to the data on the placeholder node. 2500 vm.$vnode = _parentVnode; 2501 // render self 2502 var vnode; 2503 try { 2504 // There's no need to maintain a stack because all render fns are called 2505 // separately from one another. Nested component's render fns are called 2506 // when parent component is patched. 2507 setCurrentInstance(vm); 2508 currentRenderingInstance = vm; 2509 vnode = render.call(vm._renderProxy, vm.$createElement); 2510 } 2511 catch (e) { 2512 handleError(e, vm, "render"); 2513 // return error render result, 2514 // or previous vnode to prevent render error causing blank component 2515 /* istanbul ignore else */ 2516 if (vm.$options.renderError) { 2517 try { 2518 vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e); 2519 } 2520 catch (e) { 2521 handleError(e, vm, "renderError"); 2522 vnode = vm._vnode; 2523 } 2524 } 2525 else { 2526 vnode = vm._vnode; 2527 } 2528 } 2529 finally { 2530 currentRenderingInstance = null; 2531 setCurrentInstance(); 2532 } 2533 // if the returned array contains only a single node, allow it 2534 if (isArray(vnode) && vnode.length === 1) { 2535 vnode = vnode[0]; 2536 } 2537 // return empty vnode in case the render function errored out 2538 if (!(vnode instanceof VNode)) { 2539 if (isArray(vnode)) { 2540 warn$2('Multiple root nodes returned from render function. Render function ' + 2541 'should return a single root node.', vm); 2542 } 2543 vnode = createEmptyVNode(); 2544 } 2545 // set parent 2546 vnode.parent = _parentVnode; 2547 return vnode; 2548 }; 2549 } 2550 2551 function ensureCtor(comp, base) { 2552 if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) { 2553 comp = comp.default; 2554 } 2555 return isObject(comp) ? base.extend(comp) : comp; 2556 } 2557 function createAsyncPlaceholder(factory, data, context, children, tag) { 2558 var node = createEmptyVNode(); 2559 node.asyncFactory = factory; 2560 node.asyncMeta = { data: data, context: context, children: children, tag: tag }; 2561 return node; 2562 } 2563 function resolveAsyncComponent(factory, baseCtor) { 2564 if (isTrue(factory.error) && isDef(factory.errorComp)) { 2565 return factory.errorComp; 2566 } 2567 if (isDef(factory.resolved)) { 2568 return factory.resolved; 2569 } 2570 var owner = currentRenderingInstance;
2571 if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) { 2572 // already pending 2573 factory.owners.push(owner); 2574 } 2575 if (isTrue(factory.loading) && isDef(factory.loadingComp)) { 2576 return factory.loadingComp; 2577 } 2578 if (owner && !isDef(factory.owners)) { 2579 var owners_1 = (factory.owners = [owner]); 2580 var sync_1 = true; 2581 var timerLoading_1 = null; 2582 var timerTimeout_1 = null; 2583 owner.$on('hook:destroyed', function () { return remove$2(owners_1, owner); }); 2584 var forceRender_1 = function (renderCompleted) { 2585 for (var i = 0, l = owners_1.length; i < l; i++) { 2586 owners_1[i].$forceUpdate(); 2587 } 2588 if (renderCompleted) { 2589 owners_1.length = 0; 2590 if (timerLoading_1 !== null) { 2591 clearTimeout(timerLoading_1); 2592 timerLoading_1 = null; 2593 } 2594 if (timerTimeout_1 !== null) { 2595 clearTimeout(timerTimeout_1); 2596 timerTimeout_1 = null; 2597 } 2598 } 2599 }; 2600 var resolve = once(function (res) { 2601 // cache resolved 2602 factory.resolved = ensureCtor(res, baseCtor); 2603 // invoke callbacks only if this is not a synchronous resolve 2604 // (async resolves are shimmed as synchronous during SSR) 2605 if (!sync_1) { 2606 forceRender_1(true); 2607 } 2608 else { 2609 owners_1.length = 0; 2610 } 2611 }); 2612 var reject_1 = once(function (reason) { 2613 warn$2("Failed to resolve async component: ".concat(String(factory)) + 2614 (reason ? "\nReason: ".concat(reason) : '')); 2615 if (isDef(factory.errorComp)) { 2616 factory.error = true; 2617 forceRender_1(true); 2618 } 2619 }); 2620 var res_1 = factory(resolve, reject_1); 2621 if (isObject(res_1)) { 2622 if (isPromise(res_1)) { 2623 // () => Promise 2624 if (isUndef(factory.resolved)) { 2625 res_1.then(resolve, reject_1); 2626 } 2627 } 2628 else if (isPromise(res_1.component)) { 2629 res_1.component.then(resolve, reject_1); 2630 if (isDef(res_1.error)) { 2631 factory.errorComp = ensureCtor(res_1.error, baseCtor); 2632 } 2633 if (isDef(res_1.loading)) { 2634 factory.loadingComp = ensureCtor(res_1.loading, baseCtor); 2635 if (res_1.delay === 0) { 2636 factory.loading = true; 2637 } 2638 else { 2639 // @ts-expect-error NodeJS timeout type 2640 timerLoading_1 = setTimeout(function () { 2641 timerLoading_1 = null; 2642 if (isUndef(factory.resolved) && isUndef(factory.error)) { 2643 factory.loading = true; 2644 forceRender_1(false); 2645 } 2646 }, res_1.delay || 200); 2647 } 2648 } 2649 if (isDef(res_1.timeout)) { 2650 // @ts-expect-error NodeJS timeout type 2651 timerTimeout_1 = setTimeout(function () { 2652 timerTimeout_1 = null; 2653 if (isUndef(factory.resolved)) { 2654 reject_1("timeout (".concat(res_1.timeout, "ms)") ); 2655 } 2656 }, res_1.timeout); 2657 } 2658 } 2659 } 2660 sync_1 = false; 2661 // return in case resolved synchronously 2662 return factory.loading ? factory.loadingComp : factory.resolved; 2663 } 2664 } 2665 2666 function getFirstComponentChild(children) { 2667 if (isArray(children)) { 2668 for (var i = 0; i < children.length; i++) { 2669 var c = children[i]; 2670 if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) { 2671 return c; 2672 } 2673 } 2674 } 2675 } 2676 2677 function initEvents(vm) { 2678 vm._events = Object.create(null); 2679 vm._hasHookEvent = false;
2680 // init parent attached events 2681 var listeners = vm.$options._parentListeners; 2682 if (listeners) { 2683 updateComponentListeners(vm, listeners); 2684 } 2685 } 2686 var target$1; 2687 function add$1(event, fn) { 2688 target$1.$on(event, fn); 2689 } 2690 function remove$1(event, fn) { 2691 target$1.$off(event, fn); 2692 } 2693 function createOnceHandler$1(event, fn) { 2694 var _target = target$1; 2695 return function onceHandler() { 2696 var res = fn.apply(null, arguments); 2697 if (res !== null) { 2698 _target.$off(event, onceHandler); 2699 } 2700 }; 2701 } 2702 function updateComponentListeners(vm, listeners, oldListeners) { 2703 target$1 = vm; 2704 updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm); 2705 target$1 = undefined; 2706 } 2707 function eventsMixin(Vue) { 2708 var hookRE = /^hook:/; 2709 Vue.prototype.$on = function (event, fn) { 2710 var vm = this; 2711 if (isArray(event)) { 2712 for (var i = 0, l = event.length; i < l; i++) { 2713 vm.$on(event[i], fn); 2714 } 2715 } 2716 else { 2717 (vm._events[event] || (vm._events[event] = [])).push(fn); 2718 // optimize hook:event cost by using a boolean flag marked at registration 2719 // instead of a hash lookup 2720 if (hookRE.test(event)) { 2721 vm._hasHookEvent = true; 2722 } 2723 } 2724 return vm; 2725 }; 2726 Vue.prototype.$once = function (event, fn) { 2727 var vm = this; 2728 function on() { 2729 vm.$off(event, on); 2730 fn.apply(vm, arguments); 2731 } 2732 on.fn = fn; 2733 vm.$on(event, on); 2734 return vm; 2735 }; 2736 Vue.prototype.$off = function (event, fn) { 2737 var vm = this; 2738 // all 2739 if (!arguments.length) { 2740 vm._events = Object.create(null); 2741 return vm; 2742 } 2743 // array of events 2744 if (isArray(event)) { 2745 for (var i_1 = 0, l = event.length; i_1 < l; i_1++) { 2746 vm.$off(event[i_1], fn); 2747 } 2748 return vm; 2749 } 2750 // specific event 2751 var cbs = vm._events[event]; 2752 if (!cbs) { 2753 return vm; 2754 } 2755 if (!fn) { 2756 vm._events[event] = null; 2757 return vm; 2758 } 2759 // specific handler 2760 var cb; 2761 var i = cbs.length; 2762 while (i--) { 2763 cb = cbs[i]; 2764 if (cb === fn || cb.fn === fn) { 2765 cbs.splice(i, 1); 2766 break; 2767 } 2768 } 2769 return vm; 2770 }; 2771 Vue.prototype.$emit = function (event) { 2772 var vm = this; 2773 { 2774 var lowerCaseEvent = event.toLowerCase(); 2775 if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { 2776 tip("Event \"".concat(lowerCaseEvent, "\" is emitted in component ") + 2777 "".concat(formatComponentName(vm), " but the handler is registered for \"").concat(event, "\". ") + 2778 "Note that HTML attributes are case-insensitive and you cannot use " + 2779 "v-on to listen to camelCase events when using in-DOM templates. " + 2780 "You should probably use \"".concat(hyphenate(event), "\" instead of \"").concat(event, "\".")); 2781 } 2782 } 2783 var cbs = vm._events[event]; 2784 if (cbs) { 2785 cbs = cbs.length > 1 ? toArray(cbs) : cbs; 2786 var args = toArray(arguments, 1); 2787 var info = "event handler for \"".concat(event, "\""); 2788 for (var i = 0, l = cbs.length; i < l; i++) { 2789 invokeWithErrorHandling(cbs[i], vm, args, vm, info); 2790 } 2791 } 2792 return vm; 2793 }; 2794 } 2795 2796 var activeInstance = null; 2797 var isUpdatingChildComponent = false; 2798 function setActiveInstance(vm) { 2799 var prevActiveInstance = activeInstance; 2800 activeInstance = vm; 2801 return function () { 2802 activeInstance = prevActiveInstance; 2803 }; 2804 } 2805 function initLifecycle(vm) { 2806 var options = vm.$options; 2807 // locate first non-abstract parent 2808 var parent = options.parent; 2809 if (parent && !options.abstract) { 2810 while (parent.$options.abstract && parent.$parent) { 2811 parent = parent.$parent; 2812 } 2813 parent.$children.push(vm); 2814 } 2815 vm.$parent = parent; 2816 vm.$root = parent ? parent.$root : vm; 2817 vm.$children = []; 2818 vm.$refs = {}; 2819 vm._provided = parent ? parent._provided : Object.create(null); 2820 vm._watcher = null; 2821 vm._inactive = null; 2822 vm._directInactive = false;
2823 vm._isMounted = false; 2824 vm._isDestroyed = false; 2825 vm._isBeingDestroyed = false; 2826 } 2827 function lifecycleMixin(Vue) { 2828 Vue.prototype._update = function (vnode, hydrating) { 2829 var vm = this; 2830 var prevEl = vm.$el; 2831 var prevVnode = vm._vnode; 2832 var restoreActiveInstance = setActiveInstance(vm); 2833 vm._vnode = vnode; 2834 // Vue.prototype.__patch__ is injected in entry points 2835 // based on the rendering backend used. 2836 if (!prevVnode) { 2837 // initial render 2838 vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */); 2839 } 2840 else { 2841 // updates 2842 vm.$el = vm.__patch__(prevVnode, vnode); 2843 } 2844 restoreActiveInstance(); 2845 // update __vue__ reference 2846 if (prevEl) { 2847 prevEl.__vue__ = null; 2848 } 2849 if (vm.$el) { 2850 vm.$el.__vue__ = vm; 2851 } 2852 // if parent is an HOC, update its $el as well 2853 var wrapper = vm; 2854 while (wrapper && 2855 wrapper.$vnode && 2856 wrapper.$parent && 2857 wrapper.$vnode === wrapper.$parent._vnode) { 2858 wrapper.$parent.$el = wrapper.$el; 2859 wrapper = wrapper.$parent; 2860 } 2861 // updated hook is called by the scheduler to ensure that children are 2862 // updated in a parent's updated hook. 2863 }; 2864 Vue.prototype.$forceUpdate = function () { 2865 var vm = this; 2866 if (vm._watcher) { 2867 vm._watcher.update(); 2868 } 2869 }; 2870 Vue.prototype.$destroy = function () { 2871 var vm = this; 2872 if (vm._isBeingDestroyed) { 2873 return; 2874 } 2875 callHook$1(vm, 'beforeDestroy'); 2876 vm._isBeingDestroyed = true; 2877 // remove self from parent 2878 var parent = vm.$parent; 2879 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { 2880 remove$2(parent.$children, vm); 2881 } 2882 // teardown scope. this includes both the render watcher and other 2883 // watchers created 2884 vm._scope.stop(); 2885 // remove reference from data ob 2886 // frozen object may not have observer. 2887 if (vm._data.__ob__) { 2888 vm._data.__ob__.vmCount--; 2889 } 2890 // call the last hook... 2891 vm._isDestroyed = true; 2892 // invoke destroy hooks on current rendered tree 2893 vm.__patch__(vm._vnode, null); 2894 // fire destroyed hook 2895 callHook$1(vm, 'destroyed'); 2896 // turn off all instance listeners. 2897 vm.$off(); 2898 // remove __vue__ reference 2899 if (vm.$el) { 2900 vm.$el.__vue__ = null; 2901 } 2902 // release circular reference (#6759) 2903 if (vm.$vnode) { 2904 vm.$vnode.parent = null; 2905 } 2906 }; 2907 } 2908 function mountComponent(vm, el, hydrating) { 2909 vm.$el = el; 2910 if (!vm.$options.render) { 2911 // @ts-expect-error invalid type 2912 vm.$options.render = createEmptyVNode; 2913 { 2914 /* istanbul ignore if */ 2915 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') || 2916 vm.$options.el || 2917 el) { 2918 warn$2('You are using the runtime-only build of Vue where the template ' + 2919 'compiler is not available. Either pre-compile the templates into ' + 2920 'render functions, or use the compiler-included build.', vm); 2921 } 2922 else { 2923 warn$2('Failed to mount component: template or render function not defined.', vm); 2924 } 2925 } 2926 } 2927 callHook$1(vm, 'beforeMount'); 2928 var updateComponent; 2929 /* istanbul ignore if */ 2930 if (config.performance && mark) { 2931 updateComponent = function () { 2932 var name = vm._name; 2933 var id = vm._uid; 2934 var startTag = "vue-perf-start:".concat(id); 2935 var endTag = "vue-perf-end:".concat(id); 2936 mark(startTag); 2937 var vnode = vm._render(); 2938 mark(endTag); 2939 measure("vue ".concat(name, " render"), startTag, endTag); 2940 mark(startTag); 2941 vm._update(vnode, hydrating); 2942 mark(endTag); 2943 measure("vue ".concat(name, " patch"), startTag, endTag); 2944 }; 2945 } 2946 else { 2947 updateComponent = function () { 2948 vm._update(vm._render(), hydrating); 2949 }; 2950 } 2951 var watcherOptions = { 2952 before: function () { 2953 if (vm._isMounted && !vm._isDestroyed) { 2954 callHook$1(vm, 'beforeUpdate'); 2955 } 2956 } 2957 }; 2958 { 2959 watcherOptions.onTrack = function (e) { return callHook$1(vm, 'renderTracked', [e]); }; 2960 watcherOptions.onTrigger = function (e) { return callHook$1(vm, 'renderTriggered', [e]); }; 2961 } 2962 // we set this to vm._watcher inside the watcher's constructor 2963 // since the watcher's initial patch may call $forceUpdate (e.g. inside child 2964 // component's mounted hook), which relies on vm._watcher being already defined 2965 new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */); 2966 hydrating = false;
2967 // flush buffer for flush: "pre" watchers queued in setup() 2968 var preWatchers = vm._preWatchers; 2969 if (preWatchers) { 2970 for (var i = 0; i < preWatchers.length; i++) { 2971 preWatchers[i].run(); 2972 } 2973 } 2974 // manually mounted instance, call mounted on self 2975 // mounted is called for render-created child components in its inserted hook 2976 if (vm.$vnode == null) { 2977 vm._isMounted = true; 2978 callHook$1(vm, 'mounted'); 2979 } 2980 return vm; 2981 } 2982 function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) { 2983 { 2984 isUpdatingChildComponent = true; 2985 } 2986 // determine whether component has slot children 2987 // we need to do this before overwriting $options._renderChildren. 2988 // check if there are dynamic scopedSlots (hand-written or compiled but with 2989 // dynamic slot names). Static scoped slots compiled from template has the 2990 // "$stable" marker. 2991 var newScopedSlots = parentVnode.data.scopedSlots; 2992 var oldScopedSlots = vm.$scopedSlots; 2993 var hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) || 2994 (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) || 2995 (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) || 2996 (!newScopedSlots && vm.$scopedSlots.$key)); 2997 // Any static slot children from the parent may have changed during parent's 2998 // update. Dynamic scoped slots may also have changed. In such cases, a forced 2999 // update is necessary to ensure correctness. 3000 var needsForceUpdate = !!(renderChildren || // has new static slots 3001 vm.$options._renderChildren || // has old static slots 3002 hasDynamicScopedSlot); 3003 var prevVNode = vm.$vnode; 3004 vm.$options._parentVnode = parentVnode; 3005 vm.$vnode = parentVnode; // update vm's placeholder node without re-render 3006 if (vm._vnode) { 3007 // update child tree's parent 3008 vm._vnode.parent = parentVnode; 3009 } 3010 vm.$options._renderChildren = renderChildren; 3011 // update $attrs and $listeners hash 3012 // these are also reactive so they may trigger child update if the child 3013 // used them during render 3014 var attrs = parentVnode.data.attrs || emptyObject; 3015 if (vm._attrsProxy) { 3016 // force update if attrs are accessed and has changed since it may be 3017 // passed to a child component. 3018 if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) { 3019 needsForceUpdate = true; 3020 } 3021 } 3022 vm.$attrs = attrs; 3023 // update listeners 3024 listeners = listeners || emptyObject; 3025 var prevListeners = vm.$options._parentListeners; 3026 if (vm._listenersProxy) { 3027 syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners'); 3028 } 3029 vm.$listeners = vm.$options._parentListeners = listeners; 3030 updateComponentListeners(vm, listeners, prevListeners); 3031 // update props 3032 if (propsData && vm.$options.props) { 3033 toggleObserving(false); 3034 var props = vm._props; 3035 var propKeys = vm.$options._propKeys || []; 3036 for (var i = 0; i < propKeys.length; i++) { 3037 var key = propKeys[i]; 3038 var propOptions = vm.$options.props; // wtf flow? 3039 props[key] = validateProp(key, propOptions, propsData, vm); 3040 } 3041 toggleObserving(true); 3042 // keep a copy of raw propsData 3043 vm.$options.propsData = propsData; 3044 } 3045 // resolve slots + force update if has children 3046 if (needsForceUpdate) { 3047 vm.$slots = resolveSlots(renderChildren, parentVnode.context); 3048 vm.$forceUpdate(); 3049 } 3050 { 3051 isUpdatingChildComponent = false; 3052 } 3053 } 3054 function isInInactiveTree(vm) { 3055 while (vm && (vm = vm.$parent)) { 3056 if (vm._inactive) 3057 return true; 3058 } 3059 return false; 3060 } 3061 function activateChildComponent(vm, direct) { 3062 if (direct) { 3063 vm._directInactive = false;
3064 if (isInInactiveTree(vm)) { 3065 return; 3066 } 3067 } 3068 else if (vm._directInactive) { 3069 return; 3070 } 3071 if (vm._inactive || vm._inactive === null) { 3072 vm._inactive = false; 3073 for (var i = 0; i < vm.$children.length; i++) { 3074 activateChildComponent(vm.$children[i]); 3075 } 3076 callHook$1(vm, 'activated'); 3077 } 3078 } 3079 function deactivateChildComponent(vm, direct) { 3080 if (direct) { 3081 vm._directInactive = true; 3082 if (isInInactiveTree(vm)) { 3083 return; 3084 } 3085 } 3086 if (!vm._inactive) { 3087 vm._inactive = true; 3088 for (var i = 0; i < vm.$children.length; i++) { 3089 deactivateChildComponent(vm.$children[i]); 3090 } 3091 callHook$1(vm, 'deactivated'); 3092 } 3093 } 3094 function callHook$1(vm, hook, args, setContext) { 3095 if (setContext === void 0) { setContext = true; } 3096 // #7573 disable dep collection when invoking lifecycle hooks 3097 pushTarget(); 3098 var prev = currentInstance; 3099 setContext && setCurrentInstance(vm); 3100 var handlers = vm.$options[hook]; 3101 var info = "".concat(hook, " hook"); 3102 if (handlers) { 3103 for (var i = 0, j = handlers.length; i < j; i++) { 3104 invokeWithErrorHandling(handlers[i], vm, args || null, vm, info); 3105 } 3106 } 3107 if (vm._hasHookEvent) { 3108 vm.$emit('hook:' + hook); 3109 } 3110 setContext && setCurrentInstance(prev); 3111 popTarget(); 3112 } 3113 3114 var MAX_UPDATE_COUNT = 100; 3115 var queue = []; 3116 var activatedChildren = []; 3117 var has = {}; 3118 var circular = {}; 3119 var waiting = false; 3120 var flushing = false; 3121 var index$1 = 0; 3122 /** 3123 * Reset the scheduler's state. 3124 */ 3125 function resetSchedulerState() { 3126 index$1 = queue.length = activatedChildren.length = 0; 3127 has = {}; 3128 { 3129 circular = {}; 3130 } 3131 waiting = flushing = false; 3132 } 3133 // Async edge case #6566 requires saving the timestamp when event listeners are 3134 // attached. However, calling performance.now() has a perf overhead especially 3135 // if the page has thousands of event listeners. Instead, we take a timestamp 3136 // every time the scheduler flushes and use that for all event listeners 3137 // attached during that flush. 3138 var currentFlushTimestamp = 0; 3139 // Async edge case fix requires storing an event listener's attach timestamp. 3140 var getNow = Date.now; 3141 // Determine what event timestamp the browser is using. Annoyingly, the 3142 // timestamp can either be hi-res (relative to page load) or low-res 3143 // (relative to UNIX epoch), so in order to compare time we have to use the 3144 // same timestamp type when saving the flush timestamp. 3145 // All IE versions use low-res event timestamps, and have problematic clock 3146 // implementations (#9632) 3147 if (inBrowser && !isIE) { 3148 var performance_1 = window.performance; 3149 if (performance_1 && 3150 typeof performance_1.now === 'function' && 3151 getNow() > document.createEvent('Event').timeStamp) { 3152 // if the event timestamp, although evaluated AFTER the Date.now(), is 3153 // smaller than it, it means the event is using a hi-res timestamp, 3154 // and we need to use the hi-res version for event listener timestamps as 3155 // well. 3156 getNow = function () { return performance_1.now(); }; 3157 } 3158 } 3159 var sortCompareFn = function (a, b) { 3160 if (a.post) { 3161 if (!b.post) 3162 return 1; 3163 } 3164 else if (b.post) { 3165 return -1; 3166 } 3167 return a.id - b.id; 3168 }; 3169 /** 3170 * Flush both queues and run the watchers. 3171 */ 3172 function flushSchedulerQueue() { 3173 currentFlushTimestamp = getNow(); 3174 flushing = true; 3175 var watcher, id; 3176 // Sort queue before flush. 3177 // This ensures that: 3178 // 1. Components are updated from parent to child. (because parent is always 3179 // created before the child) 3180 // 2. A component's user watchers are run before its render watcher (because 3181 // user watchers are created before the render watcher) 3182 // 3. If a component is destroyed during a parent component's watcher run,
3183 // its watchers can be skipped. 3184 queue.sort(sortCompareFn); 3185 // do not cache length because more watchers might be pushed 3186 // as we run existing watchers 3187 for (index$1 = 0; index$1 < queue.length; index$1++) { 3188 watcher = queue[index$1]; 3189 if (watcher.before) { 3190 watcher.before(); 3191 } 3192 id = watcher.id; 3193 has[id] = null; 3194 watcher.run(); 3195 // in dev build, check and stop circular updates. 3196 if (has[id] != null) { 3197 circular[id] = (circular[id] || 0) + 1; 3198 if (circular[id] > MAX_UPDATE_COUNT) { 3199 warn$2('You may have an infinite update loop ' + 3200 (watcher.user 3201 ? "in watcher with expression \"".concat(watcher.expression, "\"") 3202 : "in a component render function."), watcher.vm); 3203 break; 3204 } 3205 } 3206 } 3207 // keep copies of post queues before resetting state 3208 var activatedQueue = activatedChildren.slice(); 3209 var updatedQueue = queue.slice(); 3210 resetSchedulerState(); 3211 // call component updated and activated hooks 3212 callActivatedHooks(activatedQueue); 3213 callUpdatedHooks(updatedQueue); 3214 cleanupDeps(); 3215 // devtool hook 3216 /* istanbul ignore if */ 3217 if (devtools && config.devtools) { 3218 devtools.emit('flush'); 3219 } 3220 } 3221 function callUpdatedHooks(queue) { 3222 var i = queue.length; 3223 while (i--) { 3224 var watcher = queue[i]; 3225 var vm = watcher.vm; 3226 if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) { 3227 callHook$1(vm, 'updated'); 3228 } 3229 } 3230 } 3231 /** 3232 * Queue a kept-alive component that was activated during patch. 3233 * The queue will be processed after the entire tree has been patched. 3234 */ 3235 function queueActivatedComponent(vm) { 3236 // setting _inactive to false here so that a render function can 3237 // rely on checking whether it's in an inactive tree (e.g. router-view) 3238 vm._inactive = false; 3239 activatedChildren.push(vm); 3240 } 3241 function callActivatedHooks(queue) { 3242 for (var i = 0; i < queue.length; i++) { 3243 queue[i]._inactive = true; 3244 activateChildComponent(queue[i], true /* true */); 3245 } 3246 } 3247 /** 3248 * Push a watcher into the watcher queue. 3249 * Jobs with duplicate IDs will be skipped unless it's 3250 * pushed when the queue is being flushed. 3251 */ 3252 function queueWatcher(watcher) { 3253 var id = watcher.id; 3254 if (has[id] != null) { 3255 return; 3256 } 3257 if (watcher === Dep.target && watcher.noRecurse) { 3258 return; 3259 } 3260 has[id] = true; 3261 if (!flushing) { 3262 queue.push(watcher); 3263 } 3264 else { 3265 // if already flushing, splice the watcher based on its id 3266 // if already past its id, it will be run next immediately. 3267 var i = queue.length - 1; 3268 while (i > index$1 && queue[i].id > watcher.id) { 3269 i--; 3270 } 3271 queue.splice(i + 1, 0, watcher); 3272 } 3273 // queue the flush 3274 if (!waiting) { 3275 waiting = true; 3276 if (!config.async) { 3277 flushSchedulerQueue(); 3278 return; 3279 } 3280 nextTick(flushSchedulerQueue); 3281 } 3282 } 3283 3284 var WATCHER = "watcher"; 3285 var WATCHER_CB = "".concat(WATCHER, " callback"); 3286 var WATCHER_GETTER = "".concat(WATCHER, " getter"); 3287 var WATCHER_CLEANUP = "".concat(WATCHER, " cleanup"); 3288 // Simple effect. 3289 function watchEffect(effect, options) { 3290 return doWatch(effect, null, options); 3291 } 3292 function watchPostEffect(effect, options) { 3293 return doWatch(effect, null, (__assign(__assign({}, options), { flush: 'post' }) )); 3294 } 3295 function watchSyncEffect(effect, options) { 3296 return doWatch(effect, null, (__assign(__assign({}, options), { flush: 'sync' }) )); 3297 } 3298 // initial value for watchers to trigger on undefined initial values 3299 var INITIAL_WATCHER_VALUE = {}; 3300 // implementation 3301 function watch(source, cb, options) { 3302 if (typeof cb !== 'function') { 3303 warn$2("`watch(fn, options?)` signature has been moved to a separate API. " + 3304 "Use `watchEffect(fn, options?)` instead. `watch` now only " + 3305 "supports `watch(source, cb, options?) signature."); 3306 } 3307 return doWatch(source, cb, options); 3308 } 3309 function doWatch(source, cb, _a) { 3310 var _b = _a === void 0 ? emptyObject : _a, immediate = _b.immediate, deep = _b.deep, _c = _b.flush, flush = _c === void 0 ? 'pre' : _c, onTrack = _b.onTrack, onTrigger = _b.onTrigger; 3311 if (!cb) { 3312 if (immediate !== undefined) { 3313 warn$2("watch() \"immediate\" option is only respected when using the " + 3314 "watch(source, callback, options?) signature."); 3315 } 3316 if (deep !== undefined) { 3317 warn$2("watch() \"deep\" option is only respected when using the " + 3318 "watch(source, callback, options?) signature."); 3319 } 3320 }
3321 var warnInvalidSource = function (s) { 3322 warn$2("Invalid watch source: ".concat(s, ". A watch source can only be a getter/effect ") + 3323 "function, a ref, a reactive object, or an array of these types."); 3324 }; 3325 var instance = currentInstance; 3326 var call = function (fn, type, args) { 3327 if (args === void 0) { args = null; } 3328 return invokeWithErrorHandling(fn, null, args, instance, type); 3329 }; 3330 var getter; 3331 var forceTrigger = false; 3332 var isMultiSource = false; 3333 if (isRef(source)) { 3334 getter = function () { return source.value; }; 3335 forceTrigger = isShallow(source); 3336 } 3337 else if (isReactive(source)) { 3338 getter = function () { 3339 source.__ob__.dep.depend(); 3340 return source; 3341 }; 3342 deep = true; 3343 } 3344 else if (isArray(source)) { 3345 isMultiSource = true; 3346 forceTrigger = source.some(function (s) { return isReactive(s) || isShallow(s); }); 3347 getter = function () { 3348 return source.map(function (s) { 3349 if (isRef(s)) { 3350 return s.value; 3351 } 3352 else if (isReactive(s)) { 3353 return traverse(s); 3354 } 3355 else if (isFunction(s)) { 3356 return call(s, WATCHER_GETTER); 3357 } 3358 else { 3359 warnInvalidSource(s); 3360 } 3361 }); 3362 }; 3363 } 3364 else if (isFunction(source)) { 3365 if (cb) { 3366 // getter with cb 3367 getter = function () { return call(source, WATCHER_GETTER); }; 3368 } 3369 else { 3370 // no cb -> simple effect 3371 getter = function () { 3372 if (instance && instance._isDestroyed) { 3373 return; 3374 } 3375 if (cleanup) { 3376 cleanup(); 3377 } 3378 return call(source, WATCHER, [onCleanup]); 3379 }; 3380 } 3381 } 3382 else { 3383 getter = noop; 3384 warnInvalidSource(source); 3385 } 3386 if (cb && deep) { 3387 var baseGetter_1 = getter; 3388 getter = function () { return traverse(baseGetter_1()); }; 3389 } 3390 var cleanup; 3391 var onCleanup = function (fn) { 3392 cleanup = watcher.onStop = function () { 3393 call(fn, WATCHER_CLEANUP); 3394 }; 3395 }; 3396 // in SSR there is no need to setup an actual effect, and it should be noop 3397 // unless it's eager 3398 if (isServerRendering()) { 3399 // we will also not call the invalidate callback (+ runner is not set up) 3400 onCleanup = noop; 3401 if (!cb) { 3402 getter(); 3403 } 3404 else if (immediate) { 3405 call(cb, WATCHER_CB, [ 3406 getter(), 3407 isMultiSource ? [] : undefined, 3408 onCleanup 3409 ]); 3410 } 3411 return noop; 3412 } 3413 var watcher = new Watcher(currentInstance, getter, noop, { 3414 lazy: true 3415 }); 3416 watcher.noRecurse = !cb; 3417 var oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE; 3418 // overwrite default run 3419 watcher.run = function () { 3420 if (!watcher.active) { 3421 return; 3422 } 3423 if (cb) { 3424 // watch(source, cb) 3425 var newValue = watcher.get(); 3426 if (deep || 3427 forceTrigger || 3428 (isMultiSource 3429 ? newValue.some(function (v, i) { 3430 return hasChanged(v, oldValue[i]); 3431 }) 3432 : hasChanged(newValue, oldValue))) { 3433 // cleanup before running cb again 3434 if (cleanup) { 3435 cleanup(); 3436 } 3437 call(cb, WATCHER_CB, [ 3438 newValue, 3439 // pass undefined as the old value when it's changed for the first time 3440 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, 3441 onCleanup 3442 ]); 3443 oldValue = newValue; 3444 } 3445 } 3446 else { 3447 // watchEffect 3448 watcher.get(); 3449 } 3450 }; 3451 if (flush === 'sync') { 3452 watcher.update = watcher.run; 3453 } 3454 else if (flush === 'post') { 3455 watcher.post = true; 3456 watcher.update = function () { return queueWatcher(watcher); }; 3457 } 3458 else { 3459 // pre 3460 watcher.update = function () { 3461 if (instance && instance === currentInstance && !instance._isMounted) { 3462 // pre-watcher triggered before 3463 var buffer = instance._preWatchers || (instance._preWatchers = []); 3464 if (buffer.indexOf(watcher) < 0) 3465 buffer.push(watcher); 3466 } 3467 else { 3468 queueWatcher(watcher); 3469 } 3470 }; 3471 } 3472 { 3473 watcher.onTrack = onTrack; 3474 watcher.onTrigger = onTrigger; 3475 } 3476 // initial run 3477 if (cb) { 3478 if (immediate) { 3479 watcher.run(); 3480 } 3481 else { 3482 oldValue = watcher.get(); 3483 } 3484 } 3485 else if (flush === 'post' && instance) { 3486 instance.$once('hook:mounted', function () { return watcher.get(); }); 3487 } 3488 else { 3489 watcher.get(); 3490 } 3491 return function () { 3492 watcher.teardown(); 3493 }; 3494 } 3495 3496 var activeEffectScope; 3497 var EffectScope = /** @class */ (function () { 3498 function EffectScope(detached) { 3499 if (detached === void 0) { detached = false; } 3500 this.detached = detached; 3501 /** 3502 * @internal 3503 */ 3504 this.active = true; 3505 /** 3506 * @internal 3507 */ 3508 this.effects = []; 3509 /** 3510 * @internal 3511 */ 3512 this.cleanups = []; 3513 this.parent = activeEffectScope; 3514 if (!detached && activeEffectScope) { 3515 this.index = 3516 (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1; 3517 } 3518 }
3519 EffectScope.prototype.run = function (fn) { 3520 if (this.active) { 3521 var currentEffectScope = activeEffectScope; 3522 try { 3523 activeEffectScope = this; 3524 return fn(); 3525 } 3526 finally { 3527 activeEffectScope = currentEffectScope; 3528 } 3529 } 3530 else { 3531 warn$2("cannot run an inactive effect scope."); 3532 } 3533 }; 3534 /** 3535 * This should only be called on non-detached scopes 3536 * @internal 3537 */ 3538 EffectScope.prototype.on = function () { 3539 activeEffectScope = this; 3540 }; 3541 /** 3542 * This should only be called on non-detached scopes 3543 * @internal 3544 */ 3545 EffectScope.prototype.off = function () { 3546 activeEffectScope = this.parent; 3547 }; 3548 EffectScope.prototype.stop = function (fromParent) { 3549 if (this.active) { 3550 var i = void 0, l = void 0; 3551 for (i = 0, l = this.effects.length; i < l; i++) { 3552 this.effects[i].teardown(); 3553 } 3554 for (i = 0, l = this.cleanups.length; i < l; i++) { 3555 this.cleanups[i](); 3556 } 3557 if (this.scopes) { 3558 for (i = 0, l = this.scopes.length; i < l; i++) { 3559 this.scopes[i].stop(true); 3560 } 3561 } 3562 // nested scope, dereference from parent to avoid memory leaks 3563 if (!this.detached && this.parent && !fromParent) { 3564 // optimized O(1) removal 3565 var last = this.parent.scopes.pop(); 3566 if (last && last !== this) { 3567 this.parent.scopes[this.index] = last; 3568 last.index = this.index; 3569 } 3570 } 3571 this.parent = undefined; 3572 this.active = false; 3573 } 3574 }; 3575 return EffectScope; 3576 }()); 3577 function effectScope(detached) { 3578 return new EffectScope(detached); 3579 } 3580 /** 3581 * @internal 3582 */ 3583 function recordEffectScope(effect, scope) { 3584 if (scope === void 0) { scope = activeEffectScope; } 3585 if (scope && scope.active) { 3586 scope.effects.push(effect); 3587 } 3588 } 3589 function getCurrentScope() { 3590 return activeEffectScope; 3591 } 3592 function onScopeDispose(fn) { 3593 if (activeEffectScope) { 3594 activeEffectScope.cleanups.push(fn); 3595 } 3596 else { 3597 warn$2("onScopeDispose() is called when there is no active effect scope" + 3598 " to be associated with."); 3599 } 3600 } 3601 3602 function provide(key, value) { 3603 if (!currentInstance) { 3604 { 3605 warn$2("provide() can only be used inside setup()."); 3606 } 3607 } 3608 else { 3609 // TS doesn't allow symbol as index type 3610 resolveProvided(currentInstance)[key] = value; 3611 } 3612 } 3613 function resolveProvided(vm) { 3614 // by default an instance inherits its parent's provides object 3615 // but when it needs to provide values of its own, it creates its 3616 // own provides object using parent provides object as prototype. 3617 // this way in `inject` we can simply look up injections from direct 3618 // parent and let the prototype chain do the work. 3619 var existing = vm._provided; 3620 var parentProvides = vm.$parent && vm.$parent._provided; 3621 if (parentProvides === existing) { 3622 return (vm._provided = Object.create(parentProvides)); 3623 } 3624 else { 3625 return existing; 3626 } 3627 } 3628 function inject(key, defaultValue, treatDefaultAsFactory) { 3629 if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } 3630 // fallback to `currentRenderingInstance` so that this can be called in 3631 // a functional component 3632 var instance = currentInstance; 3633 if (instance) { 3634 // #2400 3635 // to support `app.use` plugins, 3636 // fallback to appContext's `provides` if the instance is at root 3637 var provides = instance.$parent && instance.$parent._provided; 3638 if (provides && key in provides) { 3639 // TS doesn't allow symbol as index type 3640 return provides[key]; 3641 } 3642 else if (arguments.length > 1) { 3643 return treatDefaultAsFactory && isFunction(defaultValue) 3644 ? defaultValue.call(instance) 3645 : defaultValue; 3646 } 3647 else { 3648 warn$2("injection \"".concat(String(key), "\" not found.")); 3649 } 3650 } 3651 else { 3652 warn$2("inject() can only be used inside setup() or functional components."); 3653 } 3654 } 3655 3656 /** 3657 * @internal this function needs manual public type declaration because it relies 3658 * on previously manually authored types from Vue 2 3659 */ 3660 function h(type, props, children) { 3661 if (!currentInstance) { 3662 warn$2("globally imported h() can only be invoked when there is an active " + 3663 "component instance, e.g. synchronously in a component's render or setup function."); 3664 } 3665 return createElement$1(currentInstance, type, props, children, 2, true); 3666 } 3667 3668 function handleError(err, vm, info) { 3669 // Deactivate deps tracking while processing error handler to avoid possible infinite rendering. 3670 // See: https://github.com/vuejs/vuex/issues/1505 3671 pushTarget();
vendor: 4,889 bytes, lines 3672-3797
3672 try { 3673 if (vm) { 3674 var cur = vm; 3675 while ((cur = cur.$parent)) { 3676 var hooks = cur.$options.errorCaptured; 3677 if (hooks) { 3678 for (var i = 0; i < hooks.length; i++) { 3679 try { 3680 var capture = hooks[i].call(cur, err, vm, info) === false; 3681 if (capture) 3682 return; 3683 } 3684 catch (e) { 3685 globalHandleError(e, cur, 'errorCaptured hook'); 3686 } 3687 } 3688 } 3689 } 3690 } 3691 globalHandleError(err, vm, info); 3692 } 3693 finally { 3694 popTarget(); 3695 } 3696 } 3697 function invokeWithErrorHandling(handler, context, args, vm, info) { 3698 var res; 3699 try { 3700 res = args ? handler.apply(context, args) : handler.call(context); 3701 if (res && !res._isVue && isPromise(res) && !res._handled) { 3702 res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); }); 3703 res._handled = true; 3704 } 3705 } 3706 catch (e) { 3707 handleError(e, vm, info); 3708 } 3709 return res; 3710 } 3711 function globalHandleError(err, vm, info) { 3712 if (config.errorHandler) { 3713 try { 3714 return config.errorHandler.call(null, err, vm, info); 3715 } 3716 catch (e) { 3717 // if the user intentionally throws the original error in the handler, 3718 // do not log it twice 3719 if (e !== err) { 3720 logError(e, null, 'config.errorHandler'); 3721 } 3722 } 3723 } 3724 logError(err, vm, info); 3725 } 3726 function logError(err, vm, info) { 3727 { 3728 warn$2("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); 3729 } 3730 /* istanbul ignore else */ 3731 if (inBrowser && typeof console !== 'undefined') { 3732 console.error(err); 3733 } 3734 else { 3735 throw err; 3736 } 3737 } 3738 3739 /* globals MutationObserver */ 3740 var isUsingMicroTask = false; 3741 var callbacks = []; 3742 var pending = false; 3743 function flushCallbacks() { 3744 pending = false; 3745 var copies = callbacks.slice(0); 3746 callbacks.length = 0; 3747 for (var i = 0; i < copies.length; i++) { 3748 copies[i](); 3749 } 3750 } 3751 // Here we have async deferring wrappers using microtasks. 3752 // In 2.5 we used (macro) tasks (in combination with microtasks). 3753 // However, it has subtle problems when state is changed right before repaint 3754 // (e.g. #6813, out-in transitions). 3755 // Also, using (macro) tasks in event handler would cause some weird behaviors 3756 // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109). 3757 // So we now use microtasks everywhere, again. 3758 // A major drawback of this tradeoff is that there are some scenarios 3759 // where microtasks have too high a priority and fire in between supposedly 3760 // sequential events (e.g. #4521, #6690, which have workarounds) 3761 // or even between bubbling of the same event (#6566). 3762 var timerFunc; 3763 // The nextTick behavior leverages the microtask queue, which can be accessed 3764 // via either native Promise.then or MutationObserver. 3765 // MutationObserver has wider support, however it is seriously bugged in 3766 // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It 3767 // completely stops working after triggering a few times... so, if native 3768 // Promise is available, we will use it: 3769 /* istanbul ignore next, $flow-disable-line */ 3770 if (typeof Promise !== 'undefined' && isNative(Promise)) { 3771 var p_1 = Promise.resolve(); 3772 timerFunc = function () { 3773 p_1.then(flushCallbacks); 3774 // In problematic UIWebViews, Promise.then doesn't completely break, but 3775 // it can get stuck in a weird state where callbacks are pushed into the 3776 // microtask queue but the queue isn't being flushed, until the browser 3777 // needs to do some other work, e.g. handle a timer. Therefore we can 3778 // "force" the microtask queue to be flushed by adding an empty timer. 3779 if (isIOS) 3780 setTimeout(noop); 3781 }; 3782 isUsingMicroTask = true; 3783 } 3784 else if (!isIE && 3785 typeof MutationObserver !== 'undefined' && 3786 (isNative(MutationObserver) || 3787 // PhantomJS and iOS 7.x 3788 MutationObserver.toString() === '[object MutationObserverConstructor]')) { 3789 // Use MutationObserver where native Promise is not available, 3790 // e.g. PhantomJS, iOS7, Android 4.4 3791 // (#6466 MutationObserver is unreliable in IE11) 3792 var counter_1 = 1; 3793 var observer = new MutationObserver(flushCallbacks); 3794 var textNode_1 = document.createTextNode(String(counter_1)); 3795 observer.observe(textNode_1, { 3796 characterData: true 3797 });
3798 timerFunc = function () { 3799 counter_1 = (counter_1 + 1) % 2; 3800 textNode_1.data = String(counter_1); 3801 }; 3802 isUsingMicroTask = true; 3803 } 3804 else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { 3805 // Fallback to setImmediate. 3806 // Technically it leverages the (macro) task queue, 3807 // but it is still a better choice than setTimeout. 3808 timerFunc = function () { 3809 setImmediate(flushCallbacks); 3810 }; 3811 } 3812 else { 3813 // Fallback to setTimeout. 3814 timerFunc = function () { 3815 setTimeout(flushCallbacks, 0); 3816 }; 3817 } 3818 /** 3819 * @internal 3820 */ 3821 function nextTick(cb, ctx) { 3822 var _resolve; 3823 callbacks.push(function () { 3824 if (cb) { 3825 try { 3826 cb.call(ctx); 3827 } 3828 catch (e) { 3829 handleError(e, ctx, 'nextTick'); 3830 } 3831 } 3832 else if (_resolve) { 3833 _resolve(ctx); 3834 } 3835 }); 3836 if (!pending) { 3837 pending = true; 3838 timerFunc(); 3839 } 3840 // $flow-disable-line 3841 if (!cb && typeof Promise !== 'undefined') { 3842 return new Promise(function (resolve) { 3843 _resolve = resolve; 3844 }); 3845 } 3846 } 3847 3848 function useCssModule(name) { 3849 /* istanbul ignore else */ 3850 { 3851 { 3852 warn$2("useCssModule() is not supported in the global build."); 3853 } 3854 return emptyObject; 3855 } 3856 } 3857 3858 /** 3859 * Runtime helper for SFC's CSS variable injection feature. 3860 * @private 3861 */ 3862 function useCssVars(getter) { 3863 if (!inBrowser && !false) 3864 return; 3865 var instance = currentInstance; 3866 if (!instance) { 3867 warn$2("useCssVars is called without current active component instance."); 3868 return; 3869 } 3870 watchPostEffect(function () { 3871 var el = instance.$el; 3872 var vars = getter(instance, instance._setupProxy); 3873 if (el && el.nodeType === 1) { 3874 var style = el.style; 3875 for (var key in vars) { 3876 style.setProperty("--".concat(key), vars[key]); 3877 } 3878 } 3879 }); 3880 } 3881 3882 /** 3883 * v3-compatible async component API. 3884 * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts 3885 * because it relies on existing manual types 3886 */ 3887 function defineAsyncComponent(source) { 3888 if (isFunction(source)) { 3889 source = { loader: source }; 3890 } 3891 var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out 3892 _b = source.suspensible, // undefined = never times out 3893 suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true 3894 userOnError = source.onError; 3895 if (suspensible) { 3896 warn$2("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); 3897 } 3898 var pendingRequest = null; 3899 var retries = 0; 3900 var retry = function () { 3901 retries++; 3902 pendingRequest = null; 3903 return load(); 3904 }; 3905 var load = function () { 3906 var thisRequest; 3907 return (pendingRequest || 3908 (thisRequest = pendingRequest = 3909 loader() 3910 .catch(function (err) { 3911 err = err instanceof Error ? err : new Error(String(err)); 3912 if (userOnError) { 3913 return new Promise(function (resolve, reject) { 3914 var userRetry = function () { return resolve(retry()); }; 3915 var userFail = function () { return reject(err); }; 3916 userOnError(err, userRetry, userFail, retries + 1); 3917 }); 3918 } 3919 else { 3920 throw err; 3921 } 3922 }) 3923 .then(function (comp) { 3924 if (thisRequest !== pendingRequest && pendingRequest) { 3925 return pendingRequest; 3926 } 3927 if (!comp) { 3928 warn$2("Async component loader resolved to undefined. " + 3929 "If you are using retry(), make sure to return its return value."); 3930 } 3931 // interop module default 3932 if (comp && 3933 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { 3934 comp = comp.default; 3935 } 3936 if (comp && !isObject(comp) && !isFunction(comp)) { 3937 throw new Error("Invalid async component load result: ".concat(comp)); 3938 } 3939 return comp; 3940 }))); 3941 }; 3942 return function () { 3943 var component = load(); 3944 return { 3945 component: component, 3946 delay: delay, 3947 timeout: timeout, 3948 error: errorComponent, 3949 loading: loadingComponent 3950 }; 3951 }; 3952 } 3953 3954 function createLifeCycle(hookName) { 3955 return function (fn, target) { 3956 if (target === void 0) { target = currentInstance; } 3957 if (!target) { 3958 warn$2("".concat(formatName(hookName), " is called when there is no active component instance to be ") + 3959 "associated with. " + 3960 "Lifecycle injection APIs can only be used during execution of setup()."); 3961 return; 3962 } 3963 return injectHook(target, hookName, fn); 3964 }; 3965 } 3966 function formatName(name) { 3967 if (name === 'beforeDestroy') { 3968 name = 'beforeUnmount'; 3969 } 3970 else if (name === 'destroyed') { 3971 name = 'unmounted'; 3972 } 3973 return "on".concat(name[0].toUpperCase() + name.slice(1)); 3974 } 3975 function injectHook(instance, hookName, fn) { 3976 var options = instance.$options; 3977 options[hookName] = mergeLifecycleHook(options[hookName], fn); 3978 } 3979 var onBeforeMount = createLifeCycle('beforeMount'); 3980 var onMounted = createLifeCycle('mounted'); 3981 var onBeforeUpdate = createLifeCycle('beforeUpdate'); 3982 var onUpdated = createLifeCycle('updated'); 3983 var onBeforeUnmount = createLifeCycle('beforeDestroy'); 3984 var onUnmounted = createLifeCycle('destroyed'); 3985 var onActivated = createLifeCycle('activated'); 3986 var onDeactivated = createLifeCycle('deactivated'); 3987 var onServerPrefetch = createLifeCycle('serverPrefetch'); 3988 var onRenderTracked = createLifeCycle('renderTracked'); 3989 var onRenderTriggered = createLifeCycle('renderTriggered'); 3990 var injectErrorCapturedHook = createLifeCycle('errorCaptured'); 3991 function onErrorCaptured(hook, target) { 3992 if (target === void 0) { target = currentInstance; } 3993 injectErrorCapturedHook(hook, target); 3994 } 3995 3996 /** 3997 * Note: also update dist/vue.runtime.mjs when adding new exports to this file. 3998 */ 3999 var version = '2.7.14'; 4000 /** 4001 * @internal type is manually declared in <root>/types/v3-define-component.d.ts 4002 */ 4003 function defineComponent(options) { 4004 return options; 4005 } 4006 4007 var vca = /*#__PURE__*/Object.freeze({ 4008 __proto__: null, 4009 version: version, 4010 defineComponent: defineComponent, 4011 ref: ref$1, 4012 shallowRef: shallowRef, 4013 isRef: isRef, 4014 toRef: toRef, 4015 toRefs: toRefs, 4016 unref: unref, 4017 proxyRefs: proxyRefs, 4018 customRef: customRef, 4019 triggerRef: triggerRef, 4020 reactive: reactive, 4021 isReactive: isReactive, 4022 isReadonly: isReadonly, 4023 isShallow: isShallow, 4024 isProxy: isProxy, 4025 shallowReactive: shallowReactive, 4026 markRaw: markRaw, 4027 toRaw: toRaw, 4028 readonly: readonly, 4029 shallowReadonly: shallowReadonly, 4030 computed: computed, 4031 watch: watch, 4032 watchEffect: watchEffect, 4033 watchPostEffect: watchPostEffect, 4034 watchSyncEffect: watchSyncEffect, 4035 EffectScope: EffectScope, 4036 effectScope: effectScope, 4037 onScopeDispose: onScopeDispose, 4038 getCurrentScope: getCurrentScope, 4039 provide: provide, 4040 inject: inject, 4041 h: h, 4042 getCurrentInstance: getCurrentInstance, 4043 useSlots: useSlots, 4044 useAttrs: useAttrs, 4045 useListeners: useListeners, 4046 mergeDefaults: mergeDefaults, 4047 nextTick: nextTick, 4048 set: set, 4049 del: del, 4050 useCssModule: useCssModule, 4051 useCssVars: useCssVars, 4052 defineAsyncComponent: defineAsyncComponent, 4053 onBeforeMount: onBeforeMount, 4054 onMounted: onMounted, 4055 onBeforeUpdate: onBeforeUpdate, 4056 onUpdated: onUpdated, 4057 onBeforeUnmount: onBeforeUnmount, 4058 onUnmounted: onUnmounted, 4059 onActivated: onActivated, 4060 onDeactivated: onDeactivated, 4061 onServerPrefetch: onServerPrefetch, 4062 onRenderTracked: onRenderTracked, 4063 onRenderTriggered: onRenderTriggered, 4064 onErrorCaptured: onErrorCaptured 4065 }); 4066 4067 var seenObjects = new _Set(); 4068 /** 4069 * Recursively traverse an object to evoke all converted 4070 * getters, so that every nested property inside the object 4071 * is collected as a "deep" dependency. 4072 */ 4073 function traverse(val) { 4074 _traverse(val, seenObjects); 4075 seenObjects.clear(); 4076 return val; 4077 } 4078 function _traverse(val, seen) { 4079 var i, keys; 4080 var isA = isArray(val); 4081 if ((!isA && !isObject(val)) || 4082 val.__v_skip /* ReactiveFlags.SKIP */ || 4083 Object.isFrozen(val) || 4084 val instanceof VNode) { 4085 return; 4086 } 4087 if (val.__ob__) { 4088 var depId = val.__ob__.dep.id; 4089 if (seen.has(depId)) { 4090 return; 4091 } 4092 seen.add(depId); 4093 } 4094 if (isA) { 4095 i = val.length; 4096 while (i--) 4097 _traverse(val[i], seen); 4098 } 4099 else if (isRef(val)) { 4100 _traverse(val.value, seen); 4101 } 4102 else { 4103 keys = Object.keys(val); 4104 i = keys.length; 4105 while (i--) 4106 _traverse(val[keys[i]], seen); 4107 } 4108 } 4109 4110 var uid$1 = 0; 4111 /** 4112 * A watcher parses an expression, collects dependencies, 4113 * and fires callback when the expression value changes. 4114 * This is used for both the $watch() api and directives. 4115 * @internal 4116 */ 4117 var Watcher = /** @class */ (function () { 4118 function Watcher(vm, expOrFn, cb, options, isRenderWatcher) { 4119 recordEffectScope(this, 4120 // if the active effect scope is manually created (not a component scope), 4121 // prioritize it 4122 activeEffectScope && !activeEffectScope._vm 4123 ? activeEffectScope 4124 : vm 4125 ? vm._scope 4126 : undefined); 4127 if ((this.vm = vm) && isRenderWatcher) { 4128 vm._watcher = this; 4129 } 4130 // options 4131 if (options) { 4132 this.deep = !!options.deep; 4133 this.user = !!options.user; 4134 this.lazy = !!options.lazy; 4135 this.sync = !!options.sync; 4136 this.before = options.before; 4137 { 4138 this.onTrack = options.onTrack; 4139 this.onTrigger = options.onTrigger; 4140 } 4141 } 4142 else { 4143 this.deep = this.user = this.lazy = this.sync = false;
4144 } 4145 this.cb = cb; 4146 this.id = ++uid$1; // uid for batching 4147 this.active = true; 4148 this.post = false; 4149 this.dirty = this.lazy; // for lazy watchers 4150 this.deps = []; 4151 this.newDeps = []; 4152 this.depIds = new _Set(); 4153 this.newDepIds = new _Set(); 4154 this.expression = expOrFn.toString() ; 4155 // parse expression for getter 4156 if (isFunction(expOrFn)) { 4157 this.getter = expOrFn; 4158 } 4159 else { 4160 this.getter = parsePath(expOrFn); 4161 if (!this.getter) { 4162 this.getter = noop; 4163 warn$2("Failed watching path: \"".concat(expOrFn, "\" ") + 4164 'Watcher only accepts simple dot-delimited paths. ' + 4165 'For full control, use a function instead.', vm); 4166 } 4167 } 4168 this.value = this.lazy ? undefined : this.get(); 4169 } 4170 /** 4171 * Evaluate the getter, and re-collect dependencies. 4172 */ 4173 Watcher.prototype.get = function () { 4174 pushTarget(this); 4175 var value; 4176 var vm = this.vm; 4177 try { 4178 value = this.getter.call(vm, vm); 4179 } 4180 catch (e) { 4181 if (this.user) { 4182 handleError(e, vm, "getter for watcher \"".concat(this.expression, "\"")); 4183 } 4184 else { 4185 throw e; 4186 } 4187 } 4188 finally { 4189 // "touch" every property so they are all tracked as 4190 // dependencies for deep watching 4191 if (this.deep) { 4192 traverse(value); 4193 } 4194 popTarget(); 4195 this.cleanupDeps(); 4196 } 4197 return value; 4198 }; 4199 /** 4200 * Add a dependency to this directive. 4201 */ 4202 Watcher.prototype.addDep = function (dep) { 4203 var id = dep.id; 4204 if (!this.newDepIds.has(id)) { 4205 this.newDepIds.add(id); 4206 this.newDeps.push(dep); 4207 if (!this.depIds.has(id)) { 4208 dep.addSub(this); 4209 } 4210 } 4211 }; 4212 /** 4213 * Clean up for dependency collection. 4214 */ 4215 Watcher.prototype.cleanupDeps = function () { 4216 var i = this.deps.length; 4217 while (i--) { 4218 var dep = this.deps[i]; 4219 if (!this.newDepIds.has(dep.id)) { 4220 dep.removeSub(this); 4221 } 4222 } 4223 var tmp = this.depIds; 4224 this.depIds = this.newDepIds; 4225 this.newDepIds = tmp; 4226 this.newDepIds.clear(); 4227 tmp = this.deps; 4228 this.deps = this.newDeps; 4229 this.newDeps = tmp; 4230 this.newDeps.length = 0; 4231 }; 4232 /** 4233 * Subscriber interface. 4234 * Will be called when a dependency changes. 4235 */ 4236 Watcher.prototype.update = function () { 4237 /* istanbul ignore else */ 4238 if (this.lazy) { 4239 this.dirty = true; 4240 } 4241 else if (this.sync) { 4242 this.run(); 4243 } 4244 else { 4245 queueWatcher(this); 4246 } 4247 }; 4248 /** 4249 * Scheduler job interface. 4250 * Will be called by the scheduler. 4251 */ 4252 Watcher.prototype.run = function () { 4253 if (this.active) { 4254 var value = this.get(); 4255 if (value !== this.value || 4256 // Deep watchers and watchers on Object/Arrays should fire even 4257 // when the value is the same, because the value may 4258 // have mutated. 4259 isObject(value) || 4260 this.deep) { 4261 // set new value 4262 var oldValue = this.value; 4263 this.value = value; 4264 if (this.user) { 4265 var info = "callback for watcher \"".concat(this.expression, "\""); 4266 invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info); 4267 } 4268 else { 4269 this.cb.call(this.vm, value, oldValue); 4270 } 4271 } 4272 } 4273 }; 4274 /** 4275 * Evaluate the value of the watcher. 4276 * This only gets called for lazy watchers. 4277 */ 4278 Watcher.prototype.evaluate = function () { 4279 this.value = this.get(); 4280 this.dirty = false;
4281 }; 4282 /** 4283 * Depend on all deps collected by this watcher. 4284 */ 4285 Watcher.prototype.depend = function () { 4286 var i = this.deps.length; 4287 while (i--) { 4288 this.deps[i].depend(); 4289 } 4290 }; 4291 /** 4292 * Remove self from all dependencies' subscriber list. 4293 */ 4294 Watcher.prototype.teardown = function () { 4295 if (this.vm && !this.vm._isBeingDestroyed) { 4296 remove$2(this.vm._scope.effects, this); 4297 } 4298 if (this.active) { 4299 var i = this.deps.length; 4300 while (i--) { 4301 this.deps[i].removeSub(this); 4302 } 4303 this.active = false; 4304 if (this.onStop) { 4305 this.onStop(); 4306 } 4307 } 4308 }; 4309 return Watcher; 4310 }()); 4311 4312 var sharedPropertyDefinition = { 4313 enumerable: true, 4314 configurable: true, 4315 get: noop, 4316 set: noop 4317 }; 4318 function proxy(target, sourceKey, key) { 4319 sharedPropertyDefinition.get = function proxyGetter() { 4320 return this[sourceKey][key]; 4321 }; 4322 sharedPropertyDefinition.set = function proxySetter(val) { 4323 this[sourceKey][key] = val; 4324 }; 4325 Object.defineProperty(target, key, sharedPropertyDefinition); 4326 } 4327 function initState(vm) { 4328 var opts = vm.$options; 4329 if (opts.props) 4330 initProps$1(vm, opts.props); 4331 // Composition API 4332 initSetup(vm); 4333 if (opts.methods) 4334 initMethods(vm, opts.methods); 4335 if (opts.data) { 4336 initData(vm); 4337 } 4338 else { 4339 var ob = observe((vm._data = {})); 4340 ob && ob.vmCount++; 4341 } 4342 if (opts.computed) 4343 initComputed$1(vm, opts.computed); 4344 if (opts.watch && opts.watch !== nativeWatch) { 4345 initWatch(vm, opts.watch); 4346 } 4347 } 4348 function initProps$1(vm, propsOptions) { 4349 var propsData = vm.$options.propsData || {}; 4350 var props = (vm._props = shallowReactive({})); 4351 // cache prop keys so that future props updates can iterate using Array 4352 // instead of dynamic object key enumeration. 4353 var keys = (vm.$options._propKeys = []); 4354 var isRoot = !vm.$parent; 4355 // root instance props should be converted 4356 if (!isRoot) { 4357 toggleObserving(false); 4358 } 4359 var _loop_1 = function (key) { 4360 keys.push(key); 4361 var value = validateProp(key, propsOptions, propsData, vm); 4362 /* istanbul ignore else */ 4363 { 4364 var hyphenatedKey = hyphenate(key); 4365 if (isReservedAttribute(hyphenatedKey) || 4366 config.isReservedAttr(hyphenatedKey)) { 4367 warn$2("\"".concat(hyphenatedKey, "\" is a reserved attribute and cannot be used as component prop."), vm); 4368 } 4369 defineReactive(props, key, value, function () { 4370 if (!isRoot && !isUpdatingChildComponent) { 4371 warn$2("Avoid mutating a prop directly since the value will be " + 4372 "overwritten whenever the parent component re-renders. " + 4373 "Instead, use a data or computed property based on the prop's " + 4374 "value. Prop being mutated: \"".concat(key, "\""), vm); 4375 } 4376 }); 4377 } 4378 // static props are already proxied on the component's prototype 4379 // during Vue.extend(). We only need to proxy props defined at 4380 // instantiation here. 4381 if (!(key in vm)) { 4382 proxy(vm, "_props", key); 4383 } 4384 }; 4385 for (var key in propsOptions) { 4386 _loop_1(key); 4387 } 4388 toggleObserving(true); 4389 } 4390 function initData(vm) { 4391 var data = vm.$options.data; 4392 data = vm._data = isFunction(data) ? getData(data, vm) : data || {}; 4393 if (!isPlainObject(data)) { 4394 data = {}; 4395 warn$2('data functions should return an object:\n' + 4396 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm); 4397 } 4398 // proxy data on instance 4399 var keys = Object.keys(data); 4400 var props = vm.$options.props; 4401 var methods = vm.$options.methods; 4402 var i = keys.length; 4403 while (i--) { 4404 var key = keys[i]; 4405 { 4406 if (methods && hasOwn(methods, key)) { 4407 warn$2("Method \"".concat(key, "\" has already been defined as a data property."), vm); 4408 } 4409 } 4410 if (props && hasOwn(props, key)) { 4411 warn$2("The data property \"".concat(key, "\" is already declared as a prop. ") + 4412 "Use prop default value instead.", vm); 4413 } 4414 else if (!isReserved(key)) { 4415 proxy(vm, "_data", key); 4416 } 4417 } 4418 // observe data 4419 var ob = observe(data); 4420 ob && ob.vmCount++; 4421 } 4422 function getData(data, vm) { 4423 // #7573 disable dep collection when invoking data getters 4424 pushTarget();
4425 try { 4426 return data.call(vm, vm); 4427 } 4428 catch (e) { 4429 handleError(e, vm, "data()"); 4430 return {}; 4431 } 4432 finally { 4433 popTarget(); 4434 } 4435 } 4436 var computedWatcherOptions = { lazy: true }; 4437 function initComputed$1(vm, computed) { 4438 // $flow-disable-line 4439 var watchers = (vm._computedWatchers = Object.create(null)); 4440 // computed properties are just getters during SSR 4441 var isSSR = isServerRendering(); 4442 for (var key in computed) { 4443 var userDef = computed[key]; 4444 var getter = isFunction(userDef) ? userDef : userDef.get; 4445 if (getter == null) { 4446 warn$2("Getter is missing for computed property \"".concat(key, "\"."), vm); 4447 } 4448 if (!isSSR) { 4449 // create internal watcher for the computed property. 4450 watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions); 4451 } 4452 // component-defined computed properties are already defined on the 4453 // component prototype. We only need to define computed properties defined 4454 // at instantiation here. 4455 if (!(key in vm)) { 4456 defineComputed(vm, key, userDef); 4457 } 4458 else { 4459 if (key in vm.$data) { 4460 warn$2("The computed property \"".concat(key, "\" is already defined in data."), vm); 4461 } 4462 else if (vm.$options.props && key in vm.$options.props) { 4463 warn$2("The computed property \"".concat(key, "\" is already defined as a prop."), vm); 4464 } 4465 else if (vm.$options.methods && key in vm.$options.methods) { 4466 warn$2("The computed property \"".concat(key, "\" is already defined as a method."), vm); 4467 } 4468 } 4469 } 4470 } 4471 function defineComputed(target, key, userDef) { 4472 var shouldCache = !isServerRendering(); 4473 if (isFunction(userDef)) { 4474 sharedPropertyDefinition.get = shouldCache 4475 ? createComputedGetter(key) 4476 : createGetterInvoker(userDef); 4477 sharedPropertyDefinition.set = noop; 4478 } 4479 else { 4480 sharedPropertyDefinition.get = userDef.get 4481 ? shouldCache && userDef.cache !== false 4482 ? createComputedGetter(key) 4483 : createGetterInvoker(userDef.get) 4484 : noop; 4485 sharedPropertyDefinition.set = userDef.set || noop; 4486 } 4487 if (sharedPropertyDefinition.set === noop) { 4488 sharedPropertyDefinition.set = function () { 4489 warn$2("Computed property \"".concat(key, "\" was assigned to but it has no setter."), this); 4490 }; 4491 } 4492 Object.defineProperty(target, key, sharedPropertyDefinition); 4493 } 4494 function createComputedGetter(key) { 4495 return function computedGetter() { 4496 var watcher = this._computedWatchers && this._computedWatchers[key]; 4497 if (watcher) { 4498 if (watcher.dirty) { 4499 watcher.evaluate(); 4500 } 4501 if (Dep.target) { 4502 if (Dep.target.onTrack) { 4503 Dep.target.onTrack({ 4504 effect: Dep.target, 4505 target: this, 4506 type: "get" /* TrackOpTypes.GET */, 4507 key: key 4508 }); 4509 } 4510 watcher.depend(); 4511 } 4512 return watcher.value; 4513 } 4514 }; 4515 } 4516 function createGetterInvoker(fn) { 4517 return function computedGetter() { 4518 return fn.call(this, this); 4519 }; 4520 } 4521 function initMethods(vm, methods) { 4522 var props = vm.$options.props; 4523 for (var key in methods) { 4524 { 4525 if (typeof methods[key] !== 'function') { 4526 warn$2("Method \"".concat(key, "\" has type \"").concat(typeof methods[key], "\" in the component definition. ") + 4527 "Did you reference the function correctly?", vm); 4528 } 4529 if (props && hasOwn(props, key)) { 4530 warn$2("Method \"".concat(key, "\" has already been defined as a prop."), vm); 4531 } 4532 if (key in vm && isReserved(key)) { 4533 warn$2("Method \"".concat(key, "\" conflicts with an existing Vue instance method. ") + 4534 "Avoid defining component methods that start with _ or $."); 4535 } 4536 } 4537 vm[key] = typeof methods[key] !== 'function' ? noop : bind$1(methods[key], vm); 4538 } 4539 } 4540 function initWatch(vm, watch) { 4541 for (var key in watch) { 4542 var handler = watch[key]; 4543 if (isArray(handler)) { 4544 for (var i = 0; i < handler.length; i++) { 4545 createWatcher(vm, key, handler[i]); 4546 } 4547 } 4548 else { 4549 createWatcher(vm, key, handler); 4550 } 4551 } 4552 } 4553 function createWatcher(vm, expOrFn, handler, options) { 4554 if (isPlainObject(handler)) { 4555 options = handler; 4556 handler = handler.handler; 4557 } 4558 if (typeof handler === 'string') { 4559 handler = vm[handler]; 4560 } 4561 return vm.$watch(expOrFn, handler, options); 4562 } 4563 function stateMixin(Vue) { 4564 // flow somehow has problems with directly declared definition object 4565 // when using Object.defineProperty, so we have to procedurally build up 4566 // the object here. 4567 var dataDef = {}; 4568 dataDef.get = function () { 4569 return this._data; 4570 }; 4571 var propsDef = {}; 4572 propsDef.get = function () { 4573 return this._props; 4574 }; 4575 { 4576 dataDef.set = function () { 4577 warn$2('Avoid replacing instance root $data. ' + 4578 'Use nested data properties instead.', this); 4579 }; 4580 propsDef.set = function () { 4581 warn$2("$props is readonly.", this); 4582 }; 4583 } 4584 Object.defineProperty(Vue.prototype, '$data', dataDef); 4585 Object.defineProperty(Vue.prototype, '$props', propsDef); 4586 Vue.prototype.$set = set; 4587 Vue.prototype.$delete = del; 4588 Vue.prototype.$watch = function (expOrFn, cb, options) { 4589 var vm = this; 4590 if (isPlainObject(cb)) { 4591 return createWatcher(vm, expOrFn, cb, options); 4592 } 4593 options = options || {}; 4594 options.user = true; 4595 var watcher = new Watcher(vm, expOrFn, cb, options); 4596 if (options.immediate) { 4597 var info = "callback for immediate watcher \"".concat(watcher.expression, "\""); 4598 pushTarget(); 4599 invokeWithErrorHandling(cb, vm, [watcher.value], vm, info); 4600 popTarget(); 4601 } 4602 return function unwatchFn() { 4603 watcher.teardown(); 4604 }; 4605 }; 4606 } 4607 4608 function initProvide(vm) { 4609 var provideOption = vm.$options.provide; 4610 if (provideOption) { 4611 var provided = isFunction(provideOption) 4612 ? provideOption.call(vm) 4613 : provideOption; 4614 if (!isObject(provided)) { 4615 return; 4616 } 4617 var source = resolveProvided(vm); 4618 // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to 4619 // iterate the keys ourselves. 4620 var keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided); 4621 for (var i = 0; i < keys.length; i++) { 4622 var key = keys[i];
4623 Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key)); 4624 } 4625 } 4626 } 4627 function initInjections(vm) { 4628 var result = resolveInject(vm.$options.inject, vm); 4629 if (result) { 4630 toggleObserving(false); 4631 Object.keys(result).forEach(function (key) { 4632 /* istanbul ignore else */ 4633 { 4634 defineReactive(vm, key, result[key], function () { 4635 warn$2("Avoid mutating an injected value directly since the changes will be " + 4636 "overwritten whenever the provided component re-renders. " + 4637 "injection being mutated: \"".concat(key, "\""), vm); 4638 }); 4639 } 4640 }); 4641 toggleObserving(true); 4642 } 4643 } 4644 function resolveInject(inject, vm) { 4645 if (inject) { 4646 // inject is :any because flow is not smart enough to figure out cached 4647 var result = Object.create(null); 4648 var keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject); 4649 for (var i = 0; i < keys.length; i++) { 4650 var key = keys[i]; 4651 // #6574 in case the inject object is observed... 4652 if (key === '__ob__') 4653 continue; 4654 var provideKey = inject[key].from; 4655 if (provideKey in vm._provided) { 4656 result[key] = vm._provided[provideKey]; 4657 } 4658 else if ('default' in inject[key]) { 4659 var provideDefault = inject[key].default; 4660 result[key] = isFunction(provideDefault) 4661 ? provideDefault.call(vm) 4662 : provideDefault; 4663 } 4664 else { 4665 warn$2("Injection \"".concat(key, "\" not found"), vm); 4666 } 4667 } 4668 return result; 4669 } 4670 } 4671 4672 var uid = 0; 4673 function initMixin$1(Vue) { 4674 Vue.prototype._init = function (options) { 4675 var vm = this; 4676 // a uid 4677 vm._uid = uid++; 4678 var startTag, endTag; 4679 /* istanbul ignore if */ 4680 if (config.performance && mark) { 4681 startTag = "vue-perf-start:".concat(vm._uid); 4682 endTag = "vue-perf-end:".concat(vm._uid); 4683 mark(startTag); 4684 } 4685 // a flag to mark this as a Vue instance without having to do instanceof 4686 // check 4687 vm._isVue = true; 4688 // avoid instances from being observed 4689 vm.__v_skip = true; 4690 // effect scope 4691 vm._scope = new EffectScope(true /* detached */); 4692 vm._scope._vm = true; 4693 // merge options 4694 if (options && options._isComponent) { 4695 // optimize internal component instantiation 4696 // since dynamic options merging is pretty slow, and none of the 4697 // internal component options needs special treatment. 4698 initInternalComponent(vm, options); 4699 } 4700 else { 4701 vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm); 4702 } 4703 /* istanbul ignore else */ 4704 { 4705 initProxy(vm); 4706 } 4707 // expose real self 4708 vm._self = vm; 4709 initLifecycle(vm); 4710 initEvents(vm); 4711 initRender(vm); 4712 callHook$1(vm, 'beforeCreate', undefined, false /* setContext */); 4713 initInjections(vm); // resolve injections before data/props 4714 initState(vm); 4715 initProvide(vm); // resolve provide after data/props 4716 callHook$1(vm, 'created'); 4717 /* istanbul ignore if */ 4718 if (config.performance && mark) { 4719 vm._name = formatComponentName(vm, false); 4720 mark(endTag); 4721 measure("vue ".concat(vm._name, " init"), startTag, endTag); 4722 } 4723 if (vm.$options.el) { 4724 vm.$mount(vm.$options.el); 4725 } 4726 }; 4727 } 4728 function initInternalComponent(vm, options) { 4729 var opts = (vm.$options = Object.create(vm.constructor.options)); 4730 // doing this because it's faster than dynamic enumeration. 4731 var parentVnode = options._parentVnode; 4732 opts.parent = options.parent; 4733 opts._parentVnode = parentVnode; 4734 var vnodeComponentOptions = parentVnode.componentOptions; 4735 opts.propsData = vnodeComponentOptions.propsData; 4736 opts._parentListeners = vnodeComponentOptions.listeners; 4737 opts._renderChildren = vnodeComponentOptions.children; 4738 opts._componentTag = vnodeComponentOptions.tag; 4739 if (options.render) { 4740 opts.render = options.render; 4741 opts.staticRenderFns = options.staticRenderFns; 4742 } 4743 }
4744 function resolveConstructorOptions(Ctor) { 4745 var options = Ctor.options; 4746 if (Ctor.super) { 4747 var superOptions = resolveConstructorOptions(Ctor.super); 4748 var cachedSuperOptions = Ctor.superOptions; 4749 if (superOptions !== cachedSuperOptions) { 4750 // super option changed, 4751 // need to resolve new options. 4752 Ctor.superOptions = superOptions; 4753 // check if there are any late-modified/attached options (#4976) 4754 var modifiedOptions = resolveModifiedOptions(Ctor); 4755 // update base extend options 4756 if (modifiedOptions) { 4757 extend(Ctor.extendOptions, modifiedOptions); 4758 } 4759 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions); 4760 if (options.name) { 4761 options.components[options.name] = Ctor; 4762 } 4763 } 4764 } 4765 return options; 4766 } 4767 function resolveModifiedOptions(Ctor) { 4768 var modified; 4769 var latest = Ctor.options; 4770 var sealed = Ctor.sealedOptions; 4771 for (var key in latest) { 4772 if (latest[key] !== sealed[key]) { 4773 if (!modified) 4774 modified = {}; 4775 modified[key] = latest[key]; 4776 } 4777 } 4778 return modified; 4779 } 4780 4781 function FunctionalRenderContext(data, props, children, parent, Ctor) { 4782 var _this = this; 4783 var options = Ctor.options; 4784 // ensure the createElement function in functional components 4785 // gets a unique context - this is necessary for correct named slot check 4786 var contextVm; 4787 if (hasOwn(parent, '_uid')) { 4788 contextVm = Object.create(parent); 4789 contextVm._original = parent; 4790 } 4791 else { 4792 // the context vm passed in is a functional context as well. 4793 // in this case we want to make sure we are able to get a hold to the 4794 // real context instance. 4795 contextVm = parent; 4796 // @ts-ignore 4797 parent = parent._original; 4798 } 4799 var isCompiled = isTrue(options._compiled); 4800 var needNormalization = !isCompiled; 4801 this.data = data; 4802 this.props = props; 4803 this.children = children; 4804 this.parent = parent; 4805 this.listeners = data.on || emptyObject; 4806 this.injections = resolveInject(options.inject, parent); 4807 this.slots = function () { 4808 if (!_this.$slots) { 4809 normalizeScopedSlots(parent, data.scopedSlots, (_this.$slots = resolveSlots(children, parent))); 4810 } 4811 return _this.$slots; 4812 }; 4813 Object.defineProperty(this, 'scopedSlots', { 4814 enumerable: true, 4815 get: function () { 4816 return normalizeScopedSlots(parent, data.scopedSlots, this.slots()); 4817 } 4818 }); 4819 // support for compiled functional template 4820 if (isCompiled) { 4821 // exposing $options for renderStatic() 4822 this.$options = options; 4823 // pre-resolve slots for renderSlot() 4824 this.$slots = this.slots(); 4825 this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots); 4826 } 4827 if (options._scopeId) { 4828 this._c = function (a, b, c, d) { 4829 var vnode = createElement$1(contextVm, a, b, c, d, needNormalization); 4830 if (vnode && !isArray(vnode)) { 4831 vnode.fnScopeId = options._scopeId; 4832 vnode.fnContext = parent; 4833 } 4834 return vnode; 4835 }; 4836 } 4837 else { 4838 this._c = function (a, b, c, d) { 4839 return createElement$1(contextVm, a, b, c, d, needNormalization); 4840 }; 4841 } 4842 } 4843 installRenderHelpers(FunctionalRenderContext.prototype); 4844 function createFunctionalComponent(Ctor, propsData, data, contextVm, children) { 4845 var options = Ctor.options; 4846 var props = {}; 4847 var propOptions = options.props; 4848 if (isDef(propOptions)) { 4849 for (var key in propOptions) { 4850 props[key] = validateProp(key, propOptions, propsData || emptyObject); 4851 } 4852 } 4853 else { 4854 if (isDef(data.attrs)) 4855 mergeProps(props, data.attrs); 4856 if (isDef(data.props)) 4857 mergeProps(props, data.props); 4858 } 4859 var renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor); 4860 var vnode = options.render.call(null, renderContext._c, renderContext); 4861 if (vnode instanceof VNode) { 4862 return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext); 4863 } 4864 else if (isArray(vnode)) { 4865 var vnodes = normalizeChildren(vnode) || []; 4866 var res = new Array(vnodes.length); 4867 for (var i = 0; i < vnodes.length; i++) { 4868 res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext); 4869 } 4870 return res; 4871 } 4872 } 4873 function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) { 4874 // #7817 clone node before setting fnContext, otherwise if the node is reused 4875 // (e.g. it was from a cached normal slot) the fnContext c
4875auses named slots 4876 // that should not be matched to match. 4877 var clone = cloneVNode(vnode); 4878 clone.fnContext = contextVm; 4879 clone.fnOptions = options; 4880 { 4881 (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = 4882 renderContext; 4883 } 4884 if (data.slot) { 4885 (clone.data || (clone.data = {})).slot = data.slot; 4886 } 4887 return clone; 4888 } 4889 function mergeProps(to, from) { 4890 for (var key in from) { 4891 to[camelize(key)] = from[key]; 4892 } 4893 } 4894 4895 function getComponentName(options) { 4896 return options.name || options.__name || options._componentTag; 4897 } 4898 // inline hooks to be invoked on component VNodes during patch 4899 var componentVNodeHooks = { 4900 init: function (vnode, hydrating) { 4901 if (vnode.componentInstance && 4902 !vnode.componentInstance._isDestroyed && 4903 vnode.data.keepAlive) { 4904 // kept-alive components, treat as a patch 4905 var mountedNode = vnode; // work around flow 4906 componentVNodeHooks.prepatch(mountedNode, mountedNode); 4907 } 4908 else { 4909 var child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance)); 4910 child.$mount(hydrating ? vnode.elm : undefined, hydrating); 4911 } 4912 }, 4913 prepatch: function (oldVnode, vnode) { 4914 var options = vnode.componentOptions; 4915 var child = (vnode.componentInstance = oldVnode.componentInstance); 4916 updateChildComponent(child, options.propsData, // updated props 4917 options.listeners, // updated listeners 4918 vnode, // new parent vnode 4919 options.children // new children 4920 ); 4921 }, 4922 insert: function (vnode) { 4923 var context = vnode.context, componentInstance = vnode.componentInstance; 4924 if (!componentInstance._isMounted) { 4925 componentInstance._isMounted = true; 4926 callHook$1(componentInstance, 'mounted'); 4927 } 4928 if (vnode.data.keepAlive) { 4929 if (context._isMounted) { 4930 // vue-router#1212 4931 // During updates, a kept-alive component's child components may 4932 // change, so directly walking the tree here may call activated hooks 4933 // on incorrect children. Instead we push them into a queue which will 4934 // be processed after the whole patch process ended. 4935 queueActivatedComponent(componentInstance); 4936 } 4937 else { 4938 activateChildComponent(componentInstance, true /* direct */); 4939 } 4940 } 4941 }, 4942 destroy: function (vnode) { 4943 var componentInstance = vnode.componentInstance; 4944 if (!componentInstance._isDestroyed) { 4945 if (!vnode.data.keepAlive) { 4946 componentInstance.$destroy(); 4947 } 4948 else { 4949 deactivateChildComponent(componentInstance, true /* direct */); 4950 } 4951 } 4952 } 4953 }; 4954 var hooksToMerge = Object.keys(componentVNodeHooks); 4955 function createComponent(Ctor, data, context, children, tag) { 4956 if (isUndef(Ctor)) { 4957 return; 4958 } 4959 var baseCtor = context.$options._base; 4960 // plain options object: turn it into a constructor 4961 if (isObject(Ctor)) { 4962 Ctor = baseCtor.extend(Ctor); 4963 } 4964 // if at this stage it's not a constructor or an async component factory, 4965 // reject. 4966 if (typeof Ctor !== 'function') { 4967 { 4968 warn$2("Invalid Component definition: ".concat(String(Ctor)), context); 4969 } 4970 return; 4971 } 4972 // async component 4973 var asyncFactory; 4974 // @ts-expect-error 4975 if (isUndef(Ctor.cid)) { 4976 asyncFactory = Ctor; 4977 Ctor = resolveAsyncComponent(asyncFactory, baseCtor); 4978 if (Ctor === undefined) { 4979 // return a placeholder node for async component, which is rendered 4980 // as a comment node but preserves all the raw information for the node. 4981 // the information will be used for async server-rendering and hydration. 4982 return createAsyncPlaceholder(asyncFactory, data, context, children, tag); 4983 } 4984 } 4985 data = data || {}; 4986 // resolve constructor options in case global mixins are applied after 4987 // component constructor creation 4988 resolveConstructorOptions(Ctor); 4989 // transform component v-model data into props & events 4990 if (isDef(data.model)) { 4991 // @ts-expect-error 4992 transformModel(Ctor.options, data); 4993 } 4994 // extract props 4995 // @ts-expect-error 4996 var propsData = extractPropsFromVNodeData(data, Ctor, tag); 4997 // functional component 4998 // @ts-expect-error 4999 if (isTrue(Ctor.options.functional)) { 5000 return createFunctionalComponent(Ctor, propsData, data, context, children); 5001 } 5002 // extract listeners, since these needs to be treated as 5003 // child component listeners instead of DOM listeners 5004 var listeners = data.on; 5005 // replace with listeners with .native modifier 5006 // so it gets processed during parent component patch. 5007 data.on = data.nativeOn; 5008 // @ts-expect-error 5009 if (isTrue(Ctor.options.abstract)) { 5010 // abstract components do not keep anything 5011 // other than props & listeners & slot 5012 // work around flow 5013 var slot = data.slot; 5014 data = {}; 5015 if (slot) { 5016 data.slot = slot; 5017 } 5018 }
5019 // install component management hooks onto the placeholder node 5020 installComponentHooks(data); 5021 // return a placeholder vnode 5022 // @ts-expect-error 5023 var name = getComponentName(Ctor.options) || tag; 5024 var vnode = new VNode( 5025 // @ts-expect-error 5026 "vue-component-".concat(Ctor.cid).concat(name ? "-".concat(name) : ''), data, undefined, undefined, undefined, context, 5027 // @ts-expect-error 5028 { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }, asyncFactory); 5029 return vnode; 5030 } 5031 function createComponentInstanceForVnode( 5032 // we know it's MountedComponentVNode but flow doesn't 5033 vnode, 5034 // activeInstance in lifecycle state 5035 parent) { 5036 var options = { 5037 _isComponent: true, 5038 _parentVnode: vnode, 5039 parent: parent 5040 }; 5041 // check inline-template render functions 5042 var inlineTemplate = vnode.data.inlineTemplate; 5043 if (isDef(inlineTemplate)) { 5044 options.render = inlineTemplate.render; 5045 options.staticRenderFns = inlineTemplate.staticRenderFns; 5046 } 5047 return new vnode.componentOptions.Ctor(options); 5048 } 5049 function installComponentHooks(data) { 5050 var hooks = data.hook || (data.hook = {}); 5051 for (var i = 0; i < hooksToMerge.length; i++) { 5052 var key = hooksToMerge[i]; 5053 var existing = hooks[key]; 5054 var toMerge = componentVNodeHooks[key]; 5055 // @ts-expect-error 5056 if (existing !== toMerge && !(existing && existing._merged)) { 5057 hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge; 5058 } 5059 } 5060 } 5061 function mergeHook(f1, f2) { 5062 var merged = function (a, b) { 5063 // flow complains about extra args which is why we use any 5064 f1(a, b); 5065 f2(a, b); 5066 }; 5067 merged._merged = true; 5068 return merged; 5069 } 5070 // transform component v-model info (value and callback) into 5071 // prop and event handler respectively. 5072 function transformModel(options, data) { 5073 var prop = (options.model && options.model.prop) || 'value'; 5074 var event = (options.model && options.model.event) || 'input'; 5075 (data.attrs || (data.attrs = {}))[prop] = data.model.value; 5076 var on = data.on || (data.on = {}); 5077 var existing = on[event]; 5078 var callback = data.model.callback; 5079 if (isDef(existing)) { 5080 if (isArray(existing) 5081 ? existing.indexOf(callback) === -1 5082 : existing !== callback) { 5083 on[event] = [callback].concat(existing); 5084 } 5085 } 5086 else { 5087 on[event] = callback; 5088 } 5089 } 5090 5091 var warn$2 = noop; 5092 var tip = noop; 5093 var generateComponentTrace; // work around flow check 5094 var formatComponentName; 5095 { 5096 var hasConsole_1 = typeof console !== 'undefined'; 5097 var classifyRE_1 = /(?:^|[-_])(\w)/g; 5098 var classify_1 = function (str) { 5099 return str.replace(classifyRE_1, function (c) { return c.toUpperCase(); }).replace(/[-_]/g, ''); 5100 }; 5101 warn$2 = function (msg, vm) { 5102 if (vm === void 0) { vm = currentInstance; } 5103 var trace = vm ? generateComponentTrace(vm) : ''; 5104 if (config.warnHandler) { 5105 config.warnHandler.call(null, msg, vm, trace); 5106 } 5107 else if (hasConsole_1 && !config.silent) { 5108 console.error("[Vue warn]: ".concat(msg).concat(trace)); 5109 } 5110 }; 5111 tip = function (msg, vm) { 5112 if (hasConsole_1 && !config.silent) { 5113 console.warn("[Vue tip]: ".concat(msg) + (vm ? generateComponentTrace(vm) : '')); 5114 } 5115 }; 5116 formatComponentName = function (vm, includeFile) { 5117 if (vm.$root === vm) { 5118 return '<Root>'; 5119 } 5120 var options = isFunction(vm) && vm.cid != null 5121 ? vm.options 5122 : vm._isVue 5123 ? vm.$options || vm.constructor.options 5124 : vm; 5125 var name = getComponentName(options); 5126 var file = options.__file; 5127 if (!name && file) { 5128 var match = file.match(/([^/\\]+)\.vue$/); 5129 name = match && match[1]; 5130 } 5131 return ((name ? "<".concat(classify_1(name), ">") : "<Anonymous>") + 5132 (file && includeFile !== false ? " at ".concat(file) : '')); 5133 }; 5134 var repeat_1 = function (str, n) { 5135 var res = ''; 5136 while (n) { 5137 if (n % 2 === 1) 5138 res += str; 5139 if (n > 1) 5140 str += str; 5141 n >>= 1; 5142 } 5143 return res; 5144 }; 5145 generateComponentTrace = function (vm) { 5146 if (vm._isVue && vm.$parent) { 5147 var tree = []; 5148 var currentRecursiveSequence = 0; 5149 while (vm) { 5150 if (tree.length > 0) { 5151 var last = tree[tree.length - 1]; 5152 if (last.constructor === vm.constructor) { 5153 currentRecursiveSequence++; 5154 vm = vm.$parent; 5155 continue; 5156 } 5157 else if (currentRecursiveSequence > 0) { 5158 tree[tree.length - 1] = [last, currentRecursiveSequence]; 5159 currentRecursiveSequence = 0; 5160 } 5161 } 5162 tree.push(vm); 5163 vm = vm.$parent; 5164 } 5165 return ('\n\nfound in\n\n' + 5166 tree 5167 .map(function (vm, i) { 5168 return "".concat(i === 0 ? '---> ' : repeat_1(' ', 5 + i * 2)).concat(isArray(vm) 5169 ? "".concat(formatComponentName(vm[0]), "... (").concat(vm[1], " recursive calls)") 5170 : formatComponentName(vm)); 5171 }) 5172 .join('\n')); 5173 } 5174 else { 5175 return "\n\n(found in ".concat(formatComponentName(vm), ")"); 5176 } 5177 }; 5178 } 5179 5180 /** 5181 * Option overwriting strategies are functions that handle 5182 * how to merge a parent option value and a child option 5183 * value into the final value. 5184 */ 5185 var strats = config.optionMergeStrategies; 5186 /** 5187 * Options with restrictions 5188 */ 5189 { 5190 strats.el = strats.propsData = function (parent, child, vm, key) { 5191 if (!vm) { 5192 warn$2("option \"".concat(key, "\" can only be used during instance ") + 5193 'creation with the `new` keyword.'); 5194 } 5195 return defaultStrat(parent, child); 5196 }; 5197 } 5198 /** 5199 * Helper that recursively merges two data objects together. 5200 */ 5201 function mergeData(to, from, recursive) { 5202 if (recursive === void 0) { recursive = true; } 5203 if (!from) 5204 return to; 5205 var key, toVal, fromVal; 5206 var keys = hasSymbol 5207 ? Reflect.ownKeys(from) 5208 : Object.keys(from); 5209 for (var i = 0; i < keys.length; i++) { 5210 key = keys[i]; 5211 // in case the object is already observed... 5212 if (key === '__ob__') 5213 continue; 5214 toVal = to[key]; 5215 fromVal = from[key]; 5216 if (!recursive || !hasOwn(to, key)) { 5217 set(to, key, fromVal); 5218 } 5219 else if (toVal !== fromVal && 5220 isPlainObject(toVal) && 5221 isPlainObject(fromVal)) { 5222 mergeData(toVal, fromVal); 5223 } 5224 } 5225 return to; 5226 } 5227 /** 5228 * Data 5229 */ 5230 function mergeDataOrFn(parentVal, childVal, vm) { 5231 if (!vm) {
5232 // in a Vue.extend merge, both should be functions 5233 if (!childVal) { 5234 return parentVal; 5235 } 5236 if (!parentVal) { 5237 return childVal; 5238 } 5239 // when parentVal & childVal are both present, 5240 // we need to return a function that returns the 5241 // merged result of both functions... no need to 5242 // check if parentVal is a function here because 5243 // it has to be a function to pass previous merges. 5244 return function mergedDataFn() { 5245 return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal); 5246 }; 5247 } 5248 else { 5249 return function mergedInstanceDataFn() { 5250 // instance merge 5251 var instanceData = isFunction(childVal) 5252 ? childVal.call(vm, vm) 5253 : childVal; 5254 var defaultData = isFunction(parentVal) 5255 ? parentVal.call(vm, vm) 5256 : parentVal; 5257 if (instanceData) { 5258 return mergeData(instanceData, defaultData); 5259 } 5260 else { 5261 return defaultData; 5262 } 5263 }; 5264 } 5265 } 5266 strats.data = function (parentVal, childVal, vm) { 5267 if (!vm) { 5268 if (childVal && typeof childVal !== 'function') { 5269 warn$2('The "data" option should be a function ' + 5270 'that returns a per-instance value in component ' + 5271 'definitions.', vm); 5272 return parentVal; 5273 } 5274 return mergeDataOrFn(parentVal, childVal); 5275 } 5276 return mergeDataOrFn(parentVal, childVal, vm); 5277 }; 5278 /** 5279 * Hooks and props are merged as arrays. 5280 */ 5281 function mergeLifecycleHook(parentVal, childVal) { 5282 var res = childVal 5283 ? parentVal 5284 ? parentVal.concat(childVal) 5285 : isArray(childVal) 5286 ? childVal 5287 : [childVal] 5288 : parentVal; 5289 return res ? dedupeHooks(res) : res; 5290 } 5291 function dedupeHooks(hooks) { 5292 var res = []; 5293 for (var i = 0; i < hooks.length; i++) { 5294 if (res.indexOf(hooks[i]) === -1) { 5295 res.push(hooks[i]); 5296 } 5297 } 5298 return res; 5299 } 5300 LIFECYCLE_HOOKS.forEach(function (hook) { 5301 strats[hook] = mergeLifecycleHook; 5302 }); 5303 /** 5304 * Assets 5305 * 5306 * When a vm is present (instance creation), we need to do 5307 * a three-way merge between constructor options, instance 5308 * options and parent options. 5309 */ 5310 function mergeAssets(parentVal, childVal, vm, key) { 5311 var res = Object.create(parentVal || null); 5312 if (childVal) { 5313 assertObjectType(key, childVal, vm); 5314 return extend(res, childVal); 5315 } 5316 else { 5317 return res; 5318 } 5319 } 5320 ASSET_TYPES.forEach(function (type) { 5321 strats[type + 's'] = mergeAssets; 5322 }); 5323 /** 5324 * Watchers. 5325 * 5326 * Watchers hashes should not overwrite one 5327 * another, so we merge them as arrays. 5328 */ 5329 strats.watch = function (parentVal, childVal, vm, key) { 5330 // work around Firefox's Object.prototype.watch... 5331 //@ts-expect-error work around 5332 if (parentVal === nativeWatch) 5333 parentVal = undefined; 5334 //@ts-expect-error work around 5335 if (childVal === nativeWatch) 5336 childVal = undefined; 5337 /* istanbul ignore if */ 5338 if (!childVal) 5339 return Object.create(parentVal || null); 5340 { 5341 assertObjectType(key, childVal, vm); 5342 } 5343 if (!parentVal) 5344 return childVal; 5345 var ret = {}; 5346 extend(ret, parentVal); 5347 for (var key_1 in childVal) { 5348 var parent_1 = ret[key_1]; 5349 var child = childVal[key_1]; 5350 if (parent_1 && !isArray(parent_1)) { 5351 parent_1 = [parent_1]; 5352 } 5353 ret[key_1] = parent_1 ? parent_1.concat(child) : isArray(child) ? child : [child]; 5354 } 5355 return ret; 5356 }; 5357 /** 5358 * Other object hashes. 5359 */ 5360 strats.props = 5361 strats.methods = 5362 strats.inject = 5363 strats.computed = 5364 function (parentVal, childVal, vm, key) { 5365 if (childVal && true) { 5366 assertObjectType(key, childVal, vm); 5367 } 5368 if (!parentVal) 5369 return childVal; 5370 var ret = Object.create(null); 5371 extend(ret, parentVal); 5372 if (childVal) 5373 extend(ret, childVal); 5374 return ret; 5375 }; 5376 strats.provide = function (parentVal, childVal) { 5377 if (!parentVal) 5378 return childVal; 5379 return function () { 5380 var ret = Object.create(null); 5381 mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal); 5382 if (childVal) { 5383 mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive 5384 ); 5385 } 5386 return ret; 5387 }; 5388 }; 5389 /** 5390 * Default strategy. 5391 */ 5392 var defaultStrat = function (parentVal, childVal) { 5393 return childVal === undefined ? parentVal : childVal; 5394 }; 5395 /** 5396 * Validate component names 5397 */ 5398 function checkComponents(options) { 5399 for (var key in options.components) { 5400 validateComponentName(key); 5401 } 5402 } 5403 function validateComponentName(name) { 5404 if (!new RegExp("^[a-zA-Z][\\-\\.0-9_".concat(unicodeRegExp.source, "]*$")).test(name)) { 5405 warn$2('Invalid component name: "' + 5406 name + 5407 '". Component names ' + 5408 'should conform to valid custom element name in html5 specification.'); 5409 } 5410 if (isBuiltInTag(name) || config.isReservedTag(name)) { 5411 warn$2('Do not use built-in or reserved HTML elements as component ' + 5412 'id: ' + 5413 name); 5414 } 5415 } 5416 /** 5417 * Ensure all props option syntax are normalized into the 5418 * Object-based format. 5419 */ 5420 function normalizeProps(options, vm) { 5421 var props = options.props; 5422 if (!props) 5423 return; 5424 var res = {}; 5425 var i, val, name; 5426 if (isArray(props)) { 5427 i = props.length; 5428 while (i--) { 5429 val = props[i]; 5430 if (typeof val === 'string') { 5431 name = camelize(val); 5432 res[name] = { type: null }; 5433 } 5434 else { 5435 warn$2('props must be strings when using array syntax.'); 5436 } 5437 } 5438 } 5439 else if (isPlainObject(props)) { 5440 for (var key in props) { 5441 val = props[key]; 5442 name = camelize(key); 5443 res[name] = isPlainObject(val) ? val : { type: val }; 5444 } 5445 } 5446 else { 5447 warn$2("Invalid value for option \"props\": expected an Array or an Object, " + 5448 "but got ".concat(toRawType(props), "."), vm); 5449 } 5450 options.props = res; 5451 } 5452 /** 5453 * Normalize all injections into Object-based format 5454 */ 5455 function normalizeInject(options, vm) { 5456 var inject = options.inject; 5457 if (!inject) 5458 return; 5459 var normalized = (options.inject = {}); 5460 if (isArray(inject)) { 5461 for (var i = 0; i < inject.length; i++) { 5462 normalized[inject[i]] = { from: inject[i] }; 5463 } 5464 } 5465 else if (isPlainObject(inject)) { 5466 for (var key in inject) { 5467 var val = inject[key]; 5468 normalized[key] = isPlainObject(val) 5469 ? extend({ from: key }, val) 5470 : { from: val }; 5471 } 5472 } 5473 else { 5474 warn$2("Invalid value for option \"inject\": expected an Array or an Object, " + 5475 "but got ".concat(toRawType(inject), "."), vm); 5476 } 5477 } 5478 /** 5479 * Normalize raw function directives into object format. 5480 */ 5481 function normalizeDirectives$1(options) { 5482 var dirs = options.directives; 5483 if (dirs) { 5484 for (var key in dirs) { 5485 var def = dirs[key]; 5486 if (isFunction(def)) { 5487 dirs[key] = { bind: def, update: def }; 5488 } 5489 } 5490 } 5491 } 5492 function assertObjectType(name, value, vm) { 5493 if (!isPlainObject(value)) { 5494 warn$2("Invalid value for option \"".concat(name, "\": expected an Object, ") + 5495 "but got ".concat(toRawType(value), "."), vm); 5496 } 5497 } 5498 /** 5499 * Merge two option objects into a new one. 5500 * Core utility used in both instantiation and inheritance. 5501 */ 5502 function mergeOptions(parent, child, vm) { 5503 { 5504 checkComponents(child); 5505 } 5506 if (isFunction(child)) { 5507 // @ts-expect-error 5508 child = child.options; 5509 } 5510 normalizeProps(child, vm); 5511 normalizeInject(child, vm); 5512 normalizeDirectives$1(child); 5513 // Apply extends and mixins on the child options, 5514 // but only if it is a raw options object that isn't 5515 // the result of another mergeOptions call. 5516 // Only merged options has the _base property. 5517 if (!child._base) { 5518 if (child.extends) { 5519 parent = mergeOptions(parent, child.extends, vm); 5520 } 5521 if (child.mixins) { 5522 for (var i = 0, l = child.mixins.length; i < l; i++) { 5523 parent = mergeOptions(parent, child.mixins[i], vm); 5524 } 5525 } 5526 } 5527 var options = {}; 5528 var key; 5529 for (key in parent) { 5530 mergeField(key); 5531 } 5532 for (key in child) { 5533 if (!hasOwn(parent, key)) { 5534 mergeField(key); 5535 } 5536 } 5537 function mergeField(key) { 5538 var strat = strats[key] || defaultStrat; 5539 options[key] = strat(parent[key], child[key], vm, key); 5540 } 5541 return options; 5542 } 5543 /** 5544 * Resolve an asset. 5545 * This function is used because child instances need access 5546 * to assets defined in its ancestor chain. 5547 */ 5548 function resolveAsset(options, type, id, warnMissing) { 5549 /* istanbul ignore if */ 5550 if (typeof id !== 'string') { 5551 return; 5552 } 5553 var assets = options[type]; 5554 // check local registration variations first 5555 if (hasOwn(assets, id)) 5556 return assets[id]; 5557 var camelizedId = camelize(id); 5558 if (hasOwn(assets, camelizedId)) 5559 return assets[camelizedId]; 5560 var PascalCaseId = capitalize(camelizedId); 5561 if (hasOwn(assets, PascalCaseId)) 5562 return assets[PascalCaseId]; 5563 // fallback to prototype chain 5564 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; 5565 if (warnMissing && !res) { 5566 warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id); 5567 } 5568 return res; 5569 } 5570 5571 function validateProp(key, propOptions, propsData, vm) { 5572 var prop = propOptions[key]; 5573 var absent = !hasOwn(propsData, key); 5574 var value = propsData[key]; 5575 // boolean casting 5576 var booleanIndex = getTypeIndex(Boolean, prop.type); 5577 if (booleanIndex > -1) { 5578 if (absent && !hasOwn(prop, 'default')) { 5579 value = false;
5580 } 5581 else if (value === '' || value === hyphenate(key)) { 5582 // only cast empty string / same name to boolean if 5583 // boolean has higher priority 5584 var stringIndex = getTypeIndex(String, prop.type); 5585 if (stringIndex < 0 || booleanIndex < stringIndex) { 5586 value = true; 5587 } 5588 } 5589 } 5590 // check default value 5591 if (value === undefined) { 5592 value = getPropDefaultValue(vm, prop, key); 5593 // since the default value is a fresh copy, 5594 // make sure to observe it. 5595 var prevShouldObserve = shouldObserve; 5596 toggleObserving(true); 5597 observe(value); 5598 toggleObserving(prevShouldObserve); 5599 } 5600 { 5601 assertProp(prop, key, value, vm, absent); 5602 } 5603 return value; 5604 } 5605 /** 5606 * Get the default value of a prop. 5607 */ 5608 function getPropDefaultValue(vm, prop, key) { 5609 // no default, return undefined 5610 if (!hasOwn(prop, 'default')) { 5611 return undefined; 5612 } 5613 var def = prop.default; 5614 // warn against non-factory defaults for Object & Array 5615 if (isObject(def)) { 5616 warn$2('Invalid default value for prop "' + 5617 key + 5618 '": ' + 5619 'Props with type Object/Array must use a factory function ' + 5620 'to return the default value.', vm); 5621 } 5622 // the raw prop value was also undefined from previous render, 5623 // return previous default value to avoid unnecessary watcher trigger 5624 if (vm && 5625 vm.$options.propsData && 5626 vm.$options.propsData[key] === undefined && 5627 vm._props[key] !== undefined) { 5628 return vm._props[key]; 5629 } 5630 // call factory function for non-Function types 5631 // a value is Function if its prototype is function even across different execution context 5632 return isFunction(def) && getType(prop.type) !== 'Function' 5633 ? def.call(vm) 5634 : def; 5635 } 5636 /** 5637 * Assert whether a prop is valid. 5638 */ 5639 function assertProp(prop, name, value, vm, absent) { 5640 if (prop.required && absent) { 5641 warn$2('Missing required prop: "' + name + '"', vm); 5642 return; 5643 } 5644 if (value == null && !prop.required) { 5645 return; 5646 } 5647 var type = prop.type; 5648 var valid = !type || type === true; 5649 var expectedTypes = []; 5650 if (type) { 5651 if (!isArray(type)) { 5652 type = [type]; 5653 } 5654 for (var i = 0; i < type.length && !valid; i++) { 5655 var assertedType = assertType(value, type[i], vm); 5656 expectedTypes.push(assertedType.expectedType || ''); 5657 valid = assertedType.valid; 5658 } 5659 } 5660 var haveExpectedTypes = expectedTypes.some(function (t) { return t; }); 5661 if (!valid && haveExpectedTypes) { 5662 warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm); 5663 return; 5664 } 5665 var validator = prop.validator; 5666 if (validator) { 5667 if (!validator(value)) { 5668 warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm); 5669 } 5670 } 5671 } 5672 var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/; 5673 function assertType(value, type, vm) { 5674 var valid; 5675 var expectedType = getType(type); 5676 if (simpleCheckRE.test(expectedType)) { 5677 var t = typeof value; 5678 valid = t === expectedType.toLowerCase(); 5679 // for primitive wrapper objects 5680 if (!valid && t === 'object') { 5681 valid = value instanceof type; 5682 } 5683 } 5684 else if (expectedType === 'Object') { 5685 valid = isPlainObject(value); 5686 } 5687 else if (expectedType === 'Array') { 5688 valid = isArray(value); 5689 } 5690 else { 5691 try { 5692 valid = value instanceof type; 5693 } 5694 catch (e) { 5695 warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm); 5696 valid = false; 5697 } 5698 } 5699 return { 5700 valid: valid, 5701 expectedType: expectedType 5702 }; 5703 } 5704 var functionTypeCheckRE = /^\s*function (\w+)/; 5705 /** 5706 * Use function string name to check built-in types, 5707 * because a simple equality check will fail when running 5708 * across different vms / iframes. 5709 */ 5710 function getType(fn) { 5711 var match = fn && fn.toString().match(functionTypeCheckRE); 5712 return match ? match[1] : ''; 5713 } 5714 function isSameType(a, b) { 5715 return getType(a) === getType(b); 5716 } 5717 function getTypeIndex(type, expectedTypes) { 5718 if (!isArray(expectedTypes)) { 5719 return isSameType(expectedTypes, type) ? 0 : -1; 5720 } 5721 for (var i = 0, len = expectedTypes.length; i < len; i++) { 5722 if (isSameType(expectedTypes[i], type)) { 5723 return i; 5724 } 5725 } 5726 return -1; 5727 } 5728 function getInvalidTypeMessage(name, value, expectedTypes) { 5729 var message = "Invalid prop: type check failed for prop \"".concat(name, "\".") + 5730 " Expected ".concat(expectedTypes.map(capitalize).join(', ')); 5731 var expectedType = expectedTypes[0]; 5732 var receivedType = toRawType(value); 5733 // check if we need to specify expected value 5734 if (expectedTypes.length === 1 && 5735 isExplicable(expectedType) && 5736 isExplicable(typeof value) && 5737 !isBoolean(expectedType, receivedType)) { 5738 message += " with value ".concat(styleValue(value, expectedType)); 5739 } 5740 message += ", got ".concat(receivedType, " "); 5741 // check if we need to specify received value 5742 if (isExplicable(receivedType)) { 5743 message += "with value ".concat(styleValue(value, receivedType), "."); 5744 } 5745 return message; 5746 } 5747 function styleValue(value, type) { 5748 if (type === 'String') { 5749 return "\"".concat(value, "\""); 5750 } 5751 else if (type === 'Number') { 5752 return "".concat(Number(value)); 5753 } 5754 else { 5755 return "".concat(value); 5756 } 5757 } 5758 var EXPLICABLE_TYPES = ['string', 'number', 'boolean']; 5759 function isExplicable(value) { 5760 return EXPLICABLE_TYPES.some(function (elem) { return value.toLowerCase() === elem; }); 5761 } 5762 function isBoolean() { 5763 var args = []; 5764 for (var _i = 0; _i < arguments.length; _i++) { 5765 args[_i] = arguments[_i]; 5766 } 5767 return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; }); 5768 } 5769 5770 function Vue(options) { 5771 if (!(this instanceof Vue)) { 5772 warn$2('Vue is a constructor and should be called with the `new` keyword'); 5773 } 5774 this._init(options); 5775 } 5776 //@ts-expect-error Vue has function type 5777 initMixin$1(Vue); 5778 //@ts-expect-error Vue has function type 5779 stateMixin(Vue); 5780 //@ts-expect-error Vue has function type 5781 eventsMixin(Vue); 5782 //@ts-expect-error Vue has function type 5783 lifecycleMixin(Vue); 5784 //@ts-expect-error Vue has function type 5785 renderMixin(Vue); 5786 5787 function initUse(Vue) { 5788 Vue.use = function (plugin) { 5789 var installedPlugins = this._installedPlugins || (this._installedPlugins = []); 5790 if (installedPlugins.indexOf(plugin) > -1) { 5791 return this; 5792 } 5793 // additional parameters 5794 var args = toArray(arguments, 1); 5795 args.unshift(this); 5796 if (isFunction(plugin.install)) { 5797 plugin.install.apply(plugin, args); 5798 } 5799 else if (isFunction(plugin)) {
vendor: 8,414 bytes, lines 5800-6031
5800 plugin.apply(null, args); 5801 } 5802 installedPlugins.push(plugin); 5803 return this; 5804 }; 5805 } 5806 5807 function initMixin(Vue) { 5808 Vue.mixin = function (mixin) { 5809 this.options = mergeOptions(this.options, mixin); 5810 return this; 5811 }; 5812 } 5813 5814 function initExtend(Vue) { 5815 /** 5816 * Each instance constructor, including Vue, has a unique 5817 * cid. This enables us to create wrapped "child 5818 * constructors" for prototypal inheritance and cache them. 5819 */ 5820 Vue.cid = 0; 5821 var cid = 1; 5822 /** 5823 * Class inheritance 5824 */ 5825 Vue.extend = function (extendOptions) { 5826 extendOptions = extendOptions || {}; 5827 var Super = this; 5828 var SuperId = Super.cid; 5829 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {}); 5830 if (cachedCtors[SuperId]) { 5831 return cachedCtors[SuperId]; 5832 } 5833 var name = getComponentName(extendOptions) || getComponentName(Super.options); 5834 if (name) { 5835 validateComponentName(name); 5836 } 5837 var Sub = function VueComponent(options) { 5838 this._init(options); 5839 }; 5840 Sub.prototype = Object.create(Super.prototype); 5841 Sub.prototype.constructor = Sub; 5842 Sub.cid = cid++; 5843 Sub.options = mergeOptions(Super.options, extendOptions); 5844 Sub['super'] = Super; 5845 // For props and computed properties, we define the proxy getters on 5846 // the Vue instances at extension time, on the extended prototype. This 5847 // avoids Object.defineProperty calls for each instance created. 5848 if (Sub.options.props) { 5849 initProps(Sub); 5850 } 5851 if (Sub.options.computed) { 5852 initComputed(Sub); 5853 } 5854 // allow further extension/mixin/plugin usage 5855 Sub.extend = Super.extend; 5856 Sub.mixin = Super.mixin; 5857 Sub.use = Super.use; 5858 // create asset registers, so extended classes 5859 // can have their private assets too. 5860 ASSET_TYPES.forEach(function (type) { 5861 Sub[type] = Super[type]; 5862 }); 5863 // enable recursive self-lookup 5864 if (name) { 5865 Sub.options.components[name] = Sub; 5866 } 5867 // keep a reference to the super options at extension time. 5868 // later at instantiation we can check if Super's options have 5869 // been updated. 5870 Sub.superOptions = Super.options; 5871 Sub.extendOptions = extendOptions; 5872 Sub.sealedOptions = extend({}, Sub.options); 5873 // cache constructor 5874 cachedCtors[SuperId] = Sub; 5875 return Sub; 5876 }; 5877 } 5878 function initProps(Comp) { 5879 var props = Comp.options.props; 5880 for (var key in props) { 5881 proxy(Comp.prototype, "_props", key); 5882 } 5883 } 5884 function initComputed(Comp) { 5885 var computed = Comp.options.computed; 5886 for (var key in computed) { 5887 defineComputed(Comp.prototype, key, computed[key]); 5888 } 5889 } 5890 5891 function initAssetRegisters(Vue) { 5892 /** 5893 * Create asset registration methods. 5894 */ 5895 ASSET_TYPES.forEach(function (type) { 5896 // @ts-expect-error function is not exact same type 5897 Vue[type] = function (id, definition) { 5898 if (!definition) { 5899 return this.options[type + 's'][id]; 5900 } 5901 else { 5902 /* istanbul ignore if */ 5903 if (type === 'component') { 5904 validateComponentName(id); 5905 } 5906 if (type === 'component' && isPlainObject(definition)) { 5907 // @ts-expect-error 5908 definition.name = definition.name || id; 5909 definition = this.options._base.extend(definition); 5910 } 5911 if (type === 'directive' && isFunction(definition)) { 5912 definition = { bind: definition, update: definition }; 5913 } 5914 this.options[type + 's'][id] = definition; 5915 return definition; 5916 } 5917 }; 5918 }); 5919 } 5920 5921 function _getComponentName(opts) { 5922 return opts && (getComponentName(opts.Ctor.options) || opts.tag); 5923 } 5924 function matches(pattern, name) { 5925 if (isArray(pattern)) { 5926 return pattern.indexOf(name) > -1; 5927 } 5928 else if (typeof pattern === 'string') { 5929 return pattern.split(',').indexOf(name) > -1; 5930 } 5931 else if (isRegExp(pattern)) { 5932 return pattern.test(name); 5933 } 5934 /* istanbul ignore next */ 5935 return false; 5936 } 5937 function pruneCache(keepAliveInstance, filter) { 5938 var cache = keepAliveInstance.cache, keys = keepAliveInstance.keys, _vnode = keepAliveInstance._vnode; 5939 for (var key in cache) { 5940 var entry = cache[key]; 5941 if (entry) { 5942 var name_1 = entry.name; 5943 if (name_1 && !filter(name_1)) { 5944 pruneCacheEntry(cache, key, keys, _vnode); 5945 } 5946 } 5947 } 5948 } 5949 function pruneCacheEntry(cache, key, keys, current) { 5950 var entry = cache[key]; 5951 if (entry && (!current || entry.tag !== current.tag)) { 5952 // @ts-expect-error can be undefined 5953 entry.componentInstance.$destroy(); 5954 } 5955 cache[key] = null; 5956 remove$2(keys, key); 5957 } 5958 var patternTypes = [String, RegExp, Array]; 5959 // TODO defineComponent 5960 var KeepAlive = { 5961 name: 'keep-alive', 5962 abstract: true, 5963 props: { 5964 include: patternTypes, 5965 exclude: patternTypes, 5966 max: [String, Number] 5967 }, 5968 methods: { 5969 cacheVNode: function () { 5970 var _a = this, cache = _a.cache, keys = _a.keys, vnodeToCache = _a.vnodeToCache, keyToCache = _a.keyToCache; 5971 if (vnodeToCache) { 5972 var tag = vnodeToCache.tag, componentInstance = vnodeToCache.componentInstance, componentOptions = vnodeToCache.componentOptions; 5973 cache[keyToCache] = { 5974 name: _getComponentName(componentOptions), 5975 tag: tag, 5976 componentInstance: componentInstance 5977 }; 5978 keys.push(keyToCache); 5979 // prune oldest entry 5980 if (this.max && keys.length > parseInt(this.max)) { 5981 pruneCacheEntry(cache, keys[0], keys, this._vnode); 5982 } 5983 this.vnodeToCache = null; 5984 } 5985 } 5986 }, 5987 created: function () { 5988 this.cache = Object.create(null); 5989 this.keys = []; 5990 }, 5991 destroyed: function () { 5992 for (var key in this.cache) { 5993 pruneCacheEntry(this.cache, key, this.keys); 5994 } 5995 }, 5996 mounted: function () { 5997 var _this = this; 5998 this.cacheVNode(); 5999 this.$watch('include', function (val) { 6000 pruneCache(_this, function (name) { return matches(val, name); }); 6001 }); 6002 this.$watch('exclude', function (val) { 6003 pruneCache(_this, function (name) { return !matches(val, name); }); 6004 }); 6005 }, 6006 updated: function () { 6007 this.cacheVNode(); 6008 }, 6009 render: function () { 6010 var slot = this.$slots.default; 6011 var vnode = getFirstComponentChild(slot); 6012 var componentOptions = vnode && vnode.componentOptions; 6013 if (componentOptions) { 6014 // check pattern 6015 var name_2 = _getComponentName(componentOptions); 6016 var _a = this, include = _a.include, exclude = _a.exclude; 6017 if ( 6018 // not included 6019 (include && (!name_2 || !matches(include, name_2))) || 6020 // excluded 6021 (exclude && name_2 && matches(exclude, name_2))) { 6022 return vnode; 6023 } 6024 var _b = this, cache = _b.cache, keys = _b.keys; 6025 var key = vnode.key == null 6026 ? // same constructor may get registered as different local components 6027 // so cid alone is not enough (#3269) 6028 componentOptions.Ctor.cid + 6029 (componentOptions.tag ? "::".concat(componentOptions.tag) : '') 6030 : vnode.key; 6031 if (cache[key]) {
6032 vnode.componentInstance = cache[key].componentInstance; 6033 // make current key freshest 6034 remove$2(keys, key); 6035 keys.push(key); 6036 } 6037 else { 6038 // delay setting the cache until update 6039 this.vnodeToCache = vnode; 6040 this.keyToCache = key; 6041 } 6042 // @ts-expect-error can vnode.data can be undefined 6043 vnode.data.keepAlive = true; 6044 } 6045 return vnode || (slot && slot[0]); 6046 } 6047 }; 6048 6049 var builtInComponents = { 6050 KeepAlive: KeepAlive 6051 }; 6052 6053 function initGlobalAPI(Vue) { 6054 // config 6055 var configDef = {}; 6056 configDef.get = function () { return config; }; 6057 { 6058 configDef.set = function () { 6059 warn$2('Do not replace the Vue.config object, set individual fields instead.'); 6060 }; 6061 } 6062 Object.defineProperty(Vue, 'config', configDef); 6063 // exposed util methods. 6064 // NOTE: these are not considered part of the public API - avoid relying on 6065 // them unless you are aware of the risk. 6066 Vue.util = { 6067 warn: warn$2, 6068 extend: extend, 6069 mergeOptions: mergeOptions, 6070 defineReactive: defineReactive 6071 }; 6072 Vue.set = set; 6073 Vue.delete = del; 6074 Vue.nextTick = nextTick; 6075 // 2.6 explicit observable API 6076 Vue.observable = function (obj) { 6077 observe(obj); 6078 return obj; 6079 }; 6080 Vue.options = Object.create(null); 6081 ASSET_TYPES.forEach(function (type) { 6082 Vue.options[type + 's'] = Object.create(null); 6083 }); 6084 // this is used to identify the "base" constructor to extend all plain-object 6085 // components with in Weex's multi-instance scenarios. 6086 Vue.options._base = Vue; 6087 extend(Vue.options.components, builtInComponents); 6088 initUse(Vue); 6089 initMixin(Vue); 6090 initExtend(Vue); 6091 initAssetRegisters(Vue); 6092 } 6093 6094 initGlobalAPI(Vue); 6095 Object.defineProperty(Vue.prototype, '$isServer', { 6096 get: isServerRendering 6097 }); 6098 Object.defineProperty(Vue.prototype, '$ssrContext', { 6099 get: function () { 6100 /* istanbul ignore next */ 6101 return this.$vnode && this.$vnode.ssrContext; 6102 } 6103 }); 6104 // expose FunctionalRenderContext for ssr runtime helper installation 6105 Object.defineProperty(Vue, 'FunctionalRenderContext', { 6106 value: FunctionalRenderContext 6107 }); 6108 Vue.version = version; 6109 6110 // these are reserved for web because they are directly compiled away 6111 // during template compilation 6112 var isReservedAttr = makeMap('style,class'); 6113 // attributes that should be using props for binding 6114 var acceptValue = makeMap('input,textarea,option,select,progress'); 6115 var mustUseProp = function (tag, type, attr) { 6116 return ((attr === 'value' && acceptValue(tag) && type !== 'button') || 6117 (attr === 'selected' && tag === 'option') || 6118 (attr === 'checked' && tag === 'input') || 6119 (attr === 'muted' && tag === 'video')); 6120 }; 6121 var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck'); 6122 var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only'); 6123 var convertEnumeratedValue = function (key, value) { 6124 return isFalsyAttrValue(value) || value === 'false' 6125 ? 'false' 6126 : // allow arbitrary string value for contenteditable 6127 key === 'contenteditable' && isValidContentEditableValue(value) 6128 ? value 6129 : 'true'; 6130 }; 6131 var isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 6132 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 6133 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 6134 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 6135 'required,reversed,scoped,seamless,selected,sortable,' + 6136 'truespeed,typemustmatch,visible'); 6137 var xlinkNS = 'http://www.w3.org/1999/xlink'; 6138 var isXlink = function (name) { 6139 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'; 6140 }; 6141 var getXlinkProp = function (name) { 6142 return isXlink(name) ? name.slice(6, name.length) : ''; 6143 }; 6144 var isFalsyAttrValue = function (val) { 6145 return val == null || val === false; 6146 }; 6147 6148 function genClassForVnode(vnode) { 6149 var data = vnode.data; 6150 var parentNode = vnode; 6151 var childNode = vnode; 6152 while (isDef(childNode.componentInstance)) { 6153 childNode = childNode.componentInstance._vnode; 6154 if (childNode && childNode.data) { 6155 data = mergeClassData(childNode.data, data); 6156 } 6157 } 6158 // @ts-expect-error parentNode.parent not VNodeWithData 6159 while (isDef((parentNode = parentNode.parent))) { 6160 if (parentNode && parentNode.data) { 6161 data = mergeClassData(data, parentNode.data); 6162 } 6163 } 6164 return renderClass(data.staticClass, data.class); 6165 } 6166 function mergeClassData(child, parent) { 6167 return { 6168 staticClass: concat(child.staticClass, parent.staticClass), 6169 class: isDef(child.class) ? [child.class, parent.class] : parent.class 6170 }; 6171 } 6172 function renderClass(staticClass, dynamicClass) { 6173 if (isDef(staticClass) || isDef(dynamicClass)) { 6174 return concat(staticClass, stringifyClass(dynamicClass)); 6175 } 6176 /* istanbul ignore next */ 6177 return ''; 6178 } 6179 function concat(a, b) { 6180 return a ? (b ? a + ' ' + b : a) : b || ''; 6181 } 6182 function stringifyClass(value) { 6183 if (Array.isArray(value)) { 6184 return stringifyArray(value); 6185 } 6186 if (isObject(value)) { 6187 return stringifyObject(value); 6188 } 6189 if (typeof value === 'string') { 6190 return value; 6191 } 6192 /* istanbul ignore next */ 6193 return ''; 6194 } 6195 function stringifyArray(value) { 6196 var res = ''; 6197 var stringified; 6198 for (var i = 0, l = value.length; i < l; i++) { 6199 if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') { 6200 if (res) 6201 res += ' '; 6202 res += stringified; 6203 } 6204 } 6205 return res; 6206 } 6207 function stringifyObject(value) { 6208 var res = ''; 6209 for (var key in value) { 6210 if (value[key]) { 6211 if (res) 6212 res += ' '; 6213 res += key; 6214 } 6215 } 6216 return res; 6217 } 6218 6219 var namespaceMap = { 6220 svg: 'http://www.w3.org/2000/svg', 6221 math: 'http://www.w3.org/1998/Math/MathML' 6222 }; 6223 var isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' + 6224 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + 6225 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' + 6226 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 6227 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 6228 'embed,object,param,source,canvas,script,noscript,del,ins,' + 6229 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + 6230 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 6231 'output,progress,select,textarea,' + 6232 'details,dialog,menu,menuitem,summary,' + 6233 'content,element,shadow,template,blockquote,iframe,tfoot'); 6234 // this map is intentionally selective, only covering SVG elements that may 6235 // contain child elements. 6236 var isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + 6237 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + 6238 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true); 6239 var isPreTag = function (tag) { return tag === 'pre'; }; 6240 var isReservedTag = function (tag) { 6241 return isHTMLTag(tag) || isSVG(tag); 6242 }; 6243 function getTagNamespace(tag) { 6244 if (isSVG(tag)) { 6245 return 'svg'; 6246 } 6247 // basic support for MathML 6248 // note it doesn't support other MathML elements being component roots 6249 if (tag === 'math') { 6250 return 'math'; 6251 } 6252 } 6253 var unknownElementCache = Object.create(null); 6254 function isUnknownElement(tag) { 6255 /* istanbul ignore if */ 6256 if (!inBrowser) { 6257 return true; 6258 } 6259 if (isReservedTag(tag)) { 6260 return false;
6261 } 6262 tag = tag.toLowerCase(); 6263 /* istanbul ignore if */ 6264 if (unknownElementCache[tag] != null) { 6265 return unknownElementCache[tag]; 6266 } 6267 var el = document.createElement(tag); 6268 if (tag.indexOf('-') > -1) { 6269 // http://stackoverflow.com/a/28210364/1070244 6270 return (unknownElementCache[tag] = 6271 el.constructor === window.HTMLUnknownElement || 6272 el.constructor === window.HTMLElement); 6273 } 6274 else { 6275 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString())); 6276 } 6277 } 6278 var isTextInputType = makeMap('text,number,password,search,email,tel,url'); 6279 6280 /** 6281 * Query an element selector if it's not an element already. 6282 */ 6283 function query(el) { 6284 if (typeof el === 'string') { 6285 var selected = document.querySelector(el); 6286 if (!selected) { 6287 warn$2('Cannot find element: ' + el); 6288 return document.createElement('div'); 6289 } 6290 return selected; 6291 } 6292 else { 6293 return el; 6294 } 6295 } 6296 6297 function createElement(tagName, vnode) { 6298 var elm = document.createElement(tagName); 6299 if (tagName !== 'select') { 6300 return elm; 6301 } 6302 // false or null will remove the attribute but undefined will not 6303 if (vnode.data && 6304 vnode.data.attrs && 6305 vnode.data.attrs.multiple !== undefined) { 6306 elm.setAttribute('multiple', 'multiple'); 6307 } 6308 return elm; 6309 } 6310 function createElementNS(namespace, tagName) { 6311 return document.createElementNS(namespaceMap[namespace], tagName); 6312 } 6313 function createTextNode(text) { 6314 return document.createTextNode(text); 6315 } 6316 function createComment(text) { 6317 return document.createComment(text); 6318 } 6319 function insertBefore(parentNode, newNode, referenceNode) { 6320 parentNode.insertBefore(newNode, referenceNode); 6321 } 6322 function removeChild(node, child) { 6323 node.removeChild(child); 6324 } 6325 function appendChild(node, child) { 6326 node.appendChild(child); 6327 } 6328 function parentNode(node) { 6329 return node.parentNode; 6330 } 6331 function nextSibling(node) { 6332 return node.nextSibling; 6333 } 6334 function tagName(node) { 6335 return node.tagName; 6336 } 6337 function setTextContent(node, text) { 6338 node.textContent = text; 6339 } 6340 function setStyleScope(node, scopeId) { 6341 node.setAttribute(scopeId, ''); 6342 } 6343 6344 var nodeOps = /*#__PURE__*/Object.freeze({ 6345 __proto__: null, 6346 createElement: createElement, 6347 createElementNS: createElementNS, 6348 createTextNode: createTextNode, 6349 createComment: createComment, 6350 insertBefore: insertBefore, 6351 removeChild: removeChild, 6352 appendChild: appendChild, 6353 parentNode: parentNode, 6354 nextSibling: nextSibling, 6355 tagName: tagName, 6356 setTextContent: setTextContent, 6357 setStyleScope: setStyleScope 6358 }); 6359 6360 var ref = { 6361 create: function (_, vnode) { 6362 registerRef(vnode); 6363 }, 6364 update: function (oldVnode, vnode) { 6365 if (oldVnode.data.ref !== vnode.data.ref) { 6366 registerRef(oldVnode, true); 6367 registerRef(vnode); 6368 } 6369 }, 6370 destroy: function (vnode) { 6371 registerRef(vnode, true); 6372 } 6373 }; 6374 function registerRef(vnode, isRemoval) { 6375 var ref = vnode.data.ref; 6376 if (!isDef(ref)) 6377 return; 6378 var vm = vnode.context; 6379 var refValue = vnode.componentInstance || vnode.elm; 6380 var value = isRemoval ? null : refValue; 6381 var $refsValue = isRemoval ? undefined : refValue; 6382 if (isFunction(ref)) { 6383 invokeWithErrorHandling(ref, vm, [value], vm, "template ref function"); 6384 return; 6385 } 6386 var isFor = vnode.data.refInFor; 6387 var _isString = typeof ref === 'string' || typeof ref === 'number'; 6388 var _isRef = isRef(ref); 6389 var refs = vm.$refs; 6390 if (_isString || _isRef) { 6391 if (isFor) { 6392 var existing = _isString ? refs[ref] : ref.value; 6393 if (isRemoval) { 6394 isArray(existing) && remove$2(existing, refValue); 6395 } 6396 else { 6397 if (!isArray(existing)) { 6398 if (_isString) { 6399 refs[ref] = [refValue]; 6400 setSetupRef(vm, ref, refs[ref]); 6401 } 6402 else { 6403 ref.value = [refValue]; 6404 } 6405 } 6406 else if (!existing.includes(refValue)) { 6407 existing.push(refValue); 6408 } 6409 } 6410 } 6411 else if (_isString) { 6412 if (isRemoval && refs[ref] !== refValue) { 6413 return; 6414 } 6415 refs[ref] = $refsValue; 6416 setSetupRef(vm, ref, value); 6417 } 6418 else if (_isRef) { 6419 if (isRemoval && ref.value !== refValue) { 6420 return; 6421 } 6422 ref.value = value; 6423 } 6424 else { 6425 warn$2("Invalid template ref type: ".concat(typeof ref)); 6426 } 6427 } 6428 } 6429 function setSetupRef(_a, key, val) { 6430 var _setupState = _a._setupState; 6431 if (_setupState && hasOwn(_setupState, key)) { 6432 if (isRef(_setupState[key])) { 6433 _setupState[key].value = val; 6434 } 6435 else { 6436 _setupState[key] = val; 6437 } 6438 } 6439 } 6440 6441 /** 6442 * Virtual DOM patching algorithm based on Snabbdom by 6443 * Simon Friis Vindum (@paldepind) 6444 * Licensed under the MIT License 6445 * https://github.com/paldepind/snabbdom/blob/master/LICENSE 6446 * 6447 * modified by Evan You (@yyx990803) 6448 * 6449 * Not type-checking this because this file is perf-critical and the cost 6450 * of making flow understand it is not worth it. 6451 */ 6452 var emptyNode = new VNode('', {}, []); 6453 var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; 6454 function sameVnode(a, b) {
6455 return (a.key === b.key && 6456 a.asyncFactory === b.asyncFactory && 6457 ((a.tag === b.tag && 6458 a.isComment === b.isComment && 6459 isDef(a.data) === isDef(b.data) && 6460 sameInputType(a, b)) || 6461 (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error)))); 6462 } 6463 function sameInputType(a, b) { 6464 if (a.tag !== 'input') 6465 return true; 6466 var i; 6467 var typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type; 6468 var typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type; 6469 return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB)); 6470 } 6471 function createKeyToOldIdx(children, beginIdx, endIdx) { 6472 var i, key; 6473 var map = {}; 6474 for (i = beginIdx; i <= endIdx; ++i) { 6475 key = children[i].key; 6476 if (isDef(key)) 6477 map[key] = i; 6478 } 6479 return map; 6480 } 6481 function createPatchFunction(backend) { 6482 var i, j; 6483 var cbs = {}; 6484 var modules = backend.modules, nodeOps = backend.nodeOps; 6485 for (i = 0; i < hooks.length; ++i) { 6486 cbs[hooks[i]] = []; 6487 for (j = 0; j < modules.length; ++j) { 6488 if (isDef(modules[j][hooks[i]])) { 6489 cbs[hooks[i]].push(modules[j][hooks[i]]); 6490 } 6491 } 6492 } 6493 function emptyNodeAt(elm) { 6494 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm); 6495 } 6496 function createRmCb(childElm, listeners) { 6497 function remove() { 6498 if (--remove.listeners === 0) { 6499 removeNode(childElm); 6500 } 6501 } 6502 remove.listeners = listeners; 6503 return remove; 6504 } 6505 function removeNode(el) { 6506 var parent = nodeOps.parentNode(el); 6507 // element may have already been removed due to v-html / v-text 6508 if (isDef(parent)) { 6509 nodeOps.removeChild(parent, el); 6510 } 6511 } 6512 function isUnknownElement(vnode, inVPre) { 6513 return (!inVPre && 6514 !vnode.ns && 6515 !(config.ignoredElements.length && 6516 config.ignoredElements.some(function (ignore) { 6517 return isRegExp(ignore) 6518 ? ignore.test(vnode.tag) 6519 : ignore === vnode.tag; 6520 })) && 6521 config.isUnknownElement(vnode.tag)); 6522 } 6523 var creatingElmInVPre = 0; 6524 function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
6525 if (isDef(vnode.elm) && isDef(ownerArray)) { 6526 // This vnode was used in a previous render! 6527 // now it's used as a new node, overwriting its elm would cause 6528 // potential patch errors down the road when it's used as an insertion 6529 // reference node. Instead, we clone the node on-demand before creating 6530 // associated DOM element for it. 6531 vnode = ownerArray[index] = cloneVNode(vnode); 6532 } 6533 vnode.isRootInsert = !nested; // for transition enter check 6534 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { 6535 return; 6536 } 6537 var data = vnode.data; 6538 var children = vnode.children; 6539 var tag = vnode.tag; 6540 if (isDef(tag)) { 6541 { 6542 if (data && data.pre) { 6543 creatingElmInVPre++; 6544 } 6545 if (isUnknownElement(vnode, creatingElmInVPre)) { 6546 warn$2('Unknown custom element: <' + 6547 tag + 6548 '> - did you ' + 6549 'register the component correctly? For recursive components, ' + 6550 'make sure to provide the "name" option.', vnode.context); 6551 } 6552 } 6553 vnode.elm = vnode.ns 6554 ? nodeOps.createElementNS(vnode.ns, tag) 6555 : nodeOps.createElement(tag, vnode); 6556 setScope(vnode); 6557 createChildren(vnode, children, insertedVnodeQueue); 6558 if (isDef(data)) { 6559 invokeCreateHooks(vnode, insertedVnodeQueue); 6560 } 6561 insert(parentElm, vnode.elm, refElm); 6562 if (data && data.pre) { 6563 creatingElmInVPre--; 6564 } 6565 } 6566 else if (isTrue(vnode.isComment)) { 6567 vnode.elm = nodeOps.createComment(vnode.text); 6568 insert(parentElm, vnode.elm, refElm); 6569 } 6570 else { 6571 vnode.elm = nodeOps.createTextNode(vnode.text); 6572 insert(parentElm, vnode.elm, refElm); 6573 } 6574 } 6575 function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) { 6576 var i = vnode.data; 6577 if (isDef(i)) { 6578 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; 6579 if (isDef((i = i.hook)) && isDef((i = i.init))) { 6580 i(vnode, false /* hydrating */); 6581 } 6582 // after calling the init hook, if the vnode is a child component 6583 // it should've created a child instance and mounted it. the child 6584 // component also has set the placeholder vnode's elm. 6585 // in that case we can just return the element and be done.
6586 if (isDef(vnode.componentInstance)) { 6587 initComponent(vnode, insertedVnodeQueue); 6588 insert(parentElm, vnode.elm, refElm); 6589 if (isTrue(isReactivated)) { 6590 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); 6591 } 6592 return true; 6593 } 6594 } 6595 } 6596 function initComponent(vnode, insertedVnodeQueue) { 6597 if (isDef(vnode.data.pendingInsert)) { 6598 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); 6599 vnode.data.pendingInsert = null; 6600 } 6601 vnode.elm = vnode.componentInstance.$el; 6602 if (isPatchable(vnode)) { 6603 invokeCreateHooks(vnode, insertedVnodeQueue); 6604 setScope(vnode); 6605 } 6606 else { 6607 // empty component root. 6608 // skip all element-related modules except for ref (#3455) 6609 registerRef(vnode); 6610 // make sure to invoke the insert hook 6611 insertedVnodeQueue.push(vnode); 6612 } 6613 } 6614 function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) { 6615 var i; 6616 // hack for #4339: a reactivated component with inner transition 6617 // does not trigger because the inner node's created hooks are not called 6618 // again. It's not ideal to involve module-specific logic in here but 6619 // there doesn't seem to be a better way to do it. 6620 var innerNode = vnode; 6621 while (innerNode.componentInstance) { 6622 innerNode = innerNode.componentInstance._vnode; 6623 if (isDef((i = innerNode.data)) && isDef((i = i.transition))) { 6624 for (i = 0; i < cbs.activate.length; ++i) { 6625 cbs.activate[i](emptyNode, innerNode); 6626 } 6627 insertedVnodeQueue.push(innerNode); 6628 break; 6629 } 6630 } 6631 // unlike a newly created component, 6632 // a reactivated keep-alive component doesn't insert itself 6633 insert(parentElm, vnode.elm, refElm); 6634 } 6635 function insert(parent, elm, ref) { 6636 if (isDef(parent)) { 6637 if (isDef(ref)) { 6638 if (nodeOps.parentNode(ref) === parent) { 6639 nodeOps.insertBefore(parent, elm, ref); 6640 } 6641 } 6642 else { 6643 nodeOps.appendChild(parent, elm); 6644 } 6645 } 6646 } 6647 function createChildren(vnode, children, insertedVnodeQueue) { 6648 if (isArray(children)) { 6649 { 6650 checkDuplicateKeys(children); 6651 } 6652 for (var i_1 = 0; i_1 < children.length; ++i_1) { 6653 createElm(children[i_1], insertedVnodeQueue, vnode.elm, null, true, children, i_1); 6654 } 6655 } 6656 else if (isPrimitive(vnode.text)) { 6657 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text))); 6658 } 6659 } 6660 function isPatchable(vnode) { 6661 while (vnode.componentInstance) { 6662 vnode = vnode.componentInstance._vnode; 6663 } 6664 return isDef(vnode.tag); 6665 } 6666 function invokeCreateHooks(vnode, insertedVnodeQueue) { 6667 for (var i_2 = 0; i_2 < cbs.create.length; ++i_2) { 6668 cbs.create[i_2](emptyNode, vnode); 6669 } 6670 i = vnode.data.hook; // Reuse variable 6671 if (isDef(i)) { 6672 if (isDef(i.create)) 6673 i.create(emptyNode, vnode); 6674 if (isDef(i.insert)) 6675 insertedVnodeQueue.push(vnode); 6676 } 6677 } 6678 // set scope id attribute for scoped CSS. 6679 // this is implemented as a special case to avoid the overhead 6680 // of going through the normal attribute patching process. 6681 function setScope(vnode) { 6682 var i; 6683 if (isDef((i = vnode.fnScopeId))) { 6684 nodeOps.setStyleScope(vnode.elm, i); 6685 } 6686 else { 6687 var ancestor = vnode; 6688 while (ancestor) { 6689 if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) { 6690 nodeOps.setStyleScope(vnode.elm, i); 6691 } 6692 ancestor = ancestor.parent; 6693 } 6694 } 6695 // for slot content they should also get the scopeId from the host instance. 6696 if (isDef((i = activeInstance)) && 6697 i !== vnode.context && 6698 i !== vnode.fnContext && 6699 isDef((i = i.$options._scopeId))) { 6700 nodeOps.setStyleScope(vnode.elm, i); 6701 } 6702 } 6703 function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { 6704 for (; startIdx <= endIdx; ++startIdx) { 6705 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx); 6706 } 6707 } 6708 function invokeDestroyHook(vnode) { 6709 var i, j; 6710 var data = vnode.data; 6711 if (isDef(data)) { 6712 if (isDef((i = data.hook)) && isDef((i = i.destroy))) 6713 i(vnode); 6714 for (i = 0; i < cbs.destroy.length; ++i) 6715 cbs.destroy[i](vnode); 6716 } 6717 if (isDef((i = vnode.children))) { 6718 for (j = 0; j < vnode.children.length; ++j) { 6719 invokeDestroyHook(vnode.children[j]); 6720 } 6721 } 6722 } 6723 function removeVnodes(vnodes, startIdx, endIdx) { 6724 for (; startIdx <= endIdx; ++startIdx) { 6725 var ch = vnodes[startIdx]; 6726 if (isDef(ch)) { 6727 if (isDef(ch.tag)) { 6728 removeAndInvokeRemoveHook(ch); 6729 invokeDestroyHook(ch); 6730 } 6731 else { 6732 // Text node 6733 removeNode(ch.elm); 6734 } 6735 } 6736 } 6737 } 6738 function removeAndInvokeRemoveHook(vnode, rm) { 6739 if (isDef(rm) || isDef(vnode.data)) { 6740 var i_3; 6741 var listeners = cbs.remove.length + 1; 6742 if (isDef(rm)) { 6743 // we have a recursively passed down rm callback 6744 // increase the listeners count 6745 rm.listeners += listeners; 6746 } 6747 else { 6748 // directly removing 6749 rm = createRmCb(vnode.elm, listeners); 6750 } 6751 // recursively invoke hooks on child component root node 6752 if (isDef((i_3 = vnode.componentInstance)) && 6753 isDef((i_3 = i_3._vnode)) && 6754 isDef(i_3.data)) { 6755 removeAndInvokeRemoveHook(i_3, rm); 6756 } 6757 for (i_3 = 0; i_3 < cbs.remove.length; ++i_3) { 6758 cbs.remove[i_3](vnode, rm); 6759 } 6760 if (isDef((i_3 = vnode.data.hook)) && isDef((i_3 = i_3.remove))) { 6761 i_3(vnode, rm); 6762 } 6763 else { 6764 rm(); 6765 } 6766 } 6767 else { 6768 removeNode(vnode.elm); 6769 } 6770 } 6771 function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { 6772 var oldStartIdx = 0; 6773 var newStartIdx = 0; 6774 var oldEndIdx = oldCh.length - 1; 6775 var oldStartVnode = oldCh[0]; 6776 var oldEndVnode = oldCh[oldEndIdx];
vendor: 5,013 bytes, lines 6777-6880
6777 var newEndIdx = newCh.length - 1; 6778 var newStartVnode = newCh[0]; 6779 var newEndVnode = newCh[newEndIdx]; 6780 var oldKeyToIdx, idxInOld, vnodeToMove, refElm; 6781 // removeOnly is a special flag used only by <transition-group> 6782 // to ensure removed elements stay in correct relative positions 6783 // during leaving transitions 6784 var canMove = !removeOnly; 6785 { 6786 checkDuplicateKeys(newCh); 6787 } 6788 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { 6789 if (isUndef(oldStartVnode)) { 6790 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left 6791 } 6792 else if (isUndef(oldEndVnode)) { 6793 oldEndVnode = oldCh[--oldEndIdx]; 6794 } 6795 else if (sameVnode(oldStartVnode, newStartVnode)) { 6796 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); 6797 oldStartVnode = oldCh[++oldStartIdx]; 6798 newStartVnode = newCh[++newStartIdx]; 6799 } 6800 else if (sameVnode(oldEndVnode, newEndVnode)) { 6801 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx); 6802 oldEndVnode = oldCh[--oldEndIdx]; 6803 newEndVnode = newCh[--newEndIdx]; 6804 } 6805 else if (sameVnode(oldStartVnode, newEndVnode)) { 6806 // Vnode moved right 6807 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx); 6808 canMove && 6809 nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); 6810 oldStartVnode = oldCh[++oldStartIdx]; 6811 newEndVnode = newCh[--newEndIdx]; 6812 } 6813 else if (sameVnode(oldEndVnode, newStartVnode)) { 6814 // Vnode moved left 6815 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); 6816 canMove && 6817 nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); 6818 oldEndVnode = oldCh[--oldEndIdx]; 6819 newStartVnode = newCh[++newStartIdx]; 6820 } 6821 else { 6822 if (isUndef(oldKeyToIdx)) 6823 oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); 6824 idxInOld = isDef(newStartVnode.key) 6825 ? oldKeyToIdx[newStartVnode.key] 6826 : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx); 6827 if (isUndef(idxInOld)) { 6828 // New element 6829 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 6830 } 6831 else { 6832 vnodeToMove = oldCh[idxInOld]; 6833 if (sameVnode(vnodeToMove, newStartVnode)) { 6834 patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); 6835 oldCh[idxInOld] = undefined; 6836 canMove && 6837 nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); 6838 } 6839 else { 6840 // same key but different element. treat as new element 6841 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 6842 } 6843 } 6844 newStartVnode = newCh[++newStartIdx]; 6845 } 6846 } 6847 if (oldStartIdx > oldEndIdx) { 6848 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; 6849 addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); 6850 } 6851 else if (newStartIdx > newEndIdx) { 6852 removeVnodes(oldCh, oldStartIdx, oldEndIdx); 6853 } 6854 } 6855 function checkDuplicateKeys(children) { 6856 var seenKeys = {}; 6857 for (var i_4 = 0; i_4 < children.length; i_4++) { 6858 var vnode = children[i_4]; 6859 var key = vnode.key; 6860 if (isDef(key)) { 6861 if (seenKeys[key]) { 6862 warn$2("Duplicate keys detected: '".concat(key, "'. This may cause an update error."), vnode.context); 6863 } 6864 else { 6865 seenKeys[key] = true; 6866 } 6867 } 6868 } 6869 } 6870 function findIdxInOld(node, oldCh, start, end) { 6871 for (var i_5 = start; i_5 < end; i_5++) { 6872 var c = oldCh[i_5]; 6873 if (isDef(c) && sameVnode(node, c)) 6874 return i_5; 6875 } 6876 } 6877 function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) { 6878 if (oldVnode === vnode) { 6879 return; 6880 }
6881 if (isDef(vnode.elm) && isDef(ownerArray)) { 6882 // clone reused vnode 6883 vnode = ownerArray[index] = cloneVNode(vnode); 6884 } 6885 var elm = (vnode.elm = oldVnode.elm); 6886 if (isTrue(oldVnode.isAsyncPlaceholder)) { 6887 if (isDef(vnode.asyncFactory.resolved)) { 6888 hydrate(oldVnode.elm, vnode, insertedVnodeQueue); 6889 } 6890 else { 6891 vnode.isAsyncPlaceholder = true; 6892 } 6893 return; 6894 } 6895 // reuse element for static trees. 6896 // note we only do this if the vnode is cloned - 6897 // if the new node is not cloned it means the render functions have been 6898 // reset by the hot-reload-api and we need to do a proper re-render. 6899 if (isTrue(vnode.isStatic) && 6900 isTrue(oldVnode.isStatic) && 6901 vnode.key === oldVnode.key && 6902 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) { 6903 vnode.componentInstance = oldVnode.componentInstance; 6904 return; 6905 } 6906 var i; 6907 var data = vnode.data; 6908 if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) { 6909 i(oldVnode, vnode); 6910 } 6911 var oldCh = oldVnode.children; 6912 var ch = vnode.children; 6913 if (isDef(data) && isPatchable(vnode)) { 6914 for (i = 0; i < cbs.update.length; ++i) 6915 cbs.update[i](oldVnode, vnode); 6916 if (isDef((i = data.hook)) && isDef((i = i.update))) 6917 i(oldVnode, vnode); 6918 } 6919 if (isUndef(vnode.text)) { 6920 if (isDef(oldCh) && isDef(ch)) { 6921 if (oldCh !== ch) 6922 updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); 6923 } 6924 else if (isDef(ch)) { 6925 { 6926 checkDuplicateKeys(ch); 6927 } 6928 if (isDef(oldVnode.text)) 6929 nodeOps.setTextContent(elm, ''); 6930 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); 6931 } 6932 else if (isDef(oldCh)) { 6933 removeVnodes(oldCh, 0, oldCh.length - 1); 6934 } 6935 else if (isDef(oldVnode.text)) { 6936 nodeOps.setTextContent(elm, ''); 6937 } 6938 } 6939 else if (oldVnode.text !== vnode.text) { 6940 nodeOps.setTextContent(elm, vnode.text); 6941 } 6942 if (isDef(data)) { 6943 if (isDef((i = data.hook)) && isDef((i = i.postpatch))) 6944 i(oldVnode, vnode); 6945 } 6946 } 6947 function invokeInsertHook(vnode, queue, initial) { 6948 // delay insert hooks for component root nodes, invoke them after the 6949 // element is really inserted 6950 if (isTrue(initial) && isDef(vnode.parent)) { 6951 vnode.parent.data.pendingInsert = queue; 6952 } 6953 else { 6954 for (var i_6 = 0; i_6 < queue.length; ++i_6) { 6955 queue[i_6].data.hook.insert(queue[i_6]); 6956 } 6957 } 6958 } 6959 var hydrationBailed = false; 6960 // list of modules that can skip create hook during hydration because they 6961 // are already rendered on the client or has no need for initialization 6962 // Note: style is excluded because it relies on initial clone for future 6963 // deep updates (#7063). 6964 var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key'); 6965 // Note: this is a browser-only function so we can assume elms are DOM nodes. 6966 function hydrate(elm, vnode, insertedVnodeQueue, inVPre) { 6967 var i; 6968 var tag = vnode.tag, data = vnode.data, children = vnode.children; 6969 inVPre = inVPre || (data && data.pre); 6970 vnode.elm = elm; 6971 if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) { 6972 vnode.isAsyncPlaceholder = true; 6973 return true; 6974 } 6975 // assert node match 6976 { 6977 if (!assertNodeMatch(elm, vnode, inVPre)) { 6978 return false;
6979 } 6980 } 6981 if (isDef(data)) { 6982 if (isDef((i = data.hook)) && isDef((i = i.init))) 6983 i(vnode, true /* hydrating */); 6984 if (isDef((i = vnode.componentInstance))) { 6985 // child component. it should have hydrated its own tree. 6986 initComponent(vnode, insertedVnodeQueue); 6987 return true; 6988 } 6989 } 6990 if (isDef(tag)) { 6991 if (isDef(children)) { 6992 // empty element, allow client to pick up and populate children 6993 if (!elm.hasChildNodes()) { 6994 createChildren(vnode, children, insertedVnodeQueue); 6995 } 6996 else { 6997 // v-html and domProps: innerHTML 6998 if (isDef((i = data)) && 6999 isDef((i = i.domProps)) && 7000 isDef((i = i.innerHTML))) { 7001 if (i !== elm.innerHTML) { 7002 /* istanbul ignore if */ 7003 if (typeof console !== 'undefined' && 7004 !hydrationBailed) { 7005 hydrationBailed = true; 7006 console.warn('Parent: ', elm); 7007 console.warn('server innerHTML: ', i); 7008 console.warn('client innerHTML: ', elm.innerHTML); 7009 } 7010 return false; 7011 } 7012 } 7013 else { 7014 // iterate and compare children lists 7015 var childrenMatch = true; 7016 var childNode = elm.firstChild; 7017 for (var i_7 = 0; i_7 < children.length; i_7++) { 7018 if (!childNode || 7019 !hydrate(childNode, children[i_7], insertedVnodeQueue, inVPre)) { 7020 childrenMatch = false; 7021 break; 7022 } 7023 childNode = childNode.nextSibling; 7024 } 7025 // if childNode is not null, it means the actual childNodes list is 7026 // longer than the virtual children list. 7027 if (!childrenMatch || childNode) { 7028 /* istanbul ignore if */ 7029 if (typeof console !== 'undefined' && 7030 !hydrationBailed) { 7031 hydrationBailed = true; 7032 console.warn('Parent: ', elm); 7033 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); 7034 } 7035 return false; 7036 } 7037 } 7038 } 7039 } 7040 if (isDef(data)) { 7041 var fullInvoke = false; 7042 for (var key in data) { 7043 if (!isRenderedModule(key)) { 7044 fullInvoke = true; 7045 invokeCreateHooks(vnode, insertedVnodeQueue); 7046 break; 7047 } 7048 } 7049 if (!fullInvoke && data['class']) { 7050 // ensure collecting deps for deep class bindings for future updates 7051 traverse(data['class']); 7052 } 7053 } 7054 } 7055 else if (elm.data !== vnode.text) { 7056 elm.data = vnode.text; 7057 } 7058 return true; 7059 } 7060 function assertNodeMatch(node, vnode, inVPre) {
7061 if (isDef(vnode.tag)) { 7062 return (vnode.tag.indexOf('vue-component') === 0 || 7063 (!isUnknownElement(vnode, inVPre) && 7064 vnode.tag.toLowerCase() === 7065 (node.tagName && node.tagName.toLowerCase()))); 7066 } 7067 else { 7068 return node.nodeType === (vnode.isComment ? 8 : 3); 7069 } 7070 } 7071 return function patch(oldVnode, vnode, hydrating, removeOnly) { 7072 if (isUndef(vnode)) { 7073 if (isDef(oldVnode)) 7074 invokeDestroyHook(oldVnode); 7075 return; 7076 } 7077 var isInitialPatch = false; 7078 var insertedVnodeQueue = []; 7079 if (isUndef(oldVnode)) { 7080 // empty mount (likely as component), create new root element 7081 isInitialPatch = true; 7082 createElm(vnode, insertedVnodeQueue); 7083 } 7084 else { 7085 var isRealElement = isDef(oldVnode.nodeType); 7086 if (!isRealElement && sameVnode(oldVnode, vnode)) { 7087 // patch existing root node 7088 patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly); 7089 } 7090 else { 7091 if (isRealElement) { 7092 // mounting to a real element 7093 // check if this is server-rendered content and if we can perform 7094 // a successful hydration. 7095 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) { 7096 oldVnode.removeAttribute(SSR_ATTR); 7097 hydrating = true; 7098 } 7099 if (isTrue(hydrating)) { 7100 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) { 7101 invokeInsertHook(vnode, insertedVnodeQueue, true); 7102 return oldVnode; 7103 } 7104 else { 7105 warn$2('The client-side rendered virtual DOM tree is not matching ' + 7106 'server-rendered content. This is likely caused by incorrect ' + 7107 'HTML markup, for example nesting block-level elements inside ' + 7108 '<p>, or missing <tbody>. Bailing hydration and performing ' + 7109 'full client-side render.'); 7110 } 7111 } 7112 // either not server-rendered, or hydration failed. 7113 // create an empty node and replace it 7114 oldVnode = emptyNodeAt(oldVnode); 7115 } 7116 // replacing existing element 7117 var oldElm = oldVnode.elm; 7118 var parentElm = nodeOps.parentNode(oldElm); 7119 // create new node 7120 createElm(vnode, insertedVnodeQueue, 7121 // extremely rare edge case: do not insert if old element is in a 7122 // leaving transition. Only happens when combining transition + 7123 // keep-alive + HOCs. (#4590) 7124 oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm)); 7125 // update parent placeholder node element, recursively
vendor: 10,291 bytes, lines 7126-7417
7126 if (isDef(vnode.parent)) { 7127 var ancestor = vnode.parent; 7128 var patchable = isPatchable(vnode); 7129 while (ancestor) { 7130 for (var i_8 = 0; i_8 < cbs.destroy.length; ++i_8) { 7131 cbs.destroy[i_8](ancestor); 7132 } 7133 ancestor.elm = vnode.elm; 7134 if (patchable) { 7135 for (var i_9 = 0; i_9 < cbs.create.length; ++i_9) { 7136 cbs.create[i_9](emptyNode, ancestor); 7137 } 7138 // #6513 7139 // invoke insert hooks that may have been merged by create hooks. 7140 // e.g. for directives that uses the "inserted" hook. 7141 var insert_1 = ancestor.data.hook.insert; 7142 if (insert_1.merged) { 7143 // start at index 1 to avoid re-invoking component mounted hook 7144 for (var i_10 = 1; i_10 < insert_1.fns.length; i_10++) { 7145 insert_1.fns[i_10](); 7146 } 7147 } 7148 } 7149 else { 7150 registerRef(ancestor); 7151 } 7152 ancestor = ancestor.parent; 7153 } 7154 } 7155 // destroy old node 7156 if (isDef(parentElm)) { 7157 removeVnodes([oldVnode], 0, 0); 7158 } 7159 else if (isDef(oldVnode.tag)) { 7160 invokeDestroyHook(oldVnode); 7161 } 7162 } 7163 } 7164 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch); 7165 return vnode.elm; 7166 }; 7167 } 7168 7169 var directives$1 = { 7170 create: updateDirectives, 7171 update: updateDirectives, 7172 destroy: function unbindDirectives(vnode) { 7173 // @ts-expect-error emptyNode is not VNodeWithData 7174 updateDirectives(vnode, emptyNode); 7175 } 7176 }; 7177 function updateDirectives(oldVnode, vnode) { 7178 if (oldVnode.data.directives || vnode.data.directives) { 7179 _update(oldVnode, vnode); 7180 } 7181 } 7182 function _update(oldVnode, vnode) { 7183 var isCreate = oldVnode === emptyNode; 7184 var isDestroy = vnode === emptyNode; 7185 var oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context); 7186 var newDirs = normalizeDirectives(vnode.data.directives, vnode.context); 7187 var dirsWithInsert = []; 7188 var dirsWithPostpatch = []; 7189 var key, oldDir, dir; 7190 for (key in newDirs) { 7191 oldDir = oldDirs[key]; 7192 dir = newDirs[key]; 7193 if (!oldDir) { 7194 // new directive, bind 7195 callHook(dir, 'bind', vnode, oldVnode); 7196 if (dir.def && dir.def.inserted) { 7197 dirsWithInsert.push(dir); 7198 } 7199 } 7200 else { 7201 // existing directive, update 7202 dir.oldValue = oldDir.value; 7203 dir.oldArg = oldDir.arg; 7204 callHook(dir, 'update', vnode, oldVnode); 7205 if (dir.def && dir.def.componentUpdated) { 7206 dirsWithPostpatch.push(dir); 7207 } 7208 } 7209 } 7210 if (dirsWithInsert.length) { 7211 var callInsert = function () { 7212 for (var i = 0; i < dirsWithInsert.length; i++) { 7213 callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode); 7214 } 7215 }; 7216 if (isCreate) { 7217 mergeVNodeHook(vnode, 'insert', callInsert); 7218 } 7219 else { 7220 callInsert(); 7221 } 7222 } 7223 if (dirsWithPostpatch.length) { 7224 mergeVNodeHook(vnode, 'postpatch', function () { 7225 for (var i = 0; i < dirsWithPostpatch.length; i++) { 7226 callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); 7227 } 7228 }); 7229 } 7230 if (!isCreate) { 7231 for (key in oldDirs) { 7232 if (!newDirs[key]) { 7233 // no longer present, unbind 7234 callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy); 7235 } 7236 } 7237 } 7238 } 7239 var emptyModifiers = Object.create(null); 7240 function normalizeDirectives(dirs, vm) { 7241 var res = Object.create(null); 7242 if (!dirs) { 7243 // $flow-disable-line 7244 return res; 7245 } 7246 var i, dir; 7247 for (i = 0; i < dirs.length; i++) { 7248 dir = dirs[i]; 7249 if (!dir.modifiers) { 7250 // $flow-disable-line 7251 dir.modifiers = emptyModifiers; 7252 } 7253 res[getRawDirName(dir)] = dir; 7254 if (vm._setupState && vm._setupState.__sfc) { 7255 var setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name); 7256 if (typeof setupDef === 'function') { 7257 dir.def = { 7258 bind: setupDef, 7259 update: setupDef, 7260 }; 7261 } 7262 else { 7263 dir.def = setupDef; 7264 } 7265 } 7266 dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true); 7267 } 7268 // $flow-disable-line 7269 return res; 7270 } 7271 function getRawDirName(dir) { 7272 return (dir.rawName || "".concat(dir.name, ".").concat(Object.keys(dir.modifiers || {}).join('.'))); 7273 } 7274 function callHook(dir, hook, vnode, oldVnode, isDestroy) { 7275 var fn = dir.def && dir.def[hook]; 7276 if (fn) { 7277 try { 7278 fn(vnode.elm, dir, vnode, oldVnode, isDestroy); 7279 } 7280 catch (e) { 7281 handleError(e, vnode.context, "directive ".concat(dir.name, " ").concat(hook, " hook")); 7282 } 7283 } 7284 } 7285 7286 var baseModules = [ref, directives$1]; 7287 7288 function updateAttrs(oldVnode, vnode) { 7289 var opts = vnode.componentOptions; 7290 if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) { 7291 return; 7292 } 7293 if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) { 7294 return; 7295 } 7296 var key, cur, old; 7297 var elm = vnode.elm; 7298 var oldAttrs = oldVnode.data.attrs || {}; 7299 var attrs = vnode.data.attrs || {}; 7300 // clone observed objects, as the user probably wants to mutate it 7301 if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) { 7302 attrs = vnode.data.attrs = extend({}, attrs); 7303 } 7304 for (key in attrs) { 7305 cur = attrs[key]; 7306 old = oldAttrs[key]; 7307 if (old !== cur) { 7308 setAttr(elm, key, cur, vnode.data.pre); 7309 } 7310 } 7311 // #4391: in IE9, setting type can reset value for input[type=radio] 7312 // #6666: IE/Edge forces progress value down to 1 before setting a max 7313 /* istanbul ignore if */ 7314 if ((isIE || isEdge) && attrs.value !== oldAttrs.value) { 7315 setAttr(elm, 'value', attrs.value); 7316 } 7317 for (key in oldAttrs) { 7318 if (isUndef(attrs[key])) { 7319 if (isXlink(key)) { 7320 elm.removeAttributeNS(xlinkNS, getXlinkProp(key)); 7321 } 7322 else if (!isEnumeratedAttr(key)) { 7323 elm.removeAttribute(key); 7324 } 7325 } 7326 } 7327 } 7328 function setAttr(el, key, value, isInPre) { 7329 if (isInPre || el.tagName.indexOf('-') > -1) { 7330 baseSetAttr(el, key, value); 7331 } 7332 else if (isBooleanAttr(key)) { 7333 // set attribute for blank value 7334 // e.g. <option disabled>Select one</option> 7335 if (isFalsyAttrValue(value)) { 7336 el.removeAttribute(key); 7337 } 7338 else { 7339 // technically allowfullscreen is a boolean attribute for <iframe>, 7340 // but Flash expects a value of "true" when used on <embed> tag 7341 value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key; 7342 el.setAttribute(key, value); 7343 } 7344 } 7345 else if (isEnumeratedAttr(key)) { 7346 el.setAttribute(key, convertEnumeratedValue(key, value)); 7347 } 7348 else if (isXlink(key)) { 7349 if (isFalsyAttrValue(value)) { 7350 el.removeAttributeNS(xlinkNS, getXlinkProp(key)); 7351 } 7352 else { 7353 el.setAttributeNS(xlinkNS, key, value); 7354 } 7355 } 7356 else { 7357 baseSetAttr(el, key, value); 7358 } 7359 } 7360 function baseSetAttr(el, key, value) { 7361 if (isFalsyAttrValue(value)) { 7362 el.removeAttribute(key); 7363 } 7364 else { 7365 // #7138: IE10 & 11 fires input event when setting placeholder on 7366 // <textarea>... block the first input event and remove the blocker 7367 // immediately. 7368 /* istanbul ignore if */ 7369 if (isIE && 7370 !isIE9 && 7371 el.tagName === 'TEXTAREA' && 7372 key === 'placeholder' && 7373 value !== '' && 7374 !el.__ieph) { 7375 var blocker_1 = function (e) { 7376 e.stopImmediatePropagation(); 7377 el.removeEventListener('input', blocker_1); 7378 }; 7379 el.addEventListener('input', blocker_1); 7380 // $flow-disable-line 7381 el.__ieph = true; /* IE placeholder patched */ 7382 } 7383 el.setAttribute(key, value); 7384 } 7385 } 7386 var attrs = { 7387 create: updateAttrs, 7388 update: updateAttrs 7389 }; 7390 7391 function updateClass(oldVnode, vnode) { 7392 var el = vnode.elm; 7393 var data = vnode.data; 7394 var oldData = oldVnode.data; 7395 if (isUndef(data.staticClass) && 7396 isUndef(data.class) && 7397 (isUndef(oldData) || 7398 (isUndef(oldData.staticClass) && isUndef(oldData.class)))) { 7399 return; 7400 } 7401 var cls = genClassForVnode(vnode); 7402 // handle transition classes 7403 var transitionClass = el._transitionClasses; 7404 if (isDef(transitionClass)) { 7405 cls = concat(cls, stringifyClass(transitionClass)); 7406 } 7407 // set the class 7408 if (cls !== el._prevClass) { 7409 el.setAttribute('class', cls); 7410 el._prevClass = cls; 7411 } 7412 } 7413 var klass$1 = { 7414 create: updateClass, 7415 update: updateClass 7416 }; 7417
7418 var validDivisionCharRE = /[\w).+\-_$\]]/; 7419 function parseFilters(exp) { 7420 var inSingle = false; 7421 var inDouble = false; 7422 var inTemplateString = false; 7423 var inRegex = false; 7424 var curly = 0; 7425 var square = 0; 7426 var paren = 0; 7427 var lastFilterIndex = 0; 7428 var c, prev, i, expression, filters; 7429 for (i = 0; i < exp.length; i++) { 7430 prev = c; 7431 c = exp.charCodeAt(i); 7432 if (inSingle) { 7433 if (c === 0x27 && prev !== 0x5c) 7434 inSingle = false; 7435 } 7436 else if (inDouble) { 7437 if (c === 0x22 && prev !== 0x5c) 7438 inDouble = false; 7439 } 7440 else if (inTemplateString) { 7441 if (c === 0x60 && prev !== 0x5c) 7442 inTemplateString = false; 7443 } 7444 else if (inRegex) { 7445 if (c === 0x2f && prev !== 0x5c) 7446 inRegex = false; 7447 } 7448 else if (c === 0x7c && // pipe 7449 exp.charCodeAt(i + 1) !== 0x7c && 7450 exp.charCodeAt(i - 1) !== 0x7c && 7451 !curly && 7452 !square && 7453 !paren) { 7454 if (expression === undefined) { 7455 // first filter, end of expression 7456 lastFilterIndex = i + 1; 7457 expression = exp.slice(0, i).trim(); 7458 } 7459 else { 7460 pushFilter(); 7461 } 7462 } 7463 else { 7464 switch (c) { 7465 case 0x22: 7466 inDouble = true; 7467 break; // " 7468 case 0x27: 7469 inSingle = true; 7470 break; // ' 7471 case 0x60: 7472 inTemplateString = true; 7473 break; // ` 7474 case 0x28: 7475 paren++; 7476 break; // ( 7477 case 0x29: 7478 paren--; 7479 break; // ) 7480 case 0x5b: 7481 square++; 7482 break; // [ 7483 case 0x5d: 7484 square--; 7485 break; // ] 7486 case 0x7b: 7487 curly++; 7488 break; // { 7489 case 0x7d: 7490 curly--; 7491 break; // } 7492 } 7493 if (c === 0x2f) { 7494 // / 7495 var j = i - 1; 7496 var p 7497 // find first non-whitespace prev char 7498 = void 0; 7499 // find first non-whitespace prev char 7500 for (; j >= 0; j--) { 7501 p = exp.charAt(j); 7502 if (p !== ' ') 7503 break; 7504 } 7505 if (!p || !validDivisionCharRE.test(p)) { 7506 inRegex = true; 7507 } 7508 } 7509 } 7510 } 7511 if (expression === undefined) { 7512 expression = exp.slice(0, i).trim(); 7513 } 7514 else if (lastFilterIndex !== 0) { 7515 pushFilter(); 7516 } 7517 function pushFilter() { 7518 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()); 7519 lastFilterIndex = i + 1; 7520 } 7521 if (filters) { 7522 for (i = 0; i < filters.length; i++) { 7523 expression = wrapFilter(expression, filters[i]); 7524 } 7525 } 7526 return expression; 7527 } 7528 function wrapFilter(exp, filter) { 7529 var i = filter.indexOf('('); 7530 if (i < 0) { 7531 // _f: resolveFilter 7532 return "_f(\"".concat(filter, "\")(").concat(exp, ")"); 7533 } 7534 else { 7535 var name_1 = filter.slice(0, i); 7536 var args = filter.slice(i + 1); 7537 return "_f(\"".concat(name_1, "\")(").concat(exp).concat(args !== ')' ? ',' + args : args); 7538 } 7539 } 7540 7541 /* eslint-disable no-unused-vars */ 7542 function baseWarn(msg, range) { 7543 console.error("[Vue compiler]: ".concat(msg)); 7544 } 7545 /* eslint-enable no-unused-vars */ 7546 function pluckModuleFunction(modules, key) { 7547 return modules ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; }) : []; 7548 } 7549 function addProp(el, name, value, range, dynamic) { 7550 (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range)); 7551 el.plain = false;
7552 } 7553 function addAttr(el, name, value, range, dynamic) { 7554 var attrs = dynamic 7555 ? el.dynamicAttrs || (el.dynamicAttrs = []) 7556 : el.attrs || (el.attrs = []); 7557 attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range)); 7558 el.plain = false; 7559 } 7560 // add a raw attr (use this in preTransforms) 7561 function addRawAttr(el, name, value, range) { 7562 el.attrsMap[name] = value; 7563 el.attrsList.push(rangeSetItem({ name: name, value: value }, range)); 7564 } 7565 function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) { 7566 (el.directives || (el.directives = [])).push(rangeSetItem({ 7567 name: name, 7568 rawName: rawName, 7569 value: value, 7570 arg: arg, 7571 isDynamicArg: isDynamicArg, 7572 modifiers: modifiers 7573 }, range)); 7574 el.plain = false; 7575 } 7576 function prependModifierMarker(symbol, name, dynamic) { 7577 return dynamic ? "_p(".concat(name, ",\"").concat(symbol, "\")") : symbol + name; // mark the event as captured 7578 } 7579 function addHandler(el, name, value, modifiers, important, warn, range, dynamic) { 7580 modifiers = modifiers || emptyObject; 7581 // warn prevent and passive modifier 7582 /* istanbul ignore if */ 7583 if (warn && modifiers.prevent && modifiers.passive) { 7584 warn("passive and prevent can't be used together. " + 7585 "Passive handler can't prevent default event.", range); 7586 } 7587 // normalize click.right and click.middle since they don't actually fire 7588 // this is technically browser-specific, but at least for now browsers are 7589 // the only target envs that have right/middle clicks. 7590 if (modifiers.right) { 7591 if (dynamic) { 7592 name = "(".concat(name, ")==='click'?'contextmenu':(").concat(name, ")"); 7593 } 7594 else if (name === 'click') { 7595 name = 'contextmenu'; 7596 delete modifiers.right; 7597 } 7598 } 7599 else if (modifiers.middle) { 7600 if (dynamic) { 7601 name = "(".concat(name, ")==='click'?'mouseup':(").concat(name, ")"); 7602 } 7603 else if (name === 'click') { 7604 name = 'mouseup'; 7605 } 7606 } 7607 // check capture modifier 7608 if (modifiers.capture) { 7609 delete modifiers.capture; 7610 name = prependModifierMarker('!', name, dynamic); 7611 } 7612 if (modifiers.once) { 7613 delete modifiers.once; 7614 name = prependModifierMarker('~', name, dynamic); 7615 } 7616 /* istanbul ignore if */ 7617 if (modifiers.passive) { 7618 delete modifiers.passive; 7619 name = prependModifierMarker('&', name, dynamic); 7620 } 7621 var events; 7622 if (modifiers.native) { 7623 delete modifiers.native; 7624 events = el.nativeEvents || (el.nativeEvents = {}); 7625 } 7626 else { 7627 events = el.events || (el.events = {}); 7628 } 7629 var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range); 7630 if (modifiers !== emptyObject) { 7631 newHandler.modifiers = modifiers; 7632 } 7633 var handlers = events[name]; 7634 /* istanbul ignore if */ 7635 if (Array.isArray(handlers)) { 7636 important ? handlers.unshift(newHandler) : handlers.push(newHandler); 7637 } 7638 else if (handlers) { 7639 events[name] = important ? [newHandler, handlers] : [handlers, newHandler]; 7640 } 7641 else { 7642 events[name] = newHandler; 7643 } 7644 el.plain = false; 7645 } 7646 function getRawBindingAttr(el, name) { 7647 return (el.rawAttrsMap[':' + name] || 7648 el.rawAttrsMap['v-bind:' + name] || 7649 el.rawAttrsMap[name]); 7650 } 7651 function getBindingAttr(el, name, getStatic) { 7652 var dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name); 7653 if (dynamicValue != null) { 7654 return parseFilters(dynamicValue); 7655 } 7656 else if (getStatic !== false) { 7657 var staticValue = getAndRemoveAttr(el, name); 7658 if (staticValue != null) { 7659 return JSON.stringify(staticValue); 7660 } 7661 } 7662 } 7663 // note: this only removes the attr from the Array (attrsList) so that it 7664 // doesn't get processed by processAttrs. 7665 // By default it does NOT remove it from the map (attrsMap) because the map is 7666 // needed during codegen. 7667 function getAndRemoveAttr(el, name, removeFromMap) { 7668 var val; 7669 if ((val = el.attrsMap[name]) != null) { 7670 var list = el.attrsList; 7671 for (var i = 0, l = list.length; i < l; i++) { 7672 if (list[i].name === name) { 7673 list.splice(i, 1); 7674 break; 7675 } 7676 } 7677 } 7678 if (removeFromMap) { 7679 delete el.attrsMap[name]; 7680 } 7681 return val; 7682 } 7683 function getAndRemoveAttrByRegex(el, name) { 7684 var list = el.attrsList; 7685 for (var i = 0, l = list.length; i < l; i++) { 7686 var attr = list[i]; 7687 if (name.test(attr.name)) { 7688 list.splice(i, 1); 7689 return attr; 7690 } 7691 } 7692 } 7693 function rangeSetItem(item, range) { 7694 if (range) { 7695 if (range.start != null) { 7696 item.start = range.start; 7697 } 7698 if (range.end != null) { 7699 item.end = range.end; 7700 } 7701 } 7702 return item; 7703 } 7704 7705 /** 7706 * Cross-platform code generation for component v-model 7707 */ 7708 function genComponentModel(el, value, modifiers) { 7709 var _a = modifiers || {}, number = _a.number, trim = _a.trim; 7710 var baseValueExpression = '$$v'; 7711 var valueExpression = baseValueExpression; 7712 if (trim) { 7713 valueExpression = 7714 "(typeof ".concat(baseValueExpression, " === 'string'") + 7715 "? ".concat(baseValueExpression, ".trim()") + 7716 ": ".concat(baseValueExpression, ")"); 7717 } 7718 if (number) { 7719 valueExpression = "_n(".concat(valueExpression, ")"); 7720 }
7721 var assignment = genAssignmentCode(value, valueExpression); 7722 el.model = { 7723 value: "(".concat(value, ")"), 7724 expression: JSON.stringify(value), 7725 callback: "function (".concat(baseValueExpression, ") {").concat(assignment, "}") 7726 }; 7727 } 7728 /** 7729 * Cross-platform codegen helper for generating v-model value assignment code. 7730 */ 7731 function genAssignmentCode(value, assignment) { 7732 var res = parseModel(value); 7733 if (res.key === null) { 7734 return "".concat(value, "=").concat(assignment); 7735 } 7736 else { 7737 return "$set(".concat(res.exp, ", ").concat(res.key, ", ").concat(assignment, ")"); 7738 } 7739 } 7740 /** 7741 * Parse a v-model expression into a base path and a final key segment. 7742 * Handles both dot-path and possible square brackets. 7743 * 7744 * Possible cases: 7745 * 7746 * - test 7747 * - test[key] 7748 * - test[test1[key]] 7749 * - test["a"][key] 7750 * - xxx.test[a[a].test1[key]] 7751 * - test.xxx.a["asa"][test1[key]] 7752 * 7753 */ 7754 var len, str, chr, index, expressionPos, expressionEndPos; 7755 function parseModel(val) { 7756 // Fix https://github.com/vuejs/vue/pull/7730 7757 // allow v-model="obj.val " (trailing whitespace) 7758 val = val.trim(); 7759 len = val.length; 7760 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { 7761 index = val.lastIndexOf('.'); 7762 if (index > -1) { 7763 return { 7764 exp: val.slice(0, index), 7765 key: '"' + val.slice(index + 1) + '"' 7766 }; 7767 } 7768 else { 7769 return { 7770 exp: val, 7771 key: null 7772 }; 7773 } 7774 } 7775 str = val; 7776 index = expressionPos = expressionEndPos = 0; 7777 while (!eof()) { 7778 chr = next(); 7779 /* istanbul ignore if */ 7780 if (isStringStart(chr)) { 7781 parseString(chr); 7782 } 7783 else if (chr === 0x5b) { 7784 parseBracket(chr); 7785 } 7786 } 7787 return { 7788 exp: val.slice(0, expressionPos), 7789 key: val.slice(expressionPos + 1, expressionEndPos) 7790 }; 7791 } 7792 function next() { 7793 return str.charCodeAt(++index); 7794 } 7795 function eof() { 7796 return index >= len; 7797 } 7798 function isStringStart(chr) { 7799 return chr === 0x22 || chr === 0x27; 7800 } 7801 function parseBracket(chr) { 7802 var inBracket = 1; 7803 expressionPos = index; 7804 while (!eof()) { 7805 chr = next(); 7806 if (isStringStart(chr)) { 7807 parseString(chr); 7808 continue; 7809 } 7810 if (chr === 0x5b) 7811 inBracket++; 7812 if (chr === 0x5d) 7813 inBracket--; 7814 if (inBracket === 0) { 7815 expressionEndPos = index; 7816 break; 7817 } 7818 } 7819 } 7820 function parseString(chr) { 7821 var stringQuote = chr; 7822 while (!eof()) { 7823 chr = next(); 7824 if (chr === stringQuote) { 7825 break; 7826 } 7827 } 7828 } 7829 7830 var warn$1; 7831 // in some cases, the event used has to be determined at runtime 7832 // so we used some reserved tokens during compile. 7833 var RANGE_TOKEN = '__r'; 7834 var CHECKBOX_RADIO_TOKEN = '__c'; 7835 function model$1(el, dir, _warn) { 7836 warn$1 = _warn; 7837 var value = dir.value; 7838 var modifiers = dir.modifiers; 7839 var tag = el.tag; 7840 var type = el.attrsMap.type; 7841 { 7842 // inputs with type="file" are read only and setting the input's 7843 // value will throw an error. 7844 if (tag === 'input' && type === 'file') { 7845 warn$1("<".concat(el.tag, " v-model=\"").concat(value, "\" type=\"file\">:\n") + 7846 "File inputs are read only. Use a v-on:change listener instead.", el.rawAttrsMap['v-model']); 7847 } 7848 } 7849 if (el.component) { 7850 genComponentModel(el, value, modifiers); 7851 // component v-model doesn't need extra runtime 7852 return false; 7853 } 7854 else if (tag === 'select') { 7855 genSelect(el, value, modifiers); 7856 } 7857 else if (tag === 'input' && type === 'checkbox') { 7858 genCheckboxModel(el, value, modifiers); 7859 } 7860 else if (tag === 'input' && type === 'radio') { 7861 genRadioModel(el, value, modifiers); 7862 } 7863 else if (tag === 'input' || tag === 'textarea') { 7864 genDefaultModel(el, value, modifiers); 7865 } 7866 else if (!config.isReservedTag(tag)) { 7867 genComponentModel(el, value, modifiers); 7868 // component v-model doesn't need extra runtime 7869 return false;
7870 } 7871 else { 7872 warn$1("<".concat(el.tag, " v-model=\"").concat(value, "\">: ") + 7873 "v-model is not supported on this element type. " + 7874 "If you are working with contenteditable, it's recommended to " + 7875 'wrap a library dedicated for that purpose inside a custom component.', el.rawAttrsMap['v-model']); 7876 } 7877 // ensure runtime directive metadata 7878 return true; 7879 } 7880 function genCheckboxModel(el, value, modifiers) { 7881 var number = modifiers && modifiers.number; 7882 var valueBinding = getBindingAttr(el, 'value') || 'null'; 7883 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true'; 7884 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false'; 7885 addProp(el, 'checked', "Array.isArray(".concat(value, ")") + 7886 "?_i(".concat(value, ",").concat(valueBinding, ")>-1") + 7887 (trueValueBinding === 'true' 7888 ? ":(".concat(value, ")") 7889 : ":_q(".concat(value, ",").concat(trueValueBinding, ")"))); 7890 addHandler(el, 'change', "var $$a=".concat(value, ",") + 7891 '$$el=$event.target,' + 7892 "$$c=$$el.checked?(".concat(trueValueBinding, "):(").concat(falseValueBinding, ");") + 7893 'if(Array.isArray($$a)){' + 7894 "var $$v=".concat(number ? '_n(' + valueBinding + ')' : valueBinding, ",") + 7895 '$$i=_i($$a,$$v);' + 7896 "if($$el.checked){$$i<0&&(".concat(genAssignmentCode(value, '$$a.concat([$$v])'), ")}") + 7897 "else{$$i>-1&&(".concat(genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))'), ")}") + 7898 "}else{".concat(genAssignmentCode(value, '$$c'), "}"), null, true); 7899 } 7900 function genRadioModel(el, value, modifiers) { 7901 var number = modifiers && modifiers.number; 7902 var valueBinding = getBindingAttr(el, 'value') || 'null'; 7903 valueBinding = number ? "_n(".concat(valueBinding, ")") : valueBinding; 7904 addProp(el, 'checked', "_q(".concat(value, ",").concat(valueBinding, ")")); 7905 addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true); 7906 } 7907 function genSelect(el, value, modifiers) { 7908 var number = modifiers && modifiers.number; 7909 var selectedVal = "Array.prototype.filter" + 7910 ".call($event.target.options,function(o){return o.selected})" + 7911 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" + 7912 "return ".concat(number ? '_n(val)' : 'val', "})"); 7913 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'; 7914 var code = "var $$selectedVal = ".concat(selectedVal, ";"); 7915 code = "".concat(code, " ").concat(genAssignmentCode(value, assignment)); 7916 addHandler(el, 'change', code, null, true); 7917 } 7918 function genDefaultModel(el, value, modifiers) { 7919 var type = el.attrsMap.type; 7920 // warn if v-bind:value conflicts with v-model 7921 // except for inputs with v-bind:type 7922 { 7923 var value_1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value']; 7924 var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']; 7925 if (value_1 && !typeBinding) { 7926 var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'; 7927 warn$1("".concat(binding, "=\"").concat(value_1, "\" conflicts with v-model on the same element ") + 7928 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]); 7929 } 7930 } 7931 var _a = modifiers || {}, lazy = _a.lazy, number = _a.number, trim = _a.trim; 7932 var needCompositionGuard = !lazy && type !== 'range'; 7933 var event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input'; 7934 var valueExpression = '$event.target.value'; 7935 if (trim) { 7936 valueExpression = "$event.target.value.trim()"; 7937 } 7938 if (number) { 7939 valueExpression = "_n(".concat(valueExpression, ")"); 7940 } 7941 var code = genAssignmentCode(value, valueExpression); 7942 if (needCompositionGuard) { 7943 code = "if($event.target.composing)return;".concat(code); 7944 } 7945 addProp(el, 'value', "(".concat(value, ")")); 7946 addHandler(el, event, code, null, true); 7947 if (trim || number) { 7948 addHandler(el, 'blur', '$forceUpdate()'); 7949 } 7950 } 7951 7952 // normalize v-model event tokens that can only be determined at runtime. 7953 // it's important to place the event as the first in the array because 7954 // the whole point is ensuring the v-model callback gets called before 7955 // user-attached handlers. 7956 function normalizeEvents(on) { 7957 /* istanbul ignore if */ 7958 if (isDef(on[RANGE_TOKEN])) { 7959 // IE input[type=range] only supports `change` event 7960 var event_1 = isIE ? 'change' : 'input'; 7961 on[event_1] = [].concat(on[RANGE_TOKEN], on[event_1] || []); 7962 delete on[RANGE_TOKEN]; 7963 } 7964 // This was originally intended to fix #4521 but no longer necessary 7965 // after 2.5. Keeping it for backwards compat with generated code from < 2.4 7966 /* istanbul ignore if */ 7967 if (isDef(on[CHECKBOX_RADIO_TOKEN])) { 7968 on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []); 7969 delete on[CHECKBOX_RADIO_TOKEN]; 7970 } 7971 } 7972 var target; 7973 function createOnceHandler(event, handler, capture) { 7974 var _target = target; // save current target element in closure 7975 return function onceHandler() { 7976 var res = handler.apply(null, arguments); 7977 if (res !== null) { 7978 remove(event, onceHandler, capture, _target); 7979 } 7980 }; 7981 } 7982 // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp 7983 // implementation and does not fire microtasks in between event propagation, so 7984 // safe to exclude. 7985 var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53); 7986 function add(name, handler, capture, passive) {
vendor: 6,256 bytes, lines 7987-8130
7987 // async edge case #6566: inner click event triggers patch, event handler 7988 // attached to outer element during patch, and triggered again. This 7989 // happens because browsers fire microtask ticks between event propagation. 7990 // the solution is simple: we save the timestamp when a handler is attached, 7991 // and the handler would only fire if the event passed to it was fired 7992 // AFTER it was attached. 7993 if (useMicrotaskFix) { 7994 var attachedTimestamp_1 = currentFlushTimestamp; 7995 var original_1 = handler; 7996 //@ts-expect-error 7997 handler = original_1._wrapper = function (e) { 7998 if ( 7999 // no bubbling, should always fire. 8000 // this is just a safety net in case event.timeStamp is unreliable in 8001 // certain weird environments... 8002 e.target === e.currentTarget || 8003 // event is fired after handler attachment 8004 e.timeStamp >= attachedTimestamp_1 || 8005 // bail for environments that have buggy event.timeStamp implementations 8006 // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState 8007 // #9681 QtWebEngine event.timeStamp is negative value 8008 e.timeStamp <= 0 || 8009 // #9448 bail if event is fired in another document in a multi-page 8010 // electron/nw.js app, since event.timeStamp will be using a different 8011 // starting reference 8012 e.target.ownerDocument !== document) { 8013 return original_1.apply(this, arguments); 8014 } 8015 }; 8016 } 8017 target.addEventListener(name, handler, supportsPassive ? { capture: capture, passive: passive } : capture); 8018 } 8019 function remove(name, handler, capture, _target) { 8020 (_target || target).removeEventListener(name, 8021 //@ts-expect-error 8022 handler._wrapper || handler, capture); 8023 } 8024 function updateDOMListeners(oldVnode, vnode) { 8025 if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) { 8026 return; 8027 } 8028 var on = vnode.data.on || {}; 8029 var oldOn = oldVnode.data.on || {}; 8030 // vnode is empty when removing all listeners, 8031 // and use old vnode dom element 8032 target = vnode.elm || oldVnode.elm; 8033 normalizeEvents(on); 8034 updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context); 8035 target = undefined; 8036 } 8037 var events = { 8038 create: updateDOMListeners, 8039 update: updateDOMListeners, 8040 // @ts-expect-error emptyNode has actually data 8041 destroy: function (vnode) { return updateDOMListeners(vnode, emptyNode); } 8042 }; 8043 8044 var svgContainer; 8045 function updateDOMProps(oldVnode, vnode) { 8046 if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) { 8047 return; 8048 } 8049 var key, cur; 8050 var elm = vnode.elm; 8051 var oldProps = oldVnode.data.domProps || {}; 8052 var props = vnode.data.domProps || {}; 8053 // clone observed objects, as the user probably wants to mutate it 8054 if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) { 8055 props = vnode.data.domProps = extend({}, props); 8056 } 8057 for (key in oldProps) { 8058 if (!(key in props)) { 8059 elm[key] = ''; 8060 } 8061 } 8062 for (key in props) { 8063 cur = props[key]; 8064 // ignore children if the node has textContent or innerHTML, 8065 // as these will throw away existing DOM nodes and cause removal errors 8066 // on subsequent patches (#3360) 8067 if (key === 'textContent' || key === 'innerHTML') { 8068 if (vnode.children) 8069 vnode.children.length = 0; 8070 if (cur === oldProps[key]) 8071 continue; 8072 // #6601 work around Chrome version <= 55 bug where single textNode 8073 // replaced by innerHTML/textContent retains its parentNode property 8074 if (elm.childNodes.length === 1) { 8075 elm.removeChild(elm.childNodes[0]); 8076 } 8077 } 8078 if (key === 'value' && elm.tagName !== 'PROGRESS') { 8079 // store value as _value as well since 8080 // non-string values will be stringified 8081 elm._value = cur; 8082 // avoid resetting cursor position when value is the same 8083 var strCur = isUndef(cur) ? '' : String(cur); 8084 if (shouldUpdateValue(elm, strCur)) { 8085 elm.value = strCur; 8086 } 8087 } 8088 else if (key === 'innerHTML' && 8089 isSVG(elm.tagName) && 8090 isUndef(elm.innerHTML)) { 8091 // IE doesn't support innerHTML for SVG elements 8092 svgContainer = svgContainer || document.createElement('div'); 8093 svgContainer.innerHTML = "<svg>".concat(cur, "</svg>"); 8094 var svg = svgContainer.firstChild; 8095 while (elm.firstChild) { 8096 elm.removeChild(elm.firstChild); 8097 } 8098 while (svg.firstChild) { 8099 elm.appendChild(svg.firstChild); 8100 } 8101 } 8102 else if ( 8103 // skip the update if old and new VDOM state is the same. 8104 // `value` is handled separately because the DOM value may be temporarily 8105 // out of sync with VDOM state due to focus, composition and modifiers. 8106 // This #4521 by skipping the unnecessary `checked` update. 8107 cur !== oldProps[key]) { 8108 // some property updates can throw 8109 // e.g. `value` on <progress> w/ non-finite value 8110 try { 8111 elm[key] = cur; 8112 } 8113 catch (e) { } 8114 } 8115 } 8116 } 8117 function shouldUpdateValue(elm, checkVal) { 8118 return ( 8119 //@ts-expect-error 8120 !elm.composing && 8121 (elm.tagName === 'OPTION' || 8122 isNotInFocusAndDirty(elm, checkVal) || 8123 isDirtyWithModifiers(elm, checkVal))); 8124 } 8125 function isNotInFocusAndDirty(elm, checkVal) { 8126 // return true when textbox (.number and .trim) loses focus and its value is 8127 // not equal to the updated value 8128 var notInFocus = true; 8129 // #6157 8130 // work around IE bug when accessing document.activeElement in an iframe
8131 try { 8132 notInFocus = document.activeElement !== elm; 8133 } 8134 catch (e) { } 8135 return notInFocus && elm.value !== checkVal; 8136 } 8137 function isDirtyWithModifiers(elm, newVal) { 8138 var value = elm.value; 8139 var modifiers = elm._vModifiers; // injected by v-model runtime 8140 if (isDef(modifiers)) { 8141 if (modifiers.number) { 8142 return toNumber(value) !== toNumber(newVal); 8143 } 8144 if (modifiers.trim) { 8145 return value.trim() !== newVal.trim(); 8146 } 8147 } 8148 return value !== newVal; 8149 } 8150 var domProps = { 8151 create: updateDOMProps, 8152 update: updateDOMProps 8153 }; 8154 8155 var parseStyleText = cached(function (cssText) { 8156 var res = {}; 8157 var listDelimiter = /;(?![^(]*\))/g; 8158 var propertyDelimiter = /:(.+)/; 8159 cssText.split(listDelimiter).forEach(function (item) { 8160 if (item) { 8161 var tmp = item.split(propertyDelimiter); 8162 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()); 8163 } 8164 }); 8165 return res; 8166 }); 8167 // merge static and dynamic style data on the same vnode 8168 function normalizeStyleData(data) { 8169 var style = normalizeStyleBinding(data.style); 8170 // static style is pre-processed into an object during compilation 8171 // and is always a fresh object, so it's safe to merge into
vendor: 31,264 bytes, lines 8171-9041
8171it 8172 return data.staticStyle ? extend(data.staticStyle, style) : style; 8173 } 8174 // normalize possible array / string values into Object 8175 function normalizeStyleBinding(bindingStyle) { 8176 if (Array.isArray(bindingStyle)) { 8177 return toObject(bindingStyle); 8178 } 8179 if (typeof bindingStyle === 'string') { 8180 return parseStyleText(bindingStyle); 8181 } 8182 return bindingStyle; 8183 } 8184 /** 8185 * parent component style should be after child's 8186 * so that parent component's style could override it 8187 */ 8188 function getStyle(vnode, checkChild) { 8189 var res = {}; 8190 var styleData; 8191 if (checkChild) { 8192 var childNode = vnode; 8193 while (childNode.componentInstance) { 8194 childNode = childNode.componentInstance._vnode; 8195 if (childNode && 8196 childNode.data && 8197 (styleData = normalizeStyleData(childNode.data))) { 8198 extend(res, styleData); 8199 } 8200 } 8201 } 8202 if ((styleData = normalizeStyleData(vnode.data))) { 8203 extend(res, styleData); 8204 } 8205 var parentNode = vnode; 8206 // @ts-expect-error parentNode.parent not VNodeWithData 8207 while ((parentNode = parentNode.parent)) { 8208 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { 8209 extend(res, styleData); 8210 } 8211 } 8212 return res; 8213 } 8214 8215 var cssVarRE = /^--/; 8216 var importantRE = /\s*!important$/; 8217 var setProp = function (el, name, val) { 8218 /* istanbul ignore if */ 8219 if (cssVarRE.test(name)) { 8220 el.style.setProperty(name, val); 8221 } 8222 else if (importantRE.test(val)) { 8223 el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important'); 8224 } 8225 else { 8226 var normalizedName = normalize(name); 8227 if (Array.isArray(val)) { 8228 // Support values array created by autoprefixer, e.g. 8229 // {display: ["-webkit-box", "-ms-flexbox", "flex"]} 8230 // Set them one by one, and the browser will only set those it can recognize 8231 for (var i = 0, len = val.length; i < len; i++) { 8232 el.style[normalizedName] = val[i]; 8233 } 8234 } 8235 else { 8236 el.style[normalizedName] = val; 8237 } 8238 } 8239 }; 8240 var vendorNames = ['Webkit', 'Moz', 'ms']; 8241 var emptyStyle; 8242 var normalize = cached(function (prop) { 8243 emptyStyle = emptyStyle || document.createElement('div').style; 8244 prop = camelize(prop); 8245 if (prop !== 'filter' && prop in emptyStyle) { 8246 return prop; 8247 } 8248 var capName = prop.charAt(0).toUpperCase() + prop.slice(1); 8249 for (var i = 0; i < vendorNames.length; i++) { 8250 var name_1 = vendorNames[i] + capName; 8251 if (name_1 in emptyStyle) { 8252 return name_1; 8253 } 8254 } 8255 }); 8256 function updateStyle(oldVnode, vnode) { 8257 var data = vnode.data; 8258 var oldData = oldVnode.data; 8259 if (isUndef(data.staticStyle) && 8260 isUndef(data.style) && 8261 isUndef(oldData.staticStyle) && 8262 isUndef(oldData.style)) { 8263 return; 8264 } 8265 var cur, name; 8266 var el = vnode.elm; 8267 var oldStaticStyle = oldData.staticStyle; 8268 var oldStyleBinding = oldData.normalizedStyle || oldData.style || {}; 8269 // if static style exists, stylebinding already merged into it when doing normalizeStyleData 8270 var oldStyle = oldStaticStyle || oldStyleBinding; 8271 var style = normalizeStyleBinding(vnode.data.style) || {}; 8272 // store normalized style under a different key for next diff 8273 // make sure to clone it if it's reactive, since the user likely wants 8274 // to mutate it. 8275 vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style; 8276 var newStyle = getStyle(vnode, true); 8277 for (name in oldStyle) { 8278 if (isUndef(newStyle[name])) { 8279 setProp(el, name, ''); 8280 } 8281 } 8282 for (name in newStyle) { 8283 cur = newStyle[name]; 8284 if (cur !== oldStyle[name]) { 8285 // ie9 setting to null has no effect, must use empty string 8286 setProp(el, name, cur == null ? '' : cur); 8287 } 8288 } 8289 } 8290 var style$1 = { 8291 create: updateStyle, 8292 update: updateStyle 8293 }; 8294 8295 var whitespaceRE$1 = /\s+/; 8296 /** 8297 * Add class with compatibility for SVG since classList is not supported on 8298 * SVG elements in IE 8299 */ 8300 function addClass(el, cls) { 8301 /* istanbul ignore if */ 8302 if (!cls || !(cls = cls.trim())) { 8303 return; 8304 } 8305 /* istanbul ignore else */ 8306 if (el.classList) { 8307 if (cls.indexOf(' ') > -1) { 8308 cls.split(whitespaceRE$1).forEach(function (c) { return el.classList.add(c); }); 8309 } 8310 else { 8311 el.classList.add(cls); 8312 } 8313 } 8314 else { 8315 var cur = " ".concat(el.getAttribute('class') || '', " "); 8316 if (cur.indexOf(' ' + cls + ' ') < 0) { 8317 el.setAttribute('class', (cur + cls).trim()); 8318 } 8319 } 8320 } 8321 /** 8322 * Remove class with compatibility for SVG since classList is not supported on 8323 * SVG elements in IE 8324 */ 8325 function removeClass(el, cls) { 8326 /* istanbul ignore if */ 8327 if (!cls || !(cls = cls.trim())) { 8328 return; 8329 } 8330 /* istanbul ignore else */ 8331 if (el.classList) { 8332 if (cls.indexOf(' ') > -1) { 8333 cls.split(whitespaceRE$1).forEach(function (c) { return el.classList.remove(c); }); 8334 } 8335 else { 8336 el.classList.remove(cls); 8337 } 8338 if (!el.classList.length) { 8339 el.removeAttribute('class'); 8340 } 8341 } 8342 else { 8343 var cur = " ".concat(el.getAttribute('class') || '', " "); 8344 var tar = ' ' + cls + ' '; 8345 while (cur.indexOf(tar) >= 0) { 8346 cur = cur.replace(tar, ' '); 8347 } 8348 cur = cur.trim(); 8349 if (cur) { 8350 el.setAttribute('class', cur); 8351 } 8352 else { 8353 el.removeAttribute('class'); 8354 } 8355 } 8356 } 8357 8358 function resolveTransition(def) { 8359 if (!def) { 8360 return; 8361 } 8362 /* istanbul ignore else */ 8363 if (typeof def === 'object') { 8364 var res = {}; 8365 if (def.css !== false) { 8366 extend(res, autoCssTransition(def.name || 'v')); 8367 } 8368 extend(res, def); 8369 return res; 8370 } 8371 else if (typeof def === 'string') { 8372 return autoCssTransition(def); 8373 } 8374 } 8375 var autoCssTransition = cached(function (name) { 8376 return { 8377 enterClass: "".concat(name, "-enter"), 8378 enterToClass: "".concat(name, "-enter-to"), 8379 enterActiveClass: "".concat(name, "-enter-active"), 8380 leaveClass: "".concat(name, "-leave"), 8381 leaveToClass: "".concat(name, "-leave-to"), 8382 leaveActiveClass: "".concat(name, "-leave-active") 8383 }; 8384 }); 8385 var hasTransition = inBrowser && !isIE9; 8386 var TRANSITION = 'transition'; 8387 var ANIMATION = 'animation'; 8388 // Transition property/event sniffing 8389 var transitionProp = 'transition'; 8390 var transitionEndEvent = 'transitionend'; 8391 var animationProp = 'animation'; 8392 var animationEndEvent = 'animationend'; 8393 if (hasTransition) { 8394 /* istanbul ignore if */ 8395 if (window.ontransitionend === undefined && 8396 window.onwebkittransitionend !== undefined) { 8397 transitionProp = 'WebkitTransition'; 8398 transitionEndEvent = 'webkitTransitionEnd'; 8399 } 8400 if (window.onanimationend === undefined && 8401 window.onwebkitanimationend !== undefined) { 8402 animationProp = 'WebkitAnimation'; 8403 animationEndEvent = 'webkitAnimationEnd'; 8404 } 8405 } 8406 // binding to window is necessary to make hot reload work in IE in strict mode 8407 var raf = inBrowser 8408 ? window.requestAnimationFrame 8409 ? window.requestAnimationFrame.bind(window) 8410 : setTimeout 8411 : /* istanbul ignore next */ function (/* istanbul ignore next */ fn) { return fn(); }; 8412 function nextFrame(fn) { 8413 raf(function () { 8414 // @ts-expect-error 8415 raf(fn); 8416 }); 8417 } 8418 function addTransitionClass(el, cls) { 8419 var transitionClasses = el._transitionClasses || (el._transitionClasses = []); 8420 if (transitionClasses.indexOf(cls) < 0) { 8421 transitionClasses.push(cls); 8422 addClass(el, cls); 8423 } 8424 } 8425 function removeTransitionClass(el, cls) { 8426 if (el._transitionClasses) { 8427 remove$2(el._transitionClasses, cls); 8428 } 8429 removeClass(el, cls); 8430 } 8431 function whenTransitionEnds(el, expectedType, cb) { 8432 var _a = getTransitionInfo(el, expectedType), type = _a.type, timeout = _a.timeout, propCount = _a.propCount; 8433 if (!type) 8434 return cb(); 8435 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent; 8436 var ended = 0; 8437 var end = function () { 8438 el.removeEventListener(event, onEnd); 8439 cb(); 8440 }; 8441 var onEnd = function (e) { 8442 if (e.target === el) { 8443 if (++ended >= propCount) { 8444 end(); 8445 } 8446 } 8447 }; 8448 setTimeout(function () { 8449 if (ended < propCount) { 8450 end(); 8451 } 8452 }, timeout + 1); 8453 el.addEventListener(event, onEnd); 8454 } 8455 var transformRE = /\b(transform|all)(,|$)/; 8456 function getTransitionInfo(el, expectedType) { 8457 var styles = window.getComputedStyle(el); 8458 // JSDOM may return undefined for transition properties 8459 var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', '); 8460 var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', '); 8461 var transitionTimeout = getTimeout(transitionDelays, transitionDurations); 8462 var animationDelays = (styles[animationProp + 'Delay'] || '').split(', '); 8463 var animationDurations = (styles[animationProp + 'Duration'] || '').split(', '); 8464 var animationTimeout = getTimeout(animationDelays, animationDurations); 8465 var type; 8466 var timeout = 0; 8467 var propCount = 0; 8468 /* istanbul ignore if */ 8469 if (expectedType === TRANSITION) { 8470 if (transitionTimeout > 0) { 8471 type = TRANSITION; 8472 timeout = transitionTimeout; 8473 propCount = transitionDurations.length; 8474 } 8475 } 8476 else if (expectedType === ANIMATION) { 8477 if (animationTimeout > 0) { 8478 type = ANIMATION; 8479 timeout = animationTimeout; 8480 propCount = animationDurations.length; 8481 } 8482 } 8483 else { 8484 timeout = Math.max(transitionTimeout, animationTimeout); 8485 type = 8486 timeout > 0 8487 ? transitionTimeout > animationTimeout 8488 ? TRANSITION 8489 : ANIMATION 8490 : null; 8491 propCount = type 8492 ? type === TRANSITION 8493 ? transitionDurations.length 8494 : animationDurations.length 8495 : 0; 8496 } 8497 var hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']); 8498 return { 8499 type: type, 8500 timeout: timeout, 8501 propCount: propCount, 8502 hasTransform: hasTransform 8503 }; 8504 } 8505 function getTimeout(delays, durations) { 8506 /* istanbul ignore next */ 8507 while (delays.length < durations.length) { 8508 delays = delays.concat(delays); 8509 } 8510 return Math.max.apply(null, durations.map(function (d, i) { 8511 return toMs(d) + toMs(delays[i]); 8512 })); 8513 } 8514 // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers 8515 // in a locale-dependent way, using a comma instead of a dot. 8516 // If comma is not replaced with a dot, the input will be rounded down (i.e. acting 8517 // as a floor function) causing unexpected behaviors 8518 function toMs(s) { 8519 return Number(s.slice(0, -1).replace(',', '.')) * 1000; 8520 } 8521 8522 function enter(vnode, toggleDisplay) { 8523 var el = vnode.elm; 8524 // call leave callback now 8525 if (isDef(el._leaveCb)) { 8526 el._leaveCb.cancelled = true; 8527 el._leaveCb(); 8528 } 8529 var data = resolveTransition(vnode.data.transition); 8530 if (isUndef(data)) { 8531 return; 8532 } 8533 /* istanbul ignore if */ 8534 if (isDef(el._enterCb) || el.nodeType !== 1) { 8535 return; 8536 } 8537 var css = data.css, type = data.type, enterClass = data.enterClass, enterToClass = data.enterToClass, enterActiveClass = data.enterActiveClass, appearClass = data.appearClass, appearToClass = data.appearToClass, appearActiveClass = data.appearActiveClass, beforeEnter = data.beforeEnter, enter = data.enter, afterEnter = data.afterEnter, enterCancelled = data.enterCancelled, beforeAppear = data.beforeAppear, appear = data.appear, afterAppear = data.afterAppear, appearCancelled = data.appearCancelled, duration = data.duration; 8538 // activeInstance will always be the <transition> component managing this 8539 // transition. One edge case to check is when the <transition> is placed 8540 // as the root node of a child component. In that case we need to check 8541 // <transition>'s parent for appear check. 8542 var context = activeInstance; 8543 var transitionNode = activeInstance.$vnode; 8544 while (transitionNode && transitionNode.parent) { 8545 context = transitionNode.context; 8546 transitionNode = transitionNode.parent; 8547 } 8548 var isAppear = !context._isMounted || !vnode.isRootInsert; 8549 if (isAppear && !appear && appear !== '') { 8550 return; 8551 } 8552 var startClass = isAppear && appearClass ? appearClass : enterClass; 8553 var activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass; 8554 var toClass = isAppear && appearToClass ? appearToClass : enterToClass; 8555 var beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter; 8556 var enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter; 8557 var afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter; 8558 var enterCancelledHook = isAppear 8559 ? appearCancelled || enterCancelled 8560 : enterCancelled; 8561 var explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration); 8562 if (explicitEnterDuration != null) { 8563 checkDuration(explicitEnterDuration, 'enter', vnode); 8564 } 8565 var expectsCSS = css !== false && !isIE9; 8566 var userWantsControl = getHookArgumentsLength(enterHook); 8567 var cb = (el._enterCb = once(function () { 8568 if (expectsCSS) { 8569 removeTransitionClass(el, toClass); 8570 removeTransitionClass(el, activeClass); 8571 } 8572 // @ts-expect-error 8573 if (cb.cancelled) { 8574 if (expectsCSS) { 8575 removeTransitionClass(el, startClass); 8576 } 8577 enterCancelledHook && enterCancelledHook(el); 8578 } 8579 else { 8580 afterEnterHook && afterEnterHook(el); 8581 } 8582 el._enterCb = null; 8583 })); 8584 if (!vnode.data.show) { 8585 // remove pending leave element on enter by injecting an insert hook 8586 mergeVNodeHook(vnode, 'insert', function () { 8587 var parent = el.parentNode; 8588 var pendingNode = parent && parent._pending && parent._pending[vnode.key]; 8589 if (pendingNode && 8590 pendingNode.tag === vnode.tag && 8591 pendingNode.elm._leaveCb) { 8592 pendingNode.elm._leaveCb(); 8593 } 8594 enterHook && enterHook(el, cb); 8595 }); 8596 } 8597 // start enter transition 8598 beforeEnterHook && beforeEnterHook(el); 8599 if (expectsCSS) { 8600 addTransitionClass(el, startClass); 8601 addTransitionClass(el, activeClass); 8602 nextFrame(function () { 8603 removeTransitionClass(el, startClass); 8604 // @ts-expect-error 8605 if (!cb.cancelled) { 8606 addTransitionClass(el, toClass); 8607 if (!userWantsControl) { 8608 if (isValidDuration(explicitEnterDuration)) { 8609 setTimeout(cb, explicitEnterDuration); 8610 } 8611 else { 8612 whenTransitionEnds(el, type, cb); 8613 } 8614 } 8615 } 8616 }); 8617 } 8618 if (vnode.data.show) { 8619 toggleDisplay && toggleDisplay(); 8620 enterHook && enterHook(el, cb); 8621 } 8622 if (!expectsCSS && !userWantsControl) { 8623 cb(); 8624 } 8625 } 8626 function leave(vnode, rm) { 8627 var el = vnode.elm; 8628 // call enter callback now 8629 if (isDef(el._enterCb)) { 8630 el._enterCb.cancelled = true; 8631 el._enterCb(); 8632 } 8633 var data = resolveTransition(vnode.data.transition); 8634 if (isUndef(data) || el.nodeType !== 1) { 8635 return rm(); 8636 } 8637 /* istanbul ignore if */ 8638 if (isDef(el._leaveCb)) { 8639 return; 8640 } 8641 var css = data.css, type = data.type, leaveClass = data.leaveClass, leaveToClass = data.leaveToClass, leaveActiveClass = data.leaveActiveClass, beforeLeave = data.beforeLeave, leave = data.leave, afterLeave = data.afterLeave, leaveCancelled = data.leaveCancelled, delayLeave = data.delayLeave, duration = data.duration; 8642 var expectsCSS = css !== false && !isIE9; 8643 var userWantsControl = getHookArgumentsLength(leave); 8644 var explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration); 8645 if (isDef(explicitLeaveDuration)) { 8646 checkDuration(explicitLeaveDuration, 'leave', vnode); 8647 } 8648 var cb = (el._leaveCb = once(function () { 8649 if (el.parentNode && el.parentNode._pending) { 8650 el.parentNode._pending[vnode.key] = null; 8651 } 8652 if (expectsCSS) { 8653 removeTransitionClass(el, leaveToClass); 8654 removeTransitionClass(el, leaveActiveClass); 8655 } 8656 // @ts-expect-error 8657 if (cb.cancelled) { 8658 if (expectsCSS) { 8659 removeTransitionClass(el, leaveClass); 8660 } 8661 leaveCancelled && leaveCancelled(el); 8662 } 8663 else { 8664 rm(); 8665 afterLeave && afterLeave(el); 8666 } 8667 el._leaveCb = null; 8668 })); 8669 if (delayLeave) { 8670 delayLeave(performLeave); 8671 } 8672 else { 8673 performLeave(); 8674 } 8675 function performLeave() { 8676 // the delayed leave may have already been cancelled 8677 // @ts-expect-error 8678 if (cb.cancelled) { 8679 return; 8680 } 8681 // record leaving element 8682 if (!vnode.data.show && el.parentNode) { 8683 (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = 8684 vnode; 8685 } 8686 beforeLeave && beforeLeave(el); 8687 if (expectsCSS) { 8688 addTransitionClass(el, leaveClass); 8689 addTransitionClass(el, leaveActiveClass); 8690 nextFrame(function () { 8691 removeTransitionClass(el, leaveClass); 8692 // @ts-expect-error 8693 if (!cb.cancelled) { 8694 addTransitionClass(el, leaveToClass); 8695 if (!userWantsControl) { 8696 if (isValidDuration(explicitLeaveDuration)) { 8697 setTimeout(cb, explicitLeaveDuration); 8698 } 8699 else { 8700 whenTransitionEnds(el, type, cb); 8701 } 8702 } 8703 } 8704 }); 8705 } 8706 leave && leave(el, cb); 8707 if (!expectsCSS && !userWantsControl) { 8708 cb(); 8709 } 8710 } 8711 } 8712 // only used in dev mode 8713 function checkDuration(val, name, vnode) { 8714 if (typeof val !== 'number') { 8715 warn$2("<transition> explicit ".concat(name, " duration is not a valid number - ") + 8716 "got ".concat(JSON.stringify(val), "."), vnode.context); 8717 } 8718 else if (isNaN(val)) { 8719 warn$2("<transition> explicit ".concat(name, " duration is NaN - ") + 8720 'the duration expression might be incorrect.', vnode.context); 8721 } 8722 } 8723 function isValidDuration(val) { 8724 return typeof val === 'number' && !isNaN(val); 8725 } 8726 /** 8727 * Normalize a transition hook's argument length. The hook may be: 8728 * - a merged hook (invoker) with the original in .fns 8729 * - a wrapped component method (check ._length) 8730 * - a plain function (.length) 8731 */ 8732 function getHookArgumentsLength(fn) { 8733 if (isUndef(fn)) { 8734 return false; 8735 } 8736 // @ts-expect-error 8737 var invokerFns = fn.fns; 8738 if (isDef(invokerFns)) { 8739 // invoker 8740 return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns); 8741 } 8742 else { 8743 // @ts-expect-error 8744 return (fn._length || fn.length) > 1; 8745 } 8746 } 8747 function _enter(_, vnode) { 8748 if (vnode.data.show !== true) { 8749 enter(vnode); 8750 } 8751 } 8752 var transition = inBrowser 8753 ? { 8754 create: _enter, 8755 activate: _enter, 8756 remove: function (vnode, rm) { 8757 /* istanbul ignore else */ 8758 if (vnode.data.show !== true) { 8759 // @ts-expect-error 8760 leave(vnode, rm); 8761 } 8762 else { 8763 rm(); 8764 } 8765 } 8766 } 8767 : {}; 8768 8769 var platformModules = [attrs, klass$1, events, domProps, style$1, transition]; 8770 8771 // the directive module should be applied last, after all 8772 // built-in modules have been applied. 8773 var modules$1 = platformModules.concat(baseModules); 8774 var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules$1 }); 8775 8776 /** 8777 * Not type checking this file because flow doesn't like attaching 8778 * properties to Elements. 8779 */ 8780 /* istanbul ignore if */ 8781 if (isIE9) { 8782 // http://www.matts411.com/post/internet-explorer-9-oninput/ 8783 document.addEventListener('selectionchange', function () { 8784 var el = document.activeElement; 8785 // @ts-expect-error 8786 if (el && el.vmodel) { 8787 trigger(el, 'input'); 8788 } 8789 }); 8790 } 8791 var directive = { 8792 inserted: function (el, binding, vnode, oldVnode) { 8793 if (vnode.tag === 'select') { 8794 // #6903 8795 if (oldVnode.elm && !oldVnode.elm._vOptions) { 8796 mergeVNodeHook(vnode, 'postpatch', function () { 8797 directive.componentUpdated(el, binding, vnode); 8798 }); 8799 } 8800 else { 8801 setSelected(el, binding, vnode.context); 8802 } 8803 el._vOptions = [].map.call(el.options, getValue); 8804 } 8805 else if (vnode.tag === 'textarea' || isTextInputType(el.type)) { 8806 el._vModifiers = binding.modifiers; 8807 if (!binding.modifiers.lazy) { 8808 el.addEventListener('compositionstart', onCompositionStart); 8809 el.addEventListener('compositionend', onCompositionEnd); 8810 // Safari < 10.2 & UIWebView doesn't fire compositionend when 8811 // switching focus before confirming composition choice 8812 // this also fixes the issue where some browsers e.g. iOS Chrome 8813 // fires "change" instead of "input" on autocomplete. 8814 el.addEventListener('change', onCompositionEnd); 8815 /* istanbul ignore if */ 8816 if (isIE9) { 8817 el.vmodel = true; 8818 } 8819 } 8820 } 8821 }, 8822 componentUpdated: function (el, binding, vnode) { 8823 if (vnode.tag === 'select') { 8824 setSelected(el, binding, vnode.context); 8825 // in case the options rendered by v-for have changed, 8826 // it's possible that the value is out-of-sync with the rendered options. 8827 // detect such cases and filter out values that no longer has a matching 8828 // option in the DOM. 8829 var prevOptions_1 = el._vOptions; 8830 var curOptions_1 = (el._vOptions = [].map.call(el.options, getValue)); 8831 if (curOptions_1.some(function (o, i) { return !looseEqual(o, prevOptions_1[i]); })) { 8832 // trigger change event if 8833 // no matching option found for at least one value 8834 var needReset = el.multiple 8835 ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions_1); }) 8836 : binding.value !== binding.oldValue && 8837 hasNoMatchingOption(binding.value, curOptions_1); 8838 if (needReset) { 8839 trigger(el, 'change'); 8840 } 8841 } 8842 } 8843 } 8844 }; 8845 function setSelected(el, binding, vm) { 8846 actuallySetSelected(el, binding, vm); 8847 /* istanbul ignore if */ 8848 if (isIE || isEdge) { 8849 setTimeout(function () { 8850 actuallySetSelected(el, binding, vm); 8851 }, 0); 8852 } 8853 } 8854 function actuallySetSelected(el, binding, vm) { 8855 var value = binding.value; 8856 var isMultiple = el.multiple; 8857 if (isMultiple && !Array.isArray(value)) { 8858 warn$2("<select multiple v-model=\"".concat(binding.expression, "\"> ") + 8859 "expects an Array value for its binding, but got ".concat(Object.prototype.toString 8860 .call(value) 8861 .slice(8, -1)), vm); 8862 return; 8863 } 8864 var selected, option; 8865 for (var i = 0, l = el.options.length; i < l; i++) { 8866 option = el.options[i]; 8867 if (isMultiple) { 8868 selected = looseIndexOf(value, getValue(option)) > -1; 8869 if (option.selected !== selected) { 8870 option.selected = selected; 8871 } 8872 } 8873 else { 8874 if (looseEqual(getValue(option), value)) { 8875 if (el.selectedIndex !== i) { 8876 el.selectedIndex = i; 8877 } 8878 return; 8879 } 8880 } 8881 } 8882 if (!isMultiple) { 8883 el.selectedIndex = -1; 8884 } 8885 } 8886 function hasNoMatchingOption(value, options) { 8887 return options.every(function (o) { return !looseEqual(o, value); }); 8888 } 8889 function getValue(option) { 8890 return '_value' in option ? option._value : option.value; 8891 } 8892 function onCompositionStart(e) { 8893 e.target.composing = true; 8894 } 8895 function onCompositionEnd(e) { 8896 // prevent triggering an input event for no reason 8897 if (!e.target.composing) 8898 return; 8899 e.target.composing = false; 8900 trigger(e.target, 'input'); 8901 } 8902 function trigger(el, type) { 8903 var e = document.createEvent('HTMLEvents'); 8904 e.initEvent(type, true, true); 8905 el.dispatchEvent(e); 8906 } 8907 8908 // recursively search for possible transition defined inside the component root 8909 function locateNode(vnode) { 8910 // @ts-expect-error 8911 return vnode.componentInstance && (!vnode.data || !vnode.data.transition) 8912 ? locateNode(vnode.componentInstance._vnode) 8913 : vnode; 8914 } 8915 var show = { 8916 bind: function (el, _a, vnode) { 8917 var value = _a.value; 8918 vnode = locateNode(vnode); 8919 var transition = vnode.data && vnode.data.transition; 8920 var originalDisplay = (el.__vOriginalDisplay = 8921 el.style.display === 'none' ? '' : el.style.display); 8922 if (value && transition) { 8923 vnode.data.show = true; 8924 enter(vnode, function () { 8925 el.style.display = originalDisplay; 8926 }); 8927 } 8928 else { 8929 el.style.display = value ? originalDisplay : 'none'; 8930 } 8931 }, 8932 update: function (el, _a, vnode) { 8933 var value = _a.value, oldValue = _a.oldValue; 8934 /* istanbul ignore if */ 8935 if (!value === !oldValue) 8936 return; 8937 vnode = locateNode(vnode); 8938 var transition = vnode.data && vnode.data.transition; 8939 if (transition) { 8940 vnode.data.show = true; 8941 if (value) { 8942 enter(vnode, function () { 8943 el.style.display = el.__vOriginalDisplay; 8944 }); 8945 } 8946 else { 8947 leave(vnode, function () { 8948 el.style.display = 'none'; 8949 }); 8950 } 8951 } 8952 else { 8953 el.style.display = value ? el.__vOriginalDisplay : 'none'; 8954 } 8955 }, 8956 unbind: function (el, binding, vnode, oldVnode, isDestroy) { 8957 if (!isDestroy) { 8958 el.style.display = el.__vOriginalDisplay; 8959 } 8960 } 8961 }; 8962 8963 var platformDirectives = { 8964 model: directive, 8965 show: show 8966 }; 8967 8968 // Provides transition support for a single element/component. 8969 var transitionProps = { 8970 name: String, 8971 appear: Boolean, 8972 css: Boolean, 8973 mode: String, 8974 type: String, 8975 enterClass: String, 8976 leaveClass: String, 8977 enterToClass: String, 8978 leaveToClass: String, 8979 enterActiveClass: String, 8980 leaveActiveClass: String, 8981 appearClass: String, 8982 appearActiveClass: String, 8983 appearToClass: String, 8984 duration: [Number, String, Object] 8985 }; 8986 // in case the child is also an abstract component, e.g. <keep-alive> 8987 // we want to recursively retrieve the real component to be rendered 8988 function getRealChild(vnode) { 8989 var compOptions = vnode && vnode.componentOptions; 8990 if (compOptions && compOptions.Ctor.options.abstract) { 8991 return getRealChild(getFirstComponentChild(compOptions.children)); 8992 } 8993 else { 8994 return vnode; 8995 } 8996 } 8997 function extractTransitionData(comp) { 8998 var data = {}; 8999 var options = comp.$options; 9000 // props 9001 for (var key in options.propsData) { 9002 data[key] = comp[key]; 9003 } 9004 // events. 9005 // extract listeners and pass them directly to the transition methods 9006 var listeners = options._parentListeners; 9007 for (var key in listeners) { 9008 data[camelize(key)] = listeners[key]; 9009 } 9010 return data; 9011 } 9012 function placeholder(h, rawChild) { 9013 // @ts-expect-error 9014 if (/\d-keep-alive$/.test(rawChild.tag)) { 9015 return h('keep-alive', { 9016 props: rawChild.componentOptions.propsData 9017 }); 9018 } 9019 } 9020 function hasParentTransition(vnode) { 9021 while ((vnode = vnode.parent)) { 9022 if (vnode.data.transition) { 9023 return true; 9024 } 9025 } 9026 } 9027 function isSameChild(child, oldChild) { 9028 return oldChild.key === child.key && oldChild.tag === child.tag; 9029 } 9030 var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); }; 9031 var isVShowDirective = function (d) { return d.name === 'show'; }; 9032 var Transition = { 9033 name: 'transition', 9034 props: transitionProps, 9035 abstract: true, 9036 render: function (h) { 9037 var _this = this; 9038 var children = this.$slots.default; 9039 if (!children) { 9040 return; 9041 }
9042 // filter out text nodes (possible whitespaces) 9043 children = children.filter(isNotTextNode); 9044 /* istanbul ignore if */ 9045 if (!children.length) { 9046 return; 9047 } 9048 // warn multiple elements 9049 if (children.length > 1) { 9050 warn$2('<transition> can only be used on a single element. Use ' + 9051 '<transition-group> for lists.', this.$parent); 9052 } 9053 var mode = this.mode; 9054 // warn invalid mode 9055 if (mode && mode !== 'in-out' && mode !== 'out-in') { 9056 warn$2('invalid <transition> mode: ' + mode, this.$parent); 9057 } 9058 var rawChild = children[0]; 9059 // if this is a component root node and the component's 9060 // parent container node also has transition, skip. 9061 if (hasParentTransition(this.$vnode)) { 9062 return rawChild; 9063 } 9064 // apply transition data to child 9065 // use getRealChild() to ignore abstract components e.g. keep-alive 9066 var child = getRealChild(rawChild); 9067 /* istanbul ignore if */ 9068 if (!child) { 9069 return rawChild; 9070 } 9071 if (this._leaving) { 9072 return placeholder(h, rawChild); 9073 } 9074 // ensure a key that is unique to the vnode type and to this transition 9075 // component instance. This key will be used to remove pending leaving nodes 9076 // during entering. 9077 var id = "__transition-".concat(this._uid, "-"); 9078 child.key = 9079 child.key == null 9080 ? child.isComment 9081 ? id + 'comment' 9082 : id + child.tag 9083 : isPrimitive(child.key) 9084 ? String(child.key).indexOf(id) === 0 9085 ? child.key 9086 : id + child.key 9087 : child.key; 9088 var data = ((child.data || (child.data = {})).transition = 9089 extractTransitionData(this)); 9090 var oldRawChild = this._vnode; 9091 var oldChild = getRealChild(oldRawChild); 9092 // mark v-show 9093 // so that the transition module can hand over the control to the directive 9094 if (child.data.directives && child.data.directives.some(isVShowDirective)) { 9095 child.data.show = true; 9096 } 9097 if (oldChild && 9098 oldChild.data && 9099 !isSameChild(child, oldChild) && 9100 !isAsyncPlaceholder(oldChild) && 9101 // #6687 component root is a comment node 9102 !(oldChild.componentInstance && 9103 oldChild.componentInstance._vnode.isComment)) { 9104 // replace old child transition data with fresh one 9105 // important for dynamic transitions! 9106 var oldData = (oldChild.data.transition = extend({}, data)); 9107 // handle transition mode 9108 if (mode === 'out-in') { 9109 // return placeholder node and queue update when leave finishes 9110 this._leaving = true; 9111 mergeVNodeHook(oldData, 'afterLeave', function () { 9112 _this._leaving = false; 9113 _this.$forceUpdate(); 9114 }); 9115 return placeholder(h, rawChild); 9116 } 9117 else if (mode === 'in-out') { 9118 if (isAsyncPlaceholder(child)) { 9119 return oldRawChild; 9120 } 9121 var delayedLeave_1; 9122 var performLeave = function () { 9123 delayedLeave_1(); 9124 }; 9125 mergeVNodeHook(data, 'afterEnter', performLeave); 9126 mergeVNodeHook(data, 'enterCancelled', performLeave); 9127 mergeVNodeHook(oldData, 'delayLeave', function (leave) { 9128 delayedLeave_1 = leave; 9129 }); 9130 } 9131 } 9132 return rawChild; 9133 } 9134 }; 9135 9136 // Provides transition support for list items. 9137 var props = extend({ 9138 tag: String, 9139 moveClass: String 9140 }, transitionProps); 9141 delete props.mode; 9142 var TransitionGroup = { 9143 props: props, 9144 beforeMount: function () { 9145 var _this = this; 9146 var update = this._update; 9147 this._update = function (vnode, hydrating) { 9148 var restoreActiveInstance = setActiveInstance(_this); 9149 // force removing pass 9150 _this.__patch__(_this._vnode, _this.kept, false, // hydrating 9151 true // removeOnly (!important, avoids unnecessary moves) 9152 ); 9153 _this._vnode = _this.kept; 9154 restoreActiveInstance(); 9155 update.call(_this, vnode, hydrating); 9156 }; 9157 }, 9158 render: function (h) { 9159 var tag = this.tag || this.$vnode.data.tag || 'span'; 9160 var map = Object.create(null); 9161 var prevChildren = (this.prevChildren = this.children); 9162 var rawChildren = this.$slots.default || []; 9163 var children = (this.children = []); 9164 var transitionData = extractTransitionData(this); 9165 for (var i = 0; i < rawChildren.length; i++) { 9166 var c = rawChildren[i]; 9167 if (c.tag) { 9168 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { 9169 children.push(c); 9170 map[c.key] = c; 9171 (c.data || (c.data = {})).transition = transitionData; 9172 } 9173 else {
9174 var opts = c.componentOptions; 9175 var name_1 = opts 9176 ? getComponentName(opts.Ctor.options) || opts.tag || '' 9177 : c.tag; 9178 warn$2("<transition-group> children must be keyed: <".concat(name_1, ">")); 9179 } 9180 } 9181 } 9182 if (prevChildren) { 9183 var kept = []; 9184 var removed = []; 9185 for (var i = 0; i < prevChildren.length; i++) { 9186 var c = prevChildren[i]; 9187 c.data.transition = transitionData; 9188 // @ts-expect-error .getBoundingClientRect is not typed in Node 9189 c.data.pos = c.elm.getBoundingClientRect(); 9190 if (map[c.key]) { 9191 kept.push(c); 9192 } 9193 else { 9194 removed.push(c); 9195 } 9196 } 9197 this.kept = h(tag, null, kept); 9198 this.removed = removed; 9199 } 9200 return h(tag, null, children); 9201 }, 9202 updated: function () { 9203 var children = this.prevChildren; 9204 var moveClass = this.moveClass || (this.name || 'v') + '-move'; 9205 if (!children.length || !this.hasMove(children[0].elm, moveClass)) { 9206 return; 9207 } 9208 // we divide the work into three loops to avoid mixing DOM reads and writes 9209 // in each iteration - which helps prevent layout thrashing. 9210 children.forEach(callPendingCbs); 9211 children.forEach(recordPosition); 9212 children.forEach(applyTranslation); 9213 // force reflow to put everything in position 9214 // assign to this to avoid being removed in tree-shaking 9215 // $flow-disable-line 9216 this._reflow = document.body.offsetHeight; 9217 children.forEach(function (c) { 9218 if (c.data.moved) { 9219 var el_1 = c.elm; 9220 var s = el_1.style; 9221 addTransitionClass(el_1, moveClass); 9222 s.transform = s.WebkitTransform = s.transitionDuration = ''; 9223 el_1.addEventListener(transitionEndEvent, (el_1._moveCb = function cb(e) { 9224 if (e && e.target !== el_1) { 9225 return; 9226 } 9227 if (!e || /transform$/.test(e.propertyName)) { 9228 el_1.removeEventListener(transitionEndEvent, cb); 9229 el_1._moveCb = null; 9230 removeTransitionClass(el_1, moveClass); 9231 } 9232 })); 9233 } 9234 }); 9235 }, 9236 methods: { 9237 hasMove: function (el, moveClass) { 9238 /* istanbul ignore if */ 9239 if (!hasTransition) { 9240 return false; 9241 } 9242 /* istanbul ignore if */ 9243 if (this._hasMove) { 9244 return this._hasMove; 9245 } 9246 // Detect whether an element with the move class applied has 9247 // CSS transitions. Since the element may be inside an entering 9248 // transition at this very moment, we make a clone of it and remove 9249 // all other transition classes applied to ensure only the move class 9250 // is applied. 9251 var clone = el.cloneNode(); 9252 if (el._transitionClasses) { 9253 el._transitionClasses.forEach(function (cls) { 9254 removeClass(clone, cls); 9255 }); 9256 } 9257 addClass(clone, moveClass); 9258 clone.style.display = 'none'; 9259 this.$el.appendChild(clone); 9260 var info = getTransitionInfo(clone); 9261 this.$el.removeChild(clone); 9262 return (this._hasMove = info.hasTransform); 9263 } 9264 } 9265 }; 9266 function callPendingCbs(c) { 9267 /* istanbul ignore if */ 9268 if (c.elm._moveCb) { 9269 c.elm._moveCb(); 9270 } 9271 /* istanbul ignore if */ 9272 if (c.elm._enterCb) { 9273 c.elm._enterCb(); 9274 } 9275 } 9276 function recordPosition(c) { 9277 c.data.newPos = c.elm.getBoundingClientRect(); 9278 } 9279 function applyTranslation(c) { 9280 var oldPos = c.data.pos; 9281 var newPos = c.data.newPos; 9282 var dx = oldPos.left - newPos.left; 9283 var dy = oldPos.top - newPos.top; 9284 if (dx || dy) { 9285 c.data.moved = true; 9286 var s = c.elm.style; 9287 s.transform = s.WebkitTransform = "translate(".concat(dx, "px,").concat(dy, "px)"); 9288 s.transitionDuration = '0s'; 9289 } 9290 } 9291 9292 var platformComponents = { 9293 Transition: Transition, 9294 TransitionGroup: TransitionGroup 9295 }; 9296 9297 // install platform specific utils 9298 Vue.config.mustUseProp = mustUseProp; 9299 Vue.config.isReservedTag = isReservedTag; 9300 Vue.config.isReservedAttr = isReservedAttr; 9301 Vue.config.getTagNamespace = getTagNamespace; 9302 Vue.config.isUnknownElement = isUnknownElement; 9303 // install platform runtime directives & components 9304 extend(Vue.options.directives, platformDirectives); 9305 extend(Vue.options.components, platformComponents); 9306 // install platform patch function 9307 Vue.prototype.__patch__ = inBrowser ? patch : noop; 9308 // public mount method 9309 Vue.prototype.$mount = function (el, hydrating) { 9310 el = el && inBrowser ? query(el) : undefined; 9311 return mountComponent(this, el, hydrating); 9312 }; 9313 // devtools global hook 9314 /* istanbul ignore next */ 9315 if (inBrowser) { 9316 setTimeout(function () { 9317 if (config.devtools) { 9318 if (devtools) { 9319 devtools.emit('init', Vue); 9320 } 9321 else { 9322 // @ts-expect-error 9323 console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' + 9324 'https://github.com/vuejs/vue-devtools'); 9325 } 9326 } 9327 if (config.productionTip !== false && 9328 typeof console !== 'undefined') { 9329 // @ts-expect-error 9330 console[console.info ? 'info' : 'log']("You are running Vue in development mode.\n" + 9331 "Make sure to turn on production mode when deploying for production.\n" + 9332 "See more tips at https://vuejs.org/guide/deployment.html"); 9333 } 9334 }, 0); 9335 } 9336 9337 var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g; 9338 var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; 9339 var buildRegex = cached(function (delimiters) { 9340 var open = delimiters[0].replace(regexEscapeRE, '\\$&'); 9341 var close = delimiters[1].replace(regexEscapeRE, '\\$&'); 9342 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g'); 9343 }); 9344 function parseText(text, delimiters) { 9345 //@ts-expect-error 9346 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; 9347 if (!tagRE.test(text)) { 9348 return; 9349 } 9350 var tokens = []; 9351 var rawTokens = []; 9352 var lastIndex = (tagRE.lastIndex = 0); 9353 var match, index, tokenValue; 9354 while ((match = tagRE.exec(text))) { 9355 index = match.index; 9356 // push text token 9357 if (index > lastIndex) { 9358 rawTokens.push((tokenValue = text.slice(lastIndex, index))); 9359 tokens.push(JSON.stringify(tokenValue)); 9360 } 9361 // tag token 9362 var exp = parseFilters(match[1].trim()); 9363 tokens.push("_s(".concat(exp, ")")); 9364 rawTokens.push({ '@binding': exp }); 9365 lastIndex = index + match[0].length; 9366 } 9367 if (lastIndex < text.length) { 9368 rawTokens.push((tokenValue = text.slice(lastIndex))); 9369 tokens.push(JSON.stringify(tokenValue)); 9370 } 9371 return { 9372 expression: tokens.join('+'), 9373 tokens: rawTokens 9374 }; 9375 } 9376 9377 function transformNode$1(el, options) { 9378 var warn = options.warn || baseWarn; 9379 var staticClass = getAndRemoveAttr(el, 'class'); 9380 if (staticClass) { 9381 var res = parseText(staticClass, options.delimiters); 9382 if (res) { 9383 warn("class=\"".concat(staticClass, "\": ") + 9384 'Interpolation inside attributes has been removed. ' + 9385 'Use v-bind or the colon shorthand instead. For example, ' + 9386 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']); 9387 } 9388 } 9389 if (staticClass) { 9390 el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim()); 9391 } 9392 var classBinding = getBindingAttr(el, 'class', false /* getStatic */); 9393 if (classBinding) { 9394 el.classBinding = classBinding; 9395 } 9396 } 9397 function genData$2(el) { 9398 var data = ''; 9399 if (el.staticClass) { 9400 data += "staticClass:".concat(el.staticClass, ","); 9401 } 9402 if (el.classBinding) { 9403 data += "class:".concat(el.classBinding, ","); 9404 } 9405 return data; 9406 } 9407 var klass = { 9408 staticKeys: ['staticClass'], 9409 transformNode: transformNode$1, 9410 genData: genData$2 9411 }; 9412 9413 function transformNode(el, options) { 9414 var warn = options.warn || baseWarn; 9415 var staticStyle = getAndRemoveAttr(el, 'style'); 9416 if (staticStyle) { 9417 /* istanbul ignore if */ 9418 { 9419 var res = parseText(staticStyle, options.delimiters); 9420 if (res) { 9421 warn("style=\"".concat(staticStyle, "\": ") + 9422 'Interpolation inside attributes has been removed. ' + 9423 'Use v-bind or the colon shorthand instead. For example, ' + 9424 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']); 9425 } 9426 } 9427 el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); 9428 } 9429 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); 9430 if (styleBinding) { 9431 el.styleBinding = styleBinding; 9432 } 9433 } 9434 function genData$1(el) { 9435 var data = ''; 9436 if (el.staticStyle) { 9437 data += "staticStyle:".concat(el.staticStyle, ","); 9438 } 9439 if (el.styleBinding) { 9440 data += "style:(".concat(el.styleBinding, "),"); 9441 } 9442 return data; 9443 } 9444 var style = { 9445 staticKeys: ['staticStyle'], 9446 transformNode: transformNode, 9447 genData: genData$1 9448 }; 9449 9450 var decoder; 9451 var he = { 9452 decode: function (html) { 9453 decoder = decoder || document.createElement('div'); 9454 decoder.innerHTML = html; 9455 return decoder.textContent; 9456 } 9457 }; 9458 9459 var isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 9460 'link,meta,param,source,track,wbr'); 9461 // Elements that you can, intentionally, leave open 9462 // (and which close themselves)
9463 var canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'); 9464 // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 9465 // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content 9466 var isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + 9467 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + 9468 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + 9469 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + 9470 'title,tr,track'); 9471 9472 /** 9473 * Not type-checking this file because it's mostly vendor code. 9474 */ 9475 // Regular Expressions for parsing tags and attributes 9476 var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; 9477 var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; 9478 var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z".concat(unicodeRegExp.source, "]*"); 9479 var qnameCapture = "((?:".concat(ncname, "\\:)?").concat(ncname, ")"); 9480 var startTagOpen = new RegExp("^<".concat(qnameCapture)); 9481 var startTagClose = /^\s*(\/?)>/; 9482 var endTag = new RegExp("^<\\/".concat(qnameCapture, "[^>]*>")); 9483 var doctype = /^<!DOCTYPE [^>]+>/i; 9484 // #7298: escape - to avoid being passed as HTML comment when inlined in page 9485 var comment = /^<!\--/; 9486 var conditionalComment = /^<!\[/; 9487 // Special Elements (can contain anything) 9488 var isPlainTextElement = makeMap('script,style,textarea', true); 9489 var reCache = {}; 9490 var decodingMap = { 9491 '<': '<', 9492 '>': '>', 9493 '"': '"', 9494 '&': '&', 9495 ' ': '\n', 9496 '	': '\t', 9497 ''': "'" 9498 }; 9499 var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g; 9500 var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g; 9501 // #5992 9502 var isIgnoreNewlineTag = makeMap('pre,textarea', true); 9503 var shouldIgnoreFirstNewline = function (tag, html) { 9504 return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; 9505 }; 9506 function decodeAttr(value, shouldDecodeNewlines) { 9507 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; 9508 return value.replace(re, function (match) { return decodingMap[match]; }); 9509 } 9510 function parseHTML(html, options) { 9511 var stack = []; 9512 var expectHTML = options.expectHTML; 9513 var isUnaryTag = options.isUnaryTag || no; 9514 var canBeLeftOpenTag = options.canBeLeftOpenTag || no; 9515 var index = 0; 9516 var last, lastTag; 9517 var _loop_1 = function () { 9518 last = html; 9519 // Make sure we're not in a plaintext content element like script/style 9520 if (!lastTag || !isPlainTextElement(lastTag)) { 9521 var textEnd = html.indexOf('<'); 9522 if (textEnd === 0) { 9523 // Comment: 9524 if (comment.test(html)) { 9525 var commentEnd = html.indexOf('-->'); 9526 if (commentEnd >= 0) { 9527 if (options.shouldKeepComment && options.comment) { 9528 options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3); 9529 } 9530 advance(commentEnd + 3); 9531 return "continue"; 9532 } 9533 } 9534 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment 9535 if (conditionalComment.test(html)) { 9536 var conditionalEnd = html.indexOf(']>'); 9537 if (conditionalEnd >= 0) { 9538 advance(conditionalEnd + 2); 9539 return "continue"; 9540 } 9541 } 9542 // Doctype: 9543 var doctypeMatch = html.match(doctype); 9544 if (doctypeMatch) { 9545 advance(doctypeMatch[0].length); 9546 return "continue"; 9547 } 9548 // End tag: 9549 var endTagMatch = html.match(endTag); 9550 if (endTagMatch) { 9551 var curIndex = index; 9552 advance(endTagMatch[0].length); 9553 parseEndTag(endTagMatch[1], curIndex, index); 9554 return "continue";
9555 } 9556 // Start tag: 9557 var startTagMatch = parseStartTag(); 9558 if (startTagMatch) { 9559 handleStartTag(startTagMatch); 9560 if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) { 9561 advance(1); 9562 } 9563 return "continue"; 9564 } 9565 } 9566 var text = void 0, rest = void 0, next = void 0; 9567 if (textEnd >= 0) { 9568 rest = html.slice(textEnd); 9569 while (!endTag.test(rest) && 9570 !startTagOpen.test(rest) && 9571 !comment.test(rest) && 9572 !conditionalComment.test(rest)) { 9573 // < in plain text, be forgiving and treat it as text 9574 next = rest.indexOf('<', 1); 9575 if (next < 0) 9576 break; 9577 textEnd += next; 9578 rest = html.slice(textEnd); 9579 } 9580 text = html.substring(0, textEnd); 9581 } 9582 if (textEnd < 0) { 9583 text = html; 9584 } 9585 if (text) { 9586 advance(text.length); 9587 } 9588 if (options.chars && text) { 9589 options.chars(text, index - text.length, index); 9590 } 9591 } 9592 else { 9593 var endTagLength_1 = 0; 9594 var stackedTag_1 = lastTag.toLowerCase(); 9595 var reStackedTag = reCache[stackedTag_1] || 9596 (reCache[stackedTag_1] = new RegExp('([\\s\\S]*?)(</' + stackedTag_1 + '[^>]*>)', 'i')); 9597 var rest = html.replace(reStackedTag, function (all, text, endTag) { 9598 endTagLength_1 = endTag.length; 9599 if (!isPlainTextElement(stackedTag_1) && stackedTag_1 !== 'noscript') { 9600 text = text 9601 .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298 9602 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); 9603 } 9604 if (shouldIgnoreFirstNewline(stackedTag_1, text)) { 9605 text = text.slice(1); 9606 } 9607 if (options.chars) { 9608 options.chars(text); 9609 } 9610 return ''; 9611 }); 9612 index += html.length - rest.length; 9613 html = rest; 9614 parseEndTag(stackedTag_1, index - endTagLength_1, index); 9615 } 9616 if (html === last) { 9617 options.chars && options.chars(html); 9618 if (!stack.length && options.warn) { 9619 options.warn("Mal-formatted tag at end of template: \"".concat(html, "\""), { 9620 start: index + html.length 9621 }); 9622 } 9623 return "break"; 9624 } 9625 }; 9626 while (html) { 9627 var state_1 = _loop_1(); 9628 if (state_1 === "break") 9629 break; 9630 } 9631 // Clean up any remaining tags 9632 parseEndTag(); 9633 function advance(n) { 9634 index += n; 9635 html = html.substring(n); 9636 } 9637 function parseStartTag() { 9638 var start = html.match(startTagOpen); 9639 if (start) { 9640 var match = { 9641 tagName: start[1], 9642 attrs: [], 9643 start: index 9644 }; 9645 advance(start[0].length); 9646 var end = void 0, attr = void 0; 9647 while (!(end = html.match(startTagClose)) && 9648 (attr = html.match(dynamicArgAttribute) || html.match(attribute))) { 9649 attr.start = index; 9650 advance(attr[0].length); 9651 attr.end = index; 9652 match.attrs.push(attr); 9653 } 9654 if (end) { 9655 match.unarySlash = end[1]; 9656 advance(end[0].length); 9657 match.end = index; 9658 return match; 9659 } 9660 } 9661 } 9662 function handleStartTag(match) { 9663 var tagName = match.tagName; 9664 var unarySlash = match.unarySlash; 9665 if (expectHTML) { 9666 if (lastTag === 'p' && isNonPhrasingTag(tagName)) { 9667 parseEndTag(lastTag); 9668 } 9669 if (canBeLeftOpenTag(tagName) && lastTag === tagName) { 9670 parseEndTag(tagName); 9671 } 9672 } 9673 var unary = isUnaryTag(tagName) || !!unarySlash; 9674 var l = match.attrs.length; 9675 var attrs = new Array(l); 9676 for (var i = 0; i < l; i++) { 9677 var args = match.attrs[i]; 9678 var value = args[3] || args[4] || args[5] || ''; 9679 var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href' 9680 ? options.shouldDecodeNewlinesForHref 9681 : options.shouldDecodeNewlines; 9682 attrs[i] = { 9683 name: args[1], 9684 value: decodeAttr(value, shouldDecodeNewlines) 9685 }; 9686 if (options.outputSourceRange) { 9687 attrs[i].start = args.start + args[0].match(/^\s*/).length; 9688 attrs[i].end = args.end; 9689 } 9690 } 9691 if (!unary) { 9692 stack.push({ 9693 tag: tagName, 9694 lowerCasedTag: tagName.toLowerCase(), 9695 attrs: attrs, 9696 start: match.start, 9697 end: match.end 9698 }); 9699 lastTag = tagName; 9700 } 9701 if (options.start) { 9702 options.start(tagName, attrs, unary, match.start, match.end); 9703 } 9704 } 9705 function parseEndTag(tagName, start, end) { 9706 var pos, lowerCasedTagName; 9707 if (start == null) 9708 start = index; 9709 if (end == null) 9710 end = index; 9711 // Find the closest opened tag of the same type 9712 if (tagName) { 9713 lowerCasedTagName = tagName.toLowerCase(); 9714 for (pos = stack.length - 1; pos >= 0; pos--) { 9715 if (stack[pos].lowerCasedTag === lowerCasedTagName) { 9716 break; 9717 } 9718 } 9719 } 9720 else { 9721 // If no tag name is provided, clean shop 9722 pos = 0; 9723 } 9724 if (pos >= 0) { 9725 // Close all the open elements, up the stack 9726 for (var i = stack.length - 1; i >= pos; i--) { 9727 if ((i > pos || !tagName) && options.warn) { 9728 options.warn("tag <".concat(stack[i].tag, "> has no matching end tag."), { 9729 start: stack[i].start, 9730 end: stack[i].end 9731 }); 9732 } 9733 if (options.end) { 9734 options.end(stack[i].tag, start, end); 9735 } 9736 } 9737 // Remove the open elements from the stack 9738 stack.length = pos; 9739 lastTag = pos && stack[pos - 1].tag; 9740 } 9741 else if (lowerCasedTagName === 'br') { 9742 if (options.start) { 9743 options.start(tagName, [], true, start, end); 9744 } 9745 } 9746 else if (lowerCasedTagName === 'p') { 9747 if (options.start) { 9748 options.start(tagName, [], false, start, end); 9749 } 9750 if (options.end) { 9751 options.end(tagName, start, end); 9752 } 9753 } 9754 } 9755 } 9756 9757 var onRE = /^@|^v-on:/; 9758 var dirRE = /^v-|^@|^:|^#/; 9759 var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; 9760 var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; 9761 var stripParensRE = /^\(|\)$/g; 9762 var dynamicArgRE = /^\[.*\]$/; 9763 var argRE = /:(.*)$/; 9764 var bindRE = /^:|^\.|^v-bind:/; 9765 var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g; 9766 var slotRE = /^v-slot(:|$)|^#/; 9767 var lineBreakRE = /[\r\n]/; 9768 var whitespaceRE = /[ \f\t\r\n]+/g; 9769 var invalidAttributeRE = /[\s"'<>\/=]/;
9770 var decodeHTMLCached = cached(he.decode); 9771 var emptySlotScopeToken = "_empty_"; 9772 // configurable state 9773 var warn; 9774 var delimiters; 9775 var transforms; 9776 var preTransforms; 9777 var postTransforms; 9778 var platformIsPreTag; 9779 var platformMustUseProp; 9780 var platformGetTagNamespace; 9781 var maybeComponent; 9782 function createASTElement(tag, attrs, parent) { 9783 return { 9784 type: 1, 9785 tag: tag, 9786 attrsList: attrs, 9787 attrsMap: makeAttrsMap(attrs), 9788 rawAttrsMap: {}, 9789 parent: parent, 9790 children: [] 9791 }; 9792 } 9793 /** 9794 * Convert HTML string to AST. 9795 */ 9796 function parse(template, options) { 9797 warn = options.warn || baseWarn; 9798 platformIsPreTag = options.isPreTag || no; 9799 platformMustUseProp = options.mustUseProp || no; 9800 platformGetTagNamespace = options.getTagNamespace || no; 9801 var isReservedTag = options.isReservedTag || no; 9802 maybeComponent = function (el) { 9803 return !!(el.component || 9804 el.attrsMap[':is'] || 9805 el.attrsMap['v-bind:is'] || 9806 !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag))); 9807 }; 9808 transforms = pluckModuleFunction(options.modules, 'transformNode'); 9809 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); 9810 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); 9811 delimiters = options.delimiters; 9812 var stack = []; 9813 var preserveWhitespace = options.preserveWhitespace !== false; 9814 var whitespaceOption = options.whitespace; 9815 var root; 9816 var currentParent; 9817 var inVPre = false; 9818 var inPre = false; 9819 var warned = false; 9820 function warnOnce(msg, range) { 9821 if (!warned) { 9822 warned = true; 9823 warn(msg, range); 9824 } 9825 } 9826 function closeElement(element) { 9827 trimEndingWhitespace(element); 9828 if (!inVPre && !element.processed) { 9829 element = processElement(element, options); 9830 } 9831 // tree management 9832 if (!stack.length && element !== root) { 9833 // allow root elements with v-if, v-else-if and v-else 9834 if (root.if && (element.elseif || element.else)) { 9835 { 9836 checkRootConstraints(element); 9837 } 9838 addIfCondition(root, { 9839 exp: element.elseif, 9840 block: element 9841 }); 9842 } 9843 else { 9844 warnOnce("Component template should contain exactly one root element. " + 9845 "If you are using v-if on multiple elements, " + 9846 "use v-else-if to chain them instead.", { start: element.start }); 9847 } 9848 } 9849 if (currentParent && !element.forbidden) { 9850 if (element.elseif || element.else) { 9851 processIfConditions(element, currentParent); 9852 } 9853 else { 9854 if (element.slotScope) { 9855 // scoped slot 9856 // keep it in the children list so that v-else(-if) conditions can 9857 // find it as the prev node. 9858 var name_1 = element.slotTarget || '"default"'; 9859 (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name_1] = element; 9860 } 9861 currentParent.children.push(element); 9862 element.parent = currentParent; 9863 } 9864 } 9865 // final children cleanup 9866 // filter out scoped slots 9867 element.children = element.children.filter(function (c) { return !c.slotScope; }); 9868 // remove trailing whitespace node again 9869 trimEndingWhitespace(element); 9870 // check pre state 9871 if (element.pre) { 9872 inVPre = false; 9873 } 9874 if (platformIsPreTag(element.tag)) { 9875 inPre = false; 9876 } 9877 // apply post-transforms 9878 for (var i = 0; i < postTransforms.length; i++) { 9879 postTransforms[i](element, options); 9880 } 9881 } 9882 function trimEndingWhitespace(el) { 9883 // remove trailing whitespace node 9884 if (!inPre) { 9885 var lastNode = void 0; 9886 while ((lastNode = el.children[el.children.length - 1]) && 9887 lastNode.type === 3 && 9888 lastNode.text === ' ') { 9889 el.children.pop(); 9890 } 9891 } 9892 } 9893 function checkRootConstraints(el) { 9894 if (el.tag === 'slot' || el.tag === 'template') { 9895 warnOnce("Cannot use <".concat(el.tag, "> as component root element because it may ") + 9896 'contain multiple nodes.', { start: el.start }); 9897 } 9898 if (el.attrsMap.hasOwnProperty('v-for')) { 9899 warnOnce('Cannot use v-for on stateful component root element because ' + 9900 'it renders multiple elements.', el.rawAttrsMap['v-for']); 9901 } 9902 } 9903 parseHTML(template, { 9904 warn: warn, 9905 expectHTML: options.expectHTML, 9906 isUnaryTag: options.isUnaryTag, 9907 canBeLeftOpenTag: options.canBeLeftOpenTag, 9908 shouldDecodeNewlines: options.shouldDecodeNewlines, 9909 shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref, 9910 shouldKeepComment: options.comments, 9911 outputSourceRange: options.outputSourceRange, 9912 start: function (tag, attrs, unary, start, end) { 9913 // check namespace. 9914 // inherit parent ns if there is one 9915 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag); 9916 // handle IE svg bug 9917 /* istanbul ignore if */ 9918 if (isIE && ns === 'svg') { 9919 attrs = guardIESVGBug(attrs); 9920 } 9921 var element = createASTElement(tag, attrs, currentParent); 9922 if (ns) { 9923 element.ns = ns; 9924 } 9925 { 9926 if (options.outputSourceRange) { 9927 element.start = start; 9928 element.end = end; 9929 element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) { 9930 cumulated[attr.name] = attr; 9931 return cumulated; 9932 }, {}); 9933 }
9934 attrs.forEach(function (attr) { 9935 if (invalidAttributeRE.test(attr.name)) { 9936 warn("Invalid dynamic argument expression: attribute names cannot contain " + 9937 "spaces, quotes, <, >, / or =.", options.outputSourceRange 9938 ? { 9939 start: attr.start + attr.name.indexOf("["), 9940 end: attr.start + attr.name.length 9941 } 9942 : undefined); 9943 } 9944 }); 9945 } 9946 if (isForbiddenTag(element) && !isServerRendering()) { 9947 element.forbidden = true; 9948 warn('Templates should only be responsible for mapping the state to the ' + 9949 'UI. Avoid placing tags with side-effects in your templates, such as ' + 9950 "<".concat(tag, ">") + 9951 ', as they will not be parsed.', { start: element.start }); 9952 } 9953 // apply pre-transforms 9954 for (var i = 0; i < preTransforms.length; i++) { 9955 element = preTransforms[i](element, options) || element; 9956 } 9957 if (!inVPre) { 9958 processPre(element); 9959 if (element.pre) { 9960 inVPre = true; 9961 } 9962 } 9963 if (platformIsPreTag(element.tag)) { 9964 inPre = true; 9965 } 9966 if (inVPre) { 9967 processRawAttrs(element); 9968 } 9969 else if (!element.processed) { 9970 // structural directives 9971 processFor(element); 9972 processIf(element); 9973 processOnce(element); 9974 } 9975 if (!root) { 9976 root = element; 9977 { 9978 checkRootConstraints(root); 9979 } 9980 } 9981 if (!unary) { 9982 currentParent = element; 9983 stack.push(element); 9984 } 9985 else { 9986 closeElement(element); 9987 } 9988 }, 9989 end: function (tag, start, end) { 9990 var element = stack[stack.length - 1]; 9991 // pop stack 9992 stack.length -= 1; 9993 currentParent = stack[stack.length - 1]; 9994 if (options.outputSourceRange) { 9995 element.end = end; 9996 } 9997 closeElement(element); 9998 }, 9999 chars: function (text, start, end) { 10000 if (!currentParent) { 10001 { 10002 if (text === template) { 10003 warnOnce('Component template requires a root element, rather than just text.', { start: start }); 10004 } 10005 else if ((text = text.trim())) { 10006 warnOnce("text \"".concat(text, "\" outside root element will be ignored."), { 10007 start: start 10008 }); 10009 } 10010 } 10011 return; 10012 } 10013 // IE textarea placeholder bug 10014 /* istanbul ignore if */ 10015 if (isIE && 10016 currentParent.tag === 'textarea' && 10017 currentParent.attrsMap.placeholder === text) { 10018 return; 10019 } 10020 var children = currentParent.children; 10021 if (inPre || text.trim()) { 10022 text = isTextTag(currentParent) 10023 ? text 10024 : decodeHTMLCached(text); 10025 } 10026 else if (!children.length) { 10027 // remove the whitespace-only node right after an opening tag 10028 text = ''; 10029 } 10030 else if (whitespaceOption) { 10031 if (whitespaceOption === 'condense') { 10032 // in condense mode, remove the whitespace node if it contains 10033 // line break, otherwise condense to a single space 10034 text = lineBreakRE.test(text) ? '' : ' '; 10035 } 10036 else { 10037 text = ' '; 10038 } 10039 } 10040 else { 10041 text = preserveWhitespace ? ' ' : ''; 10042 } 10043 if (text) { 10044 if (!inPre && whitespaceOption === 'condense') {
10045 // condense consecutive whitespaces into single space 10046 text = text.replace(whitespaceRE, ' '); 10047 } 10048 var res = void 0; 10049 var child = void 0; 10050 if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) { 10051 child = { 10052 type: 2, 10053 expression: res.expression, 10054 tokens: res.tokens, 10055 text: text 10056 }; 10057 } 10058 else if (text !== ' ' || 10059 !children.length || 10060 children[children.length - 1].text !== ' ') { 10061 child = { 10062 type: 3, 10063 text: text 10064 }; 10065 } 10066 if (child) { 10067 if (options.outputSourceRange) { 10068 child.start = start; 10069 child.end = end; 10070 } 10071 children.push(child); 10072 } 10073 } 10074 }, 10075 comment: function (text, start, end) { 10076 // adding anything as a sibling to the root node is forbidden 10077 // comments should still be allowed, but ignored 10078 if (currentParent) { 10079 var child = { 10080 type: 3, 10081 text: text, 10082 isComment: true 10083 }; 10084 if (options.outputSourceRange) { 10085 child.start = start; 10086 child.end = end; 10087 } 10088 currentParent.children.push(child); 10089 } 10090 } 10091 }); 10092 return root; 10093 } 10094 function processPre(el) { 10095 if (getAndRemoveAttr(el, 'v-pre') != null) { 10096 el.pre = true; 10097 } 10098 } 10099 function processRawAttrs(el) { 10100 var list = el.attrsList; 10101 var len = list.length; 10102 if (len) { 10103 var attrs = (el.attrs = new Array(len)); 10104 for (var i = 0; i < len; i++) { 10105 attrs[i] = { 10106 name: list[i].name, 10107 value: JSON.stringify(list[i].value) 10108 }; 10109 if (list[i].start != null) { 10110 attrs[i].start = list[i].start; 10111 attrs[i].end = list[i].end; 10112 } 10113 } 10114 } 10115 else if (!el.pre) { 10116 // non root node in pre blocks with no attributes 10117 el.plain = true; 10118 } 10119 } 10120 function processElement(element, options) { 10121 processKey(element); 10122 // determine whether this is a plain element after 10123 // removing structural attributes 10124 element.plain = 10125 !element.key && !element.scopedSlots && !element.attrsList.length; 10126 processRef(element); 10127 processSlotContent(element); 10128 processSlotOutlet(element); 10129 processComponent(element); 10130 for (var i = 0; i < transforms.length; i++) { 10131 element = transforms[i](element, options) || element; 10132 } 10133 processAttrs(element); 10134 return element; 10135 } 10136 function processKey(el) { 10137 var exp = getBindingAttr(el, 'key'); 10138 if (exp) { 10139 { 10140 if (el.tag === 'template') { 10141 warn("<template> cannot be keyed. Place the key on real elements instead.", getRawBindingAttr(el, 'key')); 10142 } 10143 if (el.for) { 10144 var iterator = el.iterator2 || el.iterator1; 10145 var parent_1 = el.parent; 10146 if (iterator && 10147 iterator === exp && 10148 parent_1 && 10149 parent_1.tag === 'transition-group') { 10150 warn("Do not use v-for index as key on <transition-group> children, " + 10151 "this is the same as not using keys.", getRawBindingAttr(el, 'key'), true /* tip */); 10152 } 10153 } 10154 } 10155 el.key = exp; 10156 } 10157 } 10158 function processRef(el) { 10159 var ref = getBindingAttr(el, 'ref'); 10160 if (ref) { 10161 el.ref = ref; 10162 el.refInFor = checkInFor(el); 10163 } 10164 }
10165 function processFor(el) { 10166 var exp; 10167 if ((exp = getAndRemoveAttr(el, 'v-for'))) { 10168 var res = parseFor(exp); 10169 if (res) { 10170 extend(el, res); 10171 } 10172 else { 10173 warn("Invalid v-for expression: ".concat(exp), el.rawAttrsMap['v-for']); 10174 } 10175 } 10176 } 10177 function parseFor(exp) { 10178 var inMatch = exp.match(forAliasRE); 10179 if (!inMatch) 10180 return; 10181 var res = {}; 10182 res.for = inMatch[2].trim(); 10183 var alias = inMatch[1].trim().replace(stripParensRE, ''); 10184 var iteratorMatch = alias.match(forIteratorRE); 10185 if (iteratorMatch) { 10186 res.alias = alias.replace(forIteratorRE, '').trim(); 10187 res.iterator1 = iteratorMatch[1].trim(); 10188 if (iteratorMatch[2]) { 10189 res.iterator2 = iteratorMatch[2].trim(); 10190 } 10191 } 10192 else { 10193 res.alias = alias; 10194 } 10195 return res; 10196 } 10197 function processIf(el) { 10198 var exp = getAndRemoveAttr(el, 'v-if'); 10199 if (exp) { 10200 el.if = exp; 10201 addIfCondition(el, { 10202 exp: exp, 10203 block: el 10204 }); 10205 } 10206 else { 10207 if (getAndRemoveAttr(el, 'v-else') != null) { 10208 el.else = true; 10209 } 10210 var elseif = getAndRemoveAttr(el, 'v-else-if'); 10211 if (elseif) { 10212 el.elseif = elseif; 10213 } 10214 } 10215 } 10216 function processIfConditions(el, parent) { 10217 var prev = findPrevElement(parent.children); 10218 if (prev && prev.if) { 10219 addIfCondition(prev, { 10220 exp: el.elseif, 10221 block: el 10222 }); 10223 } 10224 else { 10225 warn("v-".concat(el.elseif ? 'else-if="' + el.elseif + '"' : 'else', " ") + 10226 "used on element <".concat(el.tag, "> without corresponding v-if."), el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']); 10227 } 10228 } 10229 function findPrevElement(children) { 10230 var i = children.length; 10231 while (i--) { 10232 if (children[i].type === 1) { 10233 return children[i]; 10234 } 10235 else { 10236 if (children[i].text !== ' ') { 10237 warn("text \"".concat(children[i].text.trim(), "\" between v-if and v-else(-if) ") + 10238 "will be ignored.", children[i]); 10239 } 10240 children.pop(); 10241 } 10242 } 10243 } 10244 function addIfCondition(el, condition) { 10245 if (!el.ifConditions) { 10246 el.ifConditions = []; 10247 } 10248 el.ifConditions.push(condition); 10249 } 10250 function processOnce(el) { 10251 var once = getAndRemoveAttr(el, 'v-once'); 10252 if (once != null) { 10253 el.once = true; 10254 } 10255 } 10256 // handle content being passed to a component as slot, 10257 // e.g. <template slot="xxx">, <div slot-scope="xxx"> 10258 function processSlotContent(el) { 10259 var slotScope; 10260 if (el.tag === 'template') { 10261 slotScope = getAndRemoveAttr(el, 'scope'); 10262 /* istanbul ignore if */ 10263 if (slotScope) { 10264 warn("the \"scope\" attribute for scoped slots have been deprecated and " + 10265 "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " + 10266 "can also be used on plain elements in addition to <template> to " + 10267 "denote scoped slots.", el.rawAttrsMap['scope'], true); 10268 } 10269 el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope'); 10270 } 10271 else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) { 10272 /* istanbul ignore if */ 10273 if (el.attrsMap['v-for']) { 10274 warn("Ambiguous combined usage of slot-scope and v-for on <".concat(el.tag, "> ") + 10275 "(v-for takes higher priority). Use a wrapper <template> for the " + 10276 "scoped slot to make it clearer.", el.rawAttrsMap['slot-scope'], true); 10277 } 10278 el.slotScope = slotScope; 10279 } 10280 // slot="xxx" 10281 var slotTarget = getBindingAttr(el, 'slot'); 10282 if (slotTarget) { 10283 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; 10284 el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']); 10285 // preserve slot as an attribute for native shadow DOM compat 10286 // only for non-scoped slots. 10287 if (el.tag !== 'template' && !el.slotScope) { 10288 addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot')); 10289 } 10290 } 10291 // 2.6 v-slot syntax 10292 { 10293 if (el.tag === 'template') { 10294 // v-slot on <template> 10295 var slotBinding = getAndRemoveAttrByRegex(el, slotRE); 10296 if (slotBinding) { 10297 { 10298 if (el.slotTarget || el.slotScope) { 10299 warn("Unexpected mixed usage of different slot syntaxes.", el); 10300 } 10301 if (el.parent && !maybeComponent(el.parent)) { 10302 warn("<template v-slot> can only appear at the root level inside " + 10303 "the receiving component", el); 10304 } 10305 } 10306 var _a = getSlotName(slotBinding), name_2 = _a.name, dynamic = _a.dynamic; 10307 el.slotTarget = name_2; 10308 el.slotTargetDynamic = dynamic; 10309 el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf 10310 } 10311 } 10312 else { 10313 // v-slot on component, denotes default slot 10314 var slotBinding = getAndRemoveAttrByRegex(el, slotRE); 10315 if (slotBinding) { 10316 { 10317 if (!maybeComponent(el)) { 10318 warn("v-slot can only be used on components or <template>.", slotBinding); 10319 } 10320 if (el.slotScope || el.slotTarget) { 10321 warn("Unexpected mixed usage of different slot syntaxes.", el); 10322 } 10323 if (el.scopedSlots) { 10324 warn("To avoid scope ambiguity, the default slot should also use " + 10325 "<template> syntax when there are other named slots.", slotBinding); 10326 } 10327 } 10328 // add the component's children to its default slot 10329 var slots = el.scopedSlots || (el.scopedSlots = {}); 10330 var _b = getSlotName(slotBinding), name_3 = _b.name, dynamic = _b.dynamic; 10331 var slotContainer_1 = (slots[name_3] = createASTElement('template', [], el));
10332 slotContainer_1.slotTarget = name_3; 10333 slotContainer_1.slotTargetDynamic = dynamic; 10334 slotContainer_1.children = el.children.filter(function (c) { 10335 if (!c.slotScope) { 10336 c.parent = slotContainer_1; 10337 return true; 10338 } 10339 }); 10340 slotContainer_1.slotScope = slotBinding.value || emptySlotScopeToken; 10341 // remove children as they are returned from scopedSlots now 10342 el.children = []; 10343 // mark el non-plain so data gets generated 10344 el.plain = false; 10345 } 10346 } 10347 } 10348 } 10349 function getSlotName(binding) { 10350 var name = binding.name.replace(slotRE, ''); 10351 if (!name) { 10352 if (binding.name[0] !== '#') { 10353 name = 'default'; 10354 } 10355 else { 10356 warn("v-slot shorthand syntax requires a slot name.", binding); 10357 } 10358 } 10359 return dynamicArgRE.test(name) 10360 ? // dynamic [name] 10361 { name: name.slice(1, -1), dynamic: true } 10362 : // static name 10363 { name: "\"".concat(name, "\""), dynamic: false }; 10364 } 10365 // handle <slot/> outlets 10366 function processSlotOutlet(el) { 10367 if (el.tag === 'slot') { 10368 el.slotName = getBindingAttr(el, 'name'); 10369 if (el.key) { 10370 warn("`key` does not work on <slot> because slots are abstract outlets " + 10371 "and can possibly expand into multiple elements. " + 10372 "Use the key on a wrapping element instead.", getRawBindingAttr(el, 'key')); 10373 } 10374 } 10375 } 10376 function processComponent(el) { 10377 var binding; 10378 if ((binding = getBindingAttr(el, 'is'))) { 10379 el.component = binding; 10380 } 10381 if (getAndRemoveAttr(el, 'inline-template') != null) { 10382 el.inlineTemplate = true; 10383 } 10384 } 10385 function processAttrs(el) { 10386 var list = el.attrsList; 10387 var i, l, name, rawName, value, modifiers, syncGen, isDynamic; 10388 for (i = 0, l = list.length; i < l; i++) { 10389 name = rawName = list[i].name; 10390 value = list[i].value; 10391 if (dirRE.test(name)) { 10392 // mark element as dynamic 10393 el.hasBindings = true; 10394 // modifiers 10395 modifiers = parseModifiers(name.replace(dirRE, '')); 10396 // support .foo shorthand syntax for the .prop modifier 10397 if (modifiers) { 10398 name = name.replace(modifierRE, ''); 10399 } 10400 if (bindRE.test(name)) { 10401 // v-bind 10402 name = name.replace(bindRE, ''); 10403 value = parseFilters(value); 10404 isDynamic = dynamicArgRE.test(name); 10405 if (isDynamic) { 10406 name = name.slice(1, -1); 10407 } 10408 if (value.trim().length === 0) { 10409 warn("The value for a v-bind expression cannot be empty. Found in \"v-bind:".concat(name, "\"")); 10410 } 10411 if (modifiers) { 10412 if (modifiers.prop && !isDynamic) { 10413 name = camelize(name); 10414 if (name === 'innerHtml') 10415 name = 'innerHTML'; 10416 } 10417 if (modifiers.camel && !isDynamic) { 10418 name = camelize(name); 10419 } 10420 if (modifiers.sync) { 10421 syncGen = genAssignmentCode(value, "$event"); 10422 if (!isDynamic) { 10423 addHandler(el, "update:".concat(camelize(name)), syncGen, null, false, warn, list[i]); 10424 if (hyphenate(name) !== camelize(name)) { 10425 addHandler(el, "update:".concat(hyphenate(name)), syncGen, null, false, warn, list[i]); 10426 } 10427 } 10428 else { 10429 // handler w/ dynamic event name 10430 addHandler(el, "\"update:\"+(".concat(name, ")"), syncGen, null, false, warn, list[i], true // dynamic 10431 ); 10432 } 10433 } 10434 } 10435 if ((modifiers && modifiers.prop) || 10436 (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) { 10437 addProp(el, name, value, list[i], isDynamic); 10438 } 10439 else { 10440 addAttr(el, name, value, list[i], isDynamic); 10441 } 10442 } 10443 else if (onRE.test(name)) { 10444 // v-on 10445 name = name.replace(onRE, ''); 10446 isDynamic = dynamicArgRE.test(name); 10447 if (isDynamic) { 10448 name = name.slice(1, -1); 10449 } 10450 addHandler(el, name, value, modifiers, false, warn, list[i], isDynamic); 10451 } 10452 else { 10453 // normal directives 10454 name = name.replace(dirRE, ''); 10455 // parse arg 10456 var argMatch = name.match(argRE); 10457 var arg = argMatch && argMatch[1]; 10458 isDynamic = false;
10459 if (arg) { 10460 name = name.slice(0, -(arg.length + 1)); 10461 if (dynamicArgRE.test(arg)) { 10462 arg = arg.slice(1, -1); 10463 isDynamic = true; 10464 } 10465 } 10466 addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]); 10467 if (name === 'model') { 10468 checkForAliasModel(el, value); 10469 } 10470 } 10471 } 10472 else { 10473 // literal attribute 10474 { 10475 var res = parseText(value, delimiters); 10476 if (res) { 10477 warn("".concat(name, "=\"").concat(value, "\": ") + 10478 'Interpolation inside attributes has been removed. ' + 10479 'Use v-bind or the colon shorthand instead. For example, ' + 10480 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]); 10481 } 10482 } 10483 addAttr(el, name, JSON.stringify(value), list[i]); 10484 // #6887 firefox doesn't update muted state if set via attribute 10485 // even immediately after element creation 10486 if (!el.component && 10487 name === 'muted' && 10488 platformMustUseProp(el.tag, el.attrsMap.type, name)) { 10489 addProp(el, name, 'true', list[i]); 10490 } 10491 } 10492 } 10493 } 10494 function checkInFor(el) { 10495 var parent = el; 10496 while (parent) { 10497 if (parent.for !== undefined) { 10498 return true; 10499 } 10500 parent = parent.parent; 10501 } 10502 return false; 10503 } 10504 function parseModifiers(name) { 10505 var match = name.match(modifierRE); 10506 if (match) { 10507 var ret_1 = {}; 10508 match.forEach(function (m) { 10509 ret_1[m.slice(1)] = true; 10510 }); 10511 return ret_1; 10512 } 10513 } 10514 function makeAttrsMap(attrs) { 10515 var map = {}; 10516 for (var i = 0, l = attrs.length; i < l; i++) { 10517 if (map[attrs[i].name] && !isIE && !isEdge) { 10518 warn('duplicate attribute: ' + attrs[i].name, attrs[i]); 10519 } 10520 map[attrs[i].name] = attrs[i].value; 10521 } 10522 return map; 10523 } 10524 // for script (e.g. type="x/template") or style, do not decode content 10525 function isTextTag(el) { 10526 return el.tag === 'script' || el.tag === 'style'; 10527 } 10528 function isForbiddenTag(el) { 10529 return (el.tag === 'style' || 10530 (el.tag === 'script' && 10531 (!el.attrsMap.type || el.attrsMap.type === 'text/javascript'))); 10532 } 10533 var ieNSBug = /^xmlns:NS\d+/; 10534 var ieNSPrefix = /^NS\d+:/; 10535 /* istanbul ignore next */ 10536 function guardIESVGBug(attrs) { 10537 var res = []; 10538 for (var i = 0; i < attrs.length; i++) { 10539 var attr = attrs[i]; 10540 if (!ieNSBug.test(attr.name)) { 10541 attr.name = attr.name.replace(ieNSPrefix, ''); 10542 res.push(attr); 10543 } 10544 } 10545 return res; 10546 } 10547 function checkForAliasModel(el, value) { 10548 var _el = el; 10549 while (_el) { 10550 if (_el.for && _el.alias === value) { 10551 warn("<".concat(el.tag, " v-model=\"").concat(value, "\">: ") + 10552 "You are binding v-model directly to a v-for iteration alias. " + 10553 "This will not be able to modify the v-for source array because " + 10554 "writing to the alias is like modifying a function local variable. " + 10555 "Consider using an array of objects and use v-model on an object property instead.", el.rawAttrsMap['v-model']); 10556 } 10557 _el = _el.parent; 10558 } 10559 } 10560 10561 /** 10562 * Expand input[v-model] with dynamic type bindings into v-if-else chains 10563 * Turn this: 10564 * <input v-model="data[type]" :type="type"> 10565 * into this: 10566 * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]"> 10567 * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]"> 10568 * <input v-else :type="type" v-model="data[type]"> 10569 */ 10570 function preTransformNode(el, options) { 10571 if (el.tag === 'input') { 10572 var map = el.attrsMap; 10573 if (!map['v-model']) { 10574 return; 10575 } 10576 var typeBinding = void 0; 10577 if (map[':type'] || map['v-bind:type']) { 10578 typeBinding = getBindingAttr(el, 'type'); 10579 } 10580 if (!map.type && !typeBinding && map['v-bind']) { 10581 typeBinding = "(".concat(map['v-bind'], ").type"); 10582 } 10583 if (typeBinding) { 10584 var ifCondition = getAndRemoveAttr(el, 'v-if', true); 10585 var ifConditionExtra = ifCondition ? "&&(".concat(ifCondition, ")") : ""; 10586 var hasElse = getAndRemoveAttr(el, 'v-else', true) != null; 10587 var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true); 10588 // 1. checkbox 10589 var branch0 = cloneASTElement(el); 10590 // process for on the main node 10591 processFor(branch0); 10592 addRawAttr(branch0, 'type', 'checkbox'); 10593 processElement(branch0, options); 10594 branch0.processed = true; // prevent it from double-processed 10595 branch0.if = "(".concat(typeBinding, ")==='checkbox'") + ifConditionExtra; 10596 addIfCondition(branch0, { 10597 exp: branch0.if, 10598 block: branch0 10599 }); 10600 // 2. add radio else-if condition 10601 var branch1 = cloneASTElement(el); 10602 getAndRemoveAttr(branch1, 'v-for', true); 10603 addRawAttr(branch1, 'type', 'radio'); 10604 processElement(branch1, options); 10605 addIfCondition(branch0, { 10606 exp: "(".concat(typeBinding, ")==='radio'") + ifConditionExtra, 10607 block: branch1 10608 }); 10609 // 3. other 10610 var branch2 = cloneASTElement(el); 10611 getAndRemoveAttr(branch2, 'v-for', true); 10612 addRawAttr(branch2, ':type', typeBinding); 10613 processElement(branch2, options); 10614 addIfCondition(branch0, { 10615 exp: ifCondition, 10616 block: branch2 10617 }); 10618 if (hasElse) { 10619 branch0.else = true; 10620 } 10621 else if (elseIfCondition) { 10622 branch0.elseif = elseIfCondition; 10623 } 10624 return branch0; 10625 } 10626 } 10627 } 10628 function cloneASTElement(el) { 10629 return createASTElement(el.tag, el.attrsList.slice(), el.parent); 10630 } 10631 var model = { 10632 preTransformNode: preTransformNode 10633 }; 10634 10635 var modules = [klass, style, model]; 10636 10637 function text(el, dir) { 10638 if (dir.value) { 10639 addProp(el, 'textContent', "_s(".concat(dir.value, ")"), dir); 10640 } 10641 } 10642 10643 function html(el, dir) { 10644 if (dir.value) { 10645 addProp(el, 'innerHTML', "_s(".concat(dir.value, ")"), dir); 10646 } 10647 } 10648 10649 var directives = { 10650 model: model$1, 10651 text: text, 10652 html: html 10653 }; 10654 10655 var baseOptions = { 10656 expectHTML: true, 10657 modules: modules, 10658 directives: directives, 10659 isPreTag: isPreTag, 10660 isUnaryTag: isUnaryTag, 10661 mustUseProp: mustUseProp, 10662 canBeLeftOpenTag: canBeLeftOpenTag, 10663 isReservedTag: isReservedTag, 10664 getTagNamespace: getTagNamespace, 10665 staticKeys: genStaticKeys$1(modules) 10666 }; 10667 10668 var isStaticKey; 10669 var isPlatformReservedTag;
10670 var genStaticKeysCached = cached(genStaticKeys); 10671 /** 10672 * Goal of the optimizer: walk the generated template AST tree 10673 * and detect sub-trees that are purely static, i.e. parts of 10674 * the DOM that never needs to change. 10675 * 10676 * Once we detect these sub-trees, we can: 10677 * 10678 * 1. Hoist them into constants, so that we no longer need to 10679 * create fresh nodes for them on each re-render; 10680 * 2. Completely skip them in the patching process. 10681 */ 10682 function optimize(root, options) { 10683 if (!root) 10684 return; 10685 isStaticKey = genStaticKeysCached(options.staticKeys || ''); 10686 isPlatformReservedTag = options.isReservedTag || no; 10687 // first pass: mark all non-static nodes. 10688 markStatic(root); 10689 // second pass: mark static roots. 10690 markStaticRoots(root, false); 10691 } 10692 function genStaticKeys(keys) { 10693 return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' + 10694 (keys ? ',' + keys : '')); 10695 } 10696 function markStatic(node) { 10697 node.static = isStatic(node); 10698 if (node.type === 1) { 10699 // do not make component slot content static. this avoids 10700 // 1. components not able to mutate slot nodes 10701 // 2. static slot content fails for hot-reloading 10702 if (!isPlatformReservedTag(node.tag) && 10703 node.tag !== 'slot' && 10704 node.attrsMap['inline-template'] == null) { 10705 return; 10706 } 10707 for (var i = 0, l = node.children.length; i < l; i++) { 10708 var child = node.children[i]; 10709 markStatic(child); 10710 if (!child.static) { 10711 node.static = false; 10712 } 10713 } 10714 if (node.ifConditions) { 10715 for (var i = 1, l = node.ifConditions.length; i < l; i++) { 10716 var block = node.ifConditions[i].block; 10717 markStatic(block); 10718 if (!block.static) { 10719 node.static = false; 10720 } 10721 } 10722 } 10723 } 10724 } 10725 function markStaticRoots(node, isInFor) { 10726 if (node.type === 1) { 10727 if (node.static || node.once) { 10728 node.staticInFor = isInFor; 10729 } 10730 // For a node to qualify as a static root, it should have children that 10731 // are not just static text. Otherwise the cost of hoisting out will 10732 // outweigh the benefits and it's better off to just always render it fresh. 10733 if (node.static && 10734 node.children.length && 10735 !(node.children.length === 1 && node.children[0].type === 3)) { 10736 node.staticRoot = true; 10737 return; 10738 } 10739 else { 10740 node.staticRoot = false; 10741 } 10742 if (node.children) { 10743 for (var i = 0, l = node.children.length; i < l; i++) { 10744 markStaticRoots(node.children[i], isInFor || !!node.for); 10745 } 10746 } 10747 if (node.ifConditions) { 10748 for (var i = 1, l = node.ifConditions.length; i < l; i++) { 10749 markStaticRoots(node.ifConditions[i].block, isInFor); 10750 } 10751 } 10752 } 10753 } 10754 function isStatic(node) { 10755 if (node.type === 2) { 10756 // expression 10757 return false; 10758 } 10759 if (node.type === 3) { 10760 // text 10761 return true; 10762 } 10763 return !!(node.pre || 10764 (!node.hasBindings && // no dynamic bindings 10765 !node.if && 10766 !node.for && // not v-if or v-for or v-else 10767 !isBuiltInTag(node.tag) && // not a built-in 10768 isPlatformReservedTag(node.tag) && // not a component 10769 !isDirectChildOfTemplateFor(node) && 10770 Object.keys(node).every(isStaticKey))); 10771 } 10772 function isDirectChildOfTemplateFor(node) { 10773 while (node.parent) { 10774 node = node.parent; 10775 if (node.tag !== 'template') { 10776 return false; 10777 } 10778 if (node.for) { 10779 return true; 10780 } 10781 } 10782 return false; 10783 } 10784 10785 var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/; 10786 var fnInvokeRE = /\([^)]*?\);*$/; 10787 var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; 10788 // KeyboardEvent.keyCode aliases 10789 var keyCodes = { 10790 esc: 27, 10791 tab: 9, 10792 enter: 13, 10793 space: 32, 10794 up: 38, 10795 left: 37, 10796 right: 39, 10797 down: 40, 10798 delete: [8, 46] 10799 }; 10800 // KeyboardEvent.key aliases 10801 var keyNames = { 10802 // #7880: IE11 and Edge use `Esc` for Escape key name. 10803 esc: ['Esc', 'Escape'], 10804 tab: 'Tab', 10805 enter: 'Enter', 10806 // #9112: IE11 uses `Spacebar` for Space key name. 10807 space: [' ', 'Spacebar'], 10808 // #7806: IE11 uses key names without `Arrow` prefix for arrow keys. 10809 up: ['Up', 'ArrowUp'], 10810 left: ['Left', 'ArrowLeft'], 10811 right: ['Right', 'ArrowRight'],
10812 down: ['Down', 'ArrowDown'], 10813 // #9112: IE11 uses `Del` for Delete key name. 10814 delete: ['Backspace', 'Delete', 'Del'] 10815 }; 10816 // #4868: modifiers that prevent the execution of the listener 10817 // need to explicitly return null so that we can determine whether to remove 10818 // the listener for .once 10819 var genGuard = function (condition) { return "if(".concat(condition, ")return null;"); }; 10820 var modifierCode = { 10821 stop: '$event.stopPropagation();', 10822 prevent: '$event.preventDefault();', 10823 self: genGuard("$event.target !== $event.currentTarget"), 10824 ctrl: genGuard("!$event.ctrlKey"), 10825 shift: genGuard("!$event.shiftKey"), 10826 alt: genGuard("!$event.altKey"), 10827 meta: genGuard("!$event.metaKey"), 10828 left: genGuard("'button' in $event && $event.button !== 0"), 10829 middle: genGuard("'button' in $event && $event.button !== 1"), 10830 right: genGuard("'button' in $event && $event.button !== 2") 10831 }; 10832 function genHandlers(events, isNative) { 10833 var prefix = isNative ? 'nativeOn:' : 'on:'; 10834 var staticHandlers = ""; 10835 var dynamicHandlers = ""; 10836 for (var name_1 in events) { 10837 var handlerCode = genHandler(events[name_1]); 10838 //@ts-expect-error 10839 if (events[name_1] && events[name_1].dynamic) { 10840 dynamicHandlers += "".concat(name_1, ",").concat(handlerCode, ","); 10841 } 10842 else { 10843 staticHandlers += "\"".concat(name_1, "\":").concat(handlerCode, ","); 10844 } 10845 } 10846 staticHandlers = "{".concat(staticHandlers.slice(0, -1), "}"); 10847 if (dynamicHandlers) { 10848 return prefix + "_d(".concat(staticHandlers, ",[").concat(dynamicHandlers.slice(0, -1), "])"); 10849 } 10850 else { 10851 return prefix + staticHandlers; 10852 } 10853 } 10854 function genHandler(handler) { 10855 if (!handler) { 10856 return 'function(){}'; 10857 } 10858 if (Array.isArray(handler)) { 10859 return "[".concat(handler.map(function (handler) { return genHandler(handler); }).join(','), "]"); 10860 } 10861 var isMethodPath = simplePathRE.test(handler.value); 10862 var isFunctionExpression = fnExpRE.test(handler.value); 10863 var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, '')); 10864 if (!handler.modifiers) { 10865 if (isMethodPath || isFunctionExpression) { 10866 return handler.value; 10867 } 10868 return "function($event){".concat(isFunctionInvocation ? "return ".concat(handler.value) : handler.value, "}"); // inline statement 10869 } 10870 else { 10871 var code = ''; 10872 var genModifierCode = ''; 10873 var keys = []; 10874 var _loop_1 = function (key) { 10875 if (modifierCode[key]) { 10876 genModifierCode += modifierCode[key]; 10877 // left/right 10878 if (keyCodes[key]) { 10879 keys.push(key); 10880 } 10881 } 10882 else if (key === 'exact') { 10883 var modifiers_1 = handler.modifiers; 10884 genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta'] 10885 .filter(function (keyModifier) { return !modifiers_1[keyModifier]; }) 10886 .map(function (keyModifier) { return "$event.".concat(keyModifier, "Key"); }) 10887 .join('||')); 10888 } 10889 else { 10890 keys.push(key); 10891 } 10892 }; 10893 for (var key in handler.modifiers) { 10894 _loop_1(key); 10895 } 10896 if (keys.length) { 10897 code += genKeyFilter(keys); 10898 } 10899 // Make sure modifiers like prevent and stop get executed after key filtering 10900 if (genModifierCode) { 10901 code += genModifierCode; 10902 } 10903 var handlerCode = isMethodPath 10904 ? "return ".concat(handler.value, ".apply(null, arguments)") 10905 : isFunctionExpression 10906 ? "return (".concat(handler.value, ").apply(null, arguments)") 10907 : isFunctionInvocation 10908 ? "return ".concat(handler.value) 10909 : handler.value; 10910 return "function($event){".concat(code).concat(handlerCode, "}"); 10911 } 10912 } 10913 function genKeyFilter(keys) { 10914 return ( 10915 // make sure the key filters only apply to KeyboardEvents 10916 // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake 10917 // key events that do not have keyCode property... 10918 "if(!$event.type.indexOf('key')&&" + 10919 "".concat(keys.map(genFilterCode).join('&&'), ")return null;")); 10920 } 10921 function genFilterCode(key) { 10922 var keyVal = parseInt(key, 10); 10923 if (keyVal) { 10924 return "$event.keyCode!==".concat(keyVal); 10925 } 10926 var keyCode = keyCodes[key]; 10927 var keyName = keyNames[key]; 10928 return ("_k($event.keyCode," + 10929 "".concat(JSON.stringify(key), ",") + 10930 "".concat(JSON.stringify(keyCode), ",") + 10931 "$event.key," + 10932 "".concat(JSON.stringify(keyName)) + 10933 ")"); 10934 } 10935 10936 function on(el, dir) { 10937 if (dir.modifiers) { 10938 warn$2("v-on without argument does not support modifiers."); 10939 } 10940 el.wrapListeners = function (code) { return "_g(".concat(code, ",").concat(dir.value, ")"); }; 10941 } 10942 10943 function bind(el, dir) { 10944 el.wrapData = function (code) { 10945 return "_b(".concat(code, ",'").concat(el.tag, "',").concat(dir.value, ",").concat(dir.modifiers && dir.modifiers.prop ? 'true' : 'false').concat(dir.modifiers && dir.modifiers.sync ? ',true' : '', ")"); 10946 }; 10947 } 10948 10949 var baseDirectives = { 10950 on: on, 10951 bind: bind, 10952 cloak: noop 10953 }; 10954 10955 var CodegenState = /** @class */ (function () { 10956 function CodegenState(options) { 10957 this.options = options; 10958 this.warn = options.warn || baseWarn; 10959 this.transforms = pluckModuleFunction(options.modules, 'transformCode'); 10960 this.dataGenFns = pluckModuleFunction(options.modules, 'genData'); 10961 this.directives = extend(extend({}, baseDirectives), options.directives); 10962 var isReservedTag = options.isReservedTag || no; 10963 this.maybeComponent = function (el) { 10964 return !!el.component || !isReservedTag(el.tag); 10965 }; 10966 this.onceId = 0; 10967 this.staticRenderFns = []; 10968 this.pre = false;
10969 } 10970 return CodegenState; 10971 }()); 10972 function generate(ast, options) { 10973 var state = new CodegenState(options); 10974 // fix #11483, Root level <script> tags should not be rendered. 10975 var code = ast 10976 ? ast.tag === 'script' 10977 ? 'null' 10978 : genElement(ast, state) 10979 : '_c("div")'; 10980 return { 10981 render: "with(this){return ".concat(code, "}"), 10982 staticRenderFns: state.staticRenderFns 10983 }; 10984 } 10985 function genElement(el, state) { 10986 if (el.parent) { 10987 el.pre = el.pre || el.parent.pre; 10988 } 10989 if (el.staticRoot && !el.staticProcessed) { 10990 return genStatic(el, state); 10991 } 10992 else if (el.once && !el.onceProcessed) { 10993 return genOnce(el, state); 10994 } 10995 else if (el.for && !el.forProcessed) { 10996 return genFor(el, state); 10997 } 10998 else if (el.if && !el.ifProcessed) { 10999 return genIf(el, state); 11000 } 11001 else if (el.tag === 'template' && !el.slotTarget && !state.pre) { 11002 return genChildren(el, state) || 'void 0'; 11003 } 11004 else if (el.tag === 'slot') { 11005 return genSlot(el, state); 11006 } 11007 else { 11008 // component or element 11009 var code = void 0; 11010 if (el.component) { 11011 code = genComponent(el.component, el, state); 11012 } 11013 else { 11014 var data = void 0; 11015 var maybeComponent = state.maybeComponent(el); 11016 if (!el.plain || (el.pre && maybeComponent)) { 11017 data = genData(el, state); 11018 } 11019 var tag 11020 // check if this is a component in <script setup> 11021 = void 0; 11022 // check if this is a component in <script setup> 11023 var bindings = state.options.bindings; 11024 if (maybeComponent && bindings && bindings.__isScriptSetup !== false) { 11025 tag = checkBindingType(bindings, el.tag); 11026 } 11027 if (!tag) 11028 tag = "'".concat(el.tag, "'"); 11029 var children = el.inlineTemplate ? null : genChildren(el, state, true); 11030 code = "_c(".concat(tag).concat(data ? ",".concat(data) : '' // data 11031 ).concat(children ? ",".concat(children) : '' // children 11032 , ")"); 11033 } 11034 // module transforms 11035 for (var i = 0; i < state.transforms.length; i++) { 11036 code = state.transforms[i](el, code); 11037 } 11038 return code; 11039 } 11040 } 11041 function checkBindingType(bindings, key) { 11042 var camelName = camelize(key); 11043 var PascalName = capitalize(camelName); 11044 var checkType = function (type) { 11045 if (bindings[key] === type) { 11046 return key; 11047 } 11048 if (bindings[camelName] === type) { 11049 return camelName; 11050 } 11051 if (bindings[PascalName] === type) { 11052 return PascalName; 11053 } 11054 }; 11055 var fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) || 11056 checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */); 11057 if (fromConst) { 11058 return fromConst; 11059 } 11060 var fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) || 11061 checkType("setup-ref" /* BindingTypes.SETUP_REF */) || 11062 checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */); 11063 if (fromMaybeRef) { 11064 return fromMaybeRef; 11065 } 11066 } 11067 // hoist static sub-trees out 11068 function genStatic(el, state) { 11069 el.staticProcessed = true; 11070 // Some elements (templates) need to behave differently inside of a v-pre 11071 // node. All pre nodes are static roots, so we can use this as a location to 11072 // wrap a state change and reset it upon exiting the pre node. 11073 var originalPreState = state.pre; 11074 if (el.pre) { 11075 state.pre = el.pre; 11076 } 11077 state.staticRenderFns.push("with(this){return ".concat(genElement(el, state), "}")); 11078 state.pre = originalPreState; 11079 return "_m(".concat(state.staticRenderFns.length - 1).concat(el.staticInFor ? ',true' : '', ")"); 11080 } 11081 // v-once 11082 function genOnce(el, state) { 11083 el.onceProcessed = true; 11084 if (el.if && !el.ifProcessed) { 11085 return genIf(el, state); 11086 } 11087 else if (el.staticInFor) { 11088 var key = ''; 11089 var parent_1 = el.parent; 11090 while (parent_1) { 11091 if (parent_1.for) { 11092 key = parent_1.key; 11093 break; 11094 } 11095 parent_1 = parent_1.parent; 11096 } 11097 if (!key) { 11098 state.warn("v-once can only be used inside v-for that is keyed. ", el.rawAttrsMap['v-once']); 11099 return genElement(el, state); 11100 } 11101 return "_o(".concat(genElement(el, state), ",").concat(state.onceId++, ",").concat(key, ")"); 11102 } 11103 else { 11104 return genStatic(el, state); 11105 } 11106 } 11107 function genIf(el, state, altGen, altEmpty) { 11108 el.ifProcessed = true; // avoid recursion 11109 return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty); 11110 } 11111 function genIfConditions(conditions, state, altGen, altEmpty) { 11112 if (!conditions.length) { 11113 return altEmpty || '_e()'; 11114 } 11115 var condition = conditions.shift(); 11116 if (condition.exp) { 11117 return "(".concat(condition.exp, ")?").concat(genTernaryExp(condition.block), ":").concat(genIfConditions(conditions, state, altGen, altEmpty)); 11118 } 11119 else { 11120 return "".concat(genTernaryExp(condition.block)); 11121 } 11122 // v-if with v-once should generate code like (a)?_m(0):_m(1) 11123 function genTernaryExp(el) { 11124 return altGen 11125 ? altGen(el, state) 11126 : el.once 11127 ? genOnce(el, state) 11128 : genElement(el, state); 11129 } 11130 } 11131 function genFor(el, state, altGen, altHelper) { 11132 var exp = el.for; 11133 var alias = el.alias; 11134 var iterator1 = el.iterator1 ? ",".concat(el.iterator1) : ''; 11135 var iterator2 = el.iterator2 ? ",".concat(el.iterator2) : ''; 11136 if (state.maybeComponent(el) && 11137 el.tag !== 'slot' && 11138 el.tag !== 'template' && 11139 !el.key) { 11140 state.warn("<".concat(el.tag, " v-for=\"").concat(alias, " in ").concat(exp, "\">: component lists rendered with ") + 11141 "v-for should have explicit keys. " + 11142 "See https://v2.vuejs.org/v2/guide/list.html#key for more info.", el.rawAttrsMap['v-for'], true /* tip */); 11143 } 11144 el.forProcessed = true; // avoid recursion 11145 return ("".concat(altHelper || '_l', "((").concat(exp, "),") + 11146 "function(".concat(alias).concat(iterator1).concat(iterator2, "){") + 11147 "return ".concat((altGen || genElement)(el, state)) + 11148 '})'); 11149 } 11150 function genData(el, state) { 11151 var data = '{'; 11152 // directives first. 11153 // directives may mutate the el's other properties before they are generated. 11154 var dirs = genDirectives(el, state); 11155 if (dirs) 11156 data += dirs + ','; 11157 // key 11158 if (el.key) { 11159 data += "key:".concat(el.key, ","); 11160 } 11161 // ref 11162 if (el.ref) { 11163 data += "ref:".concat(el.ref, ","); 11164 } 11165 if (el.refInFor) { 11166 data += "refInFor:true,"; 11167 } 11168 // pre 11169 if (el.pre) { 11170 data += "pre:true,"; 11171 } 11172 // record original tag name for components using "is" attribute 11173 if (el.component) { 11174 data += "tag:\"".concat(el.tag, "\","); 11175 } 11176 // module data generation functions 11177 for (var i = 0; i < state.dataGenFns.length; i++) { 11178 data += state.dataGenFns[i](el); 11179 } 11180 // attributes 11181 if (el.attrs) { 11182 data += "attrs:".concat(genProps(el.attrs), ","); 11183 } 11184 // DOM props 11185 if (el.props) { 11186 data += "domProps:".concat(genProps(el.props), ","); 11187 } 11188 // event handlers 11189 if (el.events) { 11190 data += "".concat(genHandlers(el.events, false), ","); 11191 } 11192 if (el.nativeEvents) { 11193 data += "".concat(genHandlers(el.nativeEvents, true), ","); 11194 } 11195 // slot target 11196 // only for non-scoped slots 11197 if (el.slotTarget && !el.slotScope) { 11198 data += "slot:".concat(el.slotTarget, ","); 11199 } 11200 // scoped slots 11201 if (el.scopedSlots) { 11202 data += "".concat(genScopedSlots(el, el.scopedSlots, state), ","); 11203 } 11204 // component v-model 11205 if (el.model) { 11206 data += "model:{value:".concat(el.model.value, ",callback:").concat(el.model.callback, ",expression:").concat(el.model.expression, "},"); 11207 } 11208 // inline-template 11209 if (el.inlineTemplate) { 11210 var inlineTemplate = genInlineTemplate(el, state); 11211 if (inlineTemplate) { 11212 data += "".concat(inlineTemplate, ","); 11213 } 11214 } 11215 data = data.replace(/,$/, '') + '}'; 11216 // v-bind dynamic argument wrap 11217 // v-bind with dynamic arguments must be applied using the same v-bind object 11218 // merge helper so that class/style/mustUseProp attrs are handled correctly. 11219 if (el.dynamicAttrs) { 11220 data = "_b(".concat(data, ",\"").concat(el.tag, "\",").concat(genProps(el.dynamicAttrs), ")"); 11221 } 11222 // v-bind data wrap 11223 if (el.wrapData) { 11224 data = el.wrapData(data); 11225 } 11226 // v-on data wrap 11227 if (el.wrapListeners) { 11228 data = el.wrapListeners(data); 11229 } 11230 return data; 11231 } 11232 function genDirectives(el, state) { 11233 var dirs = el.directives; 11234 if (!dirs) 11235 return; 11236 var res = 'directives:['; 11237 var hasRuntime = false;
11238 var i, l, dir, needRuntime; 11239 for (i = 0, l = dirs.length; i < l; i++) { 11240 dir = dirs[i]; 11241 needRuntime = true; 11242 var gen = state.directives[dir.name]; 11243 if (gen) { 11244 // compile-time directive that manipulates AST. 11245 // returns true if it also needs a runtime counterpart. 11246 needRuntime = !!gen(el, dir, state.warn); 11247 } 11248 if (needRuntime) { 11249 hasRuntime = true; 11250 res += "{name:\"".concat(dir.name, "\",rawName:\"").concat(dir.rawName, "\"").concat(dir.value 11251 ? ",value:(".concat(dir.value, "),expression:").concat(JSON.stringify(dir.value)) 11252 : '').concat(dir.arg ? ",arg:".concat(dir.isDynamicArg ? dir.arg : "\"".concat(dir.arg, "\"")) : '').concat(dir.modifiers ? ",modifiers:".concat(JSON.stringify(dir.modifiers)) : '', "},"); 11253 } 11254 } 11255 if (hasRuntime) { 11256 return res.slice(0, -1) + ']'; 11257 } 11258 } 11259 function genInlineTemplate(el, state) { 11260 var ast = el.children[0]; 11261 if ((el.children.length !== 1 || ast.type !== 1)) { 11262 state.warn('Inline-template components must have exactly one child element.', { start: el.start }); 11263 } 11264 if (ast && ast.type === 1) { 11265 var inlineRenderFns = generate(ast, state.options); 11266 return "inlineTemplate:{render:function(){".concat(inlineRenderFns.render, "},staticRenderFns:[").concat(inlineRenderFns.staticRenderFns 11267 .map(function (code) { return "function(){".concat(code, "}"); }) 11268 .join(','), "]}"); 11269 } 11270 } 11271 function genScopedSlots(el, slots, state) { 11272 // by default scoped slots are considered "stable", this allows child 11273 // components with only scoped slots to skip forced updates from parent. 11274 // but in some cases we have to bail-out of this optimization 11275 // for example if the slot contains dynamic names, has v-if or v-for on them... 11276 var needsForceUpdate = el.for || 11277 Object.keys(slots).some(function (key) { 11278 var slot = slots[key]; 11279 return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic 11280 ); 11281 }); 11282 // #9534: if a component with scoped slots is inside a conditional branch, 11283 // it's possible for the same component to be reused but with different 11284 // compiled slot content. To avoid that, we generate a unique key based on 11285 // the generated code of all the slot contents. 11286 var needsKey = !!el.if; 11287 // OR when it is inside another scoped slot or v-for (the reactivity may be 11288 // disconnected due to the intermediate scope variable) 11289 // #9438, #9506 11290 // TODO: this can be further optimized by properly analyzing in-scope bindings 11291 // and skip force updating ones that do not actually use scope variables. 11292 if (!needsForceUpdate) { 11293 var parent_2 = el.parent; 11294 while (parent_2) { 11295 if ((parent_2.slotScope && parent_2.slotScope !== emptySlotScopeToken) || 11296 parent_2.for) { 11297 needsForceUpdate = true; 11298 break; 11299 } 11300 if (parent_2.if) { 11301 needsKey = true; 11302 } 11303 parent_2 = parent_2.parent; 11304 } 11305 } 11306 var generatedSlots = Object.keys(slots) 11307 .map(function (key) { return genScopedSlot(slots[key], state); }) 11308 .join(','); 11309 return "scopedSlots:_u([".concat(generatedSlots, "]").concat(needsForceUpdate ? ",null,true" : "").concat(!needsForceUpdate && needsKey ? ",null,false,".concat(hash(generatedSlots)) : "", ")"); 11310 } 11311 function hash(str) { 11312 var hash = 5381; 11313 var i = str.length; 11314 while (i) { 11315 hash = (hash * 33) ^ str.charCodeAt(--i); 11316 } 11317 return hash >>> 0; 11318 } 11319 function containsSlotChild(el) { 11320 if (el.type === 1) { 11321 if (el.tag === 'slot') { 11322 return true; 11323 } 11324 return el.children.some(containsSlotChild); 11325 } 11326 return false;
11327 } 11328 function genScopedSlot(el, state) { 11329 var isLegacySyntax = el.attrsMap['slot-scope']; 11330 if (el.if && !el.ifProcessed && !isLegacySyntax) { 11331 return genIf(el, state, genScopedSlot, "null"); 11332 } 11333 if (el.for && !el.forProcessed) { 11334 return genFor(el, state, genScopedSlot); 11335 } 11336 var slotScope = el.slotScope === emptySlotScopeToken ? "" : String(el.slotScope); 11337 var fn = "function(".concat(slotScope, "){") + 11338 "return ".concat(el.tag === 'template' 11339 ? el.if && isLegacySyntax 11340 ? "(".concat(el.if, ")?").concat(genChildren(el, state) || 'undefined', ":undefined") 11341 : genChildren(el, state) || 'undefined' 11342 : genElement(el, state), "}"); 11343 // reverse proxy v-slot without scope on this.$slots 11344 var reverseProxy = slotScope ? "" : ",proxy:true"; 11345 return "{key:".concat(el.slotTarget || "\"default\"", ",fn:").concat(fn).concat(reverseProxy, "}"); 11346 } 11347 function genChildren(el, state, checkSkip, altGenElement, altGenNode) { 11348 var children = el.children; 11349 if (children.length) { 11350 var el_1 = children[0]; 11351 // optimize single v-for 11352 if (children.length === 1 && 11353 el_1.for && 11354 el_1.tag !== 'template' && 11355 el_1.tag !== 'slot') { 11356 var normalizationType_1 = checkSkip 11357 ? state.maybeComponent(el_1) 11358 ? ",1" 11359 : ",0" 11360 : ""; 11361 return "".concat((altGenElement || genElement)(el_1, state)).concat(normalizationType_1); 11362 } 11363 var normalizationType = checkSkip 11364 ? getNormalizationType(children, state.maybeComponent) 11365 : 0; 11366 var gen_1 = altGenNode || genNode; 11367 return "[".concat(children.map(function (c) { return gen_1(c, state); }).join(','), "]").concat(normalizationType ? ",".concat(normalizationType) : ''); 11368 } 11369 } 11370 // determine the normalization needed for the children array. 11371 // 0: no normalization needed 11372 // 1: simple normalization needed (possible 1-level deep nested array) 11373 // 2: full normalization needed 11374 function getNormalizationType(children, maybeComponent) { 11375 var res = 0; 11376 for (var i = 0; i < children.length; i++) { 11377 var el = children[i]; 11378 if (el.type !== 1) { 11379 continue; 11380 } 11381 if (needsNormalization(el) || 11382 (el.ifConditions && 11383 el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) { 11384 res = 2; 11385 break; 11386 } 11387 if (maybeComponent(el) || 11388 (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) { 11389 res = 1; 11390 } 11391 } 11392 return res; 11393 } 11394 function needsNormalization(el) { 11395 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'; 11396 } 11397 function genNode(node, state) { 11398 if (node.type === 1) { 11399 return genElement(node, state); 11400 } 11401 else if (node.type === 3 && node.isComment) { 11402 return genComment(node); 11403 } 11404 else { 11405 return genText(node); 11406 } 11407 } 11408 function genText(text) { 11409 return "_v(".concat(text.type === 2 11410 ? text.expression // no need for () because already wrapped in _s() 11411 : transformSpecialNewlines(JSON.stringify(text.text)), ")"); 11412 } 11413 function genComment(comment) { 11414 return "_e(".concat(JSON.stringify(comment.text), ")"); 11415 } 11416 function genSlot(el, state) { 11417 var slotName = el.slotName || '"default"'; 11418 var children = genChildren(el, state); 11419 var res = "_t(".concat(slotName).concat(children ? ",function(){return ".concat(children, "}") : ''); 11420 var attrs = el.attrs || el.dynamicAttrs 11421 ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({ 11422 // slot props are camelized 11423 name: camelize(attr.name), 11424 value: attr.value, 11425 dynamic: attr.dynamic 11426 }); })) 11427 : null; 11428 var bind = el.attrsMap['v-bind']; 11429 if ((attrs || bind) && !children) { 11430 res += ",null"; 11431 } 11432 if (attrs) { 11433 res += ",".concat(attrs); 11434 } 11435 if (bind) { 11436 res += "".concat(attrs ? '' : ',null', ",").concat(bind); 11437 } 11438 return res + ')'; 11439 } 11440 // componentName is el.component, take it as argument to shun flow's pessimistic refinement 11441 function genComponent(componentName, el, state) { 11442 var children = el.inlineTemplate ? null : genChildren(el, state, true); 11443 return "_c(".concat(componentName, ",").concat(genData(el, state)).concat(children ? ",".concat(children) : '', ")"); 11444 } 11445 function genProps(props) { 11446 var staticProps = ""; 11447 var dynamicProps = ""; 11448 for (var i = 0; i < props.length; i++) { 11449 var prop = props[i]; 11450 var value = transformSpecialNewlines(prop.value); 11451 if (prop.dynamic) { 11452 dynamicProps += "".concat(prop.name, ",").concat(value, ","); 11453 } 11454 else { 11455 staticProps += "\"".concat(prop.name, "\":").concat(value, ","); 11456 } 11457 } 11458 staticProps = "{".concat(staticProps.slice(0, -1), "}"); 11459 if (dynamicProps) { 11460 return "_d(".concat(staticProps, ",[").concat(dynamicProps.slice(0, -1), "])"); 11461 } 11462 else { 11463 return staticProps; 11464 } 11465 } 11466 // #3895, #4268 11467 function transformSpecialNewlines(text) { 11468 return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029'); 11469 } 11470 11471 // these keywords should not appear inside expressions, but operators like 11472 // typeof, instanceof and in are allowed 11473 var prohibitedKeywordRE = new RegExp('\\b' + 11474 ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 11475 'super,throw,while,yield,delete,export,import,return,switch,default,' + 11476 'extends,finally,continue,debugger,function,arguments') 11477 .split(',') 11478 .join('\\b|\\b') + 11479 '\\b'); 11480 // these unary operators should not be used as property/method names 11481 var unaryOperatorsRE = new RegExp('\\b' + 11482 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') + 11483 '\\s*\\([^\\)]*\\)'); 11484 // strip strings in expressions 11485 var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g; 11486 // detect problematic expressions in a template 11487 function detectErrors(ast, warn) { 11488 if (ast) { 11489 checkNode(ast, warn); 11490 } 11491 } 11492 function checkNode(node, warn) { 11493 if (node.type === 1) { 11494 for (var name_1 in node.attrsMap) { 11495 if (dirRE.test(name_1)) { 11496 var value = node.attrsMap[name_1]; 11497 if (value) { 11498 var range = node.rawAttrsMap[name_1]; 11499 if (name_1 === 'v-for') { 11500 checkFor(node, "v-for=\"".concat(value, "\""), warn, range); 11501 } 11502 else if (name_1 === 'v-slot' || name_1[0] === '#') { 11503 checkFunctionParameterExpression(value, "".concat(name_1, "=\"").concat(value, "\""), warn, range); 11504 } 11505 else if (onRE.test(name_1)) { 11506 checkEvent(value, "".concat(name_1, "=\"").concat(value, "\""), warn, range); 11507 } 11508 else { 11509 checkExpression(value, "".concat(name_1, "=\"").concat(value, "\""), warn, range); 11510 } 11511 } 11512 } 11513 } 11514 if (node.children) { 11515 for (var i = 0; i < node.children.length; i++) { 11516 checkNode(node.children[i], warn); 11517 } 11518 } 11519 } 11520 else if (node.type === 2) { 11521 checkExpression(node.expression, node.text, warn, node); 11522 } 11523 } 11524 function checkEvent(exp, text, warn, range) { 11525 var stripped = exp.replace(stripStringRE, ''); 11526 var keywordMatch = stripped.match(unaryOperatorsRE); 11527 if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') { 11528 warn("avoid using JavaScript unary operator as property name: " + 11529 "\"".concat(keywordMatch[0], "\" in expression ").concat(text.trim()), range); 11530 } 11531 checkExpression(exp, text, warn, range); 11532 } 11533 function checkFor(node, text, warn, range) { 11534 checkExpression(node.for || '', text, warn, range); 11535 checkIdentifier(node.alias, 'v-for alias', text, warn, range); 11536 checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range); 11537 checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range); 11538 } 11539 function checkIdentifier(ident, type, text, warn, range) { 11540 if (typeof ident === 'string') { 11541 try { 11542 new Function("var ".concat(ident, "=_")); 11543 } 11544 catch (e) { 11545 warn("invalid ".concat(type, " \"").concat(ident, "\" in expression: ").concat(text.trim()), range); 11546 } 11547 } 11548 } 11549 function checkExpression(exp, text, warn, range) {
11550 try { 11551 new Function("return ".concat(exp)); 11552 } 11553 catch (e) { 11554 var keywordMatch = exp 11555 .replace(stripStringRE, '') 11556 .match(prohibitedKeywordRE); 11557 if (keywordMatch) { 11558 warn("avoid using JavaScript keyword as property name: " + 11559 "\"".concat(keywordMatch[0], "\"\n Raw expression: ").concat(text.trim()), range); 11560 } 11561 else { 11562 warn("invalid expression: ".concat(e.message, " in\n\n") + 11563 " ".concat(exp, "\n\n") + 11564 " Raw expression: ".concat(text.trim(), "\n"), range); 11565 } 11566 } 11567 } 11568 function checkFunctionParameterExpression(exp, text, warn, range) { 11569 try { 11570 new Function(exp, ''); 11571 } 11572 catch (e) { 11573 warn("invalid function parameter expression: ".concat(e.message, " in\n\n") + 11574 " ".concat(exp, "\n\n") + 11575 " Raw expression: ".concat(text.trim(), "\n"), range); 11576 } 11577 } 11578 11579 var range = 2; 11580 function generateCodeFrame(source, start, end) { 11581 if (start === void 0) { start = 0; } 11582 if (end === void 0) { end = source.length; } 11583 var lines = source.split(/\r?\n/); 11584 var count = 0; 11585 var res = []; 11586 for (var i = 0; i < lines.length; i++) { 11587 count += lines[i].length + 1; 11588 if (count >= start) { 11589 for (var j = i - range; j <= i + range || end > count; j++) { 11590 if (j < 0 || j >= lines.length) 11591 continue; 11592 res.push("".concat(j + 1).concat(repeat(" ", 3 - String(j + 1).length), "| ").concat(lines[j])); 11593 var lineLength = lines[j].length; 11594 if (j === i) { 11595 // push underline 11596 var pad = start - (count - lineLength) + 1; 11597 var length_1 = end > count ? lineLength - pad : end - start; 11598 res.push(" | " + repeat(" ", pad) + repeat("^", length_1)); 11599 } 11600 else if (j > i) { 11601 if (end > count) { 11602 var length_2 = Math.min(end - count, lineLength); 11603 res.push(" | " + repeat("^", length_2)); 11604 } 11605 count += lineLength + 1; 11606 } 11607 } 11608 break; 11609 } 11610 } 11611 return res.join('\n'); 11612 } 11613 function repeat(str, n) { 11614 var result = ''; 11615 if (n > 0) { 11616 // eslint-disable-next-line no-constant-condition 11617 while (true) { 11618 // eslint-disable-line 11619 if (n & 1) 11620 result += str; 11621 n >>>= 1; 11622 if (n <= 0) 11623 break; 11624 str += str; 11625 } 11626 } 11627 return result; 11628 } 11629 11630 function createFunction(code, errors) { 11631 try { 11632 return new Function(code); 11633 } 11634 catch (err) { 11635 errors.push({ err: err, code: code }); 11636 return noop; 11637 } 11638 } 11639 function createCompileToFunctionFn(compile) { 11640 var cache = Object.create(null); 11641 return function compileToFunctions(template, options, vm) { 11642 options = extend({}, options); 11643 var warn = options.warn || warn$2; 11644 delete options.warn; 11645 /* istanbul ignore if */ 11646 { 11647 // detect possible CSP restriction 11648 try { 11649 new Function('return 1'); 11650 } 11651 catch (e) { 11652 if (e.toString().match(/unsafe-eval|CSP/)) { 11653 warn('It seems you are using the standalone build of Vue.js in an ' + 11654 'environment with Content Security Policy that prohibits unsafe-eval. ' + 11655 'The template compiler cannot work in this environment. Consider ' + 11656 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + 11657 'templates into render functions.'); 11658 } 11659 } 11660 } 11661 // check cache 11662 var key = options.delimiters 11663 ? String(options.delimiters) + template 11664 : template; 11665 if (cache[key]) { 11666 return cache[key]; 11667 } 11668 // compile 11669 var compiled = compile(template, options); 11670 // check compilation errors/tips 11671 { 11672 if (compiled.errors && compiled.errors.length) { 11673 if (options.outputSourceRange) {
11674 compiled.errors.forEach(function (e) { 11675 warn("Error compiling template:\n\n".concat(e.msg, "\n\n") + 11676 generateCodeFrame(template, e.start, e.end), vm); 11677 }); 11678 } 11679 else { 11680 warn("Error compiling template:\n\n".concat(template, "\n\n") + 11681 compiled.errors.map(function (e) { return "- ".concat(e); }).join('\n') + 11682 '\n', vm); 11683 } 11684 } 11685 if (compiled.tips && compiled.tips.length) { 11686 if (options.outputSourceRange) { 11687 compiled.tips.forEach(function (e) { return tip(e.msg, vm); }); 11688 } 11689 else { 11690 compiled.tips.forEach(function (msg) { return tip(msg, vm); }); 11691 } 11692 } 11693 } 11694 // turn code into functions 11695 var res = {}; 11696 var fnGenErrors = []; 11697 res.render = createFunction(compiled.render, fnGenErrors); 11698 res.staticRenderFns = compiled.staticRenderFns.map(function (code) { 11699 return createFunction(code, fnGenErrors); 11700 }); 11701 // check function generation errors. 11702 // this should only happen if there is a bug in the compiler itself. 11703 // mostly for codegen development use 11704 /* istanbul ignore if */ 11705 { 11706 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) { 11707 warn("Failed to generate render function:\n\n" + 11708 fnGenErrors 11709 .map(function (_a) { 11710 var err = _a.err, code = _a.code; 11711 return "".concat(err.toString(), " in\n\n").concat(code, "\n"); 11712 }) 11713 .join('\n'), vm); 11714 } 11715 } 11716 return (cache[key] = res); 11717 }; 11718 } 11719 11720 function createCompilerCreator(baseCompile) { 11721 return function createCompiler(baseOptions) { 11722 function compile(template, options) { 11723 var finalOptions = Object.create(baseOptions); 11724 var errors = []; 11725 var tips = []; 11726 var warn = function (msg, range, tip) { 11727 (tip ? tips : errors).push(msg); 11728 }; 11729 if (options) { 11730 if (options.outputSourceRange) { 11731 // $flow-disable-line 11732 var leadingSpaceLength_1 = template.match(/^\s*/)[0].length; 11733 warn = function (msg, range, tip) { 11734 var data = typeof msg === 'string' ? { msg: msg } : msg; 11735 if (range) { 11736 if (range.start != null) { 11737 data.start = range.start + leadingSpaceLength_1; 11738 } 11739 if (range.end != null) { 11740 data.end = range.end + leadingSpaceLength_1; 11741 } 11742 } 11743 (tip ? tips : errors).push(data); 11744 }; 11745 } 11746 // merge custom modules 11747 if (options.modules) { 11748 finalOptions.modules = (baseOptions.modules || []).concat(options.modules); 11749 } 11750 // merge custom directives 11751 if (options.directives) { 11752 finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives); 11753 } 11754 // copy other options 11755 for (var key in options) { 11756 if (key !== 'modules' && key !== 'directives') { 11757 finalOptions[key] = options[key]; 11758 } 11759 } 11760 } 11761 finalOptions.warn = warn; 11762 var compiled = baseCompile(template.trim(), finalOptions); 11763 { 11764 detectErrors(compiled.ast, warn); 11765 } 11766 compiled.errors = errors; 11767 compiled.tips = tips; 11768 return compiled; 11769 } 11770 return { 11771 compile: compile, 11772 compileToFunctions: createCompileToFunctionFn(compile) 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(template, options) { 11781 var ast = parse(template.trim(), options); 11782 if (options.optimize !== false) { 11783 optimize(ast, options); 11784 } 11785 var code = generate(ast, options); 11786 return { 11787 ast: ast, 11788 render: code.render, 11789 staticRenderFns: code.staticRenderFns 11790 }; 11791 }); 11792 11793 var _a = createCompiler(baseOptions), compileToFunctions = _a.compileToFunctions; 11794 11795 // check whether current browser encodes a char inside attribute values 11796 var div; 11797 function getShouldDecode(href) { 11798 div = div || document.createElement('div'); 11799 div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>"; 11800 return div.innerHTML.indexOf(' ') > 0; 11801 } 11802 // #3663: IE encodes newlines inside attribute values while other browsers don't 11803 var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
11804 // #6828: chrome encodes content in a[href] 11805 var shouldDecodeNewlinesForHref = inBrowser 11806 ? getShouldDecode(true) 11807 : false; 11808 11809 var idToTemplate = cached(function (id) { 11810 var el = query(id); 11811 return el && el.innerHTML; 11812 }); 11813 var mount = Vue.prototype.$mount; 11814 Vue.prototype.$mount = function (el, hydrating) { 11815 el = el && query(el); 11816 /* istanbul ignore if */ 11817 if (el === document.body || el === document.documentElement) { 11818 warn$2("Do not mount Vue to <html> or <body> - mount to normal elements instead."); 11819 return this; 11820 } 11821 var options = this.$options; 11822 // resolve template/el and convert to render function 11823 if (!options.render) { 11824 var template = options.template; 11825 if (template) { 11826 if (typeof template === 'string') { 11827 if (template.charAt(0) === '#') { 11828 template = idToTemplate(template); 11829 /* istanbul ignore if */ 11830 if (!template) { 11831 warn$2("Template element not found or is empty: ".concat(options.template), this); 11832 } 11833 } 11834 } 11835 else if (template.nodeType) { 11836 template = template.innerHTML; 11837 } 11838 else { 11839 { 11840 warn$2('invalid template option:' + template, this); 11841 } 11842 return this; 11843 } 11844 } 11845 else if (el) { 11846 // @ts-expect-error 11847 template = getOuterHTML(el); 11848 } 11849 if (template) { 11850 /* istanbul ignore if */ 11851 if (config.performance && mark) { 11852 mark('compile'); 11853 } 11854 var _a = compileToFunctions(template, { 11855 outputSourceRange: true, 11856 shouldDecodeNewlines: shouldDecodeNewlines, 11857 shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref, 11858 delimiters: options.delimiters, 11859 comments: options.comments 11860 }, this), render = _a.render, staticRenderFns = _a.staticRenderFns; 11861 options.render = render; 11862 options.staticRenderFns = staticRenderFns; 11863 /* istanbul ignore if */ 11864 if (config.performance && mark) { 11865 mark('compile end'); 11866 measure("vue ".concat(this._name, " compile"), 'compile', 'compile end'); 11867 } 11868 } 11869 } 11870 return mount.call(this, el, hydrating); 11871 }; 11872 /** 11873 * Get outerHTML of elements, taking care 11874 * of SVG elements in IE as well. 11875 */ 11876 function getOuterHTML(el) { 11877 if (el.outerHTML) { 11878 return el.outerHTML; 11879 } 11880 else { 11881 var container = document.createElement('div'); 11882 container.appendChild(el.cloneNode(true)); 11883 return container.innerHTML; 11884 } 11885 } 11886 Vue.compile = compileToFunctions; 11887 11888 // export type EffectScheduler = (...args: any[]) => any 11889 /** 11890 * @internal since we are not exposing this in Vue 2, it's used only for 11891 * internal testing. 11892 */ 11893 function effect(fn, scheduler) { 11894 var watcher = new Watcher(currentInstance, fn, noop, { 11895 sync: true 11896 }); 11897 if (scheduler) { 11898 watcher.update = function () { 11899 scheduler(function () { return watcher.run(); }); 11900 }; 11901 } 11902 } 11903 11904 extend(Vue, vca); 11905 Vue.effect = effect; 11906 11907 return Vue; 11908 11909}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.