@vue/compat 3.5.24 → 3.5.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.24
2
+ * @vue/compat v3.5.25
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1014,10 +1014,16 @@ function shallowReadArray(arr) {
1014
1014
  track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
1015
1015
  return arr;
1016
1016
  }
1017
+ function toWrapped(target, item) {
1018
+ if (isReadonly(target)) {
1019
+ return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
1020
+ }
1021
+ return toReactive(item);
1022
+ }
1017
1023
  const arrayInstrumentations = {
1018
1024
  __proto__: null,
1019
1025
  [Symbol.iterator]() {
1020
- return iterator(this, Symbol.iterator, toReactive);
1026
+ return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
1021
1027
  },
1022
1028
  concat(...args) {
1023
1029
  return reactiveReadArray(this).concat(
@@ -1026,7 +1032,7 @@ const arrayInstrumentations = {
1026
1032
  },
1027
1033
  entries() {
1028
1034
  return iterator(this, "entries", (value) => {
1029
- value[1] = toReactive(value[1]);
1035
+ value[1] = toWrapped(this, value[1]);
1030
1036
  return value;
1031
1037
  });
1032
1038
  },
@@ -1034,16 +1040,37 @@ const arrayInstrumentations = {
1034
1040
  return apply(this, "every", fn, thisArg, void 0, arguments);
1035
1041
  },
1036
1042
  filter(fn, thisArg) {
1037
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
1043
+ return apply(
1044
+ this,
1045
+ "filter",
1046
+ fn,
1047
+ thisArg,
1048
+ (v) => v.map((item) => toWrapped(this, item)),
1049
+ arguments
1050
+ );
1038
1051
  },
1039
1052
  find(fn, thisArg) {
1040
- return apply(this, "find", fn, thisArg, toReactive, arguments);
1053
+ return apply(
1054
+ this,
1055
+ "find",
1056
+ fn,
1057
+ thisArg,
1058
+ (item) => toWrapped(this, item),
1059
+ arguments
1060
+ );
1041
1061
  },
1042
1062
  findIndex(fn, thisArg) {
1043
1063
  return apply(this, "findIndex", fn, thisArg, void 0, arguments);
1044
1064
  },
1045
1065
  findLast(fn, thisArg) {
1046
- return apply(this, "findLast", fn, thisArg, toReactive, arguments);
1066
+ return apply(
1067
+ this,
1068
+ "findLast",
1069
+ fn,
1070
+ thisArg,
1071
+ (item) => toWrapped(this, item),
1072
+ arguments
1073
+ );
1047
1074
  },
1048
1075
  findLastIndex(fn, thisArg) {
1049
1076
  return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
@@ -1103,7 +1130,7 @@ const arrayInstrumentations = {
1103
1130
  return noTracking(this, "unshift", args);
1104
1131
  },
1105
1132
  values() {
1106
- return iterator(this, "values", toReactive);
1133
+ return iterator(this, "values", (item) => toWrapped(this, item));
1107
1134
  }
1108
1135
  };
1109
1136
  function iterator(self, method, wrapValue) {
@@ -1134,7 +1161,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1134
1161
  if (arr !== self) {
1135
1162
  if (needsWrap) {
1136
1163
  wrappedFn = function(item, index) {
1137
- return fn.call(this, toReactive(item), index, self);
1164
+ return fn.call(this, toWrapped(self, item), index, self);
1138
1165
  };
1139
1166
  } else if (fn.length > 2) {
1140
1167
  wrappedFn = function(item, index) {
@@ -1151,7 +1178,7 @@ function reduce(self, method, fn, args) {
1151
1178
  if (arr !== self) {
1152
1179
  if (!isShallow(self)) {
1153
1180
  wrappedFn = function(acc, item, index) {
1154
- return fn.call(this, acc, toReactive(item), index, self);
1181
+ return fn.call(this, acc, toWrapped(self, item), index, self);
1155
1182
  };
1156
1183
  } else if (fn.length > 3) {
1157
1184
  wrappedFn = function(acc, item, index) {
@@ -1255,13 +1282,14 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1255
1282
  }
1256
1283
  set(target, key, value, receiver) {
1257
1284
  let oldValue = target[key];
1285
+ const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
1258
1286
  if (!this._isShallow) {
1259
1287
  const isOldValueReadonly = isReadonly(oldValue);
1260
1288
  if (!isShallow(value) && !isReadonly(value)) {
1261
1289
  oldValue = toRaw(oldValue);
1262
1290
  value = toRaw(value);
1263
1291
  }
1264
- if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
1292
+ if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
1265
1293
  if (isOldValueReadonly) {
1266
1294
  return true;
1267
1295
  } else {
@@ -1270,7 +1298,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1270
1298
  }
1271
1299
  }
1272
1300
  }
1273
- const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1301
+ const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
1274
1302
  const result = Reflect.set(
1275
1303
  target,
1276
1304
  key,
@@ -1740,16 +1768,35 @@ class ObjectRefImpl {
1740
1768
  this._defaultValue = _defaultValue;
1741
1769
  this["__v_isRef"] = true;
1742
1770
  this._value = void 0;
1771
+ this._raw = toRaw(_object);
1772
+ let shallow = true;
1773
+ let obj = _object;
1774
+ if (!isArray(_object) || !isIntegerKey(String(_key))) {
1775
+ do {
1776
+ shallow = !isProxy(obj) || isShallow(obj);
1777
+ } while (shallow && (obj = obj["__v_raw"]));
1778
+ }
1779
+ this._shallow = shallow;
1743
1780
  }
1744
1781
  get value() {
1745
- const val = this._object[this._key];
1782
+ let val = this._object[this._key];
1783
+ if (this._shallow) {
1784
+ val = unref(val);
1785
+ }
1746
1786
  return this._value = val === void 0 ? this._defaultValue : val;
1747
1787
  }
1748
1788
  set value(newVal) {
1789
+ if (this._shallow && isRef(this._raw[this._key])) {
1790
+ const nestedRef = this._object[this._key];
1791
+ if (isRef(nestedRef)) {
1792
+ nestedRef.value = newVal;
1793
+ return;
1794
+ }
1795
+ }
1749
1796
  this._object[this._key] = newVal;
1750
1797
  }
1751
1798
  get dep() {
1752
- return getDepFromReactive(toRaw(this._object), this._key);
1799
+ return getDepFromReactive(this._raw, this._key);
1753
1800
  }
1754
1801
  }
1755
1802
  class GetterRefImpl {
@@ -1775,8 +1822,7 @@ function toRef(source, key, defaultValue) {
1775
1822
  }
1776
1823
  }
1777
1824
  function propertyToRef(source, key, defaultValue) {
1778
- const val = source[key];
1779
- return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1825
+ return new ObjectRefImpl(source, key, defaultValue);
1780
1826
  }
1781
1827
 
1782
1828
  class ComputedRefImpl {
@@ -5248,7 +5294,6 @@ const PublicInstanceProxyHandlers = {
5248
5294
  return true;
5249
5295
  }
5250
5296
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
5251
- let normalizedProps;
5252
5297
  if (key[0] !== "$") {
5253
5298
  const n = accessCache[key];
5254
5299
  if (n !== void 0) {
@@ -5268,11 +5313,7 @@ const PublicInstanceProxyHandlers = {
5268
5313
  } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5269
5314
  accessCache[key] = 2 /* DATA */;
5270
5315
  return data[key];
5271
- } else if (
5272
- // only cache other properties when instance has declared (thus stable)
5273
- // props
5274
- (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
5275
- ) {
5316
+ } else if (hasOwn(props, key)) {
5276
5317
  accessCache[key] = 3 /* PROPS */;
5277
5318
  return props[key];
5278
5319
  } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
@@ -5333,10 +5374,10 @@ const PublicInstanceProxyHandlers = {
5333
5374
  return true;
5334
5375
  },
5335
5376
  has({
5336
- _: { data, setupState, accessCache, ctx, appContext, propsOptions, type }
5377
+ _: { data, setupState, accessCache, ctx, appContext, props, type }
5337
5378
  }, key) {
5338
- let normalizedProps, cssModules;
5339
- return !!(accessCache[key] || data !== EMPTY_OBJ && key[0] !== "$" && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
5379
+ let cssModules;
5380
+ return !!(accessCache[key] || data !== EMPTY_OBJ && key[0] !== "$" && hasOwn(data, key) || hasSetupBinding(setupState, key) || hasOwn(props, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
5340
5381
  },
5341
5382
  defineProperty(target, key, descriptor) {
5342
5383
  if (descriptor.get != null) {
@@ -5872,7 +5913,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5872
5913
  return vm;
5873
5914
  }
5874
5915
  }
5875
- Vue.version = `2.6.14-compat:${"3.5.24"}`;
5916
+ Vue.version = `2.6.14-compat:${"3.5.25"}`;
5876
5917
  Vue.config = singletonApp.config;
5877
5918
  Vue.use = (plugin, ...options) => {
5878
5919
  if (plugin && isFunction(plugin.install)) {
@@ -6340,7 +6381,7 @@ function createAppAPI(render, hydrate) {
6340
6381
  let currentApp = null;
6341
6382
 
6342
6383
  function provide(key, value) {
6343
- if (!currentInstance) ; else {
6384
+ if (currentInstance) {
6344
6385
  let provides = currentInstance.provides;
6345
6386
  const parentProvides = currentInstance.parent && currentInstance.parent.provides;
6346
6387
  if (parentProvides === provides) {
@@ -6364,1037 +6405,1536 @@ function hasInjectionContext() {
6364
6405
  return !!(getCurrentInstance() || currentApp);
6365
6406
  }
6366
6407
 
6367
- function createPropsDefaultThis(instance, rawProps, propKey) {
6368
- return new Proxy(
6369
- {},
6370
- {
6371
- get(_, key) {
6372
- if (key === "$options") {
6373
- return resolveMergedOptions(instance);
6374
- }
6375
- if (key in rawProps) {
6376
- return rawProps[key];
6377
- }
6378
- const injections = instance.type.inject;
6379
- if (injections) {
6380
- if (isArray(injections)) {
6381
- if (injections.includes(key)) {
6382
- return inject(key);
6383
- }
6384
- } else if (key in injections) {
6385
- return inject(key);
6386
- }
6387
- }
6388
- }
6389
- }
6408
+ const ssrContextKey = Symbol.for("v-scx");
6409
+ const useSSRContext = () => {
6410
+ {
6411
+ const ctx = inject(ssrContextKey);
6412
+ return ctx;
6413
+ }
6414
+ };
6415
+
6416
+ function watchEffect(effect, options) {
6417
+ return doWatch(effect, null, options);
6418
+ }
6419
+ function watchPostEffect(effect, options) {
6420
+ return doWatch(
6421
+ effect,
6422
+ null,
6423
+ { flush: "post" }
6390
6424
  );
6391
6425
  }
6392
-
6393
- function shouldSkipAttr(key, instance) {
6394
- if (key === "is") {
6395
- return true;
6396
- }
6397
- if ((key === "class" || key === "style") && isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
6398
- return true;
6399
- }
6400
- if (isOn(key) && isCompatEnabled$1("INSTANCE_LISTENERS", instance)) {
6401
- return true;
6402
- }
6403
- if (key.startsWith("routerView") || key === "registerRouteInstance") {
6404
- return true;
6405
- }
6406
- return false;
6426
+ function watchSyncEffect(effect, options) {
6427
+ return doWatch(
6428
+ effect,
6429
+ null,
6430
+ { flush: "sync" }
6431
+ );
6407
6432
  }
6408
-
6409
- const internalObjectProto = {};
6410
- const createInternalObject = () => Object.create(internalObjectProto);
6411
- const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
6412
-
6413
- function initProps(instance, rawProps, isStateful, isSSR = false) {
6414
- const props = {};
6415
- const attrs = createInternalObject();
6416
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
6417
- setFullProps(instance, rawProps, props, attrs);
6418
- for (const key in instance.propsOptions[0]) {
6419
- if (!(key in props)) {
6420
- props[key] = void 0;
6421
- }
6422
- }
6423
- if (isStateful) {
6424
- instance.props = isSSR ? props : shallowReactive(props);
6425
- } else {
6426
- if (!instance.type.props) {
6427
- instance.props = attrs;
6428
- } else {
6429
- instance.props = props;
6433
+ function watch(source, cb, options) {
6434
+ return doWatch(source, cb, options);
6435
+ }
6436
+ function doWatch(source, cb, options = EMPTY_OBJ) {
6437
+ const { immediate, deep, flush, once } = options;
6438
+ const baseWatchOptions = extend$1({}, options);
6439
+ const runsImmediately = cb && immediate || !cb && flush !== "post";
6440
+ let ssrCleanup;
6441
+ if (isInSSRComponentSetup) {
6442
+ if (flush === "sync") {
6443
+ const ctx = useSSRContext();
6444
+ ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
6445
+ } else if (!runsImmediately) {
6446
+ const watchStopHandle = () => {
6447
+ };
6448
+ watchStopHandle.stop = NOOP;
6449
+ watchStopHandle.resume = NOOP;
6450
+ watchStopHandle.pause = NOOP;
6451
+ return watchStopHandle;
6430
6452
  }
6431
6453
  }
6432
- instance.attrs = attrs;
6433
- }
6434
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
6435
- const {
6436
- props,
6437
- attrs,
6438
- vnode: { patchFlag }
6439
- } = instance;
6440
- const rawCurrentProps = toRaw(props);
6441
- const [options] = instance.propsOptions;
6442
- let hasAttrsChanged = false;
6443
- if (
6444
- // always force full diff in dev
6445
- // - #1942 if hmr is enabled with sfc component
6446
- // - vite#872 non-sfc component used by sfc component
6447
- (optimized || patchFlag > 0) && !(patchFlag & 16)
6448
- ) {
6449
- if (patchFlag & 8) {
6450
- const propsToUpdate = instance.vnode.dynamicProps;
6451
- for (let i = 0; i < propsToUpdate.length; i++) {
6452
- let key = propsToUpdate[i];
6453
- if (isEmitListener(instance.emitsOptions, key)) {
6454
- continue;
6455
- }
6456
- const value = rawProps[key];
6457
- if (options) {
6458
- if (hasOwn(attrs, key)) {
6459
- if (value !== attrs[key]) {
6460
- attrs[key] = value;
6461
- hasAttrsChanged = true;
6462
- }
6463
- } else {
6464
- const camelizedKey = camelize(key);
6465
- props[camelizedKey] = resolvePropValue(
6466
- options,
6467
- rawCurrentProps,
6468
- camelizedKey,
6469
- value,
6470
- instance,
6471
- false
6472
- );
6473
- }
6474
- } else {
6475
- {
6476
- if (isOn(key) && key.endsWith("Native")) {
6477
- key = key.slice(0, -6);
6478
- } else if (shouldSkipAttr(key, instance)) {
6479
- continue;
6480
- }
6481
- }
6482
- if (value !== attrs[key]) {
6483
- attrs[key] = value;
6484
- hasAttrsChanged = true;
6485
- }
6486
- }
6454
+ const instance = currentInstance;
6455
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
6456
+ let isPre = false;
6457
+ if (flush === "post") {
6458
+ baseWatchOptions.scheduler = (job) => {
6459
+ queuePostRenderEffect(job, instance && instance.suspense);
6460
+ };
6461
+ } else if (flush !== "sync") {
6462
+ isPre = true;
6463
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
6464
+ if (isFirstRun) {
6465
+ job();
6466
+ } else {
6467
+ queueJob(job);
6487
6468
  }
6469
+ };
6470
+ }
6471
+ baseWatchOptions.augmentJob = (job) => {
6472
+ if (cb) {
6473
+ job.flags |= 4;
6488
6474
  }
6489
- } else {
6490
- if (setFullProps(instance, rawProps, props, attrs)) {
6491
- hasAttrsChanged = true;
6492
- }
6493
- let kebabKey;
6494
- for (const key in rawCurrentProps) {
6495
- if (!rawProps || // for camelCase
6496
- !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
6497
- // and converted to camelCase (#955)
6498
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
6499
- if (options) {
6500
- if (rawPrevProps && // for camelCase
6501
- (rawPrevProps[key] !== void 0 || // for kebab-case
6502
- rawPrevProps[kebabKey] !== void 0)) {
6503
- props[key] = resolvePropValue(
6504
- options,
6505
- rawCurrentProps,
6506
- key,
6507
- void 0,
6508
- instance,
6509
- true
6510
- );
6511
- }
6512
- } else {
6513
- delete props[key];
6514
- }
6475
+ if (isPre) {
6476
+ job.flags |= 2;
6477
+ if (instance) {
6478
+ job.id = instance.uid;
6479
+ job.i = instance;
6515
6480
  }
6516
6481
  }
6517
- if (attrs !== rawCurrentProps) {
6518
- for (const key in attrs) {
6519
- if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
6520
- delete attrs[key];
6521
- hasAttrsChanged = true;
6522
- }
6523
- }
6482
+ };
6483
+ const watchHandle = watch$1(source, cb, baseWatchOptions);
6484
+ if (isInSSRComponentSetup) {
6485
+ if (ssrCleanup) {
6486
+ ssrCleanup.push(watchHandle);
6487
+ } else if (runsImmediately) {
6488
+ watchHandle();
6524
6489
  }
6525
6490
  }
6526
- if (hasAttrsChanged) {
6527
- trigger(instance.attrs, "set", "");
6491
+ return watchHandle;
6492
+ }
6493
+ function instanceWatch(source, value, options) {
6494
+ const publicThis = this.proxy;
6495
+ const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
6496
+ let cb;
6497
+ if (isFunction(value)) {
6498
+ cb = value;
6499
+ } else {
6500
+ cb = value.handler;
6501
+ options = value;
6528
6502
  }
6503
+ const reset = setCurrentInstance(this);
6504
+ const res = doWatch(getter, cb.bind(publicThis), options);
6505
+ reset();
6506
+ return res;
6529
6507
  }
6530
- function setFullProps(instance, rawProps, props, attrs) {
6531
- const [options, needCastKeys] = instance.propsOptions;
6532
- let hasAttrsChanged = false;
6533
- let rawCastValues;
6534
- if (rawProps) {
6535
- for (let key in rawProps) {
6536
- if (isReservedProp(key)) {
6537
- continue;
6508
+ function createPathGetter(ctx, path) {
6509
+ const segments = path.split(".");
6510
+ return () => {
6511
+ let cur = ctx;
6512
+ for (let i = 0; i < segments.length && cur; i++) {
6513
+ cur = cur[segments[i]];
6514
+ }
6515
+ return cur;
6516
+ };
6517
+ }
6518
+
6519
+ function useModel(props, name, options = EMPTY_OBJ) {
6520
+ const i = getCurrentInstance();
6521
+ const camelizedName = camelize(name);
6522
+ const hyphenatedName = hyphenate(name);
6523
+ const modifiers = getModelModifiers(props, camelizedName);
6524
+ const res = customRef((track, trigger) => {
6525
+ let localValue;
6526
+ let prevSetValue = EMPTY_OBJ;
6527
+ let prevEmittedValue;
6528
+ watchSyncEffect(() => {
6529
+ const propValue = props[camelizedName];
6530
+ if (hasChanged(localValue, propValue)) {
6531
+ localValue = propValue;
6532
+ trigger();
6538
6533
  }
6539
- {
6540
- if (key.startsWith("onHook:")) {
6541
- softAssertCompatEnabled(
6542
- "INSTANCE_EVENT_HOOKS",
6543
- instance,
6544
- key.slice(2).toLowerCase()
6545
- );
6534
+ });
6535
+ return {
6536
+ get() {
6537
+ track();
6538
+ return options.get ? options.get(localValue) : localValue;
6539
+ },
6540
+ set(value) {
6541
+ const emittedValue = options.set ? options.set(value) : value;
6542
+ if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
6543
+ return;
6546
6544
  }
6547
- if (key === "inline-template") {
6548
- continue;
6545
+ const rawProps = i.vnode.props;
6546
+ if (!(rawProps && // check if parent has passed v-model
6547
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
6548
+ localValue = value;
6549
+ trigger();
6550
+ }
6551
+ i.emit(`update:${name}`, emittedValue);
6552
+ if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
6553
+ trigger();
6549
6554
  }
6555
+ prevSetValue = value;
6556
+ prevEmittedValue = emittedValue;
6550
6557
  }
6551
- const value = rawProps[key];
6552
- let camelKey;
6553
- if (options && hasOwn(options, camelKey = camelize(key))) {
6554
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
6555
- props[camelKey] = value;
6558
+ };
6559
+ });
6560
+ res[Symbol.iterator] = () => {
6561
+ let i2 = 0;
6562
+ return {
6563
+ next() {
6564
+ if (i2 < 2) {
6565
+ return { value: i2++ ? modifiers || EMPTY_OBJ : res, done: false };
6556
6566
  } else {
6557
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
6558
- }
6559
- } else if (!isEmitListener(instance.emitsOptions, key)) {
6560
- {
6561
- if (isOn(key) && key.endsWith("Native")) {
6562
- key = key.slice(0, -6);
6563
- } else if (shouldSkipAttr(key, instance)) {
6564
- continue;
6565
- }
6566
- }
6567
- if (!(key in attrs) || value !== attrs[key]) {
6568
- attrs[key] = value;
6569
- hasAttrsChanged = true;
6567
+ return { done: true };
6570
6568
  }
6571
6569
  }
6570
+ };
6571
+ };
6572
+ return res;
6573
+ }
6574
+ const getModelModifiers = (props, modelName) => {
6575
+ return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize(modelName)}Modifiers`] || props[`${hyphenate(modelName)}Modifiers`];
6576
+ };
6577
+
6578
+ function emit(instance, event, ...rawArgs) {
6579
+ if (instance.isUnmounted) return;
6580
+ const props = instance.vnode.props || EMPTY_OBJ;
6581
+ let args = rawArgs;
6582
+ const isCompatModelListener = compatModelEventPrefix + event in props;
6583
+ const isModelListener = isCompatModelListener || event.startsWith("update:");
6584
+ const modifiers = isCompatModelListener ? props.modelModifiers : isModelListener && getModelModifiers(props, event.slice(7));
6585
+ if (modifiers) {
6586
+ if (modifiers.trim) {
6587
+ args = rawArgs.map((a) => isString(a) ? a.trim() : a);
6572
6588
  }
6573
- }
6574
- if (needCastKeys) {
6575
- const rawCurrentProps = toRaw(props);
6576
- const castValues = rawCastValues || EMPTY_OBJ;
6577
- for (let i = 0; i < needCastKeys.length; i++) {
6578
- const key = needCastKeys[i];
6579
- props[key] = resolvePropValue(
6580
- options,
6581
- rawCurrentProps,
6582
- key,
6583
- castValues[key],
6584
- instance,
6585
- !hasOwn(castValues, key)
6586
- );
6589
+ if (modifiers.number) {
6590
+ args = rawArgs.map(looseToNumber);
6587
6591
  }
6588
6592
  }
6589
- return hasAttrsChanged;
6590
- }
6591
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
6592
- const opt = options[key];
6593
- if (opt != null) {
6594
- const hasDefault = hasOwn(opt, "default");
6595
- if (hasDefault && value === void 0) {
6596
- const defaultValue = opt.default;
6597
- if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
6598
- const { propsDefaults } = instance;
6599
- if (key in propsDefaults) {
6600
- value = propsDefaults[key];
6601
- } else {
6602
- const reset = setCurrentInstance(instance);
6603
- value = propsDefaults[key] = defaultValue.call(
6604
- isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props) : null,
6605
- props
6606
- );
6607
- reset();
6608
- }
6609
- } else {
6610
- value = defaultValue;
6611
- }
6612
- if (instance.ce) {
6613
- instance.ce._setProp(key, value);
6614
- }
6615
- }
6616
- if (opt[0 /* shouldCast */]) {
6617
- if (isAbsent && !hasDefault) {
6618
- value = false;
6619
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
6620
- value = true;
6621
- }
6593
+ let handlerName;
6594
+ let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
6595
+ props[handlerName = toHandlerKey(camelize(event))];
6596
+ if (!handler && isModelListener) {
6597
+ handler = props[handlerName = toHandlerKey(hyphenate(event))];
6598
+ }
6599
+ if (handler) {
6600
+ callWithAsyncErrorHandling(
6601
+ handler,
6602
+ instance,
6603
+ 6,
6604
+ args
6605
+ );
6606
+ }
6607
+ const onceHandler = props[handlerName + `Once`];
6608
+ if (onceHandler) {
6609
+ if (!instance.emitted) {
6610
+ instance.emitted = {};
6611
+ } else if (instance.emitted[handlerName]) {
6612
+ return;
6622
6613
  }
6614
+ instance.emitted[handlerName] = true;
6615
+ callWithAsyncErrorHandling(
6616
+ onceHandler,
6617
+ instance,
6618
+ 6,
6619
+ args
6620
+ );
6621
+ }
6622
+ {
6623
+ compatModelEmit(instance, event, args);
6624
+ return emit$1(instance, event, args);
6623
6625
  }
6624
- return value;
6625
6626
  }
6626
- const mixinPropsCache = /* @__PURE__ */ new WeakMap();
6627
- function normalizePropsOptions(comp, appContext, asMixin = false) {
6628
- const cache = asMixin ? mixinPropsCache : appContext.propsCache;
6627
+ const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
6628
+ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
6629
+ const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
6629
6630
  const cached = cache.get(comp);
6630
- if (cached) {
6631
+ if (cached !== void 0) {
6631
6632
  return cached;
6632
6633
  }
6633
- const raw = comp.props;
6634
- const normalized = {};
6635
- const needCastKeys = [];
6634
+ const raw = comp.emits;
6635
+ let normalized = {};
6636
6636
  let hasExtends = false;
6637
6637
  if (!isFunction(comp)) {
6638
- const extendProps = (raw2) => {
6639
- if (isFunction(raw2)) {
6640
- raw2 = raw2.options;
6638
+ const extendEmits = (raw2) => {
6639
+ const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
6640
+ if (normalizedFromExtend) {
6641
+ hasExtends = true;
6642
+ extend$1(normalized, normalizedFromExtend);
6641
6643
  }
6642
- hasExtends = true;
6643
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
6644
- extend$1(normalized, props);
6645
- if (keys) needCastKeys.push(...keys);
6646
6644
  };
6647
6645
  if (!asMixin && appContext.mixins.length) {
6648
- appContext.mixins.forEach(extendProps);
6646
+ appContext.mixins.forEach(extendEmits);
6649
6647
  }
6650
6648
  if (comp.extends) {
6651
- extendProps(comp.extends);
6649
+ extendEmits(comp.extends);
6652
6650
  }
6653
6651
  if (comp.mixins) {
6654
- comp.mixins.forEach(extendProps);
6652
+ comp.mixins.forEach(extendEmits);
6655
6653
  }
6656
6654
  }
6657
6655
  if (!raw && !hasExtends) {
6658
6656
  if (isObject(comp)) {
6659
- cache.set(comp, EMPTY_ARR);
6657
+ cache.set(comp, null);
6660
6658
  }
6661
- return EMPTY_ARR;
6659
+ return null;
6662
6660
  }
6663
6661
  if (isArray(raw)) {
6664
- for (let i = 0; i < raw.length; i++) {
6665
- const normalizedKey = camelize(raw[i]);
6666
- if (validatePropName(normalizedKey)) {
6667
- normalized[normalizedKey] = EMPTY_OBJ;
6668
- }
6669
- }
6670
- } else if (raw) {
6671
- for (const key in raw) {
6672
- const normalizedKey = camelize(key);
6673
- if (validatePropName(normalizedKey)) {
6674
- const opt = raw[key];
6675
- const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend$1({}, opt);
6676
- const propType = prop.type;
6677
- let shouldCast = false;
6678
- let shouldCastTrue = true;
6679
- if (isArray(propType)) {
6680
- for (let index = 0; index < propType.length; ++index) {
6681
- const type = propType[index];
6682
- const typeName = isFunction(type) && type.name;
6683
- if (typeName === "Boolean") {
6684
- shouldCast = true;
6685
- break;
6686
- } else if (typeName === "String") {
6687
- shouldCastTrue = false;
6688
- }
6689
- }
6690
- } else {
6691
- shouldCast = isFunction(propType) && propType.name === "Boolean";
6692
- }
6693
- prop[0 /* shouldCast */] = shouldCast;
6694
- prop[1 /* shouldCastTrue */] = shouldCastTrue;
6695
- if (shouldCast || hasOwn(prop, "default")) {
6696
- needCastKeys.push(normalizedKey);
6697
- }
6698
- }
6699
- }
6662
+ raw.forEach((key) => normalized[key] = null);
6663
+ } else {
6664
+ extend$1(normalized, raw);
6700
6665
  }
6701
- const res = [normalized, needCastKeys];
6702
6666
  if (isObject(comp)) {
6703
- cache.set(comp, res);
6667
+ cache.set(comp, normalized);
6704
6668
  }
6705
- return res;
6669
+ return normalized;
6706
6670
  }
6707
- function validatePropName(key) {
6708
- if (key[0] !== "$" && !isReservedProp(key)) {
6671
+ function isEmitListener(options, key) {
6672
+ if (!options || !isOn(key)) {
6673
+ return false;
6674
+ }
6675
+ if (key.startsWith(compatModelEventPrefix)) {
6709
6676
  return true;
6710
6677
  }
6711
- return false;
6678
+ key = key.slice(2).replace(/Once$/, "");
6679
+ return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
6712
6680
  }
6713
6681
 
6714
- const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
6715
- const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
6716
- const normalizeSlot = (key, rawSlot, ctx) => {
6717
- if (rawSlot._n) {
6718
- return rawSlot;
6719
- }
6720
- const normalized = withCtx((...args) => {
6721
- if (false) ;
6722
- return normalizeSlotValue(rawSlot(...args));
6723
- }, ctx);
6724
- normalized._c = false;
6725
- return normalized;
6726
- };
6727
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
6728
- const ctx = rawSlots._ctx;
6729
- for (const key in rawSlots) {
6730
- if (isInternalKey(key)) continue;
6731
- const value = rawSlots[key];
6732
- if (isFunction(value)) {
6733
- slots[key] = normalizeSlot(key, value, ctx);
6734
- } else if (value != null) {
6735
- const normalized = normalizeSlotValue(value);
6736
- slots[key] = () => normalized;
6682
+ function markAttrsAccessed() {
6683
+ }
6684
+ function renderComponentRoot(instance) {
6685
+ const {
6686
+ type: Component,
6687
+ vnode,
6688
+ proxy,
6689
+ withProxy,
6690
+ propsOptions: [propsOptions],
6691
+ slots,
6692
+ attrs,
6693
+ emit,
6694
+ render,
6695
+ renderCache,
6696
+ props,
6697
+ data,
6698
+ setupState,
6699
+ ctx,
6700
+ inheritAttrs
6701
+ } = instance;
6702
+ const prev = setCurrentRenderingInstance(instance);
6703
+ let result;
6704
+ let fallthroughAttrs;
6705
+ try {
6706
+ if (vnode.shapeFlag & 4) {
6707
+ const proxyToUse = withProxy || proxy;
6708
+ const thisProxy = false ? new Proxy(proxyToUse, {
6709
+ get(target, key, receiver) {
6710
+ warn(
6711
+ `Property '${String(
6712
+ key
6713
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
6714
+ );
6715
+ return Reflect.get(target, key, receiver);
6716
+ }
6717
+ }) : proxyToUse;
6718
+ result = normalizeVNode(
6719
+ render.call(
6720
+ thisProxy,
6721
+ proxyToUse,
6722
+ renderCache,
6723
+ false ? shallowReadonly(props) : props,
6724
+ setupState,
6725
+ data,
6726
+ ctx
6727
+ )
6728
+ );
6729
+ fallthroughAttrs = attrs;
6730
+ } else {
6731
+ const render2 = Component;
6732
+ if (false) ;
6733
+ result = normalizeVNode(
6734
+ render2.length > 1 ? render2(
6735
+ false ? shallowReadonly(props) : props,
6736
+ false ? {
6737
+ get attrs() {
6738
+ markAttrsAccessed();
6739
+ return shallowReadonly(attrs);
6740
+ },
6741
+ slots,
6742
+ emit
6743
+ } : { attrs, slots, emit }
6744
+ ) : render2(
6745
+ false ? shallowReadonly(props) : props,
6746
+ null
6747
+ )
6748
+ );
6749
+ fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
6737
6750
  }
6751
+ } catch (err) {
6752
+ blockStack.length = 0;
6753
+ handleError(err, instance, 1);
6754
+ result = createVNode(Comment);
6738
6755
  }
6739
- };
6740
- const normalizeVNodeSlots = (instance, children) => {
6741
- const normalized = normalizeSlotValue(children);
6742
- instance.slots.default = () => normalized;
6743
- };
6744
- const assignSlots = (slots, children, optimized) => {
6745
- for (const key in children) {
6746
- if (optimized || !isInternalKey(key)) {
6747
- slots[key] = children[key];
6756
+ let root = result;
6757
+ if (fallthroughAttrs && inheritAttrs !== false) {
6758
+ const keys = Object.keys(fallthroughAttrs);
6759
+ const { shapeFlag } = root;
6760
+ if (keys.length) {
6761
+ if (shapeFlag & (1 | 6)) {
6762
+ if (propsOptions && keys.some(isModelListener)) {
6763
+ fallthroughAttrs = filterModelListeners(
6764
+ fallthroughAttrs,
6765
+ propsOptions
6766
+ );
6767
+ }
6768
+ root = cloneVNode(root, fallthroughAttrs, false, true);
6769
+ }
6748
6770
  }
6749
6771
  }
6750
- };
6751
- const initSlots = (instance, children, optimized) => {
6752
- const slots = instance.slots = createInternalObject();
6753
- if (instance.vnode.shapeFlag & 32) {
6754
- const type = children._;
6755
- if (type) {
6756
- assignSlots(slots, children, optimized);
6757
- if (optimized) {
6758
- def(slots, "_", type, true);
6759
- }
6760
- } else {
6761
- normalizeObjectSlots(children, slots);
6772
+ if (isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance) && vnode.shapeFlag & 4 && root.shapeFlag & (1 | 6)) {
6773
+ const { class: cls, style } = vnode.props || {};
6774
+ if (cls || style) {
6775
+ root = cloneVNode(
6776
+ root,
6777
+ {
6778
+ class: cls,
6779
+ style
6780
+ },
6781
+ false,
6782
+ true
6783
+ );
6762
6784
  }
6763
- } else if (children) {
6764
- normalizeVNodeSlots(instance, children);
6765
6785
  }
6766
- };
6767
- const updateSlots = (instance, children, optimized) => {
6768
- const { vnode, slots } = instance;
6769
- let needDeletionCheck = true;
6770
- let deletionComparisonTarget = EMPTY_OBJ;
6771
- if (vnode.shapeFlag & 32) {
6772
- const type = children._;
6773
- if (type) {
6774
- if (optimized && type === 1) {
6775
- needDeletionCheck = false;
6776
- } else {
6777
- assignSlots(slots, children, optimized);
6786
+ if (vnode.dirs) {
6787
+ root = cloneVNode(root, null, false, true);
6788
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
6789
+ }
6790
+ if (vnode.transition) {
6791
+ setTransitionHooks(root, vnode.transition);
6792
+ }
6793
+ {
6794
+ result = root;
6795
+ }
6796
+ setCurrentRenderingInstance(prev);
6797
+ return result;
6798
+ }
6799
+ function filterSingleRoot(children, recurse = true) {
6800
+ let singleRoot;
6801
+ for (let i = 0; i < children.length; i++) {
6802
+ const child = children[i];
6803
+ if (isVNode(child)) {
6804
+ if (child.type !== Comment || child.children === "v-if") {
6805
+ if (singleRoot) {
6806
+ return;
6807
+ } else {
6808
+ singleRoot = child;
6809
+ }
6778
6810
  }
6779
6811
  } else {
6780
- needDeletionCheck = !children.$stable;
6781
- normalizeObjectSlots(children, slots);
6812
+ return;
6782
6813
  }
6783
- deletionComparisonTarget = children;
6784
- } else if (children) {
6785
- normalizeVNodeSlots(instance, children);
6786
- deletionComparisonTarget = { default: 1 };
6787
6814
  }
6788
- if (needDeletionCheck) {
6789
- for (const key in slots) {
6790
- if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
6791
- delete slots[key];
6792
- }
6815
+ return singleRoot;
6816
+ }
6817
+ const getFunctionalFallthrough = (attrs) => {
6818
+ let res;
6819
+ for (const key in attrs) {
6820
+ if (key === "class" || key === "style" || isOn(key)) {
6821
+ (res || (res = {}))[key] = attrs[key];
6793
6822
  }
6794
6823
  }
6824
+ return res;
6795
6825
  };
6796
-
6797
- const queuePostRenderEffect = queueEffectWithSuspense ;
6798
- function createRenderer(options) {
6799
- return baseCreateRenderer(options);
6800
- }
6801
- function createHydrationRenderer(options) {
6802
- return baseCreateRenderer(options, createHydrationFunctions);
6803
- }
6804
- function baseCreateRenderer(options, createHydrationFns) {
6805
- const target = getGlobalThis();
6806
- target.__VUE__ = true;
6807
- const {
6808
- insert: hostInsert,
6809
- remove: hostRemove,
6810
- patchProp: hostPatchProp,
6811
- createElement: hostCreateElement,
6812
- createText: hostCreateText,
6813
- createComment: hostCreateComment,
6814
- setText: hostSetText,
6815
- setElementText: hostSetElementText,
6816
- parentNode: hostParentNode,
6817
- nextSibling: hostNextSibling,
6818
- setScopeId: hostSetScopeId = NOOP,
6819
- insertStaticContent: hostInsertStaticContent
6820
- } = options;
6821
- const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
6822
- if (n1 === n2) {
6823
- return;
6824
- }
6825
- if (n1 && !isSameVNodeType(n1, n2)) {
6826
- anchor = getNextHostNode(n1);
6827
- unmount(n1, parentComponent, parentSuspense, true);
6828
- n1 = null;
6826
+ const filterModelListeners = (attrs, props) => {
6827
+ const res = {};
6828
+ for (const key in attrs) {
6829
+ if (!isModelListener(key) || !(key.slice(9) in props)) {
6830
+ res[key] = attrs[key];
6829
6831
  }
6830
- if (n2.patchFlag === -2) {
6831
- optimized = false;
6832
- n2.dynamicChildren = null;
6832
+ }
6833
+ return res;
6834
+ };
6835
+ function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
6836
+ const { props: prevProps, children: prevChildren, component } = prevVNode;
6837
+ const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
6838
+ const emits = component.emitsOptions;
6839
+ if (nextVNode.dirs || nextVNode.transition) {
6840
+ return true;
6841
+ }
6842
+ if (optimized && patchFlag >= 0) {
6843
+ if (patchFlag & 1024) {
6844
+ return true;
6833
6845
  }
6834
- const { type, ref, shapeFlag } = n2;
6835
- switch (type) {
6836
- case Text:
6837
- processText(n1, n2, container, anchor);
6838
- break;
6839
- case Comment:
6840
- processCommentNode(n1, n2, container, anchor);
6841
- break;
6842
- case Static:
6843
- if (n1 == null) {
6844
- mountStaticNode(n2, container, anchor, namespace);
6846
+ if (patchFlag & 16) {
6847
+ if (!prevProps) {
6848
+ return !!nextProps;
6849
+ }
6850
+ return hasPropsChanged(prevProps, nextProps, emits);
6851
+ } else if (patchFlag & 8) {
6852
+ const dynamicProps = nextVNode.dynamicProps;
6853
+ for (let i = 0; i < dynamicProps.length; i++) {
6854
+ const key = dynamicProps[i];
6855
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
6856
+ return true;
6845
6857
  }
6846
- break;
6847
- case Fragment:
6848
- processFragment(
6849
- n1,
6850
- n2,
6851
- container,
6852
- anchor,
6853
- parentComponent,
6854
- parentSuspense,
6855
- namespace,
6856
- slotScopeIds,
6857
- optimized
6858
- );
6859
- break;
6860
- default:
6861
- if (shapeFlag & 1) {
6862
- processElement(
6863
- n1,
6864
- n2,
6865
- container,
6866
- anchor,
6867
- parentComponent,
6868
- parentSuspense,
6869
- namespace,
6870
- slotScopeIds,
6871
- optimized
6872
- );
6873
- } else if (shapeFlag & 6) {
6874
- processComponent(
6875
- n1,
6876
- n2,
6877
- container,
6878
- anchor,
6879
- parentComponent,
6880
- parentSuspense,
6881
- namespace,
6882
- slotScopeIds,
6883
- optimized
6884
- );
6885
- } else if (shapeFlag & 64) {
6886
- type.process(
6887
- n1,
6888
- n2,
6889
- container,
6890
- anchor,
6891
- parentComponent,
6892
- parentSuspense,
6893
- namespace,
6894
- slotScopeIds,
6895
- optimized,
6896
- internals
6897
- );
6898
- } else if (shapeFlag & 128) {
6899
- type.process(
6900
- n1,
6901
- n2,
6902
- container,
6903
- anchor,
6904
- parentComponent,
6905
- parentSuspense,
6906
- namespace,
6907
- slotScopeIds,
6908
- optimized,
6909
- internals
6910
- );
6911
- } else ;
6912
- }
6913
- if (ref != null && parentComponent) {
6914
- setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
6915
- } else if (ref == null && n1 && n1.ref != null) {
6916
- setRef(n1.ref, null, parentSuspense, n1, true);
6858
+ }
6917
6859
  }
6918
- };
6919
- const processText = (n1, n2, container, anchor) => {
6920
- if (n1 == null) {
6921
- hostInsert(
6922
- n2.el = hostCreateText(n2.children),
6923
- container,
6924
- anchor
6925
- );
6926
- } else {
6927
- const el = n2.el = n1.el;
6928
- if (n2.children !== n1.children) {
6929
- hostSetText(el, n2.children);
6860
+ } else {
6861
+ if (prevChildren || nextChildren) {
6862
+ if (!nextChildren || !nextChildren.$stable) {
6863
+ return true;
6930
6864
  }
6931
6865
  }
6932
- };
6933
- const processCommentNode = (n1, n2, container, anchor) => {
6934
- if (n1 == null) {
6935
- hostInsert(
6936
- n2.el = hostCreateComment(n2.children || ""),
6937
- container,
6938
- anchor
6939
- );
6940
- } else {
6941
- n2.el = n1.el;
6866
+ if (prevProps === nextProps) {
6867
+ return false;
6942
6868
  }
6943
- };
6944
- const mountStaticNode = (n2, container, anchor, namespace) => {
6945
- [n2.el, n2.anchor] = hostInsertStaticContent(
6946
- n2.children,
6947
- container,
6948
- anchor,
6949
- namespace,
6950
- n2.el,
6951
- n2.anchor
6952
- );
6953
- };
6954
- const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
6955
- let next;
6956
- while (el && el !== anchor) {
6957
- next = hostNextSibling(el);
6958
- hostInsert(el, container, nextSibling);
6959
- el = next;
6869
+ if (!prevProps) {
6870
+ return !!nextProps;
6960
6871
  }
6961
- hostInsert(anchor, container, nextSibling);
6962
- };
6963
- const removeStaticNode = ({ el, anchor }) => {
6964
- let next;
6965
- while (el && el !== anchor) {
6966
- next = hostNextSibling(el);
6967
- hostRemove(el);
6968
- el = next;
6872
+ if (!nextProps) {
6873
+ return true;
6969
6874
  }
6970
- hostRemove(anchor);
6971
- };
6972
- const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
6973
- if (n2.type === "svg") {
6974
- namespace = "svg";
6975
- } else if (n2.type === "math") {
6976
- namespace = "mathml";
6875
+ return hasPropsChanged(prevProps, nextProps, emits);
6876
+ }
6877
+ return false;
6878
+ }
6879
+ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
6880
+ const nextKeys = Object.keys(nextProps);
6881
+ if (nextKeys.length !== Object.keys(prevProps).length) {
6882
+ return true;
6883
+ }
6884
+ for (let i = 0; i < nextKeys.length; i++) {
6885
+ const key = nextKeys[i];
6886
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
6887
+ return true;
6977
6888
  }
6978
- if (n1 == null) {
6979
- mountElement(
6980
- n2,
6981
- container,
6982
- anchor,
6983
- parentComponent,
6984
- parentSuspense,
6985
- namespace,
6986
- slotScopeIds,
6987
- optimized
6988
- );
6889
+ }
6890
+ return false;
6891
+ }
6892
+ function updateHOCHostEl({ vnode, parent }, el) {
6893
+ while (parent) {
6894
+ const root = parent.subTree;
6895
+ if (root.suspense && root.suspense.activeBranch === vnode) {
6896
+ root.el = vnode.el;
6897
+ }
6898
+ if (root === vnode) {
6899
+ (vnode = parent.vnode).el = el;
6900
+ parent = parent.parent;
6989
6901
  } else {
6990
- const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
6991
- try {
6992
- if (customElement) {
6993
- customElement._beginPatch();
6902
+ break;
6903
+ }
6904
+ }
6905
+ }
6906
+
6907
+ function createPropsDefaultThis(instance, rawProps, propKey) {
6908
+ return new Proxy(
6909
+ {},
6910
+ {
6911
+ get(_, key) {
6912
+ if (key === "$options") {
6913
+ return resolveMergedOptions(instance);
6994
6914
  }
6995
- patchElement(
6996
- n1,
6997
- n2,
6998
- parentComponent,
6999
- parentSuspense,
7000
- namespace,
7001
- slotScopeIds,
7002
- optimized
7003
- );
7004
- } finally {
7005
- if (customElement) {
7006
- customElement._endPatch();
6915
+ if (key in rawProps) {
6916
+ return rawProps[key];
6917
+ }
6918
+ const injections = instance.type.inject;
6919
+ if (injections) {
6920
+ if (isArray(injections)) {
6921
+ if (injections.includes(key)) {
6922
+ return inject(key);
6923
+ }
6924
+ } else if (key in injections) {
6925
+ return inject(key);
6926
+ }
7007
6927
  }
7008
6928
  }
7009
6929
  }
7010
- };
7011
- const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7012
- let el;
7013
- let vnodeHook;
7014
- const { props, shapeFlag, transition, dirs } = vnode;
7015
- el = vnode.el = hostCreateElement(
7016
- vnode.type,
7017
- namespace,
7018
- props && props.is,
7019
- props
7020
- );
7021
- if (shapeFlag & 8) {
7022
- hostSetElementText(el, vnode.children);
7023
- } else if (shapeFlag & 16) {
7024
- mountChildren(
7025
- vnode.children,
7026
- el,
7027
- null,
7028
- parentComponent,
7029
- parentSuspense,
7030
- resolveChildrenNamespace(vnode, namespace),
7031
- slotScopeIds,
7032
- optimized
7033
- );
6930
+ );
6931
+ }
6932
+
6933
+ function shouldSkipAttr(key, instance) {
6934
+ if (key === "is") {
6935
+ return true;
6936
+ }
6937
+ if ((key === "class" || key === "style") && isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
6938
+ return true;
6939
+ }
6940
+ if (isOn(key) && isCompatEnabled$1("INSTANCE_LISTENERS", instance)) {
6941
+ return true;
6942
+ }
6943
+ if (key.startsWith("routerView") || key === "registerRouteInstance") {
6944
+ return true;
6945
+ }
6946
+ return false;
6947
+ }
6948
+
6949
+ const internalObjectProto = {};
6950
+ const createInternalObject = () => Object.create(internalObjectProto);
6951
+ const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
6952
+
6953
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
6954
+ const props = {};
6955
+ const attrs = createInternalObject();
6956
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
6957
+ setFullProps(instance, rawProps, props, attrs);
6958
+ for (const key in instance.propsOptions[0]) {
6959
+ if (!(key in props)) {
6960
+ props[key] = void 0;
7034
6961
  }
7035
- if (dirs) {
7036
- invokeDirectiveHook(vnode, null, parentComponent, "created");
6962
+ }
6963
+ if (isStateful) {
6964
+ instance.props = isSSR ? props : shallowReactive(props);
6965
+ } else {
6966
+ if (!instance.type.props) {
6967
+ instance.props = attrs;
6968
+ } else {
6969
+ instance.props = props;
7037
6970
  }
7038
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
7039
- if (props) {
7040
- for (const key in props) {
7041
- if (key !== "value" && !isReservedProp(key)) {
7042
- hostPatchProp(el, key, null, props[key], namespace, parentComponent);
6971
+ }
6972
+ instance.attrs = attrs;
6973
+ }
6974
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
6975
+ const {
6976
+ props,
6977
+ attrs,
6978
+ vnode: { patchFlag }
6979
+ } = instance;
6980
+ const rawCurrentProps = toRaw(props);
6981
+ const [options] = instance.propsOptions;
6982
+ let hasAttrsChanged = false;
6983
+ if (
6984
+ // always force full diff in dev
6985
+ // - #1942 if hmr is enabled with sfc component
6986
+ // - vite#872 non-sfc component used by sfc component
6987
+ (optimized || patchFlag > 0) && !(patchFlag & 16)
6988
+ ) {
6989
+ if (patchFlag & 8) {
6990
+ const propsToUpdate = instance.vnode.dynamicProps;
6991
+ for (let i = 0; i < propsToUpdate.length; i++) {
6992
+ let key = propsToUpdate[i];
6993
+ if (isEmitListener(instance.emitsOptions, key)) {
6994
+ continue;
6995
+ }
6996
+ const value = rawProps[key];
6997
+ if (options) {
6998
+ if (hasOwn(attrs, key)) {
6999
+ if (value !== attrs[key]) {
7000
+ attrs[key] = value;
7001
+ hasAttrsChanged = true;
7002
+ }
7003
+ } else {
7004
+ const camelizedKey = camelize(key);
7005
+ props[camelizedKey] = resolvePropValue(
7006
+ options,
7007
+ rawCurrentProps,
7008
+ camelizedKey,
7009
+ value,
7010
+ instance,
7011
+ false
7012
+ );
7013
+ }
7014
+ } else {
7015
+ {
7016
+ if (isOn(key) && key.endsWith("Native")) {
7017
+ key = key.slice(0, -6);
7018
+ } else if (shouldSkipAttr(key, instance)) {
7019
+ continue;
7020
+ }
7021
+ }
7022
+ if (value !== attrs[key]) {
7023
+ attrs[key] = value;
7024
+ hasAttrsChanged = true;
7025
+ }
7043
7026
  }
7044
7027
  }
7045
- if ("value" in props) {
7046
- hostPatchProp(el, "value", null, props.value, namespace);
7047
- }
7048
- if (vnodeHook = props.onVnodeBeforeMount) {
7049
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
7050
- }
7051
- }
7052
- if (dirs) {
7053
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7054
- }
7055
- const needCallTransitionHooks = needTransition(parentSuspense, transition);
7056
- if (needCallTransitionHooks) {
7057
- transition.beforeEnter(el);
7058
- }
7059
- hostInsert(el, container, anchor);
7060
- if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
7061
- queuePostRenderEffect(() => {
7062
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7063
- needCallTransitionHooks && transition.enter(el);
7064
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7065
- }, parentSuspense);
7066
7028
  }
7067
- };
7068
- const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
7069
- if (scopeId) {
7070
- hostSetScopeId(el, scopeId);
7029
+ } else {
7030
+ if (setFullProps(instance, rawProps, props, attrs)) {
7031
+ hasAttrsChanged = true;
7071
7032
  }
7072
- if (slotScopeIds) {
7073
- for (let i = 0; i < slotScopeIds.length; i++) {
7074
- hostSetScopeId(el, slotScopeIds[i]);
7033
+ let kebabKey;
7034
+ for (const key in rawCurrentProps) {
7035
+ if (!rawProps || // for camelCase
7036
+ !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
7037
+ // and converted to camelCase (#955)
7038
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
7039
+ if (options) {
7040
+ if (rawPrevProps && // for camelCase
7041
+ (rawPrevProps[key] !== void 0 || // for kebab-case
7042
+ rawPrevProps[kebabKey] !== void 0)) {
7043
+ props[key] = resolvePropValue(
7044
+ options,
7045
+ rawCurrentProps,
7046
+ key,
7047
+ void 0,
7048
+ instance,
7049
+ true
7050
+ );
7051
+ }
7052
+ } else {
7053
+ delete props[key];
7054
+ }
7075
7055
  }
7076
7056
  }
7077
- if (parentComponent) {
7078
- let subTree = parentComponent.subTree;
7079
- if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
7080
- const parentVNode = parentComponent.vnode;
7081
- setScopeId(
7082
- el,
7083
- parentVNode,
7084
- parentVNode.scopeId,
7085
- parentVNode.slotScopeIds,
7086
- parentComponent.parent
7087
- );
7057
+ if (attrs !== rawCurrentProps) {
7058
+ for (const key in attrs) {
7059
+ if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
7060
+ delete attrs[key];
7061
+ hasAttrsChanged = true;
7062
+ }
7088
7063
  }
7089
7064
  }
7090
- };
7091
- const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
7092
- for (let i = start; i < children.length; i++) {
7093
- const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
7094
- patch(
7095
- null,
7096
- child,
7097
- container,
7098
- anchor,
7099
- parentComponent,
7100
- parentSuspense,
7101
- namespace,
7102
- slotScopeIds,
7103
- optimized
7104
- );
7065
+ }
7066
+ if (hasAttrsChanged) {
7067
+ trigger(instance.attrs, "set", "");
7068
+ }
7069
+ }
7070
+ function setFullProps(instance, rawProps, props, attrs) {
7071
+ const [options, needCastKeys] = instance.propsOptions;
7072
+ let hasAttrsChanged = false;
7073
+ let rawCastValues;
7074
+ if (rawProps) {
7075
+ for (let key in rawProps) {
7076
+ if (isReservedProp(key)) {
7077
+ continue;
7078
+ }
7079
+ {
7080
+ if (key.startsWith("onHook:")) {
7081
+ softAssertCompatEnabled(
7082
+ "INSTANCE_EVENT_HOOKS",
7083
+ instance,
7084
+ key.slice(2).toLowerCase()
7085
+ );
7086
+ }
7087
+ if (key === "inline-template") {
7088
+ continue;
7089
+ }
7090
+ }
7091
+ const value = rawProps[key];
7092
+ let camelKey;
7093
+ if (options && hasOwn(options, camelKey = camelize(key))) {
7094
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
7095
+ props[camelKey] = value;
7096
+ } else {
7097
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
7098
+ }
7099
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
7100
+ {
7101
+ if (isOn(key) && key.endsWith("Native")) {
7102
+ key = key.slice(0, -6);
7103
+ } else if (shouldSkipAttr(key, instance)) {
7104
+ continue;
7105
+ }
7106
+ }
7107
+ if (!(key in attrs) || value !== attrs[key]) {
7108
+ attrs[key] = value;
7109
+ hasAttrsChanged = true;
7110
+ }
7111
+ }
7105
7112
  }
7106
- };
7107
- const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7108
- const el = n2.el = n1.el;
7109
- let { patchFlag, dynamicChildren, dirs } = n2;
7110
- patchFlag |= n1.patchFlag & 16;
7111
- const oldProps = n1.props || EMPTY_OBJ;
7112
- const newProps = n2.props || EMPTY_OBJ;
7113
- let vnodeHook;
7114
- parentComponent && toggleRecurse(parentComponent, false);
7115
- if (vnodeHook = newProps.onVnodeBeforeUpdate) {
7116
- invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
7117
- }
7118
- if (dirs) {
7119
- invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
7120
- }
7121
- parentComponent && toggleRecurse(parentComponent, true);
7122
- if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
7123
- hostSetElementText(el, "");
7124
- }
7125
- if (dynamicChildren) {
7126
- patchBlockChildren(
7127
- n1.dynamicChildren,
7128
- dynamicChildren,
7129
- el,
7130
- parentComponent,
7131
- parentSuspense,
7132
- resolveChildrenNamespace(n2, namespace),
7133
- slotScopeIds
7134
- );
7135
- } else if (!optimized) {
7136
- patchChildren(
7137
- n1,
7138
- n2,
7139
- el,
7140
- null,
7141
- parentComponent,
7142
- parentSuspense,
7143
- resolveChildrenNamespace(n2, namespace),
7144
- slotScopeIds,
7145
- false
7113
+ }
7114
+ if (needCastKeys) {
7115
+ const rawCurrentProps = toRaw(props);
7116
+ const castValues = rawCastValues || EMPTY_OBJ;
7117
+ for (let i = 0; i < needCastKeys.length; i++) {
7118
+ const key = needCastKeys[i];
7119
+ props[key] = resolvePropValue(
7120
+ options,
7121
+ rawCurrentProps,
7122
+ key,
7123
+ castValues[key],
7124
+ instance,
7125
+ !hasOwn(castValues, key)
7146
7126
  );
7147
7127
  }
7148
- if (patchFlag > 0) {
7149
- if (patchFlag & 16) {
7150
- patchProps(el, oldProps, newProps, parentComponent, namespace);
7151
- } else {
7152
- if (patchFlag & 2) {
7153
- if (oldProps.class !== newProps.class) {
7154
- hostPatchProp(el, "class", null, newProps.class, namespace);
7155
- }
7156
- }
7157
- if (patchFlag & 4) {
7158
- hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
7159
- }
7160
- if (patchFlag & 8) {
7161
- const propsToUpdate = n2.dynamicProps;
7162
- for (let i = 0; i < propsToUpdate.length; i++) {
7163
- const key = propsToUpdate[i];
7164
- const prev = oldProps[key];
7165
- const next = newProps[key];
7166
- if (next !== prev || key === "value") {
7167
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
7168
- }
7169
- }
7128
+ }
7129
+ return hasAttrsChanged;
7130
+ }
7131
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
7132
+ const opt = options[key];
7133
+ if (opt != null) {
7134
+ const hasDefault = hasOwn(opt, "default");
7135
+ if (hasDefault && value === void 0) {
7136
+ const defaultValue = opt.default;
7137
+ if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
7138
+ const { propsDefaults } = instance;
7139
+ if (key in propsDefaults) {
7140
+ value = propsDefaults[key];
7141
+ } else {
7142
+ const reset = setCurrentInstance(instance);
7143
+ value = propsDefaults[key] = defaultValue.call(
7144
+ isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props) : null,
7145
+ props
7146
+ );
7147
+ reset();
7170
7148
  }
7149
+ } else {
7150
+ value = defaultValue;
7171
7151
  }
7172
- if (patchFlag & 1) {
7173
- if (n1.children !== n2.children) {
7174
- hostSetElementText(el, n2.children);
7175
- }
7152
+ if (instance.ce) {
7153
+ instance.ce._setProp(key, value);
7176
7154
  }
7177
- } else if (!optimized && dynamicChildren == null) {
7178
- patchProps(el, oldProps, newProps, parentComponent, namespace);
7179
7155
  }
7180
- if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
7181
- queuePostRenderEffect(() => {
7182
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
7183
- dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
7184
- }, parentSuspense);
7156
+ if (opt[0 /* shouldCast */]) {
7157
+ if (isAbsent && !hasDefault) {
7158
+ value = false;
7159
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
7160
+ value = true;
7161
+ }
7185
7162
  }
7186
- };
7187
- const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
7188
- for (let i = 0; i < newChildren.length; i++) {
7189
- const oldVNode = oldChildren[i];
7190
- const newVNode = newChildren[i];
7191
- const container = (
7192
- // oldVNode may be an errored async setup() component inside Suspense
7193
- // which will not have a mounted element
7194
- oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
7195
- // of the Fragment itself so it can move its children.
7196
- (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
7197
- // which also requires the correct parent container
7198
- !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
7199
- oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
7200
- // In other cases, the parent container is not actually used so we
7201
- // just pass the block element here to avoid a DOM parentNode call.
7202
- fallbackContainer
7203
- )
7204
- );
7205
- patch(
7206
- oldVNode,
7207
- newVNode,
7208
- container,
7209
- null,
7210
- parentComponent,
7211
- parentSuspense,
7212
- namespace,
7213
- slotScopeIds,
7214
- true
7215
- );
7163
+ }
7164
+ return value;
7165
+ }
7166
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
7167
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
7168
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
7169
+ const cached = cache.get(comp);
7170
+ if (cached) {
7171
+ return cached;
7172
+ }
7173
+ const raw = comp.props;
7174
+ const normalized = {};
7175
+ const needCastKeys = [];
7176
+ let hasExtends = false;
7177
+ if (!isFunction(comp)) {
7178
+ const extendProps = (raw2) => {
7179
+ if (isFunction(raw2)) {
7180
+ raw2 = raw2.options;
7181
+ }
7182
+ hasExtends = true;
7183
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
7184
+ extend$1(normalized, props);
7185
+ if (keys) needCastKeys.push(...keys);
7186
+ };
7187
+ if (!asMixin && appContext.mixins.length) {
7188
+ appContext.mixins.forEach(extendProps);
7216
7189
  }
7217
- };
7218
- const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
7219
- if (oldProps !== newProps) {
7220
- if (oldProps !== EMPTY_OBJ) {
7221
- for (const key in oldProps) {
7222
- if (!isReservedProp(key) && !(key in newProps)) {
7223
- hostPatchProp(
7224
- el,
7225
- key,
7226
- oldProps[key],
7227
- null,
7228
- namespace,
7229
- parentComponent
7230
- );
7190
+ if (comp.extends) {
7191
+ extendProps(comp.extends);
7192
+ }
7193
+ if (comp.mixins) {
7194
+ comp.mixins.forEach(extendProps);
7195
+ }
7196
+ }
7197
+ if (!raw && !hasExtends) {
7198
+ if (isObject(comp)) {
7199
+ cache.set(comp, EMPTY_ARR);
7200
+ }
7201
+ return EMPTY_ARR;
7202
+ }
7203
+ if (isArray(raw)) {
7204
+ for (let i = 0; i < raw.length; i++) {
7205
+ const normalizedKey = camelize(raw[i]);
7206
+ if (validatePropName(normalizedKey)) {
7207
+ normalized[normalizedKey] = EMPTY_OBJ;
7208
+ }
7209
+ }
7210
+ } else if (raw) {
7211
+ for (const key in raw) {
7212
+ const normalizedKey = camelize(key);
7213
+ if (validatePropName(normalizedKey)) {
7214
+ const opt = raw[key];
7215
+ const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend$1({}, opt);
7216
+ const propType = prop.type;
7217
+ let shouldCast = false;
7218
+ let shouldCastTrue = true;
7219
+ if (isArray(propType)) {
7220
+ for (let index = 0; index < propType.length; ++index) {
7221
+ const type = propType[index];
7222
+ const typeName = isFunction(type) && type.name;
7223
+ if (typeName === "Boolean") {
7224
+ shouldCast = true;
7225
+ break;
7226
+ } else if (typeName === "String") {
7227
+ shouldCastTrue = false;
7228
+ }
7231
7229
  }
7230
+ } else {
7231
+ shouldCast = isFunction(propType) && propType.name === "Boolean";
7232
7232
  }
7233
- }
7234
- for (const key in newProps) {
7235
- if (isReservedProp(key)) continue;
7236
- const next = newProps[key];
7237
- const prev = oldProps[key];
7238
- if (next !== prev && key !== "value") {
7239
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
7233
+ prop[0 /* shouldCast */] = shouldCast;
7234
+ prop[1 /* shouldCastTrue */] = shouldCastTrue;
7235
+ if (shouldCast || hasOwn(prop, "default")) {
7236
+ needCastKeys.push(normalizedKey);
7240
7237
  }
7241
7238
  }
7242
- if ("value" in newProps) {
7243
- hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
7244
- }
7245
- }
7246
- };
7247
- const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7248
- const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
7249
- const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
7250
- let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
7251
- if (fragmentSlotScopeIds) {
7252
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
7253
7239
  }
7254
- if (n1 == null) {
7255
- hostInsert(fragmentStartAnchor, container, anchor);
7256
- hostInsert(fragmentEndAnchor, container, anchor);
7257
- mountChildren(
7258
- // #10007
7259
- // such fragment like `<></>` will be compiled into
7260
- // a fragment which doesn't have a children.
7261
- // In this case fallback to an empty array
7262
- n2.children || [],
7263
- container,
7264
- fragmentEndAnchor,
7265
- parentComponent,
7266
- parentSuspense,
7267
- namespace,
7268
- slotScopeIds,
7269
- optimized
7270
- );
7240
+ }
7241
+ const res = [normalized, needCastKeys];
7242
+ if (isObject(comp)) {
7243
+ cache.set(comp, res);
7244
+ }
7245
+ return res;
7246
+ }
7247
+ function validatePropName(key) {
7248
+ if (key[0] !== "$" && !isReservedProp(key)) {
7249
+ return true;
7250
+ }
7251
+ return false;
7252
+ }
7253
+
7254
+ const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
7255
+ const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
7256
+ const normalizeSlot = (key, rawSlot, ctx) => {
7257
+ if (rawSlot._n) {
7258
+ return rawSlot;
7259
+ }
7260
+ const normalized = withCtx((...args) => {
7261
+ if (false) ;
7262
+ return normalizeSlotValue(rawSlot(...args));
7263
+ }, ctx);
7264
+ normalized._c = false;
7265
+ return normalized;
7266
+ };
7267
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
7268
+ const ctx = rawSlots._ctx;
7269
+ for (const key in rawSlots) {
7270
+ if (isInternalKey(key)) continue;
7271
+ const value = rawSlots[key];
7272
+ if (isFunction(value)) {
7273
+ slots[key] = normalizeSlot(key, value, ctx);
7274
+ } else if (value != null) {
7275
+ const normalized = normalizeSlotValue(value);
7276
+ slots[key] = () => normalized;
7277
+ }
7278
+ }
7279
+ };
7280
+ const normalizeVNodeSlots = (instance, children) => {
7281
+ const normalized = normalizeSlotValue(children);
7282
+ instance.slots.default = () => normalized;
7283
+ };
7284
+ const assignSlots = (slots, children, optimized) => {
7285
+ for (const key in children) {
7286
+ if (optimized || !isInternalKey(key)) {
7287
+ slots[key] = children[key];
7288
+ }
7289
+ }
7290
+ };
7291
+ const initSlots = (instance, children, optimized) => {
7292
+ const slots = instance.slots = createInternalObject();
7293
+ if (instance.vnode.shapeFlag & 32) {
7294
+ const type = children._;
7295
+ if (type) {
7296
+ assignSlots(slots, children, optimized);
7297
+ if (optimized) {
7298
+ def(slots, "_", type, true);
7299
+ }
7271
7300
  } else {
7272
- if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
7273
- // of renderSlot() with no valid children
7274
- n1.dynamicChildren) {
7275
- patchBlockChildren(
7276
- n1.dynamicChildren,
7277
- dynamicChildren,
7278
- container,
7279
- parentComponent,
7280
- parentSuspense,
7281
- namespace,
7282
- slotScopeIds
7283
- );
7284
- if (
7285
- // #2080 if the stable fragment has a key, it's a <template v-for> that may
7286
- // get moved around. Make sure all root level vnodes inherit el.
7287
- // #2134 or if it's a component root, it may also get moved around
7288
- // as the component is being moved.
7289
- n2.key != null || parentComponent && n2 === parentComponent.subTree
7290
- ) {
7291
- traverseStaticChildren(
7292
- n1,
7293
- n2,
7294
- true
7295
- /* shallow */
7296
- );
7297
- }
7301
+ normalizeObjectSlots(children, slots);
7302
+ }
7303
+ } else if (children) {
7304
+ normalizeVNodeSlots(instance, children);
7305
+ }
7306
+ };
7307
+ const updateSlots = (instance, children, optimized) => {
7308
+ const { vnode, slots } = instance;
7309
+ let needDeletionCheck = true;
7310
+ let deletionComparisonTarget = EMPTY_OBJ;
7311
+ if (vnode.shapeFlag & 32) {
7312
+ const type = children._;
7313
+ if (type) {
7314
+ if (optimized && type === 1) {
7315
+ needDeletionCheck = false;
7298
7316
  } else {
7299
- patchChildren(
7317
+ assignSlots(slots, children, optimized);
7318
+ }
7319
+ } else {
7320
+ needDeletionCheck = !children.$stable;
7321
+ normalizeObjectSlots(children, slots);
7322
+ }
7323
+ deletionComparisonTarget = children;
7324
+ } else if (children) {
7325
+ normalizeVNodeSlots(instance, children);
7326
+ deletionComparisonTarget = { default: 1 };
7327
+ }
7328
+ if (needDeletionCheck) {
7329
+ for (const key in slots) {
7330
+ if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
7331
+ delete slots[key];
7332
+ }
7333
+ }
7334
+ }
7335
+ };
7336
+
7337
+ const queuePostRenderEffect = queueEffectWithSuspense ;
7338
+ function createRenderer(options) {
7339
+ return baseCreateRenderer(options);
7340
+ }
7341
+ function createHydrationRenderer(options) {
7342
+ return baseCreateRenderer(options, createHydrationFunctions);
7343
+ }
7344
+ function baseCreateRenderer(options, createHydrationFns) {
7345
+ const target = getGlobalThis();
7346
+ target.__VUE__ = true;
7347
+ const {
7348
+ insert: hostInsert,
7349
+ remove: hostRemove,
7350
+ patchProp: hostPatchProp,
7351
+ createElement: hostCreateElement,
7352
+ createText: hostCreateText,
7353
+ createComment: hostCreateComment,
7354
+ setText: hostSetText,
7355
+ setElementText: hostSetElementText,
7356
+ parentNode: hostParentNode,
7357
+ nextSibling: hostNextSibling,
7358
+ setScopeId: hostSetScopeId = NOOP,
7359
+ insertStaticContent: hostInsertStaticContent
7360
+ } = options;
7361
+ const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
7362
+ if (n1 === n2) {
7363
+ return;
7364
+ }
7365
+ if (n1 && !isSameVNodeType(n1, n2)) {
7366
+ anchor = getNextHostNode(n1);
7367
+ unmount(n1, parentComponent, parentSuspense, true);
7368
+ n1 = null;
7369
+ }
7370
+ if (n2.patchFlag === -2) {
7371
+ optimized = false;
7372
+ n2.dynamicChildren = null;
7373
+ }
7374
+ const { type, ref, shapeFlag } = n2;
7375
+ switch (type) {
7376
+ case Text:
7377
+ processText(n1, n2, container, anchor);
7378
+ break;
7379
+ case Comment:
7380
+ processCommentNode(n1, n2, container, anchor);
7381
+ break;
7382
+ case Static:
7383
+ if (n1 == null) {
7384
+ mountStaticNode(n2, container, anchor, namespace);
7385
+ }
7386
+ break;
7387
+ case Fragment:
7388
+ processFragment(
7300
7389
  n1,
7301
7390
  n2,
7302
7391
  container,
7303
- fragmentEndAnchor,
7392
+ anchor,
7304
7393
  parentComponent,
7305
7394
  parentSuspense,
7306
7395
  namespace,
7307
7396
  slotScopeIds,
7308
7397
  optimized
7309
7398
  );
7399
+ break;
7400
+ default:
7401
+ if (shapeFlag & 1) {
7402
+ processElement(
7403
+ n1,
7404
+ n2,
7405
+ container,
7406
+ anchor,
7407
+ parentComponent,
7408
+ parentSuspense,
7409
+ namespace,
7410
+ slotScopeIds,
7411
+ optimized
7412
+ );
7413
+ } else if (shapeFlag & 6) {
7414
+ processComponent(
7415
+ n1,
7416
+ n2,
7417
+ container,
7418
+ anchor,
7419
+ parentComponent,
7420
+ parentSuspense,
7421
+ namespace,
7422
+ slotScopeIds,
7423
+ optimized
7424
+ );
7425
+ } else if (shapeFlag & 64) {
7426
+ type.process(
7427
+ n1,
7428
+ n2,
7429
+ container,
7430
+ anchor,
7431
+ parentComponent,
7432
+ parentSuspense,
7433
+ namespace,
7434
+ slotScopeIds,
7435
+ optimized,
7436
+ internals
7437
+ );
7438
+ } else if (shapeFlag & 128) {
7439
+ type.process(
7440
+ n1,
7441
+ n2,
7442
+ container,
7443
+ anchor,
7444
+ parentComponent,
7445
+ parentSuspense,
7446
+ namespace,
7447
+ slotScopeIds,
7448
+ optimized,
7449
+ internals
7450
+ );
7451
+ } else ;
7452
+ }
7453
+ if (ref != null && parentComponent) {
7454
+ setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
7455
+ } else if (ref == null && n1 && n1.ref != null) {
7456
+ setRef(n1.ref, null, parentSuspense, n1, true);
7457
+ }
7458
+ };
7459
+ const processText = (n1, n2, container, anchor) => {
7460
+ if (n1 == null) {
7461
+ hostInsert(
7462
+ n2.el = hostCreateText(n2.children),
7463
+ container,
7464
+ anchor
7465
+ );
7466
+ } else {
7467
+ const el = n2.el = n1.el;
7468
+ if (n2.children !== n1.children) {
7469
+ hostSetText(el, n2.children);
7310
7470
  }
7311
7471
  }
7312
7472
  };
7313
- const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7314
- n2.slotScopeIds = slotScopeIds;
7473
+ const processCommentNode = (n1, n2, container, anchor) => {
7315
7474
  if (n1 == null) {
7316
- if (n2.shapeFlag & 512) {
7317
- parentComponent.ctx.activate(
7318
- n2,
7319
- container,
7320
- anchor,
7321
- namespace,
7322
- optimized
7323
- );
7324
- } else {
7325
- mountComponent(
7475
+ hostInsert(
7476
+ n2.el = hostCreateComment(n2.children || ""),
7477
+ container,
7478
+ anchor
7479
+ );
7480
+ } else {
7481
+ n2.el = n1.el;
7482
+ }
7483
+ };
7484
+ const mountStaticNode = (n2, container, anchor, namespace) => {
7485
+ [n2.el, n2.anchor] = hostInsertStaticContent(
7486
+ n2.children,
7487
+ container,
7488
+ anchor,
7489
+ namespace,
7490
+ n2.el,
7491
+ n2.anchor
7492
+ );
7493
+ };
7494
+ const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
7495
+ let next;
7496
+ while (el && el !== anchor) {
7497
+ next = hostNextSibling(el);
7498
+ hostInsert(el, container, nextSibling);
7499
+ el = next;
7500
+ }
7501
+ hostInsert(anchor, container, nextSibling);
7502
+ };
7503
+ const removeStaticNode = ({ el, anchor }) => {
7504
+ let next;
7505
+ while (el && el !== anchor) {
7506
+ next = hostNextSibling(el);
7507
+ hostRemove(el);
7508
+ el = next;
7509
+ }
7510
+ hostRemove(anchor);
7511
+ };
7512
+ const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7513
+ if (n2.type === "svg") {
7514
+ namespace = "svg";
7515
+ } else if (n2.type === "math") {
7516
+ namespace = "mathml";
7517
+ }
7518
+ if (n1 == null) {
7519
+ mountElement(
7520
+ n2,
7521
+ container,
7522
+ anchor,
7523
+ parentComponent,
7524
+ parentSuspense,
7525
+ namespace,
7526
+ slotScopeIds,
7527
+ optimized
7528
+ );
7529
+ } else {
7530
+ const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
7531
+ try {
7532
+ if (customElement) {
7533
+ customElement._beginPatch();
7534
+ }
7535
+ patchElement(
7536
+ n1,
7326
7537
  n2,
7327
- container,
7328
- anchor,
7329
7538
  parentComponent,
7330
7539
  parentSuspense,
7331
7540
  namespace,
7541
+ slotScopeIds,
7332
7542
  optimized
7333
7543
  );
7544
+ } finally {
7545
+ if (customElement) {
7546
+ customElement._endPatch();
7547
+ }
7334
7548
  }
7335
- } else {
7336
- updateComponent(n1, n2, optimized);
7337
7549
  }
7338
7550
  };
7339
- const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
7340
- const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
7341
- const instance = compatMountInstance || (initialVNode.component = createComponentInstance(
7342
- initialVNode,
7343
- parentComponent,
7344
- parentSuspense
7345
- ));
7346
- if (isKeepAlive(initialVNode)) {
7347
- instance.ctx.renderer = internals;
7551
+ const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7552
+ let el;
7553
+ let vnodeHook;
7554
+ const { props, shapeFlag, transition, dirs } = vnode;
7555
+ el = vnode.el = hostCreateElement(
7556
+ vnode.type,
7557
+ namespace,
7558
+ props && props.is,
7559
+ props
7560
+ );
7561
+ if (shapeFlag & 8) {
7562
+ hostSetElementText(el, vnode.children);
7563
+ } else if (shapeFlag & 16) {
7564
+ mountChildren(
7565
+ vnode.children,
7566
+ el,
7567
+ null,
7568
+ parentComponent,
7569
+ parentSuspense,
7570
+ resolveChildrenNamespace(vnode, namespace),
7571
+ slotScopeIds,
7572
+ optimized
7573
+ );
7348
7574
  }
7349
- if (!compatMountInstance) {
7350
- setupComponent(instance, false, optimized);
7575
+ if (dirs) {
7576
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
7351
7577
  }
7352
- if (instance.asyncDep) {
7353
- parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
7354
- if (!initialVNode.el) {
7355
- const placeholder = instance.subTree = createVNode(Comment);
7356
- processCommentNode(null, placeholder, container, anchor);
7357
- initialVNode.placeholder = placeholder.el;
7578
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
7579
+ if (props) {
7580
+ for (const key in props) {
7581
+ if (key !== "value" && !isReservedProp(key)) {
7582
+ hostPatchProp(el, key, null, props[key], namespace, parentComponent);
7583
+ }
7358
7584
  }
7359
- } else {
7360
- setupRenderEffect(
7361
- instance,
7362
- initialVNode,
7585
+ if ("value" in props) {
7586
+ hostPatchProp(el, "value", null, props.value, namespace);
7587
+ }
7588
+ if (vnodeHook = props.onVnodeBeforeMount) {
7589
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
7590
+ }
7591
+ }
7592
+ if (dirs) {
7593
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7594
+ }
7595
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
7596
+ if (needCallTransitionHooks) {
7597
+ transition.beforeEnter(el);
7598
+ }
7599
+ hostInsert(el, container, anchor);
7600
+ if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
7601
+ queuePostRenderEffect(() => {
7602
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7603
+ needCallTransitionHooks && transition.enter(el);
7604
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7605
+ }, parentSuspense);
7606
+ }
7607
+ };
7608
+ const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
7609
+ if (scopeId) {
7610
+ hostSetScopeId(el, scopeId);
7611
+ }
7612
+ if (slotScopeIds) {
7613
+ for (let i = 0; i < slotScopeIds.length; i++) {
7614
+ hostSetScopeId(el, slotScopeIds[i]);
7615
+ }
7616
+ }
7617
+ if (parentComponent) {
7618
+ let subTree = parentComponent.subTree;
7619
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
7620
+ const parentVNode = parentComponent.vnode;
7621
+ setScopeId(
7622
+ el,
7623
+ parentVNode,
7624
+ parentVNode.scopeId,
7625
+ parentVNode.slotScopeIds,
7626
+ parentComponent.parent
7627
+ );
7628
+ }
7629
+ }
7630
+ };
7631
+ const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
7632
+ for (let i = start; i < children.length; i++) {
7633
+ const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
7634
+ patch(
7635
+ null,
7636
+ child,
7363
7637
  container,
7364
7638
  anchor,
7639
+ parentComponent,
7365
7640
  parentSuspense,
7366
7641
  namespace,
7642
+ slotScopeIds,
7367
7643
  optimized
7368
7644
  );
7369
7645
  }
7370
7646
  };
7371
- const updateComponent = (n1, n2, optimized) => {
7372
- const instance = n2.component = n1.component;
7373
- if (shouldUpdateComponent(n1, n2, optimized)) {
7374
- if (instance.asyncDep && !instance.asyncResolved) {
7375
- updateComponentPreRender(instance, n2, optimized);
7376
- return;
7377
- } else {
7378
- instance.next = n2;
7379
- instance.update();
7380
- }
7381
- } else {
7382
- n2.el = n1.el;
7383
- instance.vnode = n2;
7647
+ const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7648
+ const el = n2.el = n1.el;
7649
+ let { patchFlag, dynamicChildren, dirs } = n2;
7650
+ patchFlag |= n1.patchFlag & 16;
7651
+ const oldProps = n1.props || EMPTY_OBJ;
7652
+ const newProps = n2.props || EMPTY_OBJ;
7653
+ let vnodeHook;
7654
+ parentComponent && toggleRecurse(parentComponent, false);
7655
+ if (vnodeHook = newProps.onVnodeBeforeUpdate) {
7656
+ invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
7384
7657
  }
7385
- };
7386
- const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
7387
- const componentUpdateFn = () => {
7388
- if (!instance.isMounted) {
7389
- let vnodeHook;
7390
- const { el, props } = initialVNode;
7391
- const { bm, m, parent, root, type } = instance;
7392
- const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
7393
- toggleRecurse(instance, false);
7394
- if (bm) {
7395
- invokeArrayFns(bm);
7658
+ if (dirs) {
7659
+ invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
7660
+ }
7661
+ parentComponent && toggleRecurse(parentComponent, true);
7662
+ if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
7663
+ hostSetElementText(el, "");
7664
+ }
7665
+ if (dynamicChildren) {
7666
+ patchBlockChildren(
7667
+ n1.dynamicChildren,
7668
+ dynamicChildren,
7669
+ el,
7670
+ parentComponent,
7671
+ parentSuspense,
7672
+ resolveChildrenNamespace(n2, namespace),
7673
+ slotScopeIds
7674
+ );
7675
+ } else if (!optimized) {
7676
+ patchChildren(
7677
+ n1,
7678
+ n2,
7679
+ el,
7680
+ null,
7681
+ parentComponent,
7682
+ parentSuspense,
7683
+ resolveChildrenNamespace(n2, namespace),
7684
+ slotScopeIds,
7685
+ false
7686
+ );
7687
+ }
7688
+ if (patchFlag > 0) {
7689
+ if (patchFlag & 16) {
7690
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
7691
+ } else {
7692
+ if (patchFlag & 2) {
7693
+ if (oldProps.class !== newProps.class) {
7694
+ hostPatchProp(el, "class", null, newProps.class, namespace);
7695
+ }
7396
7696
  }
7397
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
7697
+ if (patchFlag & 4) {
7698
+ hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
7699
+ }
7700
+ if (patchFlag & 8) {
7701
+ const propsToUpdate = n2.dynamicProps;
7702
+ for (let i = 0; i < propsToUpdate.length; i++) {
7703
+ const key = propsToUpdate[i];
7704
+ const prev = oldProps[key];
7705
+ const next = newProps[key];
7706
+ if (next !== prev || key === "value") {
7707
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
7708
+ }
7709
+ }
7710
+ }
7711
+ }
7712
+ if (patchFlag & 1) {
7713
+ if (n1.children !== n2.children) {
7714
+ hostSetElementText(el, n2.children);
7715
+ }
7716
+ }
7717
+ } else if (!optimized && dynamicChildren == null) {
7718
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
7719
+ }
7720
+ if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
7721
+ queuePostRenderEffect(() => {
7722
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
7723
+ dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
7724
+ }, parentSuspense);
7725
+ }
7726
+ };
7727
+ const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
7728
+ for (let i = 0; i < newChildren.length; i++) {
7729
+ const oldVNode = oldChildren[i];
7730
+ const newVNode = newChildren[i];
7731
+ const container = (
7732
+ // oldVNode may be an errored async setup() component inside Suspense
7733
+ // which will not have a mounted element
7734
+ oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
7735
+ // of the Fragment itself so it can move its children.
7736
+ (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
7737
+ // which also requires the correct parent container
7738
+ !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
7739
+ oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
7740
+ // In other cases, the parent container is not actually used so we
7741
+ // just pass the block element here to avoid a DOM parentNode call.
7742
+ fallbackContainer
7743
+ )
7744
+ );
7745
+ patch(
7746
+ oldVNode,
7747
+ newVNode,
7748
+ container,
7749
+ null,
7750
+ parentComponent,
7751
+ parentSuspense,
7752
+ namespace,
7753
+ slotScopeIds,
7754
+ true
7755
+ );
7756
+ }
7757
+ };
7758
+ const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
7759
+ if (oldProps !== newProps) {
7760
+ if (oldProps !== EMPTY_OBJ) {
7761
+ for (const key in oldProps) {
7762
+ if (!isReservedProp(key) && !(key in newProps)) {
7763
+ hostPatchProp(
7764
+ el,
7765
+ key,
7766
+ oldProps[key],
7767
+ null,
7768
+ namespace,
7769
+ parentComponent
7770
+ );
7771
+ }
7772
+ }
7773
+ }
7774
+ for (const key in newProps) {
7775
+ if (isReservedProp(key)) continue;
7776
+ const next = newProps[key];
7777
+ const prev = oldProps[key];
7778
+ if (next !== prev && key !== "value") {
7779
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
7780
+ }
7781
+ }
7782
+ if ("value" in newProps) {
7783
+ hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
7784
+ }
7785
+ }
7786
+ };
7787
+ const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7788
+ const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
7789
+ const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
7790
+ let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
7791
+ if (fragmentSlotScopeIds) {
7792
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
7793
+ }
7794
+ if (n1 == null) {
7795
+ hostInsert(fragmentStartAnchor, container, anchor);
7796
+ hostInsert(fragmentEndAnchor, container, anchor);
7797
+ mountChildren(
7798
+ // #10007
7799
+ // such fragment like `<></>` will be compiled into
7800
+ // a fragment which doesn't have a children.
7801
+ // In this case fallback to an empty array
7802
+ n2.children || [],
7803
+ container,
7804
+ fragmentEndAnchor,
7805
+ parentComponent,
7806
+ parentSuspense,
7807
+ namespace,
7808
+ slotScopeIds,
7809
+ optimized
7810
+ );
7811
+ } else {
7812
+ if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
7813
+ // of renderSlot() with no valid children
7814
+ n1.dynamicChildren) {
7815
+ patchBlockChildren(
7816
+ n1.dynamicChildren,
7817
+ dynamicChildren,
7818
+ container,
7819
+ parentComponent,
7820
+ parentSuspense,
7821
+ namespace,
7822
+ slotScopeIds
7823
+ );
7824
+ if (
7825
+ // #2080 if the stable fragment has a key, it's a <template v-for> that may
7826
+ // get moved around. Make sure all root level vnodes inherit el.
7827
+ // #2134 or if it's a component root, it may also get moved around
7828
+ // as the component is being moved.
7829
+ n2.key != null || parentComponent && n2 === parentComponent.subTree
7830
+ ) {
7831
+ traverseStaticChildren(
7832
+ n1,
7833
+ n2,
7834
+ true
7835
+ /* shallow */
7836
+ );
7837
+ }
7838
+ } else {
7839
+ patchChildren(
7840
+ n1,
7841
+ n2,
7842
+ container,
7843
+ fragmentEndAnchor,
7844
+ parentComponent,
7845
+ parentSuspense,
7846
+ namespace,
7847
+ slotScopeIds,
7848
+ optimized
7849
+ );
7850
+ }
7851
+ }
7852
+ };
7853
+ const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
7854
+ n2.slotScopeIds = slotScopeIds;
7855
+ if (n1 == null) {
7856
+ if (n2.shapeFlag & 512) {
7857
+ parentComponent.ctx.activate(
7858
+ n2,
7859
+ container,
7860
+ anchor,
7861
+ namespace,
7862
+ optimized
7863
+ );
7864
+ } else {
7865
+ mountComponent(
7866
+ n2,
7867
+ container,
7868
+ anchor,
7869
+ parentComponent,
7870
+ parentSuspense,
7871
+ namespace,
7872
+ optimized
7873
+ );
7874
+ }
7875
+ } else {
7876
+ updateComponent(n1, n2, optimized);
7877
+ }
7878
+ };
7879
+ const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
7880
+ const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
7881
+ const instance = compatMountInstance || (initialVNode.component = createComponentInstance(
7882
+ initialVNode,
7883
+ parentComponent,
7884
+ parentSuspense
7885
+ ));
7886
+ if (isKeepAlive(initialVNode)) {
7887
+ instance.ctx.renderer = internals;
7888
+ }
7889
+ if (!compatMountInstance) {
7890
+ setupComponent(instance, false, optimized);
7891
+ }
7892
+ if (instance.asyncDep) {
7893
+ parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
7894
+ if (!initialVNode.el) {
7895
+ const placeholder = instance.subTree = createVNode(Comment);
7896
+ processCommentNode(null, placeholder, container, anchor);
7897
+ initialVNode.placeholder = placeholder.el;
7898
+ }
7899
+ } else {
7900
+ setupRenderEffect(
7901
+ instance,
7902
+ initialVNode,
7903
+ container,
7904
+ anchor,
7905
+ parentSuspense,
7906
+ namespace,
7907
+ optimized
7908
+ );
7909
+ }
7910
+ };
7911
+ const updateComponent = (n1, n2, optimized) => {
7912
+ const instance = n2.component = n1.component;
7913
+ if (shouldUpdateComponent(n1, n2, optimized)) {
7914
+ if (instance.asyncDep && !instance.asyncResolved) {
7915
+ updateComponentPreRender(instance, n2, optimized);
7916
+ return;
7917
+ } else {
7918
+ instance.next = n2;
7919
+ instance.update();
7920
+ }
7921
+ } else {
7922
+ n2.el = n1.el;
7923
+ instance.vnode = n2;
7924
+ }
7925
+ };
7926
+ const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
7927
+ const componentUpdateFn = () => {
7928
+ if (!instance.isMounted) {
7929
+ let vnodeHook;
7930
+ const { el, props } = initialVNode;
7931
+ const { bm, m, parent, root, type } = instance;
7932
+ const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
7933
+ toggleRecurse(instance, false);
7934
+ if (bm) {
7935
+ invokeArrayFns(bm);
7936
+ }
7937
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
7398
7938
  invokeVNodeHook(vnodeHook, parent, initialVNode);
7399
7939
  }
7400
7940
  if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
@@ -7968,746 +8508,247 @@ function baseCreateRenderer(options, createHydrationFns) {
7968
8508
  );
7969
8509
  } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
7970
8510
  unmountChildren(children, parentComponent, parentSuspense);
7971
- }
7972
- if (doRemove) {
7973
- remove(vnode);
7974
- }
7975
- }
7976
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
7977
- queuePostRenderEffect(() => {
7978
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
7979
- shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
7980
- }, parentSuspense);
7981
- }
7982
- };
7983
- const remove = (vnode) => {
7984
- const { type, el, anchor, transition } = vnode;
7985
- if (type === Fragment) {
7986
- {
7987
- removeFragment(el, anchor);
7988
- }
7989
- return;
7990
- }
7991
- if (type === Static) {
7992
- removeStaticNode(vnode);
7993
- return;
7994
- }
7995
- const performRemove = () => {
7996
- hostRemove(el);
7997
- if (transition && !transition.persisted && transition.afterLeave) {
7998
- transition.afterLeave();
7999
- }
8000
- };
8001
- if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
8002
- const { leave, delayLeave } = transition;
8003
- const performLeave = () => leave(el, performRemove);
8004
- if (delayLeave) {
8005
- delayLeave(vnode.el, performRemove, performLeave);
8006
- } else {
8007
- performLeave();
8008
- }
8009
- } else {
8010
- performRemove();
8011
- }
8012
- };
8013
- const removeFragment = (cur, end) => {
8014
- let next;
8015
- while (cur !== end) {
8016
- next = hostNextSibling(cur);
8017
- hostRemove(cur);
8018
- cur = next;
8019
- }
8020
- hostRemove(end);
8021
- };
8022
- const unmountComponent = (instance, parentSuspense, doRemove) => {
8023
- const { bum, scope, job, subTree, um, m, a } = instance;
8024
- invalidateMount(m);
8025
- invalidateMount(a);
8026
- if (bum) {
8027
- invokeArrayFns(bum);
8028
- }
8029
- if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
8030
- instance.emit("hook:beforeDestroy");
8031
- }
8032
- scope.stop();
8033
- if (job) {
8034
- job.flags |= 8;
8035
- unmount(subTree, instance, parentSuspense, doRemove);
8036
- }
8037
- if (um) {
8038
- queuePostRenderEffect(um, parentSuspense);
8039
- }
8040
- if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
8041
- queuePostRenderEffect(
8042
- () => instance.emit("hook:destroyed"),
8043
- parentSuspense
8044
- );
8045
- }
8046
- queuePostRenderEffect(() => {
8047
- instance.isUnmounted = true;
8048
- }, parentSuspense);
8049
- };
8050
- const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
8051
- for (let i = start; i < children.length; i++) {
8052
- unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
8053
- }
8054
- };
8055
- const getNextHostNode = (vnode) => {
8056
- if (vnode.shapeFlag & 6) {
8057
- return getNextHostNode(vnode.component.subTree);
8058
- }
8059
- if (vnode.shapeFlag & 128) {
8060
- return vnode.suspense.next();
8061
- }
8062
- const el = hostNextSibling(vnode.anchor || vnode.el);
8063
- const teleportEnd = el && el[TeleportEndKey];
8064
- return teleportEnd ? hostNextSibling(teleportEnd) : el;
8065
- };
8066
- let isFlushing = false;
8067
- const render = (vnode, container, namespace) => {
8068
- if (vnode == null) {
8069
- if (container._vnode) {
8070
- unmount(container._vnode, null, null, true);
8071
- }
8072
- } else {
8073
- patch(
8074
- container._vnode || null,
8075
- vnode,
8076
- container,
8077
- null,
8078
- null,
8079
- null,
8080
- namespace
8081
- );
8082
- }
8083
- container._vnode = vnode;
8084
- if (!isFlushing) {
8085
- isFlushing = true;
8086
- flushPreFlushCbs();
8087
- flushPostFlushCbs();
8088
- isFlushing = false;
8089
- }
8090
- };
8091
- const internals = {
8092
- p: patch,
8093
- um: unmount,
8094
- m: move,
8095
- r: remove,
8096
- mt: mountComponent,
8097
- mc: mountChildren,
8098
- pc: patchChildren,
8099
- pbc: patchBlockChildren,
8100
- n: getNextHostNode,
8101
- o: options
8102
- };
8103
- let hydrate;
8104
- let hydrateNode;
8105
- if (createHydrationFns) {
8106
- [hydrate, hydrateNode] = createHydrationFns(
8107
- internals
8108
- );
8109
- }
8110
- return {
8111
- render,
8112
- hydrate,
8113
- createApp: createAppAPI(render, hydrate)
8114
- };
8115
- }
8116
- function resolveChildrenNamespace({ type, props }, currentNamespace) {
8117
- return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
8118
- }
8119
- function toggleRecurse({ effect, job }, allowed) {
8120
- if (allowed) {
8121
- effect.flags |= 32;
8122
- job.flags |= 4;
8123
- } else {
8124
- effect.flags &= -33;
8125
- job.flags &= -5;
8126
- }
8127
- }
8128
- function needTransition(parentSuspense, transition) {
8129
- return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8130
- }
8131
- function traverseStaticChildren(n1, n2, shallow = false) {
8132
- const ch1 = n1.children;
8133
- const ch2 = n2.children;
8134
- if (isArray(ch1) && isArray(ch2)) {
8135
- for (let i = 0; i < ch1.length; i++) {
8136
- const c1 = ch1[i];
8137
- let c2 = ch2[i];
8138
- if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
8139
- if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
8140
- c2 = ch2[i] = cloneIfMounted(ch2[i]);
8141
- c2.el = c1.el;
8142
- }
8143
- if (!shallow && c2.patchFlag !== -2)
8144
- traverseStaticChildren(c1, c2);
8145
- }
8146
- if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
8147
- c2.patchFlag !== -1) {
8148
- c2.el = c1.el;
8149
- }
8150
- if (c2.type === Comment && !c2.el) {
8151
- c2.el = c1.el;
8152
- }
8153
- }
8154
- }
8155
- }
8156
- function getSequence(arr) {
8157
- const p = arr.slice();
8158
- const result = [0];
8159
- let i, j, u, v, c;
8160
- const len = arr.length;
8161
- for (i = 0; i < len; i++) {
8162
- const arrI = arr[i];
8163
- if (arrI !== 0) {
8164
- j = result[result.length - 1];
8165
- if (arr[j] < arrI) {
8166
- p[i] = j;
8167
- result.push(i);
8168
- continue;
8169
- }
8170
- u = 0;
8171
- v = result.length - 1;
8172
- while (u < v) {
8173
- c = u + v >> 1;
8174
- if (arr[result[c]] < arrI) {
8175
- u = c + 1;
8176
- } else {
8177
- v = c;
8178
- }
8179
- }
8180
- if (arrI < arr[result[u]]) {
8181
- if (u > 0) {
8182
- p[i] = result[u - 1];
8183
- }
8184
- result[u] = i;
8185
- }
8186
- }
8187
- }
8188
- u = result.length;
8189
- v = result[u - 1];
8190
- while (u-- > 0) {
8191
- result[u] = v;
8192
- v = p[v];
8193
- }
8194
- return result;
8195
- }
8196
- function locateNonHydratedAsyncRoot(instance) {
8197
- const subComponent = instance.subTree.component;
8198
- if (subComponent) {
8199
- if (subComponent.asyncDep && !subComponent.asyncResolved) {
8200
- return subComponent;
8201
- } else {
8202
- return locateNonHydratedAsyncRoot(subComponent);
8203
- }
8204
- }
8205
- }
8206
- function invalidateMount(hooks) {
8207
- if (hooks) {
8208
- for (let i = 0; i < hooks.length; i++)
8209
- hooks[i].flags |= 8;
8210
- }
8211
- }
8212
-
8213
- const ssrContextKey = Symbol.for("v-scx");
8214
- const useSSRContext = () => {
8215
- {
8216
- const ctx = inject(ssrContextKey);
8217
- return ctx;
8218
- }
8219
- };
8220
-
8221
- function watchEffect(effect, options) {
8222
- return doWatch(effect, null, options);
8223
- }
8224
- function watchPostEffect(effect, options) {
8225
- return doWatch(
8226
- effect,
8227
- null,
8228
- { flush: "post" }
8229
- );
8230
- }
8231
- function watchSyncEffect(effect, options) {
8232
- return doWatch(
8233
- effect,
8234
- null,
8235
- { flush: "sync" }
8236
- );
8237
- }
8238
- function watch(source, cb, options) {
8239
- return doWatch(source, cb, options);
8240
- }
8241
- function doWatch(source, cb, options = EMPTY_OBJ) {
8242
- const { immediate, deep, flush, once } = options;
8243
- const baseWatchOptions = extend$1({}, options);
8244
- const runsImmediately = cb && immediate || !cb && flush !== "post";
8245
- let ssrCleanup;
8246
- if (isInSSRComponentSetup) {
8247
- if (flush === "sync") {
8248
- const ctx = useSSRContext();
8249
- ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
8250
- } else if (!runsImmediately) {
8251
- const watchStopHandle = () => {
8252
- };
8253
- watchStopHandle.stop = NOOP;
8254
- watchStopHandle.resume = NOOP;
8255
- watchStopHandle.pause = NOOP;
8256
- return watchStopHandle;
8257
- }
8258
- }
8259
- const instance = currentInstance;
8260
- baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
8261
- let isPre = false;
8262
- if (flush === "post") {
8263
- baseWatchOptions.scheduler = (job) => {
8264
- queuePostRenderEffect(job, instance && instance.suspense);
8265
- };
8266
- } else if (flush !== "sync") {
8267
- isPre = true;
8268
- baseWatchOptions.scheduler = (job, isFirstRun) => {
8269
- if (isFirstRun) {
8270
- job();
8271
- } else {
8272
- queueJob(job);
8273
- }
8274
- };
8275
- }
8276
- baseWatchOptions.augmentJob = (job) => {
8277
- if (cb) {
8278
- job.flags |= 4;
8279
- }
8280
- if (isPre) {
8281
- job.flags |= 2;
8282
- if (instance) {
8283
- job.id = instance.uid;
8284
- job.i = instance;
8285
- }
8286
- }
8287
- };
8288
- const watchHandle = watch$1(source, cb, baseWatchOptions);
8289
- if (isInSSRComponentSetup) {
8290
- if (ssrCleanup) {
8291
- ssrCleanup.push(watchHandle);
8292
- } else if (runsImmediately) {
8293
- watchHandle();
8294
- }
8295
- }
8296
- return watchHandle;
8297
- }
8298
- function instanceWatch(source, value, options) {
8299
- const publicThis = this.proxy;
8300
- const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
8301
- let cb;
8302
- if (isFunction(value)) {
8303
- cb = value;
8304
- } else {
8305
- cb = value.handler;
8306
- options = value;
8307
- }
8308
- const reset = setCurrentInstance(this);
8309
- const res = doWatch(getter, cb.bind(publicThis), options);
8310
- reset();
8311
- return res;
8312
- }
8313
- function createPathGetter(ctx, path) {
8314
- const segments = path.split(".");
8315
- return () => {
8316
- let cur = ctx;
8317
- for (let i = 0; i < segments.length && cur; i++) {
8318
- cur = cur[segments[i]];
8319
- }
8320
- return cur;
8321
- };
8322
- }
8323
-
8324
- function useModel(props, name, options = EMPTY_OBJ) {
8325
- const i = getCurrentInstance();
8326
- const camelizedName = camelize(name);
8327
- const hyphenatedName = hyphenate(name);
8328
- const modifiers = getModelModifiers(props, camelizedName);
8329
- const res = customRef((track, trigger) => {
8330
- let localValue;
8331
- let prevSetValue = EMPTY_OBJ;
8332
- let prevEmittedValue;
8333
- watchSyncEffect(() => {
8334
- const propValue = props[camelizedName];
8335
- if (hasChanged(localValue, propValue)) {
8336
- localValue = propValue;
8337
- trigger();
8338
- }
8339
- });
8340
- return {
8341
- get() {
8342
- track();
8343
- return options.get ? options.get(localValue) : localValue;
8344
- },
8345
- set(value) {
8346
- const emittedValue = options.set ? options.set(value) : value;
8347
- if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
8348
- return;
8349
- }
8350
- const rawProps = i.vnode.props;
8351
- if (!(rawProps && // check if parent has passed v-model
8352
- (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
8353
- localValue = value;
8354
- trigger();
8355
- }
8356
- i.emit(`update:${name}`, emittedValue);
8357
- if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
8358
- trigger();
8359
- }
8360
- prevSetValue = value;
8361
- prevEmittedValue = emittedValue;
8362
- }
8363
- };
8364
- });
8365
- res[Symbol.iterator] = () => {
8366
- let i2 = 0;
8367
- return {
8368
- next() {
8369
- if (i2 < 2) {
8370
- return { value: i2++ ? modifiers || EMPTY_OBJ : res, done: false };
8371
- } else {
8372
- return { done: true };
8373
- }
8374
- }
8375
- };
8376
- };
8377
- return res;
8378
- }
8379
- const getModelModifiers = (props, modelName) => {
8380
- return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize(modelName)}Modifiers`] || props[`${hyphenate(modelName)}Modifiers`];
8381
- };
8382
-
8383
- function emit(instance, event, ...rawArgs) {
8384
- if (instance.isUnmounted) return;
8385
- const props = instance.vnode.props || EMPTY_OBJ;
8386
- let args = rawArgs;
8387
- const isCompatModelListener = compatModelEventPrefix + event in props;
8388
- const isModelListener = isCompatModelListener || event.startsWith("update:");
8389
- const modifiers = isCompatModelListener ? props.modelModifiers : isModelListener && getModelModifiers(props, event.slice(7));
8390
- if (modifiers) {
8391
- if (modifiers.trim) {
8392
- args = rawArgs.map((a) => isString(a) ? a.trim() : a);
8511
+ }
8512
+ if (doRemove) {
8513
+ remove(vnode);
8514
+ }
8393
8515
  }
8394
- if (modifiers.number) {
8395
- args = rawArgs.map(looseToNumber);
8516
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
8517
+ queuePostRenderEffect(() => {
8518
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
8519
+ shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
8520
+ }, parentSuspense);
8396
8521
  }
8397
- }
8398
- let handlerName;
8399
- let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
8400
- props[handlerName = toHandlerKey(camelize(event))];
8401
- if (!handler && isModelListener) {
8402
- handler = props[handlerName = toHandlerKey(hyphenate(event))];
8403
- }
8404
- if (handler) {
8405
- callWithAsyncErrorHandling(
8406
- handler,
8407
- instance,
8408
- 6,
8409
- args
8410
- );
8411
- }
8412
- const onceHandler = props[handlerName + `Once`];
8413
- if (onceHandler) {
8414
- if (!instance.emitted) {
8415
- instance.emitted = {};
8416
- } else if (instance.emitted[handlerName]) {
8522
+ };
8523
+ const remove = (vnode) => {
8524
+ const { type, el, anchor, transition } = vnode;
8525
+ if (type === Fragment) {
8526
+ {
8527
+ removeFragment(el, anchor);
8528
+ }
8417
8529
  return;
8418
8530
  }
8419
- instance.emitted[handlerName] = true;
8420
- callWithAsyncErrorHandling(
8421
- onceHandler,
8422
- instance,
8423
- 6,
8424
- args
8425
- );
8426
- }
8427
- {
8428
- compatModelEmit(instance, event, args);
8429
- return emit$1(instance, event, args);
8430
- }
8431
- }
8432
- const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
8433
- function normalizeEmitsOptions(comp, appContext, asMixin = false) {
8434
- const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
8435
- const cached = cache.get(comp);
8436
- if (cached !== void 0) {
8437
- return cached;
8438
- }
8439
- const raw = comp.emits;
8440
- let normalized = {};
8441
- let hasExtends = false;
8442
- if (!isFunction(comp)) {
8443
- const extendEmits = (raw2) => {
8444
- const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
8445
- if (normalizedFromExtend) {
8446
- hasExtends = true;
8447
- extend$1(normalized, normalizedFromExtend);
8531
+ if (type === Static) {
8532
+ removeStaticNode(vnode);
8533
+ return;
8534
+ }
8535
+ const performRemove = () => {
8536
+ hostRemove(el);
8537
+ if (transition && !transition.persisted && transition.afterLeave) {
8538
+ transition.afterLeave();
8448
8539
  }
8449
8540
  };
8450
- if (!asMixin && appContext.mixins.length) {
8451
- appContext.mixins.forEach(extendEmits);
8541
+ if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
8542
+ const { leave, delayLeave } = transition;
8543
+ const performLeave = () => leave(el, performRemove);
8544
+ if (delayLeave) {
8545
+ delayLeave(vnode.el, performRemove, performLeave);
8546
+ } else {
8547
+ performLeave();
8548
+ }
8549
+ } else {
8550
+ performRemove();
8452
8551
  }
8453
- if (comp.extends) {
8454
- extendEmits(comp.extends);
8552
+ };
8553
+ const removeFragment = (cur, end) => {
8554
+ let next;
8555
+ while (cur !== end) {
8556
+ next = hostNextSibling(cur);
8557
+ hostRemove(cur);
8558
+ cur = next;
8455
8559
  }
8456
- if (comp.mixins) {
8457
- comp.mixins.forEach(extendEmits);
8560
+ hostRemove(end);
8561
+ };
8562
+ const unmountComponent = (instance, parentSuspense, doRemove) => {
8563
+ const { bum, scope, job, subTree, um, m, a } = instance;
8564
+ invalidateMount(m);
8565
+ invalidateMount(a);
8566
+ if (bum) {
8567
+ invokeArrayFns(bum);
8458
8568
  }
8459
- }
8460
- if (!raw && !hasExtends) {
8461
- if (isObject(comp)) {
8462
- cache.set(comp, null);
8569
+ if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
8570
+ instance.emit("hook:beforeDestroy");
8463
8571
  }
8464
- return null;
8465
- }
8466
- if (isArray(raw)) {
8467
- raw.forEach((key) => normalized[key] = null);
8468
- } else {
8469
- extend$1(normalized, raw);
8470
- }
8471
- if (isObject(comp)) {
8472
- cache.set(comp, normalized);
8473
- }
8474
- return normalized;
8475
- }
8476
- function isEmitListener(options, key) {
8477
- if (!options || !isOn(key)) {
8478
- return false;
8479
- }
8480
- if (key.startsWith(compatModelEventPrefix)) {
8481
- return true;
8482
- }
8483
- key = key.slice(2).replace(/Once$/, "");
8484
- return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
8485
- }
8486
-
8487
- function markAttrsAccessed() {
8488
- }
8489
- function renderComponentRoot(instance) {
8490
- const {
8491
- type: Component,
8492
- vnode,
8493
- proxy,
8494
- withProxy,
8495
- propsOptions: [propsOptions],
8496
- slots,
8497
- attrs,
8498
- emit,
8499
- render,
8500
- renderCache,
8501
- props,
8502
- data,
8503
- setupState,
8504
- ctx,
8505
- inheritAttrs
8506
- } = instance;
8507
- const prev = setCurrentRenderingInstance(instance);
8508
- let result;
8509
- let fallthroughAttrs;
8510
- try {
8511
- if (vnode.shapeFlag & 4) {
8512
- const proxyToUse = withProxy || proxy;
8513
- const thisProxy = false ? new Proxy(proxyToUse, {
8514
- get(target, key, receiver) {
8515
- warn(
8516
- `Property '${String(
8517
- key
8518
- )}' was accessed via 'this'. Avoid using 'this' in templates.`
8519
- );
8520
- return Reflect.get(target, key, receiver);
8521
- }
8522
- }) : proxyToUse;
8523
- result = normalizeVNode(
8524
- render.call(
8525
- thisProxy,
8526
- proxyToUse,
8527
- renderCache,
8528
- false ? shallowReadonly(props) : props,
8529
- setupState,
8530
- data,
8531
- ctx
8532
- )
8533
- );
8534
- fallthroughAttrs = attrs;
8535
- } else {
8536
- const render2 = Component;
8537
- if (false) ;
8538
- result = normalizeVNode(
8539
- render2.length > 1 ? render2(
8540
- false ? shallowReadonly(props) : props,
8541
- false ? {
8542
- get attrs() {
8543
- markAttrsAccessed();
8544
- return shallowReadonly(attrs);
8545
- },
8546
- slots,
8547
- emit
8548
- } : { attrs, slots, emit }
8549
- ) : render2(
8550
- false ? shallowReadonly(props) : props,
8551
- null
8552
- )
8572
+ scope.stop();
8573
+ if (job) {
8574
+ job.flags |= 8;
8575
+ unmount(subTree, instance, parentSuspense, doRemove);
8576
+ }
8577
+ if (um) {
8578
+ queuePostRenderEffect(um, parentSuspense);
8579
+ }
8580
+ if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
8581
+ queuePostRenderEffect(
8582
+ () => instance.emit("hook:destroyed"),
8583
+ parentSuspense
8553
8584
  );
8554
- fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
8555
8585
  }
8556
- } catch (err) {
8557
- blockStack.length = 0;
8558
- handleError(err, instance, 1);
8559
- result = createVNode(Comment);
8560
- }
8561
- let root = result;
8562
- if (fallthroughAttrs && inheritAttrs !== false) {
8563
- const keys = Object.keys(fallthroughAttrs);
8564
- const { shapeFlag } = root;
8565
- if (keys.length) {
8566
- if (shapeFlag & (1 | 6)) {
8567
- if (propsOptions && keys.some(isModelListener)) {
8568
- fallthroughAttrs = filterModelListeners(
8569
- fallthroughAttrs,
8570
- propsOptions
8571
- );
8572
- }
8573
- root = cloneVNode(root, fallthroughAttrs, false, true);
8586
+ queuePostRenderEffect(() => {
8587
+ instance.isUnmounted = true;
8588
+ }, parentSuspense);
8589
+ };
8590
+ const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
8591
+ for (let i = start; i < children.length; i++) {
8592
+ unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
8593
+ }
8594
+ };
8595
+ const getNextHostNode = (vnode) => {
8596
+ if (vnode.shapeFlag & 6) {
8597
+ return getNextHostNode(vnode.component.subTree);
8598
+ }
8599
+ if (vnode.shapeFlag & 128) {
8600
+ return vnode.suspense.next();
8601
+ }
8602
+ const el = hostNextSibling(vnode.anchor || vnode.el);
8603
+ const teleportEnd = el && el[TeleportEndKey];
8604
+ return teleportEnd ? hostNextSibling(teleportEnd) : el;
8605
+ };
8606
+ let isFlushing = false;
8607
+ const render = (vnode, container, namespace) => {
8608
+ if (vnode == null) {
8609
+ if (container._vnode) {
8610
+ unmount(container._vnode, null, null, true);
8574
8611
  }
8575
- }
8576
- }
8577
- if (isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance) && vnode.shapeFlag & 4 && root.shapeFlag & (1 | 6)) {
8578
- const { class: cls, style } = vnode.props || {};
8579
- if (cls || style) {
8580
- root = cloneVNode(
8581
- root,
8582
- {
8583
- class: cls,
8584
- style
8585
- },
8586
- false,
8587
- true
8612
+ } else {
8613
+ patch(
8614
+ container._vnode || null,
8615
+ vnode,
8616
+ container,
8617
+ null,
8618
+ null,
8619
+ null,
8620
+ namespace
8588
8621
  );
8589
8622
  }
8623
+ container._vnode = vnode;
8624
+ if (!isFlushing) {
8625
+ isFlushing = true;
8626
+ flushPreFlushCbs();
8627
+ flushPostFlushCbs();
8628
+ isFlushing = false;
8629
+ }
8630
+ };
8631
+ const internals = {
8632
+ p: patch,
8633
+ um: unmount,
8634
+ m: move,
8635
+ r: remove,
8636
+ mt: mountComponent,
8637
+ mc: mountChildren,
8638
+ pc: patchChildren,
8639
+ pbc: patchBlockChildren,
8640
+ n: getNextHostNode,
8641
+ o: options
8642
+ };
8643
+ let hydrate;
8644
+ let hydrateNode;
8645
+ if (createHydrationFns) {
8646
+ [hydrate, hydrateNode] = createHydrationFns(
8647
+ internals
8648
+ );
8590
8649
  }
8591
- if (vnode.dirs) {
8592
- root = cloneVNode(root, null, false, true);
8593
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
8594
- }
8595
- if (vnode.transition) {
8596
- setTransitionHooks(root, vnode.transition);
8597
- }
8598
- {
8599
- result = root;
8650
+ return {
8651
+ render,
8652
+ hydrate,
8653
+ createApp: createAppAPI(render, hydrate)
8654
+ };
8655
+ }
8656
+ function resolveChildrenNamespace({ type, props }, currentNamespace) {
8657
+ return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
8658
+ }
8659
+ function toggleRecurse({ effect, job }, allowed) {
8660
+ if (allowed) {
8661
+ effect.flags |= 32;
8662
+ job.flags |= 4;
8663
+ } else {
8664
+ effect.flags &= -33;
8665
+ job.flags &= -5;
8600
8666
  }
8601
- setCurrentRenderingInstance(prev);
8602
- return result;
8603
8667
  }
8604
- function filterSingleRoot(children, recurse = true) {
8605
- let singleRoot;
8606
- for (let i = 0; i < children.length; i++) {
8607
- const child = children[i];
8608
- if (isVNode(child)) {
8609
- if (child.type !== Comment || child.children === "v-if") {
8610
- if (singleRoot) {
8611
- return;
8612
- } else {
8613
- singleRoot = child;
8668
+ function needTransition(parentSuspense, transition) {
8669
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8670
+ }
8671
+ function traverseStaticChildren(n1, n2, shallow = false) {
8672
+ const ch1 = n1.children;
8673
+ const ch2 = n2.children;
8674
+ if (isArray(ch1) && isArray(ch2)) {
8675
+ for (let i = 0; i < ch1.length; i++) {
8676
+ const c1 = ch1[i];
8677
+ let c2 = ch2[i];
8678
+ if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
8679
+ if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
8680
+ c2 = ch2[i] = cloneIfMounted(ch2[i]);
8681
+ c2.el = c1.el;
8614
8682
  }
8683
+ if (!shallow && c2.patchFlag !== -2)
8684
+ traverseStaticChildren(c1, c2);
8685
+ }
8686
+ if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
8687
+ c2.patchFlag !== -1) {
8688
+ c2.el = c1.el;
8689
+ }
8690
+ if (c2.type === Comment && !c2.el) {
8691
+ c2.el = c1.el;
8615
8692
  }
8616
- } else {
8617
- return;
8618
8693
  }
8619
8694
  }
8620
- return singleRoot;
8621
8695
  }
8622
- const getFunctionalFallthrough = (attrs) => {
8623
- let res;
8624
- for (const key in attrs) {
8625
- if (key === "class" || key === "style" || isOn(key)) {
8626
- (res || (res = {}))[key] = attrs[key];
8627
- }
8628
- }
8629
- return res;
8630
- };
8631
- const filterModelListeners = (attrs, props) => {
8632
- const res = {};
8633
- for (const key in attrs) {
8634
- if (!isModelListener(key) || !(key.slice(9) in props)) {
8635
- res[key] = attrs[key];
8636
- }
8637
- }
8638
- return res;
8639
- };
8640
- function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
8641
- const { props: prevProps, children: prevChildren, component } = prevVNode;
8642
- const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
8643
- const emits = component.emitsOptions;
8644
- if (nextVNode.dirs || nextVNode.transition) {
8645
- return true;
8646
- }
8647
- if (optimized && patchFlag >= 0) {
8648
- if (patchFlag & 1024) {
8649
- return true;
8650
- }
8651
- if (patchFlag & 16) {
8652
- if (!prevProps) {
8653
- return !!nextProps;
8696
+ function getSequence(arr) {
8697
+ const p = arr.slice();
8698
+ const result = [0];
8699
+ let i, j, u, v, c;
8700
+ const len = arr.length;
8701
+ for (i = 0; i < len; i++) {
8702
+ const arrI = arr[i];
8703
+ if (arrI !== 0) {
8704
+ j = result[result.length - 1];
8705
+ if (arr[j] < arrI) {
8706
+ p[i] = j;
8707
+ result.push(i);
8708
+ continue;
8654
8709
  }
8655
- return hasPropsChanged(prevProps, nextProps, emits);
8656
- } else if (patchFlag & 8) {
8657
- const dynamicProps = nextVNode.dynamicProps;
8658
- for (let i = 0; i < dynamicProps.length; i++) {
8659
- const key = dynamicProps[i];
8660
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
8661
- return true;
8710
+ u = 0;
8711
+ v = result.length - 1;
8712
+ while (u < v) {
8713
+ c = u + v >> 1;
8714
+ if (arr[result[c]] < arrI) {
8715
+ u = c + 1;
8716
+ } else {
8717
+ v = c;
8662
8718
  }
8663
8719
  }
8664
- }
8665
- } else {
8666
- if (prevChildren || nextChildren) {
8667
- if (!nextChildren || !nextChildren.$stable) {
8668
- return true;
8720
+ if (arrI < arr[result[u]]) {
8721
+ if (u > 0) {
8722
+ p[i] = result[u - 1];
8723
+ }
8724
+ result[u] = i;
8669
8725
  }
8670
8726
  }
8671
- if (prevProps === nextProps) {
8672
- return false;
8673
- }
8674
- if (!prevProps) {
8675
- return !!nextProps;
8676
- }
8677
- if (!nextProps) {
8678
- return true;
8679
- }
8680
- return hasPropsChanged(prevProps, nextProps, emits);
8681
8727
  }
8682
- return false;
8683
- }
8684
- function hasPropsChanged(prevProps, nextProps, emitsOptions) {
8685
- const nextKeys = Object.keys(nextProps);
8686
- if (nextKeys.length !== Object.keys(prevProps).length) {
8687
- return true;
8688
- }
8689
- for (let i = 0; i < nextKeys.length; i++) {
8690
- const key = nextKeys[i];
8691
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
8692
- return true;
8693
- }
8728
+ u = result.length;
8729
+ v = result[u - 1];
8730
+ while (u-- > 0) {
8731
+ result[u] = v;
8732
+ v = p[v];
8694
8733
  }
8695
- return false;
8734
+ return result;
8696
8735
  }
8697
- function updateHOCHostEl({ vnode, parent }, el) {
8698
- while (parent) {
8699
- const root = parent.subTree;
8700
- if (root.suspense && root.suspense.activeBranch === vnode) {
8701
- root.el = vnode.el;
8702
- }
8703
- if (root === vnode) {
8704
- (vnode = parent.vnode).el = el;
8705
- parent = parent.parent;
8736
+ function locateNonHydratedAsyncRoot(instance) {
8737
+ const subComponent = instance.subTree.component;
8738
+ if (subComponent) {
8739
+ if (subComponent.asyncDep && !subComponent.asyncResolved) {
8740
+ return subComponent;
8706
8741
  } else {
8707
- break;
8742
+ return locateNonHydratedAsyncRoot(subComponent);
8708
8743
  }
8709
8744
  }
8710
8745
  }
8746
+ function invalidateMount(hooks) {
8747
+ if (hooks) {
8748
+ for (let i = 0; i < hooks.length; i++)
8749
+ hooks[i].flags |= 8;
8750
+ }
8751
+ }
8711
8752
 
8712
8753
  const isSuspense = (type) => type.__isSuspense;
8713
8754
  let suspenseId = 0;
@@ -9040,7 +9081,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9040
9081
  }
9041
9082
  unmount(activeBranch, parentComponent2, suspense, true);
9042
9083
  if (!delayEnter && isInFallback && vnode2.ssFallback) {
9043
- vnode2.ssFallback.el = null;
9084
+ queuePostRenderEffect(() => vnode2.ssFallback.el = null, suspense);
9044
9085
  }
9045
9086
  }
9046
9087
  if (!delayEnter) {
@@ -10047,7 +10088,7 @@ function isMemoSame(cached, memo) {
10047
10088
  return true;
10048
10089
  }
10049
10090
 
10050
- const version = "3.5.24";
10091
+ const version = "3.5.25";
10051
10092
  const warn$1 = NOOP;
10052
10093
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10053
10094
  const devtools = void 0;
@@ -11969,6 +12010,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
11969
12010
  mergeModels: mergeModels,
11970
12011
  mergeProps: mergeProps,
11971
12012
  nextTick: nextTick,
12013
+ nodeOps: nodeOps,
11972
12014
  normalizeClass: normalizeClass,
11973
12015
  normalizeProps: normalizeProps,
11974
12016
  normalizeStyle: normalizeStyle,
@@ -11987,6 +12029,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
11987
12029
  onUpdated: onUpdated,
11988
12030
  onWatcherCleanup: onWatcherCleanup,
11989
12031
  openBlock: openBlock,
12032
+ patchProp: patchProp,
11990
12033
  popScopeId: popScopeId,
11991
12034
  provide: provide,
11992
12035
  proxyRefs: proxyRefs,
@@ -13952,6 +13995,20 @@ function getMemoedVNodeCall(node) {
13952
13995
  }
13953
13996
  }
13954
13997
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
13998
+ function isAllWhitespace(str) {
13999
+ for (let i = 0; i < str.length; i++) {
14000
+ if (!isWhitespace(str.charCodeAt(i))) {
14001
+ return false;
14002
+ }
14003
+ }
14004
+ return true;
14005
+ }
14006
+ function isWhitespaceText(node) {
14007
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
14008
+ }
14009
+ function isCommentOrWhitespace(node) {
14010
+ return node.type === 3 || isWhitespaceText(node);
14011
+ }
13955
14012
 
13956
14013
  const defaultParserOptions = {
13957
14014
  parseMode: "base",
@@ -14541,14 +14598,6 @@ function condenseWhitespace(nodes) {
14541
14598
  }
14542
14599
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
14543
14600
  }
14544
- function isAllWhitespace(str) {
14545
- for (let i = 0; i < str.length; i++) {
14546
- if (!isWhitespace(str.charCodeAt(i))) {
14547
- return false;
14548
- }
14549
- }
14550
- return true;
14551
- }
14552
14601
  function hasNewlineChar(str) {
14553
14602
  for (let i = 0; i < str.length; i++) {
14554
14603
  const c = str.charCodeAt(i);
@@ -16331,11 +16380,7 @@ function processIf(node, dir, context, processCodegen) {
16331
16380
  let i = siblings.indexOf(node);
16332
16381
  while (i-- >= -1) {
16333
16382
  const sibling = siblings[i];
16334
- if (sibling && sibling.type === 3) {
16335
- context.removeNode(sibling);
16336
- continue;
16337
- }
16338
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
16383
+ if (sibling && isCommentOrWhitespace(sibling)) {
16339
16384
  context.removeNode(sibling);
16340
16385
  continue;
16341
16386
  }
@@ -16847,7 +16892,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16847
16892
  let prev;
16848
16893
  while (j--) {
16849
16894
  prev = children[j];
16850
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
16895
+ if (!isCommentOrWhitespace(prev)) {
16851
16896
  break;
16852
16897
  }
16853
16898
  }
@@ -16925,7 +16970,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16925
16970
  } else if (implicitDefaultChildren.length && // #3766
16926
16971
  // with whitespace: 'preserve', whitespaces between slots will end up in
16927
16972
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
16928
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
16973
+ !implicitDefaultChildren.every(isWhitespaceText)) {
16929
16974
  if (hasNamedDefaultSlot) {
16930
16975
  context.onError(
16931
16976
  createCompilerError(
@@ -16998,11 +17043,6 @@ function hasForwardedSlots(children) {
16998
17043
  }
16999
17044
  return false;
17000
17045
  }
17001
- function isNonWhitespaceContent(node) {
17002
- if (node.type !== 2 && node.type !== 12)
17003
- return true;
17004
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
17005
- }
17006
17046
 
17007
17047
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
17008
17048
  const transformElement = (node, context) => {