@vue/runtime-core 3.6.0-alpha.4 → 3.6.0-alpha.5

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/runtime-core v3.6.0-alpha.4
2
+ * @vue/runtime-core v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2616,7 +2616,6 @@ const PublicInstanceProxyHandlers = {
2616
2616
  return true;
2617
2617
  }
2618
2618
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
2619
- let normalizedProps;
2620
2619
  if (key[0] !== "$") {
2621
2620
  const n = accessCache[key];
2622
2621
  if (n !== void 0) {
@@ -2636,11 +2635,7 @@ const PublicInstanceProxyHandlers = {
2636
2635
  } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
2637
2636
  accessCache[key] = 2 /* DATA */;
2638
2637
  return data[key];
2639
- } else if (
2640
- // only cache other properties when instance has declared (thus stable)
2641
- // props
2642
- (normalizedProps = instance.propsOptions[0]) && shared.hasOwn(normalizedProps, key)
2643
- ) {
2638
+ } else if (shared.hasOwn(props, key)) {
2644
2639
  accessCache[key] = 3 /* PROPS */;
2645
2640
  return props[key];
2646
2641
  } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
@@ -2695,10 +2690,10 @@ const PublicInstanceProxyHandlers = {
2695
2690
  return true;
2696
2691
  },
2697
2692
  has({
2698
- _: { data, setupState, accessCache, ctx, appContext, propsOptions, type }
2693
+ _: { data, setupState, accessCache, ctx, appContext, props, type }
2699
2694
  }, key) {
2700
- let normalizedProps, cssModules;
2701
- return !!(accessCache[key] || data !== shared.EMPTY_OBJ && key[0] !== "$" && shared.hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && shared.hasOwn(normalizedProps, key) || shared.hasOwn(ctx, key) || shared.hasOwn(publicPropertiesMap, key) || shared.hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
2695
+ let cssModules;
2696
+ return !!(accessCache[key] || data !== shared.EMPTY_OBJ && key[0] !== "$" && shared.hasOwn(data, key) || hasSetupBinding(setupState, key) || shared.hasOwn(props, key) || shared.hasOwn(ctx, key) || shared.hasOwn(publicPropertiesMap, key) || shared.hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
2702
2697
  },
2703
2698
  defineProperty(target, key, descriptor) {
2704
2699
  if (descriptor.get != null) {
@@ -3271,8 +3266,7 @@ function createAppAPI(mount, unmount, getPublicInstance, render) {
3271
3266
  let currentApp = null;
3272
3267
 
3273
3268
  function provide(key, value) {
3274
- const currentInstance = getCurrentGenericInstance();
3275
- if (!currentInstance) ; else {
3269
+ if (currentInstance) {
3276
3270
  let provides = currentInstance.provides;
3277
3271
  const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3278
3272
  if (parentProvides === provides) {
@@ -3296,2438 +3290,2438 @@ function hasInjectionContext() {
3296
3290
  return !!(getCurrentGenericInstance() || currentApp);
3297
3291
  }
3298
3292
 
3299
- const internalObjectProto = {};
3300
- const createInternalObject = () => Object.create(internalObjectProto);
3301
- const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
3302
-
3303
- function initProps(instance, rawProps, isStateful, isSSR = false) {
3304
- const props = instance.props = {};
3305
- const attrs = createInternalObject();
3306
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3307
- setFullProps(instance, rawProps, props, attrs);
3308
- for (const key in instance.propsOptions[0]) {
3309
- if (!(key in props)) {
3310
- props[key] = void 0;
3311
- }
3312
- }
3313
- if (isStateful) {
3314
- instance.props = isSSR ? props : reactivity.shallowReactive(props);
3315
- } else {
3316
- if (!instance.type.props) {
3317
- instance.props = attrs;
3318
- } else {
3319
- instance.props = props;
3320
- }
3293
+ const ssrContextKey = Symbol.for("v-scx");
3294
+ const useSSRContext = () => {
3295
+ {
3296
+ const ctx = inject(ssrContextKey);
3297
+ return ctx;
3321
3298
  }
3322
- instance.attrs = attrs;
3299
+ };
3300
+
3301
+ function watchEffect(effect, options) {
3302
+ return doWatch(effect, null, options);
3323
3303
  }
3324
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
3325
- const {
3326
- props,
3327
- attrs,
3328
- vnode: { patchFlag }
3329
- } = instance;
3330
- const rawCurrentProps = reactivity.toRaw(props);
3331
- const [options] = instance.propsOptions;
3332
- let hasAttrsChanged = false;
3333
- if (
3334
- // always force full diff in dev
3335
- // - #1942 if hmr is enabled with sfc component
3336
- // - vite#872 non-sfc component used by sfc component
3337
- (optimized || patchFlag > 0) && !(patchFlag & 16)
3338
- ) {
3339
- if (patchFlag & 8) {
3340
- const propsToUpdate = instance.vnode.dynamicProps;
3341
- for (let i = 0; i < propsToUpdate.length; i++) {
3342
- let key = propsToUpdate[i];
3343
- if (isEmitListener(instance.emitsOptions, key)) {
3344
- continue;
3345
- }
3346
- const value = rawProps[key];
3347
- if (options) {
3348
- if (shared.hasOwn(attrs, key)) {
3349
- if (value !== attrs[key]) {
3350
- attrs[key] = value;
3351
- hasAttrsChanged = true;
3352
- }
3353
- } else {
3354
- const camelizedKey = shared.camelize(key);
3355
- props[camelizedKey] = resolvePropValue(
3356
- options,
3357
- camelizedKey,
3358
- value,
3359
- instance,
3360
- baseResolveDefault
3361
- );
3362
- }
3363
- } else {
3364
- if (value !== attrs[key]) {
3365
- attrs[key] = value;
3366
- hasAttrsChanged = true;
3367
- }
3368
- }
3304
+ function watchPostEffect(effect, options) {
3305
+ return doWatch(
3306
+ effect,
3307
+ null,
3308
+ { flush: "post" }
3309
+ );
3310
+ }
3311
+ function watchSyncEffect(effect, options) {
3312
+ return doWatch(
3313
+ effect,
3314
+ null,
3315
+ { flush: "sync" }
3316
+ );
3317
+ }
3318
+ function watch(source, cb, options) {
3319
+ return doWatch(source, cb, options);
3320
+ }
3321
+ class RenderWatcherEffect extends reactivity.WatcherEffect {
3322
+ constructor(instance, source, cb, options, flush) {
3323
+ super(source, cb, options);
3324
+ this.flush = flush;
3325
+ const job = () => {
3326
+ if (this.dirty) {
3327
+ this.run();
3369
3328
  }
3329
+ };
3330
+ if (cb) {
3331
+ this.flags |= 128;
3332
+ job.flags |= 2;
3370
3333
  }
3371
- } else {
3372
- if (setFullProps(instance, rawProps, props, attrs)) {
3373
- hasAttrsChanged = true;
3374
- }
3375
- let kebabKey;
3376
- for (const key in rawCurrentProps) {
3377
- if (!rawProps || // for camelCase
3378
- !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
3379
- // and converted to camelCase (#955)
3380
- ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
3381
- if (options) {
3382
- if (rawPrevProps && // for camelCase
3383
- (rawPrevProps[key] !== void 0 || // for kebab-case
3384
- rawPrevProps[kebabKey] !== void 0)) {
3385
- props[key] = resolvePropValue(
3386
- options,
3387
- key,
3388
- void 0,
3389
- instance,
3390
- baseResolveDefault,
3391
- true
3392
- );
3393
- }
3394
- } else {
3395
- delete props[key];
3396
- }
3397
- }
3334
+ if (instance) {
3335
+ job.i = instance;
3398
3336
  }
3399
- if (attrs !== rawCurrentProps) {
3400
- for (const key in attrs) {
3401
- if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
3402
- delete attrs[key];
3403
- hasAttrsChanged = true;
3404
- }
3337
+ this.job = job;
3338
+ }
3339
+ notify() {
3340
+ const flags = this.flags;
3341
+ if (!(flags & 256)) {
3342
+ const flush = this.flush;
3343
+ const job = this.job;
3344
+ if (flush === "post") {
3345
+ queuePostRenderEffect(job, void 0, job.i ? job.i.suspense : null);
3346
+ } else if (flush === "pre") {
3347
+ queueJob(job, job.i ? job.i.uid : void 0, true);
3348
+ } else {
3349
+ job();
3405
3350
  }
3406
3351
  }
3407
3352
  }
3408
- if (hasAttrsChanged) {
3409
- reactivity.trigger(instance.attrs, "set", "");
3410
- }
3411
3353
  }
3412
- function setFullProps(instance, rawProps, props, attrs) {
3413
- const [options, needCastKeys] = instance.propsOptions;
3414
- let hasAttrsChanged = false;
3415
- let rawCastValues;
3416
- if (rawProps) {
3417
- for (let key in rawProps) {
3418
- if (shared.isReservedProp(key)) {
3419
- continue;
3420
- }
3421
- const value = rawProps[key];
3422
- let camelKey;
3423
- if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
3424
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
3425
- props[camelKey] = value;
3426
- } else {
3427
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
3428
- }
3429
- } else if (!isEmitListener(instance.emitsOptions, key)) {
3430
- if (!(key in attrs) || value !== attrs[key]) {
3431
- attrs[key] = value;
3432
- hasAttrsChanged = true;
3433
- }
3434
- }
3354
+ function doWatch(source, cb, options = shared.EMPTY_OBJ) {
3355
+ const { immediate, deep, flush = "pre", once } = options;
3356
+ const baseWatchOptions = shared.extend({}, options);
3357
+ const runsImmediately = cb && immediate || !cb && flush !== "post";
3358
+ let ssrCleanup;
3359
+ if (isInSSRComponentSetup) {
3360
+ if (flush === "sync") {
3361
+ const ctx = useSSRContext();
3362
+ ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
3363
+ } else if (!runsImmediately) {
3364
+ const watchStopHandle = () => {
3365
+ };
3366
+ watchStopHandle.stop = shared.NOOP;
3367
+ watchStopHandle.resume = shared.NOOP;
3368
+ watchStopHandle.pause = shared.NOOP;
3369
+ return watchStopHandle;
3435
3370
  }
3436
3371
  }
3437
- if (needCastKeys) {
3438
- const castValues = rawCastValues || shared.EMPTY_OBJ;
3439
- for (let i = 0; i < needCastKeys.length; i++) {
3440
- const key = needCastKeys[i];
3441
- props[key] = resolvePropValue(
3442
- options,
3443
- key,
3444
- castValues[key],
3445
- instance,
3446
- baseResolveDefault,
3447
- !shared.hasOwn(castValues, key)
3448
- );
3372
+ const instance = currentInstance;
3373
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
3374
+ const effect = new RenderWatcherEffect(
3375
+ instance,
3376
+ source,
3377
+ cb,
3378
+ baseWatchOptions,
3379
+ flush
3380
+ );
3381
+ if (cb) {
3382
+ effect.run(true);
3383
+ } else if (flush === "post") {
3384
+ queuePostRenderEffect(effect.job, void 0, instance && instance.suspense);
3385
+ } else {
3386
+ effect.run(true);
3387
+ }
3388
+ const stop = effect.stop.bind(effect);
3389
+ stop.pause = effect.pause.bind(effect);
3390
+ stop.resume = effect.resume.bind(effect);
3391
+ stop.stop = stop;
3392
+ if (isInSSRComponentSetup) {
3393
+ if (ssrCleanup) {
3394
+ ssrCleanup.push(stop);
3395
+ } else if (runsImmediately) {
3396
+ stop();
3449
3397
  }
3450
3398
  }
3451
- return hasAttrsChanged;
3399
+ return stop;
3452
3400
  }
3453
- function resolvePropValue(options, key, value, instance, resolveDefault, isAbsent = false) {
3454
- const opt = options[key];
3455
- if (opt != null) {
3456
- const hasDefault = shared.hasOwn(opt, "default");
3457
- if (hasDefault && value === void 0) {
3458
- const defaultValue = opt.default;
3459
- if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
3460
- const cachedDefaults = instance.propsDefaults || (instance.propsDefaults = {});
3461
- if (shared.hasOwn(cachedDefaults, key)) {
3462
- value = cachedDefaults[key];
3463
- } else {
3464
- value = cachedDefaults[key] = resolveDefault(
3465
- defaultValue,
3466
- instance,
3467
- key
3468
- );
3469
- }
3470
- } else {
3471
- value = defaultValue;
3472
- }
3473
- if (instance.ce) {
3474
- instance.ce._setProp(key, value);
3475
- }
3401
+ function instanceWatch(source, value, options) {
3402
+ const publicThis = this.proxy;
3403
+ const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
3404
+ let cb;
3405
+ if (shared.isFunction(value)) {
3406
+ cb = value;
3407
+ } else {
3408
+ cb = value.handler;
3409
+ options = value;
3410
+ }
3411
+ const prev = setCurrentInstance(this);
3412
+ const res = doWatch(getter, cb.bind(publicThis), options);
3413
+ setCurrentInstance(...prev);
3414
+ return res;
3415
+ }
3416
+ function createPathGetter(ctx, path) {
3417
+ const segments = path.split(".");
3418
+ return () => {
3419
+ let cur = ctx;
3420
+ for (let i = 0; i < segments.length && cur; i++) {
3421
+ cur = cur[segments[i]];
3476
3422
  }
3477
- if (opt[0 /* shouldCast */]) {
3478
- if (isAbsent && !hasDefault) {
3479
- value = false;
3480
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
3481
- value = true;
3423
+ return cur;
3424
+ };
3425
+ }
3426
+
3427
+ function useModel(props, name, options = shared.EMPTY_OBJ) {
3428
+ const i = getCurrentGenericInstance();
3429
+ const camelizedName = shared.camelize(name);
3430
+ const hyphenatedName = shared.hyphenate(name);
3431
+ const modifiers = getModelModifiers(props, camelizedName, defaultPropGetter);
3432
+ const res = reactivity.customRef((track, trigger) => {
3433
+ let localValue;
3434
+ let prevSetValue = shared.EMPTY_OBJ;
3435
+ let prevEmittedValue;
3436
+ watchSyncEffect(() => {
3437
+ const propValue = props[camelizedName];
3438
+ if (shared.hasChanged(localValue, propValue)) {
3439
+ localValue = propValue;
3440
+ trigger();
3441
+ }
3442
+ });
3443
+ return {
3444
+ get() {
3445
+ track();
3446
+ return options.get ? options.get(localValue) : localValue;
3447
+ },
3448
+ set(value) {
3449
+ const emittedValue = options.set ? options.set(value) : value;
3450
+ if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
3451
+ return;
3452
+ }
3453
+ let rawPropKeys;
3454
+ let parentPassedModelValue = false;
3455
+ let parentPassedModelUpdater = false;
3456
+ if (i.rawKeys) {
3457
+ rawPropKeys = i.rawKeys();
3458
+ } else {
3459
+ const rawProps = i.vnode.props;
3460
+ rawPropKeys = rawProps && Object.keys(rawProps);
3461
+ }
3462
+ if (rawPropKeys) {
3463
+ for (const key of rawPropKeys) {
3464
+ if (key === name || key === camelizedName || key === hyphenatedName) {
3465
+ parentPassedModelValue = true;
3466
+ } else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) {
3467
+ parentPassedModelUpdater = true;
3468
+ }
3469
+ }
3470
+ }
3471
+ if (!parentPassedModelValue || !parentPassedModelUpdater) {
3472
+ localValue = value;
3473
+ trigger();
3474
+ }
3475
+ i.emit(`update:${name}`, emittedValue);
3476
+ if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
3477
+ trigger();
3478
+ }
3479
+ prevSetValue = value;
3480
+ prevEmittedValue = emittedValue;
3481
+ }
3482
+ };
3483
+ });
3484
+ res[Symbol.iterator] = () => {
3485
+ let i2 = 0;
3486
+ return {
3487
+ next() {
3488
+ if (i2 < 2) {
3489
+ return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
3490
+ } else {
3491
+ return { done: true };
3492
+ }
3482
3493
  }
3494
+ };
3495
+ };
3496
+ return res;
3497
+ }
3498
+ const getModelModifiers = (props, modelName, getter) => {
3499
+ return getter(props, shared.getModifierPropName(modelName)) || getter(props, `${shared.camelize(modelName)}Modifiers`) || getter(props, `${shared.hyphenate(modelName)}Modifiers`);
3500
+ };
3501
+
3502
+ function emit(instance, event, ...rawArgs) {
3503
+ return baseEmit(
3504
+ instance,
3505
+ instance.vnode.props || shared.EMPTY_OBJ,
3506
+ defaultPropGetter,
3507
+ event,
3508
+ ...rawArgs
3509
+ );
3510
+ }
3511
+ function baseEmit(instance, props, getter, event, ...rawArgs) {
3512
+ if (instance.isUnmounted) return;
3513
+ let args = rawArgs;
3514
+ const isModelListener = event.startsWith("update:");
3515
+ const modifiers = isModelListener && getModelModifiers(props, event.slice(7), getter);
3516
+ if (modifiers) {
3517
+ if (modifiers.trim) {
3518
+ args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
3519
+ }
3520
+ if (modifiers.number) {
3521
+ args = rawArgs.map(shared.looseToNumber);
3483
3522
  }
3484
3523
  }
3485
- return value;
3524
+ let handlerName;
3525
+ let handler = getter(props, handlerName = shared.toHandlerKey(event)) || // also try camelCase event handler (#2249)
3526
+ getter(props, handlerName = shared.toHandlerKey(shared.camelize(event)));
3527
+ if (!handler && isModelListener) {
3528
+ handler = getter(props, handlerName = shared.toHandlerKey(shared.hyphenate(event)));
3529
+ }
3530
+ if (handler) {
3531
+ callWithAsyncErrorHandling(
3532
+ handler,
3533
+ instance,
3534
+ 6,
3535
+ args
3536
+ );
3537
+ }
3538
+ const onceHandler = getter(props, handlerName + `Once`);
3539
+ if (onceHandler) {
3540
+ if (!instance.emitted) {
3541
+ instance.emitted = {};
3542
+ } else if (instance.emitted[handlerName]) {
3543
+ return;
3544
+ }
3545
+ instance.emitted[handlerName] = true;
3546
+ callWithAsyncErrorHandling(
3547
+ onceHandler,
3548
+ instance,
3549
+ 6,
3550
+ args
3551
+ );
3552
+ }
3486
3553
  }
3487
- function baseResolveDefault(factory, instance, key) {
3488
- let value;
3489
- const prev = setCurrentInstance(instance);
3490
- const props = reactivity.toRaw(instance.props);
3491
- value = factory.call(
3492
- null,
3493
- props
3494
- );
3495
- setCurrentInstance(...prev);
3496
- return value;
3554
+ function defaultPropGetter(props, key) {
3555
+ return props[key];
3497
3556
  }
3498
- const mixinPropsCache = /* @__PURE__ */ new WeakMap();
3499
- function normalizePropsOptions(comp, appContext, asMixin = false) {
3500
- const cache = asMixin ? mixinPropsCache : appContext.propsCache;
3557
+ const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
3558
+ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
3559
+ const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
3501
3560
  const cached = cache.get(comp);
3502
- if (cached) {
3561
+ if (cached !== void 0) {
3503
3562
  return cached;
3504
3563
  }
3505
- const raw = comp.props;
3506
- const normalized = {};
3507
- const needCastKeys = [];
3564
+ const raw = comp.emits;
3565
+ let normalized = {};
3508
3566
  let hasExtends = false;
3509
3567
  if (!shared.isFunction(comp)) {
3510
- const extendProps = (raw2) => {
3511
- hasExtends = true;
3512
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
3513
- shared.extend(normalized, props);
3514
- if (keys) needCastKeys.push(...keys);
3568
+ const extendEmits = (raw2) => {
3569
+ const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
3570
+ if (normalizedFromExtend) {
3571
+ hasExtends = true;
3572
+ shared.extend(normalized, normalizedFromExtend);
3573
+ }
3515
3574
  };
3516
3575
  if (!asMixin && appContext.mixins.length) {
3517
- appContext.mixins.forEach(extendProps);
3576
+ appContext.mixins.forEach(extendEmits);
3518
3577
  }
3519
3578
  if (comp.extends) {
3520
- extendProps(comp.extends);
3579
+ extendEmits(comp.extends);
3521
3580
  }
3522
3581
  if (comp.mixins) {
3523
- comp.mixins.forEach(extendProps);
3582
+ comp.mixins.forEach(extendEmits);
3524
3583
  }
3525
3584
  }
3526
3585
  if (!raw && !hasExtends) {
3527
3586
  if (shared.isObject(comp)) {
3528
- cache.set(comp, shared.EMPTY_ARR);
3587
+ cache.set(comp, null);
3529
3588
  }
3530
- return shared.EMPTY_ARR;
3589
+ return null;
3590
+ }
3591
+ if (shared.isArray(raw)) {
3592
+ raw.forEach((key) => normalized[key] = null);
3593
+ } else {
3594
+ shared.extend(normalized, raw);
3531
3595
  }
3532
- baseNormalizePropsOptions(raw, normalized, needCastKeys);
3533
- const res = [normalized, needCastKeys];
3534
3596
  if (shared.isObject(comp)) {
3535
- cache.set(comp, res);
3597
+ cache.set(comp, normalized);
3536
3598
  }
3537
- return res;
3599
+ return normalized;
3538
3600
  }
3539
- function baseNormalizePropsOptions(raw, normalized, needCastKeys) {
3540
- if (shared.isArray(raw)) {
3541
- for (let i = 0; i < raw.length; i++) {
3542
- const normalizedKey = shared.camelize(raw[i]);
3543
- if (validatePropName(normalizedKey)) {
3544
- normalized[normalizedKey] = shared.EMPTY_OBJ;
3545
- }
3546
- }
3547
- } else if (raw) {
3548
- for (const key in raw) {
3549
- const normalizedKey = shared.camelize(key);
3550
- if (validatePropName(normalizedKey)) {
3551
- const opt = raw[key];
3552
- const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
3553
- const propType = prop.type;
3554
- let shouldCast = false;
3555
- let shouldCastTrue = true;
3556
- if (shared.isArray(propType)) {
3557
- for (let index = 0; index < propType.length; ++index) {
3558
- const type = propType[index];
3559
- const typeName = shared.isFunction(type) && type.name;
3560
- if (typeName === "Boolean") {
3561
- shouldCast = true;
3562
- break;
3563
- } else if (typeName === "String") {
3564
- shouldCastTrue = false;
3565
- }
3566
- }
3567
- } else {
3568
- shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
3569
- }
3570
- prop[0 /* shouldCast */] = shouldCast;
3571
- prop[1 /* shouldCastTrue */] = shouldCastTrue;
3572
- if (shouldCast || shared.hasOwn(prop, "default")) {
3573
- needCastKeys.push(normalizedKey);
3574
- }
3575
- }
3576
- }
3601
+ function isEmitListener(options, key) {
3602
+ if (!options || !shared.isOn(key)) {
3603
+ return false;
3577
3604
  }
3605
+ key = key.slice(2).replace(/Once$/, "");
3606
+ return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
3578
3607
  }
3579
- function validatePropName(key) {
3580
- if (key[0] !== "$" && !shared.isReservedProp(key)) {
3581
- return true;
3608
+
3609
+ function markAttrsAccessed() {
3610
+ }
3611
+ function renderComponentRoot(instance) {
3612
+ const {
3613
+ type: Component,
3614
+ vnode,
3615
+ proxy,
3616
+ withProxy,
3617
+ propsOptions: [propsOptions],
3618
+ slots,
3619
+ attrs,
3620
+ emit,
3621
+ render,
3622
+ renderCache,
3623
+ props,
3624
+ data,
3625
+ setupState,
3626
+ ctx,
3627
+ inheritAttrs
3628
+ } = instance;
3629
+ const prev = setCurrentRenderingInstance(instance);
3630
+ let result;
3631
+ let fallthroughAttrs;
3632
+ try {
3633
+ if (vnode.shapeFlag & 4) {
3634
+ const proxyToUse = withProxy || proxy;
3635
+ const thisProxy = false ? new Proxy(proxyToUse, {
3636
+ get(target, key, receiver) {
3637
+ warn(
3638
+ `Property '${String(
3639
+ key
3640
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
3641
+ );
3642
+ return Reflect.get(target, key, receiver);
3643
+ }
3644
+ }) : proxyToUse;
3645
+ result = normalizeVNode(
3646
+ render.call(
3647
+ thisProxy,
3648
+ proxyToUse,
3649
+ renderCache,
3650
+ false ? shallowReadonly(props) : props,
3651
+ setupState,
3652
+ data,
3653
+ ctx
3654
+ )
3655
+ );
3656
+ fallthroughAttrs = attrs;
3657
+ } else {
3658
+ const render2 = Component;
3659
+ if (false) ;
3660
+ result = normalizeVNode(
3661
+ render2.length > 1 ? render2(
3662
+ false ? shallowReadonly(props) : props,
3663
+ false ? {
3664
+ get attrs() {
3665
+ markAttrsAccessed();
3666
+ return shallowReadonly(attrs);
3667
+ },
3668
+ slots,
3669
+ emit
3670
+ } : { attrs, slots, emit }
3671
+ ) : render2(
3672
+ false ? shallowReadonly(props) : props,
3673
+ null
3674
+ )
3675
+ );
3676
+ fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
3677
+ }
3678
+ } catch (err) {
3679
+ blockStack.length = 0;
3680
+ handleError(err, instance, 1);
3681
+ result = createVNode(Comment);
3582
3682
  }
3583
- return false;
3683
+ let root = result;
3684
+ if (fallthroughAttrs && inheritAttrs !== false) {
3685
+ const keys = Object.keys(fallthroughAttrs);
3686
+ const { shapeFlag } = root;
3687
+ if (keys.length) {
3688
+ if (shapeFlag & (1 | 6)) {
3689
+ if (propsOptions && keys.some(shared.isModelListener)) {
3690
+ fallthroughAttrs = filterModelListeners(
3691
+ fallthroughAttrs,
3692
+ propsOptions
3693
+ );
3694
+ }
3695
+ root = cloneVNode(root, fallthroughAttrs, false, true);
3696
+ }
3697
+ }
3698
+ }
3699
+ if (vnode.dirs) {
3700
+ root = cloneVNode(root, null, false, true);
3701
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3702
+ }
3703
+ if (vnode.transition) {
3704
+ setTransitionHooks(root, vnode.transition);
3705
+ }
3706
+ {
3707
+ result = root;
3708
+ }
3709
+ setCurrentRenderingInstance(prev);
3710
+ return result;
3584
3711
  }
3585
-
3586
- const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
3587
- const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
3588
- const normalizeSlot = (key, rawSlot, ctx) => {
3589
- if (rawSlot._n) {
3590
- return rawSlot;
3712
+ function filterSingleRoot(children, recurse = true) {
3713
+ let singleRoot;
3714
+ for (let i = 0; i < children.length; i++) {
3715
+ const child = children[i];
3716
+ if (isVNode(child)) {
3717
+ if (child.type !== Comment || child.children === "v-if") {
3718
+ if (singleRoot) {
3719
+ return;
3720
+ } else {
3721
+ singleRoot = child;
3722
+ }
3723
+ }
3724
+ } else {
3725
+ return;
3726
+ }
3591
3727
  }
3592
- const normalized = withCtx((...args) => {
3593
- if (false) ;
3594
- return normalizeSlotValue(rawSlot(...args));
3595
- }, ctx);
3596
- normalized._c = false;
3597
- return normalized;
3598
- };
3599
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
3600
- const ctx = rawSlots._ctx;
3601
- for (const key in rawSlots) {
3602
- if (isInternalKey(key)) continue;
3603
- const value = rawSlots[key];
3604
- if (shared.isFunction(value)) {
3605
- slots[key] = normalizeSlot(key, value, ctx);
3606
- } else if (value != null) {
3607
- const normalized = normalizeSlotValue(value);
3608
- slots[key] = () => normalized;
3728
+ return singleRoot;
3729
+ }
3730
+ const getFunctionalFallthrough = (attrs) => {
3731
+ let res;
3732
+ for (const key in attrs) {
3733
+ if (key === "class" || key === "style" || shared.isOn(key)) {
3734
+ (res || (res = {}))[key] = attrs[key];
3609
3735
  }
3610
3736
  }
3737
+ return res;
3611
3738
  };
3612
- const normalizeVNodeSlots = (instance, children) => {
3613
- const normalized = normalizeSlotValue(children);
3614
- instance.slots.default = () => normalized;
3615
- };
3616
- const assignSlots = (slots, children, optimized) => {
3617
- for (const key in children) {
3618
- if (optimized || !isInternalKey(key)) {
3619
- slots[key] = children[key];
3739
+ const filterModelListeners = (attrs, props) => {
3740
+ const res = {};
3741
+ for (const key in attrs) {
3742
+ if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
3743
+ res[key] = attrs[key];
3620
3744
  }
3621
3745
  }
3746
+ return res;
3622
3747
  };
3623
- const initSlots = (instance, children, optimized) => {
3624
- const slots = instance.slots = createInternalObject();
3625
- if (instance.vnode.shapeFlag & 32) {
3626
- const type = children._;
3627
- if (type) {
3628
- assignSlots(slots, children, optimized);
3629
- if (optimized) {
3630
- shared.def(slots, "_", type, true);
3748
+ function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
3749
+ const { props: prevProps, children: prevChildren, component } = prevVNode;
3750
+ const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
3751
+ const emits = component.emitsOptions;
3752
+ if (nextVNode.dirs || nextVNode.transition) {
3753
+ return true;
3754
+ }
3755
+ if (optimized && patchFlag >= 0) {
3756
+ if (patchFlag & 1024) {
3757
+ return true;
3758
+ }
3759
+ if (patchFlag & 16) {
3760
+ if (!prevProps) {
3761
+ return !!nextProps;
3762
+ }
3763
+ return hasPropsChanged(prevProps, nextProps, emits);
3764
+ } else if (patchFlag & 8) {
3765
+ const dynamicProps = nextVNode.dynamicProps;
3766
+ for (let i = 0; i < dynamicProps.length; i++) {
3767
+ const key = dynamicProps[i];
3768
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
3769
+ return true;
3770
+ }
3631
3771
  }
3632
- } else {
3633
- normalizeObjectSlots(children, slots);
3634
3772
  }
3635
- } else if (children) {
3636
- normalizeVNodeSlots(instance, children);
3637
- }
3638
- };
3639
- const updateSlots = (instance, children, optimized) => {
3640
- const { vnode, slots } = instance;
3641
- let needDeletionCheck = true;
3642
- let deletionComparisonTarget = shared.EMPTY_OBJ;
3643
- if (vnode.shapeFlag & 32) {
3644
- const type = children._;
3645
- if (type) {
3646
- if (optimized && type === 1) {
3647
- needDeletionCheck = false;
3648
- } else {
3649
- assignSlots(slots, children, optimized);
3773
+ } else {
3774
+ if (prevChildren || nextChildren) {
3775
+ if (!nextChildren || !nextChildren.$stable) {
3776
+ return true;
3650
3777
  }
3651
- } else {
3652
- needDeletionCheck = !children.$stable;
3653
- normalizeObjectSlots(children, slots);
3654
3778
  }
3655
- deletionComparisonTarget = children;
3656
- } else if (children) {
3657
- normalizeVNodeSlots(instance, children);
3658
- deletionComparisonTarget = { default: 1 };
3779
+ if (prevProps === nextProps) {
3780
+ return false;
3781
+ }
3782
+ if (!prevProps) {
3783
+ return !!nextProps;
3784
+ }
3785
+ if (!nextProps) {
3786
+ return true;
3787
+ }
3788
+ return hasPropsChanged(prevProps, nextProps, emits);
3659
3789
  }
3660
- if (needDeletionCheck) {
3661
- for (const key in slots) {
3662
- if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
3663
- delete slots[key];
3664
- }
3790
+ return false;
3791
+ }
3792
+ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
3793
+ const nextKeys = Object.keys(nextProps);
3794
+ if (nextKeys.length !== Object.keys(prevProps).length) {
3795
+ return true;
3796
+ }
3797
+ for (let i = 0; i < nextKeys.length; i++) {
3798
+ const key = nextKeys[i];
3799
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
3800
+ return true;
3665
3801
  }
3666
3802
  }
3667
- };
3668
-
3669
- const queuePostRenderEffect = queueEffectWithSuspense ;
3670
- function createRenderer(options) {
3671
- return baseCreateRenderer(options);
3803
+ return false;
3672
3804
  }
3673
- function createHydrationRenderer(options) {
3674
- return baseCreateRenderer(options, createHydrationFunctions);
3675
- }
3676
- function baseCreateRenderer(options, createHydrationFns) {
3677
- const target = shared.getGlobalThis();
3678
- target.__VUE__ = true;
3679
- const {
3680
- insert: hostInsert,
3681
- remove: hostRemove,
3682
- patchProp: hostPatchProp,
3683
- createElement: hostCreateElement,
3684
- createText: hostCreateText,
3685
- createComment: hostCreateComment,
3686
- setText: hostSetText,
3687
- setElementText: hostSetElementText,
3688
- parentNode: hostParentNode,
3689
- nextSibling: hostNextSibling,
3690
- setScopeId: hostSetScopeId = shared.NOOP,
3691
- insertStaticContent: hostInsertStaticContent
3692
- } = options;
3693
- const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
3694
- if (n1 === n2) {
3695
- return;
3696
- }
3697
- if (n1 && !isSameVNodeType(n1, n2)) {
3698
- anchor = getNextHostNode(n1);
3699
- unmount(n1, parentComponent, parentSuspense, true);
3700
- n1 = null;
3701
- }
3702
- if (n2.patchFlag === -2) {
3703
- optimized = false;
3704
- n2.dynamicChildren = null;
3705
- }
3706
- const { type, ref, shapeFlag } = n2;
3707
- switch (type) {
3708
- case Text:
3709
- processText(n1, n2, container, anchor);
3710
- break;
3711
- case Comment:
3712
- processCommentNode(n1, n2, container, anchor);
3713
- break;
3714
- case Static:
3715
- if (n1 == null) {
3716
- mountStaticNode(n2, container, anchor, namespace);
3717
- }
3718
- break;
3719
- case Fragment:
3720
- processFragment(
3721
- n1,
3722
- n2,
3723
- container,
3724
- anchor,
3725
- parentComponent,
3726
- parentSuspense,
3727
- namespace,
3728
- slotScopeIds,
3729
- optimized
3730
- );
3731
- break;
3732
- case VaporSlot:
3733
- getVaporInterface(parentComponent, n2).slot(n1, n2, container, anchor);
3734
- break;
3735
- default:
3736
- if (shapeFlag & 1) {
3737
- processElement(
3738
- n1,
3739
- n2,
3740
- container,
3741
- anchor,
3742
- parentComponent,
3743
- parentSuspense,
3744
- namespace,
3745
- slotScopeIds,
3746
- optimized
3747
- );
3748
- } else if (shapeFlag & 6) {
3749
- processComponent(
3750
- n1,
3751
- n2,
3752
- container,
3753
- anchor,
3754
- parentComponent,
3755
- parentSuspense,
3756
- namespace,
3757
- slotScopeIds,
3758
- optimized
3759
- );
3760
- } else if (shapeFlag & 64) {
3761
- type.process(
3762
- n1,
3763
- n2,
3764
- container,
3765
- anchor,
3766
- parentComponent,
3767
- parentSuspense,
3768
- namespace,
3769
- slotScopeIds,
3770
- optimized,
3771
- internals
3772
- );
3773
- } else if (shapeFlag & 128) {
3774
- type.process(
3775
- n1,
3776
- n2,
3777
- container,
3778
- anchor,
3779
- parentComponent,
3780
- parentSuspense,
3781
- namespace,
3782
- slotScopeIds,
3783
- optimized,
3784
- internals
3785
- );
3786
- } else ;
3787
- }
3788
- if (ref != null && parentComponent) {
3789
- setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
3790
- } else if (ref == null && n1 && n1.ref != null) {
3791
- setRef(n1.ref, null, parentSuspense, n1, true);
3792
- }
3793
- };
3794
- const processText = (n1, n2, container, anchor) => {
3795
- if (n1 == null) {
3796
- hostInsert(
3797
- n2.el = hostCreateText(n2.children),
3798
- container,
3799
- anchor
3800
- );
3801
- } else {
3802
- const el = n2.el = n1.el;
3803
- if (n2.children !== n1.children) {
3804
- hostSetText(el, n2.children);
3805
- }
3806
- }
3807
- };
3808
- const processCommentNode = (n1, n2, container, anchor) => {
3809
- if (n1 == null) {
3810
- hostInsert(
3811
- n2.el = hostCreateComment(n2.children || ""),
3812
- container,
3813
- anchor
3814
- );
3815
- } else {
3816
- n2.el = n1.el;
3817
- }
3818
- };
3819
- const mountStaticNode = (n2, container, anchor, namespace) => {
3820
- [n2.el, n2.anchor] = hostInsertStaticContent(
3821
- n2.children,
3822
- container,
3823
- anchor,
3824
- namespace,
3825
- n2.el,
3826
- n2.anchor
3827
- );
3828
- };
3829
- const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
3830
- let next;
3831
- while (el && el !== anchor) {
3832
- next = hostNextSibling(el);
3833
- hostInsert(el, container, nextSibling);
3834
- el = next;
3835
- }
3836
- hostInsert(anchor, container, nextSibling);
3837
- };
3838
- const removeStaticNode = ({ el, anchor }) => {
3839
- let next;
3840
- while (el && el !== anchor) {
3841
- next = hostNextSibling(el);
3842
- hostRemove(el);
3843
- el = next;
3844
- }
3845
- hostRemove(anchor);
3846
- };
3847
- const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3848
- if (n2.type === "svg") {
3849
- namespace = "svg";
3850
- } else if (n2.type === "math") {
3851
- namespace = "mathml";
3805
+ function updateHOCHostEl({ vnode, parent }, el) {
3806
+ while (parent && !parent.vapor) {
3807
+ const root = parent.subTree;
3808
+ if (root.suspense && root.suspense.activeBranch === vnode) {
3809
+ root.el = vnode.el;
3852
3810
  }
3853
- if (n1 == null) {
3854
- mountElement(
3855
- n2,
3856
- container,
3857
- anchor,
3858
- parentComponent,
3859
- parentSuspense,
3860
- namespace,
3861
- slotScopeIds,
3862
- optimized
3863
- );
3811
+ if (root === vnode) {
3812
+ (vnode = parent.vnode).el = el;
3813
+ parent = parent.parent;
3864
3814
  } else {
3865
- const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
3866
- try {
3867
- if (customElement) {
3868
- customElement._beginPatch();
3869
- }
3870
- patchElement(
3871
- n1,
3872
- n2,
3873
- parentComponent,
3874
- parentSuspense,
3875
- namespace,
3876
- slotScopeIds,
3877
- optimized
3878
- );
3879
- } finally {
3880
- if (customElement) {
3881
- customElement._endPatch();
3882
- }
3883
- }
3884
- }
3885
- };
3886
- const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3887
- let el;
3888
- let vnodeHook;
3889
- const { props, shapeFlag, transition, dirs } = vnode;
3890
- el = vnode.el = hostCreateElement(
3891
- vnode.type,
3892
- namespace,
3893
- props && props.is,
3894
- props
3895
- );
3896
- if (shapeFlag & 8) {
3897
- hostSetElementText(el, vnode.children);
3898
- } else if (shapeFlag & 16) {
3899
- mountChildren(
3900
- vnode.children,
3901
- el,
3902
- null,
3903
- parentComponent,
3904
- parentSuspense,
3905
- resolveChildrenNamespace(vnode, namespace),
3906
- slotScopeIds,
3907
- optimized
3908
- );
3909
- }
3910
- if (dirs) {
3911
- invokeDirectiveHook(vnode, null, parentComponent, "created");
3912
- }
3913
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
3914
- if (props) {
3915
- for (const key in props) {
3916
- if (key !== "value" && !shared.isReservedProp(key)) {
3917
- hostPatchProp(el, key, null, props[key], namespace, parentComponent);
3918
- }
3919
- }
3920
- if ("value" in props) {
3921
- hostPatchProp(el, "value", null, props.value, namespace);
3922
- }
3923
- if (vnodeHook = props.onVnodeBeforeMount) {
3924
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
3925
- }
3815
+ break;
3926
3816
  }
3927
- if (dirs) {
3928
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
3817
+ }
3818
+ }
3819
+
3820
+ const internalObjectProto = {};
3821
+ const createInternalObject = () => Object.create(internalObjectProto);
3822
+ const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
3823
+
3824
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
3825
+ const props = instance.props = {};
3826
+ const attrs = createInternalObject();
3827
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3828
+ setFullProps(instance, rawProps, props, attrs);
3829
+ for (const key in instance.propsOptions[0]) {
3830
+ if (!(key in props)) {
3831
+ props[key] = void 0;
3929
3832
  }
3930
- if (transition) {
3931
- performTransitionEnter(
3932
- el,
3933
- transition,
3934
- () => hostInsert(el, container, anchor),
3935
- parentSuspense
3936
- );
3833
+ }
3834
+ if (isStateful) {
3835
+ instance.props = isSSR ? props : reactivity.shallowReactive(props);
3836
+ } else {
3837
+ if (!instance.type.props) {
3838
+ instance.props = attrs;
3937
3839
  } else {
3938
- hostInsert(el, container, anchor);
3939
- }
3940
- if ((vnodeHook = props && props.onVnodeMounted) || dirs) {
3941
- queuePostRenderEffect(
3942
- () => {
3943
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
3944
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
3945
- },
3946
- void 0,
3947
- parentSuspense
3948
- );
3949
- }
3950
- };
3951
- const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
3952
- if (scopeId) {
3953
- hostSetScopeId(el, scopeId);
3954
- }
3955
- if (slotScopeIds) {
3956
- for (let i = 0; i < slotScopeIds.length; i++) {
3957
- hostSetScopeId(el, slotScopeIds[i]);
3958
- }
3959
- }
3960
- const inheritedScopeIds = getInheritedScopeIds(vnode, parentComponent);
3961
- for (let i = 0; i < inheritedScopeIds.length; i++) {
3962
- hostSetScopeId(el, inheritedScopeIds[i]);
3963
- }
3964
- };
3965
- const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
3966
- for (let i = start; i < children.length; i++) {
3967
- const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
3968
- patch(
3969
- null,
3970
- child,
3971
- container,
3972
- anchor,
3973
- parentComponent,
3974
- parentSuspense,
3975
- namespace,
3976
- slotScopeIds,
3977
- optimized
3978
- );
3979
- }
3980
- };
3981
- const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3982
- const el = n2.el = n1.el;
3983
- let { patchFlag, dynamicChildren, dirs } = n2;
3984
- patchFlag |= n1.patchFlag & 16;
3985
- const oldProps = n1.props || shared.EMPTY_OBJ;
3986
- const newProps = n2.props || shared.EMPTY_OBJ;
3987
- let vnodeHook;
3988
- parentComponent && toggleRecurse(parentComponent, false);
3989
- if (vnodeHook = newProps.onVnodeBeforeUpdate) {
3990
- invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3991
- }
3992
- if (dirs) {
3993
- invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
3994
- }
3995
- parentComponent && toggleRecurse(parentComponent, true);
3996
- if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
3997
- hostSetElementText(el, "");
3998
- }
3999
- if (dynamicChildren) {
4000
- patchBlockChildren(
4001
- n1.dynamicChildren,
4002
- dynamicChildren,
4003
- el,
4004
- parentComponent,
4005
- parentSuspense,
4006
- resolveChildrenNamespace(n2, namespace),
4007
- slotScopeIds
4008
- );
4009
- } else if (!optimized) {
4010
- patchChildren(
4011
- n1,
4012
- n2,
4013
- el,
4014
- null,
4015
- parentComponent,
4016
- parentSuspense,
4017
- resolveChildrenNamespace(n2, namespace),
4018
- slotScopeIds,
4019
- false
4020
- );
3840
+ instance.props = props;
4021
3841
  }
4022
- if (patchFlag > 0) {
4023
- if (patchFlag & 16) {
4024
- patchProps(el, oldProps, newProps, parentComponent, namespace);
4025
- } else {
4026
- if (patchFlag & 2) {
4027
- if (oldProps.class !== newProps.class) {
4028
- hostPatchProp(el, "class", null, newProps.class, namespace);
4029
- }
4030
- }
4031
- if (patchFlag & 4) {
4032
- hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
3842
+ }
3843
+ instance.attrs = attrs;
3844
+ }
3845
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3846
+ const {
3847
+ props,
3848
+ attrs,
3849
+ vnode: { patchFlag }
3850
+ } = instance;
3851
+ const rawCurrentProps = reactivity.toRaw(props);
3852
+ const [options] = instance.propsOptions;
3853
+ let hasAttrsChanged = false;
3854
+ if (
3855
+ // always force full diff in dev
3856
+ // - #1942 if hmr is enabled with sfc component
3857
+ // - vite#872 non-sfc component used by sfc component
3858
+ (optimized || patchFlag > 0) && !(patchFlag & 16)
3859
+ ) {
3860
+ if (patchFlag & 8) {
3861
+ const propsToUpdate = instance.vnode.dynamicProps;
3862
+ for (let i = 0; i < propsToUpdate.length; i++) {
3863
+ let key = propsToUpdate[i];
3864
+ if (isEmitListener(instance.emitsOptions, key)) {
3865
+ continue;
4033
3866
  }
4034
- if (patchFlag & 8) {
4035
- const propsToUpdate = n2.dynamicProps;
4036
- for (let i = 0; i < propsToUpdate.length; i++) {
4037
- const key = propsToUpdate[i];
4038
- const prev = oldProps[key];
4039
- const next = newProps[key];
4040
- if (next !== prev || key === "value") {
4041
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
3867
+ const value = rawProps[key];
3868
+ if (options) {
3869
+ if (shared.hasOwn(attrs, key)) {
3870
+ if (value !== attrs[key]) {
3871
+ attrs[key] = value;
3872
+ hasAttrsChanged = true;
4042
3873
  }
3874
+ } else {
3875
+ const camelizedKey = shared.camelize(key);
3876
+ props[camelizedKey] = resolvePropValue(
3877
+ options,
3878
+ camelizedKey,
3879
+ value,
3880
+ instance,
3881
+ baseResolveDefault
3882
+ );
3883
+ }
3884
+ } else {
3885
+ if (value !== attrs[key]) {
3886
+ attrs[key] = value;
3887
+ hasAttrsChanged = true;
4043
3888
  }
4044
3889
  }
4045
3890
  }
4046
- if (patchFlag & 1) {
4047
- if (n1.children !== n2.children) {
4048
- hostSetElementText(el, n2.children);
4049
- }
4050
- }
4051
- } else if (!optimized && dynamicChildren == null) {
4052
- patchProps(el, oldProps, newProps, parentComponent, namespace);
4053
3891
  }
4054
- if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
4055
- queuePostRenderEffect(
4056
- () => {
4057
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4058
- dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
4059
- },
4060
- void 0,
4061
- parentSuspense
4062
- );
4063
- }
4064
- };
4065
- const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
4066
- for (let i = 0; i < newChildren.length; i++) {
4067
- const oldVNode = oldChildren[i];
4068
- const newVNode = newChildren[i];
4069
- const container = (
4070
- // oldVNode may be an errored async setup() component inside Suspense
4071
- // which will not have a mounted element
4072
- oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
4073
- // of the Fragment itself so it can move its children.
4074
- (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
4075
- // which also requires the correct parent container
4076
- !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
4077
- oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
4078
- // In other cases, the parent container is not actually used so we
4079
- // just pass the block element here to avoid a DOM parentNode call.
4080
- fallbackContainer
4081
- )
4082
- );
4083
- patch(
4084
- oldVNode,
4085
- newVNode,
4086
- container,
4087
- null,
4088
- parentComponent,
4089
- parentSuspense,
4090
- namespace,
4091
- slotScopeIds,
4092
- true
4093
- );
4094
- }
4095
- };
4096
- const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
4097
- if (oldProps !== newProps) {
4098
- if (oldProps !== shared.EMPTY_OBJ) {
4099
- for (const key in oldProps) {
4100
- if (!shared.isReservedProp(key) && !(key in newProps)) {
4101
- hostPatchProp(
4102
- el,
3892
+ } else {
3893
+ if (setFullProps(instance, rawProps, props, attrs)) {
3894
+ hasAttrsChanged = true;
3895
+ }
3896
+ let kebabKey;
3897
+ for (const key in rawCurrentProps) {
3898
+ if (!rawProps || // for camelCase
3899
+ !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
3900
+ // and converted to camelCase (#955)
3901
+ ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
3902
+ if (options) {
3903
+ if (rawPrevProps && // for camelCase
3904
+ (rawPrevProps[key] !== void 0 || // for kebab-case
3905
+ rawPrevProps[kebabKey] !== void 0)) {
3906
+ props[key] = resolvePropValue(
3907
+ options,
4103
3908
  key,
4104
- oldProps[key],
4105
- null,
4106
- namespace,
4107
- parentComponent
3909
+ void 0,
3910
+ instance,
3911
+ baseResolveDefault,
3912
+ true
4108
3913
  );
4109
3914
  }
3915
+ } else {
3916
+ delete props[key];
4110
3917
  }
4111
3918
  }
4112
- for (const key in newProps) {
4113
- if (shared.isReservedProp(key)) continue;
4114
- const next = newProps[key];
4115
- const prev = oldProps[key];
4116
- if (next !== prev && key !== "value") {
4117
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
3919
+ }
3920
+ if (attrs !== rawCurrentProps) {
3921
+ for (const key in attrs) {
3922
+ if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
3923
+ delete attrs[key];
3924
+ hasAttrsChanged = true;
4118
3925
  }
4119
3926
  }
4120
- if ("value" in newProps) {
4121
- hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
4122
- }
4123
3927
  }
4124
- };
4125
- const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4126
- const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
4127
- const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
4128
- let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
4129
- if (fragmentSlotScopeIds) {
4130
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
3928
+ }
3929
+ if (hasAttrsChanged) {
3930
+ reactivity.trigger(instance.attrs, "set", "");
3931
+ }
3932
+ }
3933
+ function setFullProps(instance, rawProps, props, attrs) {
3934
+ const [options, needCastKeys] = instance.propsOptions;
3935
+ let hasAttrsChanged = false;
3936
+ let rawCastValues;
3937
+ if (rawProps) {
3938
+ for (let key in rawProps) {
3939
+ if (shared.isReservedProp(key)) {
3940
+ continue;
3941
+ }
3942
+ const value = rawProps[key];
3943
+ let camelKey;
3944
+ if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
3945
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
3946
+ props[camelKey] = value;
3947
+ } else {
3948
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
3949
+ }
3950
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
3951
+ if (!(key in attrs) || value !== attrs[key]) {
3952
+ attrs[key] = value;
3953
+ hasAttrsChanged = true;
3954
+ }
3955
+ }
4131
3956
  }
4132
- if (n1 == null) {
4133
- hostInsert(fragmentStartAnchor, container, anchor);
4134
- hostInsert(fragmentEndAnchor, container, anchor);
4135
- mountChildren(
4136
- // #10007
4137
- // such fragment like `<></>` will be compiled into
4138
- // a fragment which doesn't have a children.
4139
- // In this case fallback to an empty array
4140
- n2.children || [],
4141
- container,
4142
- fragmentEndAnchor,
4143
- parentComponent,
4144
- parentSuspense,
4145
- namespace,
4146
- slotScopeIds,
4147
- optimized
3957
+ }
3958
+ if (needCastKeys) {
3959
+ const castValues = rawCastValues || shared.EMPTY_OBJ;
3960
+ for (let i = 0; i < needCastKeys.length; i++) {
3961
+ const key = needCastKeys[i];
3962
+ props[key] = resolvePropValue(
3963
+ options,
3964
+ key,
3965
+ castValues[key],
3966
+ instance,
3967
+ baseResolveDefault,
3968
+ !shared.hasOwn(castValues, key)
4148
3969
  );
4149
- } else {
4150
- if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
4151
- // of renderSlot() with no valid children
4152
- n1.dynamicChildren) {
4153
- patchBlockChildren(
4154
- n1.dynamicChildren,
4155
- dynamicChildren,
4156
- container,
4157
- parentComponent,
4158
- parentSuspense,
4159
- namespace,
4160
- slotScopeIds
4161
- );
4162
- if (
4163
- // #2080 if the stable fragment has a key, it's a <template v-for> that may
4164
- // get moved around. Make sure all root level vnodes inherit el.
4165
- // #2134 or if it's a component root, it may also get moved around
4166
- // as the component is being moved.
4167
- n2.key != null || parentComponent && n2 === parentComponent.subTree
4168
- ) {
4169
- traverseStaticChildren(
4170
- n1,
4171
- n2,
4172
- true
4173
- /* shallow */
3970
+ }
3971
+ }
3972
+ return hasAttrsChanged;
3973
+ }
3974
+ function resolvePropValue(options, key, value, instance, resolveDefault, isAbsent = false) {
3975
+ const opt = options[key];
3976
+ if (opt != null) {
3977
+ const hasDefault = shared.hasOwn(opt, "default");
3978
+ if (hasDefault && value === void 0) {
3979
+ const defaultValue = opt.default;
3980
+ if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
3981
+ const cachedDefaults = instance.propsDefaults || (instance.propsDefaults = {});
3982
+ if (shared.hasOwn(cachedDefaults, key)) {
3983
+ value = cachedDefaults[key];
3984
+ } else {
3985
+ value = cachedDefaults[key] = resolveDefault(
3986
+ defaultValue,
3987
+ instance,
3988
+ key
4174
3989
  );
4175
3990
  }
4176
3991
  } else {
4177
- patchChildren(
4178
- n1,
4179
- n2,
4180
- container,
4181
- fragmentEndAnchor,
4182
- parentComponent,
4183
- parentSuspense,
4184
- namespace,
4185
- slotScopeIds,
4186
- optimized
4187
- );
3992
+ value = defaultValue;
3993
+ }
3994
+ if (instance.ce) {
3995
+ instance.ce._setProp(key, value);
4188
3996
  }
4189
3997
  }
4190
- };
4191
- const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4192
- n2.slotScopeIds = slotScopeIds;
4193
- if (n2.type.__vapor) {
4194
- if (n1 == null) {
4195
- if (n2.shapeFlag & 512) {
4196
- getVaporInterface(parentComponent, n2).activate(
4197
- n2,
4198
- container,
4199
- anchor,
4200
- parentComponent
4201
- );
3998
+ if (opt[0 /* shouldCast */]) {
3999
+ if (isAbsent && !hasDefault) {
4000
+ value = false;
4001
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
4002
+ value = true;
4003
+ }
4004
+ }
4005
+ }
4006
+ return value;
4007
+ }
4008
+ function baseResolveDefault(factory, instance, key) {
4009
+ let value;
4010
+ const prev = setCurrentInstance(instance);
4011
+ const props = reactivity.toRaw(instance.props);
4012
+ value = factory.call(
4013
+ null,
4014
+ props
4015
+ );
4016
+ setCurrentInstance(...prev);
4017
+ return value;
4018
+ }
4019
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
4020
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
4021
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
4022
+ const cached = cache.get(comp);
4023
+ if (cached) {
4024
+ return cached;
4025
+ }
4026
+ const raw = comp.props;
4027
+ const normalized = {};
4028
+ const needCastKeys = [];
4029
+ let hasExtends = false;
4030
+ if (!shared.isFunction(comp)) {
4031
+ const extendProps = (raw2) => {
4032
+ hasExtends = true;
4033
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
4034
+ shared.extend(normalized, props);
4035
+ if (keys) needCastKeys.push(...keys);
4036
+ };
4037
+ if (!asMixin && appContext.mixins.length) {
4038
+ appContext.mixins.forEach(extendProps);
4039
+ }
4040
+ if (comp.extends) {
4041
+ extendProps(comp.extends);
4042
+ }
4043
+ if (comp.mixins) {
4044
+ comp.mixins.forEach(extendProps);
4045
+ }
4046
+ }
4047
+ if (!raw && !hasExtends) {
4048
+ if (shared.isObject(comp)) {
4049
+ cache.set(comp, shared.EMPTY_ARR);
4050
+ }
4051
+ return shared.EMPTY_ARR;
4052
+ }
4053
+ baseNormalizePropsOptions(raw, normalized, needCastKeys);
4054
+ const res = [normalized, needCastKeys];
4055
+ if (shared.isObject(comp)) {
4056
+ cache.set(comp, res);
4057
+ }
4058
+ return res;
4059
+ }
4060
+ function baseNormalizePropsOptions(raw, normalized, needCastKeys) {
4061
+ if (shared.isArray(raw)) {
4062
+ for (let i = 0; i < raw.length; i++) {
4063
+ const normalizedKey = shared.camelize(raw[i]);
4064
+ if (validatePropName(normalizedKey)) {
4065
+ normalized[normalizedKey] = shared.EMPTY_OBJ;
4066
+ }
4067
+ }
4068
+ } else if (raw) {
4069
+ for (const key in raw) {
4070
+ const normalizedKey = shared.camelize(key);
4071
+ if (validatePropName(normalizedKey)) {
4072
+ const opt = raw[key];
4073
+ const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
4074
+ const propType = prop.type;
4075
+ let shouldCast = false;
4076
+ let shouldCastTrue = true;
4077
+ if (shared.isArray(propType)) {
4078
+ for (let index = 0; index < propType.length; ++index) {
4079
+ const type = propType[index];
4080
+ const typeName = shared.isFunction(type) && type.name;
4081
+ if (typeName === "Boolean") {
4082
+ shouldCast = true;
4083
+ break;
4084
+ } else if (typeName === "String") {
4085
+ shouldCastTrue = false;
4086
+ }
4087
+ }
4202
4088
  } else {
4203
- getVaporInterface(parentComponent, n2).mount(
4204
- n2,
4205
- container,
4206
- anchor,
4207
- parentComponent
4208
- );
4089
+ shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
4090
+ }
4091
+ prop[0 /* shouldCast */] = shouldCast;
4092
+ prop[1 /* shouldCastTrue */] = shouldCastTrue;
4093
+ if (shouldCast || shared.hasOwn(prop, "default")) {
4094
+ needCastKeys.push(normalizedKey);
4209
4095
  }
4210
- } else {
4211
- getVaporInterface(parentComponent, n2).update(
4212
- n1,
4213
- n2,
4214
- shouldUpdateComponent(n1, n2, optimized)
4215
- );
4216
- }
4217
- } else if (n1 == null) {
4218
- if (n2.shapeFlag & 512) {
4219
- parentComponent.ctx.activate(
4220
- n2,
4221
- container,
4222
- anchor,
4223
- namespace,
4224
- optimized
4225
- );
4226
- } else {
4227
- mountComponent(
4228
- n2,
4229
- container,
4230
- anchor,
4231
- parentComponent,
4232
- parentSuspense,
4233
- namespace,
4234
- optimized
4235
- );
4236
4096
  }
4237
- } else {
4238
- updateComponent(n1, n2, optimized);
4239
4097
  }
4240
- };
4241
- const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
4242
- const instance = (initialVNode.component = createComponentInstance(
4243
- initialVNode,
4244
- parentComponent,
4245
- parentSuspense
4246
- ));
4247
- if (isKeepAlive(initialVNode)) {
4248
- instance.ctx.renderer = internals;
4098
+ }
4099
+ }
4100
+ function validatePropName(key) {
4101
+ if (key[0] !== "$" && !shared.isReservedProp(key)) {
4102
+ return true;
4103
+ }
4104
+ return false;
4105
+ }
4106
+
4107
+ const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
4108
+ const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
4109
+ const normalizeSlot = (key, rawSlot, ctx) => {
4110
+ if (rawSlot._n) {
4111
+ return rawSlot;
4112
+ }
4113
+ const normalized = withCtx((...args) => {
4114
+ if (false) ;
4115
+ return normalizeSlotValue(rawSlot(...args));
4116
+ }, ctx);
4117
+ normalized._c = false;
4118
+ return normalized;
4119
+ };
4120
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
4121
+ const ctx = rawSlots._ctx;
4122
+ for (const key in rawSlots) {
4123
+ if (isInternalKey(key)) continue;
4124
+ const value = rawSlots[key];
4125
+ if (shared.isFunction(value)) {
4126
+ slots[key] = normalizeSlot(key, value, ctx);
4127
+ } else if (value != null) {
4128
+ const normalized = normalizeSlotValue(value);
4129
+ slots[key] = () => normalized;
4249
4130
  }
4250
- {
4251
- setupComponent(instance, false, optimized);
4131
+ }
4132
+ };
4133
+ const normalizeVNodeSlots = (instance, children) => {
4134
+ const normalized = normalizeSlotValue(children);
4135
+ instance.slots.default = () => normalized;
4136
+ };
4137
+ const assignSlots = (slots, children, optimized) => {
4138
+ for (const key in children) {
4139
+ if (optimized || !isInternalKey(key)) {
4140
+ slots[key] = children[key];
4252
4141
  }
4253
- if (instance.asyncDep) {
4254
- parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
4255
- if (!initialVNode.el) {
4256
- const placeholder = instance.subTree = createVNode(Comment);
4257
- processCommentNode(null, placeholder, container, anchor);
4258
- initialVNode.placeholder = placeholder.el;
4142
+ }
4143
+ };
4144
+ const initSlots = (instance, children, optimized) => {
4145
+ const slots = instance.slots = createInternalObject();
4146
+ if (instance.vnode.shapeFlag & 32) {
4147
+ const type = children._;
4148
+ if (type) {
4149
+ assignSlots(slots, children, optimized);
4150
+ if (optimized) {
4151
+ shared.def(slots, "_", type, true);
4259
4152
  }
4260
4153
  } else {
4261
- setupRenderEffect(
4262
- instance,
4263
- initialVNode,
4264
- container,
4265
- anchor,
4266
- parentSuspense,
4267
- namespace,
4268
- optimized
4269
- );
4154
+ normalizeObjectSlots(children, slots);
4270
4155
  }
4271
- };
4272
- const updateComponent = (n1, n2, optimized) => {
4273
- const instance = n2.component = n1.component;
4274
- if (shouldUpdateComponent(n1, n2, optimized)) {
4275
- if (instance.asyncDep && !instance.asyncResolved) {
4276
- updateComponentPreRender(instance, n2, optimized);
4277
- return;
4156
+ } else if (children) {
4157
+ normalizeVNodeSlots(instance, children);
4158
+ }
4159
+ };
4160
+ const updateSlots = (instance, children, optimized) => {
4161
+ const { vnode, slots } = instance;
4162
+ let needDeletionCheck = true;
4163
+ let deletionComparisonTarget = shared.EMPTY_OBJ;
4164
+ if (vnode.shapeFlag & 32) {
4165
+ const type = children._;
4166
+ if (type) {
4167
+ if (optimized && type === 1) {
4168
+ needDeletionCheck = false;
4278
4169
  } else {
4279
- instance.next = n2;
4280
- instance.effect.run();
4170
+ assignSlots(slots, children, optimized);
4281
4171
  }
4282
4172
  } else {
4283
- n2.el = n1.el;
4284
- instance.vnode = n2;
4285
- }
4286
- };
4287
- class SetupRenderEffect extends reactivity.ReactiveEffect {
4288
- constructor(instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) {
4289
- const prevScope = reactivity.setCurrentScope(instance.scope);
4290
- super();
4291
- this.instance = instance;
4292
- this.initialVNode = initialVNode;
4293
- this.container = container;
4294
- this.anchor = anchor;
4295
- this.parentSuspense = parentSuspense;
4296
- this.namespace = namespace;
4297
- this.optimized = optimized;
4298
- reactivity.setCurrentScope(prevScope);
4299
- this.job = instance.job = () => {
4300
- if (this.dirty) {
4301
- this.run();
4302
- }
4303
- };
4304
- this.job.i = instance;
4173
+ needDeletionCheck = !children.$stable;
4174
+ normalizeObjectSlots(children, slots);
4305
4175
  }
4306
- notify() {
4307
- if (!(this.flags & 256)) {
4308
- const job = this.job;
4309
- queueJob(job, job.i.uid);
4176
+ deletionComparisonTarget = children;
4177
+ } else if (children) {
4178
+ normalizeVNodeSlots(instance, children);
4179
+ deletionComparisonTarget = { default: 1 };
4180
+ }
4181
+ if (needDeletionCheck) {
4182
+ for (const key in slots) {
4183
+ if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
4184
+ delete slots[key];
4310
4185
  }
4311
4186
  }
4312
- fn() {
4313
- const {
4314
- instance,
4315
- initialVNode,
4316
- container,
4317
- anchor,
4318
- parentSuspense,
4319
- namespace,
4320
- optimized
4321
- } = this;
4322
- if (!instance.isMounted) {
4323
- let vnodeHook;
4324
- const { el, props } = initialVNode;
4325
- const { bm, m, parent, root, type } = instance;
4326
- const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4327
- toggleRecurse(instance, false);
4328
- if (bm) {
4329
- shared.invokeArrayFns(bm);
4330
- }
4331
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
4332
- invokeVNodeHook(vnodeHook, parent, initialVNode);
4187
+ }
4188
+ };
4189
+
4190
+ const queuePostRenderEffect = queueEffectWithSuspense ;
4191
+ function createRenderer(options) {
4192
+ return baseCreateRenderer(options);
4193
+ }
4194
+ function createHydrationRenderer(options) {
4195
+ return baseCreateRenderer(options, createHydrationFunctions);
4196
+ }
4197
+ function baseCreateRenderer(options, createHydrationFns) {
4198
+ const target = shared.getGlobalThis();
4199
+ target.__VUE__ = true;
4200
+ const {
4201
+ insert: hostInsert,
4202
+ remove: hostRemove,
4203
+ patchProp: hostPatchProp,
4204
+ createElement: hostCreateElement,
4205
+ createText: hostCreateText,
4206
+ createComment: hostCreateComment,
4207
+ setText: hostSetText,
4208
+ setElementText: hostSetElementText,
4209
+ parentNode: hostParentNode,
4210
+ nextSibling: hostNextSibling,
4211
+ setScopeId: hostSetScopeId = shared.NOOP,
4212
+ insertStaticContent: hostInsertStaticContent
4213
+ } = options;
4214
+ const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
4215
+ if (n1 === n2) {
4216
+ return;
4217
+ }
4218
+ if (n1 && !isSameVNodeType(n1, n2)) {
4219
+ anchor = getNextHostNode(n1);
4220
+ unmount(n1, parentComponent, parentSuspense, true);
4221
+ n1 = null;
4222
+ }
4223
+ if (n2.patchFlag === -2) {
4224
+ optimized = false;
4225
+ n2.dynamicChildren = null;
4226
+ }
4227
+ const { type, ref, shapeFlag } = n2;
4228
+ switch (type) {
4229
+ case Text:
4230
+ processText(n1, n2, container, anchor);
4231
+ break;
4232
+ case Comment:
4233
+ processCommentNode(n1, n2, container, anchor);
4234
+ break;
4235
+ case Static:
4236
+ if (n1 == null) {
4237
+ mountStaticNode(n2, container, anchor, namespace);
4333
4238
  }
4334
- toggleRecurse(instance, true);
4335
- if (el && hydrateNode) {
4336
- const hydrateSubTree = () => {
4337
- instance.subTree = renderComponentRoot(instance);
4338
- hydrateNode(
4339
- el,
4340
- instance.subTree,
4341
- instance,
4342
- parentSuspense,
4343
- null
4344
- );
4345
- };
4346
- if (isAsyncWrapperVNode && type.__asyncHydrate) {
4347
- type.__asyncHydrate(
4348
- el,
4349
- instance,
4350
- hydrateSubTree
4351
- );
4352
- } else {
4353
- hydrateSubTree();
4354
- }
4355
- } else {
4356
- if (root.ce && // @ts-expect-error _def is private
4357
- root.ce._def.shadowRoot !== false) {
4358
- root.ce._injectChildStyle(type);
4359
- }
4360
- const subTree = instance.subTree = renderComponentRoot(instance);
4361
- patch(
4362
- null,
4363
- subTree,
4239
+ break;
4240
+ case Fragment:
4241
+ processFragment(
4242
+ n1,
4243
+ n2,
4244
+ container,
4245
+ anchor,
4246
+ parentComponent,
4247
+ parentSuspense,
4248
+ namespace,
4249
+ slotScopeIds,
4250
+ optimized
4251
+ );
4252
+ break;
4253
+ case VaporSlot:
4254
+ getVaporInterface(parentComponent, n2).slot(n1, n2, container, anchor);
4255
+ break;
4256
+ default:
4257
+ if (shapeFlag & 1) {
4258
+ processElement(
4259
+ n1,
4260
+ n2,
4364
4261
  container,
4365
4262
  anchor,
4366
- instance,
4263
+ parentComponent,
4367
4264
  parentSuspense,
4368
- namespace
4265
+ namespace,
4266
+ slotScopeIds,
4267
+ optimized
4369
4268
  );
4370
- initialVNode.el = subTree.el;
4371
- }
4372
- if (m) {
4373
- queuePostRenderEffect(m, void 0, parentSuspense);
4374
- }
4375
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
4376
- const scopedInitialVNode = initialVNode;
4377
- queuePostRenderEffect(
4378
- () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
4379
- void 0,
4380
- parentSuspense
4269
+ } else if (shapeFlag & 6) {
4270
+ processComponent(
4271
+ n1,
4272
+ n2,
4273
+ container,
4274
+ anchor,
4275
+ parentComponent,
4276
+ parentSuspense,
4277
+ namespace,
4278
+ slotScopeIds,
4279
+ optimized
4381
4280
  );
4382
- }
4383
- if (initialVNode.shapeFlag & 256 || parent && parent.vnode && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
4384
- instance.a && queuePostRenderEffect(instance.a, void 0, parentSuspense);
4385
- }
4386
- instance.isMounted = true;
4387
- this.initialVNode = this.container = this.anchor = null;
4388
- } else {
4389
- let { next, bu, u, parent, vnode } = instance;
4390
- {
4391
- const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
4392
- if (nonHydratedAsyncRoot) {
4393
- if (next) {
4394
- next.el = vnode.el;
4395
- updateComponentPreRender(instance, next, optimized);
4396
- }
4397
- nonHydratedAsyncRoot.asyncDep.then(() => {
4398
- if (!instance.isUnmounted) {
4399
- this.fn();
4400
- }
4401
- });
4402
- return;
4403
- }
4404
- }
4405
- let originNext = next;
4406
- let vnodeHook;
4407
- toggleRecurse(instance, false);
4408
- if (next) {
4409
- next.el = vnode.el;
4410
- updateComponentPreRender(instance, next, optimized);
4411
- } else {
4412
- next = vnode;
4413
- }
4414
- if (bu) {
4415
- shared.invokeArrayFns(bu);
4416
- }
4417
- if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
4418
- invokeVNodeHook(vnodeHook, parent, next, vnode);
4419
- }
4420
- toggleRecurse(instance, true);
4421
- const nextTree = renderComponentRoot(instance);
4422
- const prevTree = instance.subTree;
4423
- instance.subTree = nextTree;
4424
- patch(
4425
- prevTree,
4426
- nextTree,
4427
- // parent may have changed if it's in a teleport
4428
- hostParentNode(prevTree.el),
4429
- // anchor may have changed if it's in a fragment
4430
- getNextHostNode(prevTree),
4431
- instance,
4432
- parentSuspense,
4433
- namespace
4434
- );
4435
- next.el = nextTree.el;
4436
- if (originNext === null) {
4437
- updateHOCHostEl(instance, nextTree.el);
4438
- }
4439
- if (u) {
4440
- queuePostRenderEffect(u, void 0, parentSuspense);
4441
- }
4442
- if (vnodeHook = next.props && next.props.onVnodeUpdated) {
4443
- queuePostRenderEffect(
4444
- () => invokeVNodeHook(vnodeHook, parent, next, vnode),
4445
- void 0,
4446
- parentSuspense
4281
+ } else if (shapeFlag & 64) {
4282
+ type.process(
4283
+ n1,
4284
+ n2,
4285
+ container,
4286
+ anchor,
4287
+ parentComponent,
4288
+ parentSuspense,
4289
+ namespace,
4290
+ slotScopeIds,
4291
+ optimized,
4292
+ internals
4447
4293
  );
4448
- }
4294
+ } else if (shapeFlag & 128) {
4295
+ type.process(
4296
+ n1,
4297
+ n2,
4298
+ container,
4299
+ anchor,
4300
+ parentComponent,
4301
+ parentSuspense,
4302
+ namespace,
4303
+ slotScopeIds,
4304
+ optimized,
4305
+ internals
4306
+ );
4307
+ } else ;
4308
+ }
4309
+ if (ref != null && parentComponent) {
4310
+ setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
4311
+ } else if (ref == null && n1 && n1.ref != null) {
4312
+ setRef(n1.ref, null, parentSuspense, n1, true);
4313
+ }
4314
+ };
4315
+ const processText = (n1, n2, container, anchor) => {
4316
+ if (n1 == null) {
4317
+ hostInsert(
4318
+ n2.el = hostCreateText(n2.children),
4319
+ container,
4320
+ anchor
4321
+ );
4322
+ } else {
4323
+ const el = n2.el = n1.el;
4324
+ if (n2.children !== n1.children) {
4325
+ hostSetText(el, n2.children);
4449
4326
  }
4450
4327
  }
4451
- }
4452
- const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
4453
- const effect = instance.effect = new SetupRenderEffect(
4454
- instance,
4455
- initialVNode,
4328
+ };
4329
+ const processCommentNode = (n1, n2, container, anchor) => {
4330
+ if (n1 == null) {
4331
+ hostInsert(
4332
+ n2.el = hostCreateComment(n2.children || ""),
4333
+ container,
4334
+ anchor
4335
+ );
4336
+ } else {
4337
+ n2.el = n1.el;
4338
+ }
4339
+ };
4340
+ const mountStaticNode = (n2, container, anchor, namespace) => {
4341
+ [n2.el, n2.anchor] = hostInsertStaticContent(
4342
+ n2.children,
4456
4343
  container,
4457
4344
  anchor,
4458
- parentSuspense,
4459
4345
  namespace,
4460
- optimized
4346
+ n2.el,
4347
+ n2.anchor
4461
4348
  );
4462
- instance.update = effect.run.bind(effect);
4463
- toggleRecurse(instance, true);
4464
- effect.run();
4465
- };
4466
- const updateComponentPreRender = (instance, nextVNode, optimized) => {
4467
- nextVNode.component = instance;
4468
- const prevProps = instance.vnode.props;
4469
- instance.vnode = nextVNode;
4470
- instance.next = null;
4471
- updateProps(instance, nextVNode.props, prevProps, optimized);
4472
- updateSlots(instance, nextVNode.children, optimized);
4473
- const prevSub = reactivity.setActiveSub();
4474
- flushPreFlushCbs(instance);
4475
- reactivity.setActiveSub(prevSub);
4476
4349
  };
4477
- const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
4478
- const c1 = n1 && n1.children;
4479
- const prevShapeFlag = n1 ? n1.shapeFlag : 0;
4480
- const c2 = n2.children;
4481
- const { patchFlag, shapeFlag } = n2;
4482
- if (patchFlag > 0) {
4483
- if (patchFlag & 128) {
4484
- patchKeyedChildren(
4485
- c1,
4486
- c2,
4487
- container,
4488
- anchor,
4489
- parentComponent,
4490
- parentSuspense,
4491
- namespace,
4492
- slotScopeIds,
4493
- optimized
4494
- );
4495
- return;
4496
- } else if (patchFlag & 256) {
4497
- patchUnkeyedChildren(
4498
- c1,
4499
- c2,
4500
- container,
4501
- anchor,
4350
+ const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
4351
+ let next;
4352
+ while (el && el !== anchor) {
4353
+ next = hostNextSibling(el);
4354
+ hostInsert(el, container, nextSibling);
4355
+ el = next;
4356
+ }
4357
+ hostInsert(anchor, container, nextSibling);
4358
+ };
4359
+ const removeStaticNode = ({ el, anchor }) => {
4360
+ let next;
4361
+ while (el && el !== anchor) {
4362
+ next = hostNextSibling(el);
4363
+ hostRemove(el);
4364
+ el = next;
4365
+ }
4366
+ hostRemove(anchor);
4367
+ };
4368
+ const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4369
+ if (n2.type === "svg") {
4370
+ namespace = "svg";
4371
+ } else if (n2.type === "math") {
4372
+ namespace = "mathml";
4373
+ }
4374
+ if (n1 == null) {
4375
+ mountElement(
4376
+ n2,
4377
+ container,
4378
+ anchor,
4379
+ parentComponent,
4380
+ parentSuspense,
4381
+ namespace,
4382
+ slotScopeIds,
4383
+ optimized
4384
+ );
4385
+ } else {
4386
+ const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
4387
+ try {
4388
+ if (customElement) {
4389
+ customElement._beginPatch();
4390
+ }
4391
+ patchElement(
4392
+ n1,
4393
+ n2,
4502
4394
  parentComponent,
4503
4395
  parentSuspense,
4504
4396
  namespace,
4505
4397
  slotScopeIds,
4506
4398
  optimized
4507
4399
  );
4508
- return;
4400
+ } finally {
4401
+ if (customElement) {
4402
+ customElement._endPatch();
4403
+ }
4509
4404
  }
4510
4405
  }
4406
+ };
4407
+ const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4408
+ let el;
4409
+ let vnodeHook;
4410
+ const { props, shapeFlag, transition, dirs } = vnode;
4411
+ el = vnode.el = hostCreateElement(
4412
+ vnode.type,
4413
+ namespace,
4414
+ props && props.is,
4415
+ props
4416
+ );
4511
4417
  if (shapeFlag & 8) {
4512
- if (prevShapeFlag & 16) {
4513
- unmountChildren(c1, parentComponent, parentSuspense);
4418
+ hostSetElementText(el, vnode.children);
4419
+ } else if (shapeFlag & 16) {
4420
+ mountChildren(
4421
+ vnode.children,
4422
+ el,
4423
+ null,
4424
+ parentComponent,
4425
+ parentSuspense,
4426
+ resolveChildrenNamespace(vnode, namespace),
4427
+ slotScopeIds,
4428
+ optimized
4429
+ );
4430
+ }
4431
+ if (dirs) {
4432
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
4433
+ }
4434
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
4435
+ if (props) {
4436
+ for (const key in props) {
4437
+ if (key !== "value" && !shared.isReservedProp(key)) {
4438
+ hostPatchProp(el, key, null, props[key], namespace, parentComponent);
4439
+ }
4514
4440
  }
4515
- if (c2 !== c1) {
4516
- hostSetElementText(container, c2);
4441
+ if ("value" in props) {
4442
+ hostPatchProp(el, "value", null, props.value, namespace);
4517
4443
  }
4444
+ if (vnodeHook = props.onVnodeBeforeMount) {
4445
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
4446
+ }
4447
+ }
4448
+ if (dirs) {
4449
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4450
+ }
4451
+ if (transition) {
4452
+ performTransitionEnter(
4453
+ el,
4454
+ transition,
4455
+ () => hostInsert(el, container, anchor),
4456
+ parentSuspense
4457
+ );
4518
4458
  } else {
4519
- if (prevShapeFlag & 16) {
4520
- if (shapeFlag & 16) {
4521
- patchKeyedChildren(
4522
- c1,
4523
- c2,
4524
- container,
4525
- anchor,
4526
- parentComponent,
4527
- parentSuspense,
4528
- namespace,
4529
- slotScopeIds,
4530
- optimized
4531
- );
4532
- } else {
4533
- unmountChildren(c1, parentComponent, parentSuspense, true);
4534
- }
4459
+ hostInsert(el, container, anchor);
4460
+ }
4461
+ if ((vnodeHook = props && props.onVnodeMounted) || dirs) {
4462
+ queuePostRenderEffect(
4463
+ () => {
4464
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4465
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4466
+ },
4467
+ void 0,
4468
+ parentSuspense
4469
+ );
4470
+ }
4471
+ };
4472
+ const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
4473
+ if (scopeId) {
4474
+ hostSetScopeId(el, scopeId);
4475
+ }
4476
+ if (slotScopeIds) {
4477
+ for (let i = 0; i < slotScopeIds.length; i++) {
4478
+ hostSetScopeId(el, slotScopeIds[i]);
4479
+ }
4480
+ }
4481
+ const inheritedScopeIds = getInheritedScopeIds(vnode, parentComponent);
4482
+ for (let i = 0; i < inheritedScopeIds.length; i++) {
4483
+ hostSetScopeId(el, inheritedScopeIds[i]);
4484
+ }
4485
+ };
4486
+ const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
4487
+ for (let i = start; i < children.length; i++) {
4488
+ const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
4489
+ patch(
4490
+ null,
4491
+ child,
4492
+ container,
4493
+ anchor,
4494
+ parentComponent,
4495
+ parentSuspense,
4496
+ namespace,
4497
+ slotScopeIds,
4498
+ optimized
4499
+ );
4500
+ }
4501
+ };
4502
+ const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4503
+ const el = n2.el = n1.el;
4504
+ let { patchFlag, dynamicChildren, dirs } = n2;
4505
+ patchFlag |= n1.patchFlag & 16;
4506
+ const oldProps = n1.props || shared.EMPTY_OBJ;
4507
+ const newProps = n2.props || shared.EMPTY_OBJ;
4508
+ let vnodeHook;
4509
+ parentComponent && toggleRecurse(parentComponent, false);
4510
+ if (vnodeHook = newProps.onVnodeBeforeUpdate) {
4511
+ invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4512
+ }
4513
+ if (dirs) {
4514
+ invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
4515
+ }
4516
+ parentComponent && toggleRecurse(parentComponent, true);
4517
+ if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
4518
+ hostSetElementText(el, "");
4519
+ }
4520
+ if (dynamicChildren) {
4521
+ patchBlockChildren(
4522
+ n1.dynamicChildren,
4523
+ dynamicChildren,
4524
+ el,
4525
+ parentComponent,
4526
+ parentSuspense,
4527
+ resolveChildrenNamespace(n2, namespace),
4528
+ slotScopeIds
4529
+ );
4530
+ } else if (!optimized) {
4531
+ patchChildren(
4532
+ n1,
4533
+ n2,
4534
+ el,
4535
+ null,
4536
+ parentComponent,
4537
+ parentSuspense,
4538
+ resolveChildrenNamespace(n2, namespace),
4539
+ slotScopeIds,
4540
+ false
4541
+ );
4542
+ }
4543
+ if (patchFlag > 0) {
4544
+ if (patchFlag & 16) {
4545
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4535
4546
  } else {
4536
- if (prevShapeFlag & 8) {
4537
- hostSetElementText(container, "");
4547
+ if (patchFlag & 2) {
4548
+ if (oldProps.class !== newProps.class) {
4549
+ hostPatchProp(el, "class", null, newProps.class, namespace);
4550
+ }
4538
4551
  }
4539
- if (shapeFlag & 16) {
4540
- mountChildren(
4541
- c2,
4542
- container,
4543
- anchor,
4544
- parentComponent,
4545
- parentSuspense,
4546
- namespace,
4547
- slotScopeIds,
4548
- optimized
4549
- );
4552
+ if (patchFlag & 4) {
4553
+ hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
4554
+ }
4555
+ if (patchFlag & 8) {
4556
+ const propsToUpdate = n2.dynamicProps;
4557
+ for (let i = 0; i < propsToUpdate.length; i++) {
4558
+ const key = propsToUpdate[i];
4559
+ const prev = oldProps[key];
4560
+ const next = newProps[key];
4561
+ if (next !== prev || key === "value") {
4562
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4563
+ }
4564
+ }
4565
+ }
4566
+ }
4567
+ if (patchFlag & 1) {
4568
+ if (n1.children !== n2.children) {
4569
+ hostSetElementText(el, n2.children);
4550
4570
  }
4551
4571
  }
4572
+ } else if (!optimized && dynamicChildren == null) {
4573
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4552
4574
  }
4553
- };
4554
- const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4555
- c1 = c1 || shared.EMPTY_ARR;
4556
- c2 = c2 || shared.EMPTY_ARR;
4557
- const oldLength = c1.length;
4558
- const newLength = c2.length;
4559
- const commonLength = Math.min(oldLength, newLength);
4560
- let i;
4561
- for (i = 0; i < commonLength; i++) {
4562
- const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4575
+ if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
4576
+ queuePostRenderEffect(
4577
+ () => {
4578
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4579
+ dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
4580
+ },
4581
+ void 0,
4582
+ parentSuspense
4583
+ );
4584
+ }
4585
+ };
4586
+ const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
4587
+ for (let i = 0; i < newChildren.length; i++) {
4588
+ const oldVNode = oldChildren[i];
4589
+ const newVNode = newChildren[i];
4590
+ const container = (
4591
+ // oldVNode may be an errored async setup() component inside Suspense
4592
+ // which will not have a mounted element
4593
+ oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
4594
+ // of the Fragment itself so it can move its children.
4595
+ (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
4596
+ // which also requires the correct parent container
4597
+ !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
4598
+ oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
4599
+ // In other cases, the parent container is not actually used so we
4600
+ // just pass the block element here to avoid a DOM parentNode call.
4601
+ fallbackContainer
4602
+ )
4603
+ );
4563
4604
  patch(
4564
- c1[i],
4565
- nextChild,
4605
+ oldVNode,
4606
+ newVNode,
4566
4607
  container,
4567
4608
  null,
4568
4609
  parentComponent,
4569
4610
  parentSuspense,
4570
4611
  namespace,
4571
4612
  slotScopeIds,
4572
- optimized
4613
+ true
4573
4614
  );
4574
4615
  }
4575
- if (oldLength > newLength) {
4576
- unmountChildren(
4577
- c1,
4578
- parentComponent,
4579
- parentSuspense,
4580
- true,
4581
- false,
4582
- commonLength
4583
- );
4584
- } else {
4616
+ };
4617
+ const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
4618
+ if (oldProps !== newProps) {
4619
+ if (oldProps !== shared.EMPTY_OBJ) {
4620
+ for (const key in oldProps) {
4621
+ if (!shared.isReservedProp(key) && !(key in newProps)) {
4622
+ hostPatchProp(
4623
+ el,
4624
+ key,
4625
+ oldProps[key],
4626
+ null,
4627
+ namespace,
4628
+ parentComponent
4629
+ );
4630
+ }
4631
+ }
4632
+ }
4633
+ for (const key in newProps) {
4634
+ if (shared.isReservedProp(key)) continue;
4635
+ const next = newProps[key];
4636
+ const prev = oldProps[key];
4637
+ if (next !== prev && key !== "value") {
4638
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4639
+ }
4640
+ }
4641
+ if ("value" in newProps) {
4642
+ hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
4643
+ }
4644
+ }
4645
+ };
4646
+ const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4647
+ const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
4648
+ const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
4649
+ let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
4650
+ if (fragmentSlotScopeIds) {
4651
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
4652
+ }
4653
+ if (n1 == null) {
4654
+ hostInsert(fragmentStartAnchor, container, anchor);
4655
+ hostInsert(fragmentEndAnchor, container, anchor);
4585
4656
  mountChildren(
4586
- c2,
4657
+ // #10007
4658
+ // such fragment like `<></>` will be compiled into
4659
+ // a fragment which doesn't have a children.
4660
+ // In this case fallback to an empty array
4661
+ n2.children || [],
4587
4662
  container,
4588
- anchor,
4663
+ fragmentEndAnchor,
4589
4664
  parentComponent,
4590
4665
  parentSuspense,
4591
4666
  namespace,
4592
4667
  slotScopeIds,
4593
- optimized,
4594
- commonLength
4668
+ optimized
4595
4669
  );
4596
- }
4597
- };
4598
- const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4599
- let i = 0;
4600
- const l2 = c2.length;
4601
- let e1 = c1.length - 1;
4602
- let e2 = l2 - 1;
4603
- while (i <= e1 && i <= e2) {
4604
- const n1 = c1[i];
4605
- const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4606
- if (isSameVNodeType(n1, n2)) {
4607
- patch(
4608
- n1,
4609
- n2,
4670
+ } else {
4671
+ if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
4672
+ // of renderSlot() with no valid children
4673
+ n1.dynamicChildren) {
4674
+ patchBlockChildren(
4675
+ n1.dynamicChildren,
4676
+ dynamicChildren,
4610
4677
  container,
4611
- null,
4612
4678
  parentComponent,
4613
4679
  parentSuspense,
4614
4680
  namespace,
4615
- slotScopeIds,
4616
- optimized
4681
+ slotScopeIds
4617
4682
  );
4683
+ if (
4684
+ // #2080 if the stable fragment has a key, it's a <template v-for> that may
4685
+ // get moved around. Make sure all root level vnodes inherit el.
4686
+ // #2134 or if it's a component root, it may also get moved around
4687
+ // as the component is being moved.
4688
+ n2.key != null || parentComponent && n2 === parentComponent.subTree
4689
+ ) {
4690
+ traverseStaticChildren(
4691
+ n1,
4692
+ n2,
4693
+ true
4694
+ /* shallow */
4695
+ );
4696
+ }
4618
4697
  } else {
4619
- break;
4620
- }
4621
- i++;
4622
- }
4623
- while (i <= e1 && i <= e2) {
4624
- const n1 = c1[e1];
4625
- const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
4626
- if (isSameVNodeType(n1, n2)) {
4627
- patch(
4698
+ patchChildren(
4628
4699
  n1,
4629
4700
  n2,
4630
4701
  container,
4631
- null,
4702
+ fragmentEndAnchor,
4632
4703
  parentComponent,
4633
4704
  parentSuspense,
4634
4705
  namespace,
4635
4706
  slotScopeIds,
4636
4707
  optimized
4637
4708
  );
4638
- } else {
4639
- break;
4640
4709
  }
4641
- e1--;
4642
- e2--;
4643
4710
  }
4644
- if (i > e1) {
4645
- if (i <= e2) {
4646
- const nextPos = e2 + 1;
4647
- const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
4648
- while (i <= e2) {
4649
- patch(
4650
- null,
4651
- c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
4711
+ };
4712
+ const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4713
+ n2.slotScopeIds = slotScopeIds;
4714
+ if (n2.type.__vapor) {
4715
+ if (n1 == null) {
4716
+ if (n2.shapeFlag & 512) {
4717
+ getVaporInterface(parentComponent, n2).activate(
4718
+ n2,
4652
4719
  container,
4653
4720
  anchor,
4654
- parentComponent,
4655
- parentSuspense,
4656
- namespace,
4657
- slotScopeIds,
4658
- optimized
4721
+ parentComponent
4659
4722
  );
4660
- i++;
4661
- }
4662
- }
4663
- } else if (i > e2) {
4664
- while (i <= e1) {
4665
- unmount(c1[i], parentComponent, parentSuspense, true);
4666
- i++;
4667
- }
4668
- } else {
4669
- const s1 = i;
4670
- const s2 = i;
4671
- const keyToNewIndexMap = /* @__PURE__ */ new Map();
4672
- for (i = s2; i <= e2; i++) {
4673
- const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4674
- if (nextChild.key != null) {
4675
- keyToNewIndexMap.set(nextChild.key, i);
4676
- }
4677
- }
4678
- let j;
4679
- let patched = 0;
4680
- const toBePatched = e2 - s2 + 1;
4681
- let moved = false;
4682
- let maxNewIndexSoFar = 0;
4683
- const newIndexToOldIndexMap = new Array(toBePatched);
4684
- for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
4685
- for (i = s1; i <= e1; i++) {
4686
- const prevChild = c1[i];
4687
- if (patched >= toBePatched) {
4688
- unmount(prevChild, parentComponent, parentSuspense, true);
4689
- continue;
4690
- }
4691
- let newIndex;
4692
- if (prevChild.key != null) {
4693
- newIndex = keyToNewIndexMap.get(prevChild.key);
4694
- } else {
4695
- for (j = s2; j <= e2; j++) {
4696
- if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
4697
- newIndex = j;
4698
- break;
4699
- }
4700
- }
4701
- }
4702
- if (newIndex === void 0) {
4703
- unmount(prevChild, parentComponent, parentSuspense, true);
4704
4723
  } else {
4705
- newIndexToOldIndexMap[newIndex - s2] = i + 1;
4706
- if (newIndex >= maxNewIndexSoFar) {
4707
- maxNewIndexSoFar = newIndex;
4708
- } else {
4709
- moved = true;
4710
- }
4711
- patch(
4712
- prevChild,
4713
- c2[newIndex],
4714
- container,
4715
- null,
4716
- parentComponent,
4717
- parentSuspense,
4718
- namespace,
4719
- slotScopeIds,
4720
- optimized
4721
- );
4722
- patched++;
4723
- }
4724
- }
4725
- const increasingNewIndexSequence = moved ? shared.getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
4726
- j = increasingNewIndexSequence.length - 1;
4727
- for (i = toBePatched - 1; i >= 0; i--) {
4728
- const nextIndex = s2 + i;
4729
- const nextChild = c2[nextIndex];
4730
- const anchorVNode = c2[nextIndex + 1];
4731
- const anchor = nextIndex + 1 < l2 ? (
4732
- // #13559, fallback to el placeholder for unresolved async component
4733
- anchorVNode.el || anchorVNode.placeholder
4734
- ) : parentAnchor;
4735
- if (newIndexToOldIndexMap[i] === 0) {
4736
- patch(
4737
- null,
4738
- nextChild,
4739
- container,
4740
- anchor,
4741
- parentComponent,
4742
- parentSuspense,
4743
- namespace,
4744
- slotScopeIds,
4745
- optimized
4724
+ getVaporInterface(parentComponent, n2).mount(
4725
+ n2,
4726
+ container,
4727
+ anchor,
4728
+ parentComponent
4746
4729
  );
4747
- } else if (moved) {
4748
- if (j < 0 || i !== increasingNewIndexSequence[j]) {
4749
- move(
4750
- nextChild,
4751
- container,
4752
- anchor,
4753
- 2,
4754
- parentComponent
4755
- );
4756
- } else {
4757
- j--;
4758
- }
4759
4730
  }
4731
+ } else {
4732
+ getVaporInterface(parentComponent, n2).update(
4733
+ n1,
4734
+ n2,
4735
+ shouldUpdateComponent(n1, n2, optimized)
4736
+ );
4760
4737
  }
4761
- }
4762
- };
4763
- const move = (vnode, container, anchor, moveType, parentComponent, parentSuspense = null) => {
4764
- const { el, type, transition, children, shapeFlag } = vnode;
4765
- if (shapeFlag & 6) {
4766
- if (type.__vapor) {
4767
- getVaporInterface(parentComponent, vnode).move(vnode, container, anchor);
4738
+ } else if (n1 == null) {
4739
+ if (n2.shapeFlag & 512) {
4740
+ parentComponent.ctx.activate(
4741
+ n2,
4742
+ container,
4743
+ anchor,
4744
+ namespace,
4745
+ optimized
4746
+ );
4768
4747
  } else {
4769
- move(
4770
- vnode.component.subTree,
4748
+ mountComponent(
4749
+ n2,
4771
4750
  container,
4772
4751
  anchor,
4773
- moveType,
4774
- parentComponent
4752
+ parentComponent,
4753
+ parentSuspense,
4754
+ namespace,
4755
+ optimized
4775
4756
  );
4776
4757
  }
4777
- return;
4758
+ } else {
4759
+ updateComponent(n1, n2, optimized);
4778
4760
  }
4779
- if (shapeFlag & 128) {
4780
- vnode.suspense.move(container, anchor, moveType);
4781
- return;
4761
+ };
4762
+ const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
4763
+ const instance = (initialVNode.component = createComponentInstance(
4764
+ initialVNode,
4765
+ parentComponent,
4766
+ parentSuspense
4767
+ ));
4768
+ if (isKeepAlive(initialVNode)) {
4769
+ instance.ctx.renderer = internals;
4782
4770
  }
4783
- if (shapeFlag & 64) {
4784
- type.move(
4785
- vnode,
4771
+ {
4772
+ setupComponent(instance, false, optimized);
4773
+ }
4774
+ if (instance.asyncDep) {
4775
+ parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
4776
+ if (!initialVNode.el) {
4777
+ const placeholder = instance.subTree = createVNode(Comment);
4778
+ processCommentNode(null, placeholder, container, anchor);
4779
+ initialVNode.placeholder = placeholder.el;
4780
+ }
4781
+ } else {
4782
+ setupRenderEffect(
4783
+ instance,
4784
+ initialVNode,
4786
4785
  container,
4787
4786
  anchor,
4788
- internals,
4789
- parentComponent
4787
+ parentSuspense,
4788
+ namespace,
4789
+ optimized
4790
4790
  );
4791
- return;
4792
4791
  }
4793
- if (type === Fragment) {
4794
- hostInsert(el, container, anchor);
4795
- for (let i = 0; i < children.length; i++) {
4796
- move(
4797
- children[i],
4798
- container,
4799
- anchor,
4800
- moveType,
4801
- parentComponent
4802
- );
4792
+ };
4793
+ const updateComponent = (n1, n2, optimized) => {
4794
+ const instance = n2.component = n1.component;
4795
+ if (shouldUpdateComponent(n1, n2, optimized)) {
4796
+ if (instance.asyncDep && !instance.asyncResolved) {
4797
+ updateComponentPreRender(instance, n2, optimized);
4798
+ return;
4799
+ } else {
4800
+ instance.next = n2;
4801
+ instance.effect.run();
4803
4802
  }
4804
- hostInsert(vnode.anchor, container, anchor);
4805
- return;
4803
+ } else {
4804
+ n2.el = n1.el;
4805
+ instance.vnode = n2;
4806
4806
  }
4807
- if (type === Static) {
4808
- moveStaticNode(vnode, container, anchor);
4809
- return;
4807
+ };
4808
+ class SetupRenderEffect extends reactivity.ReactiveEffect {
4809
+ constructor(instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) {
4810
+ const prevScope = reactivity.setCurrentScope(instance.scope);
4811
+ super();
4812
+ this.instance = instance;
4813
+ this.initialVNode = initialVNode;
4814
+ this.container = container;
4815
+ this.anchor = anchor;
4816
+ this.parentSuspense = parentSuspense;
4817
+ this.namespace = namespace;
4818
+ this.optimized = optimized;
4819
+ reactivity.setCurrentScope(prevScope);
4820
+ this.job = instance.job = () => {
4821
+ if (this.dirty) {
4822
+ this.run();
4823
+ }
4824
+ };
4825
+ this.job.i = instance;
4810
4826
  }
4811
- const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
4812
- if (needTransition2) {
4813
- if (moveType === 0) {
4814
- performTransitionEnter(
4815
- el,
4816
- transition,
4817
- () => hostInsert(el, container, anchor),
4827
+ notify() {
4828
+ if (!(this.flags & 256)) {
4829
+ const job = this.job;
4830
+ queueJob(job, job.i.uid);
4831
+ }
4832
+ }
4833
+ fn() {
4834
+ const {
4835
+ instance,
4836
+ initialVNode,
4837
+ container,
4838
+ anchor,
4839
+ parentSuspense,
4840
+ namespace,
4841
+ optimized
4842
+ } = this;
4843
+ if (!instance.isMounted) {
4844
+ let vnodeHook;
4845
+ const { el, props } = initialVNode;
4846
+ const { bm, m, parent, root, type } = instance;
4847
+ const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4848
+ toggleRecurse(instance, false);
4849
+ if (bm) {
4850
+ shared.invokeArrayFns(bm);
4851
+ }
4852
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
4853
+ invokeVNodeHook(vnodeHook, parent, initialVNode);
4854
+ }
4855
+ toggleRecurse(instance, true);
4856
+ if (el && hydrateNode) {
4857
+ const hydrateSubTree = () => {
4858
+ instance.subTree = renderComponentRoot(instance);
4859
+ hydrateNode(
4860
+ el,
4861
+ instance.subTree,
4862
+ instance,
4863
+ parentSuspense,
4864
+ null
4865
+ );
4866
+ };
4867
+ if (isAsyncWrapperVNode && type.__asyncHydrate) {
4868
+ type.__asyncHydrate(
4869
+ el,
4870
+ instance,
4871
+ hydrateSubTree
4872
+ );
4873
+ } else {
4874
+ hydrateSubTree();
4875
+ }
4876
+ } else {
4877
+ if (root.ce && // @ts-expect-error _def is private
4878
+ root.ce._def.shadowRoot !== false) {
4879
+ root.ce._injectChildStyle(type);
4880
+ }
4881
+ const subTree = instance.subTree = renderComponentRoot(instance);
4882
+ patch(
4883
+ null,
4884
+ subTree,
4885
+ container,
4886
+ anchor,
4887
+ instance,
4888
+ parentSuspense,
4889
+ namespace
4890
+ );
4891
+ initialVNode.el = subTree.el;
4892
+ }
4893
+ if (m) {
4894
+ queuePostRenderEffect(m, void 0, parentSuspense);
4895
+ }
4896
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
4897
+ const scopedInitialVNode = initialVNode;
4898
+ queuePostRenderEffect(
4899
+ () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
4900
+ void 0,
4901
+ parentSuspense
4902
+ );
4903
+ }
4904
+ if (initialVNode.shapeFlag & 256 || parent && parent.vnode && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
4905
+ instance.a && queuePostRenderEffect(instance.a, void 0, parentSuspense);
4906
+ }
4907
+ instance.isMounted = true;
4908
+ this.initialVNode = this.container = this.anchor = null;
4909
+ } else {
4910
+ let { next, bu, u, parent, vnode } = instance;
4911
+ {
4912
+ const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
4913
+ if (nonHydratedAsyncRoot) {
4914
+ if (next) {
4915
+ next.el = vnode.el;
4916
+ updateComponentPreRender(instance, next, optimized);
4917
+ }
4918
+ nonHydratedAsyncRoot.asyncDep.then(() => {
4919
+ if (!instance.isUnmounted) {
4920
+ this.fn();
4921
+ }
4922
+ });
4923
+ return;
4924
+ }
4925
+ }
4926
+ let originNext = next;
4927
+ let vnodeHook;
4928
+ toggleRecurse(instance, false);
4929
+ if (next) {
4930
+ next.el = vnode.el;
4931
+ updateComponentPreRender(instance, next, optimized);
4932
+ } else {
4933
+ next = vnode;
4934
+ }
4935
+ if (bu) {
4936
+ shared.invokeArrayFns(bu);
4937
+ }
4938
+ if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
4939
+ invokeVNodeHook(vnodeHook, parent, next, vnode);
4940
+ }
4941
+ toggleRecurse(instance, true);
4942
+ const nextTree = renderComponentRoot(instance);
4943
+ const prevTree = instance.subTree;
4944
+ instance.subTree = nextTree;
4945
+ patch(
4946
+ prevTree,
4947
+ nextTree,
4948
+ // parent may have changed if it's in a teleport
4949
+ hostParentNode(prevTree.el),
4950
+ // anchor may have changed if it's in a fragment
4951
+ getNextHostNode(prevTree),
4952
+ instance,
4818
4953
  parentSuspense,
4819
- true
4954
+ namespace
4820
4955
  );
4821
- } else {
4822
- const { leave, delayLeave, afterLeave } = transition;
4823
- const remove2 = () => {
4824
- if (vnode.ctx.isUnmounted) {
4825
- hostRemove(el);
4826
- } else {
4827
- hostInsert(el, container, anchor);
4828
- }
4829
- };
4830
- const performLeave = () => {
4831
- if (el._isLeaving) {
4832
- el[leaveCbKey](
4833
- true
4834
- /* cancelled */
4835
- );
4836
- }
4837
- leave(el, () => {
4838
- remove2();
4839
- afterLeave && afterLeave();
4840
- });
4841
- };
4842
- if (delayLeave) {
4843
- delayLeave(el, remove2, performLeave);
4844
- } else {
4845
- performLeave();
4956
+ next.el = nextTree.el;
4957
+ if (originNext === null) {
4958
+ updateHOCHostEl(instance, nextTree.el);
4959
+ }
4960
+ if (u) {
4961
+ queuePostRenderEffect(u, void 0, parentSuspense);
4962
+ }
4963
+ if (vnodeHook = next.props && next.props.onVnodeUpdated) {
4964
+ queuePostRenderEffect(
4965
+ () => invokeVNodeHook(vnodeHook, parent, next, vnode),
4966
+ void 0,
4967
+ parentSuspense
4968
+ );
4846
4969
  }
4847
4970
  }
4848
- } else {
4849
- hostInsert(el, container, anchor);
4850
4971
  }
4972
+ }
4973
+ const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
4974
+ const effect = instance.effect = new SetupRenderEffect(
4975
+ instance,
4976
+ initialVNode,
4977
+ container,
4978
+ anchor,
4979
+ parentSuspense,
4980
+ namespace,
4981
+ optimized
4982
+ );
4983
+ instance.update = effect.run.bind(effect);
4984
+ toggleRecurse(instance, true);
4985
+ effect.run();
4851
4986
  };
4852
- const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
4853
- const {
4854
- type,
4855
- props,
4856
- ref,
4857
- children,
4858
- dynamicChildren,
4859
- shapeFlag,
4860
- patchFlag,
4861
- dirs,
4862
- cacheIndex
4863
- } = vnode;
4864
- if (patchFlag === -2) {
4865
- optimized = false;
4866
- }
4867
- if (ref != null) {
4868
- const prevSub = reactivity.setActiveSub();
4869
- setRef(ref, null, parentSuspense, vnode, true);
4870
- reactivity.setActiveSub(prevSub);
4871
- }
4872
- if (cacheIndex != null) {
4873
- parentComponent.renderCache[cacheIndex] = void 0;
4874
- }
4875
- if (shapeFlag & 256) {
4876
- if (vnode.type.__vapor) {
4877
- getVaporInterface(parentComponent, vnode).deactivate(
4878
- vnode,
4879
- parentComponent.ctx.getStorageContainer()
4880
- );
4881
- } else {
4882
- parentComponent.ctx.deactivate(vnode);
4883
- }
4884
- return;
4885
- }
4886
- const shouldInvokeDirs = shapeFlag & 1 && dirs;
4887
- const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
4888
- let vnodeHook;
4889
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
4890
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
4891
- }
4892
- if (shapeFlag & 6) {
4893
- if (type.__vapor) {
4894
- getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
4895
- return;
4896
- } else {
4897
- unmountComponent(vnode.component, parentSuspense, doRemove);
4898
- }
4899
- } else {
4900
- if (shapeFlag & 128) {
4901
- vnode.suspense.unmount(parentSuspense, doRemove);
4902
- return;
4903
- }
4904
- if (shouldInvokeDirs) {
4905
- invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
4906
- }
4907
- if (shapeFlag & 64) {
4908
- vnode.type.remove(
4909
- vnode,
4987
+ const updateComponentPreRender = (instance, nextVNode, optimized) => {
4988
+ nextVNode.component = instance;
4989
+ const prevProps = instance.vnode.props;
4990
+ instance.vnode = nextVNode;
4991
+ instance.next = null;
4992
+ updateProps(instance, nextVNode.props, prevProps, optimized);
4993
+ updateSlots(instance, nextVNode.children, optimized);
4994
+ const prevSub = reactivity.setActiveSub();
4995
+ flushPreFlushCbs(instance);
4996
+ reactivity.setActiveSub(prevSub);
4997
+ };
4998
+ const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
4999
+ const c1 = n1 && n1.children;
5000
+ const prevShapeFlag = n1 ? n1.shapeFlag : 0;
5001
+ const c2 = n2.children;
5002
+ const { patchFlag, shapeFlag } = n2;
5003
+ if (patchFlag > 0) {
5004
+ if (patchFlag & 128) {
5005
+ patchKeyedChildren(
5006
+ c1,
5007
+ c2,
5008
+ container,
5009
+ anchor,
4910
5010
  parentComponent,
4911
5011
  parentSuspense,
4912
- internals,
4913
- doRemove
5012
+ namespace,
5013
+ slotScopeIds,
5014
+ optimized
4914
5015
  );
4915
- } else if (dynamicChildren && // #5154
4916
- // when v-once is used inside a block, setBlockTracking(-1) marks the
4917
- // parent block with hasOnce: true
4918
- // so that it doesn't take the fast path during unmount - otherwise
4919
- // components nested in v-once are never unmounted.
4920
- !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
4921
- (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
4922
- unmountChildren(
4923
- dynamicChildren,
5016
+ return;
5017
+ } else if (patchFlag & 256) {
5018
+ patchUnkeyedChildren(
5019
+ c1,
5020
+ c2,
5021
+ container,
5022
+ anchor,
4924
5023
  parentComponent,
4925
5024
  parentSuspense,
4926
- false,
4927
- true
5025
+ namespace,
5026
+ slotScopeIds,
5027
+ optimized
4928
5028
  );
4929
- } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
4930
- unmountChildren(children, parentComponent, parentSuspense);
4931
- }
4932
- if (type === VaporSlot) {
4933
- getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
4934
5029
  return;
4935
5030
  }
4936
- if (doRemove) {
4937
- remove(vnode);
4938
- }
4939
- }
4940
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
4941
- queuePostRenderEffect(
4942
- () => {
4943
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4944
- shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
4945
- },
4946
- void 0,
4947
- parentSuspense
4948
- );
4949
5031
  }
4950
- };
4951
- const remove = (vnode) => {
4952
- const { type, el, anchor, transition } = vnode;
4953
- if (type === Fragment) {
4954
- {
4955
- removeFragment(el, anchor);
5032
+ if (shapeFlag & 8) {
5033
+ if (prevShapeFlag & 16) {
5034
+ unmountChildren(c1, parentComponent, parentSuspense);
4956
5035
  }
4957
- return;
4958
- }
4959
- if (type === Static) {
4960
- removeStaticNode(vnode);
4961
- return;
4962
- }
4963
- if (transition) {
4964
- performTransitionLeave(
4965
- el,
4966
- transition,
4967
- () => hostRemove(el),
4968
- !!(vnode.shapeFlag & 1)
4969
- );
4970
- } else {
4971
- hostRemove(el);
4972
- }
4973
- };
4974
- const removeFragment = (cur, end) => {
4975
- let next;
4976
- while (cur !== end) {
4977
- next = hostNextSibling(cur);
4978
- hostRemove(cur);
4979
- cur = next;
4980
- }
4981
- hostRemove(end);
4982
- };
4983
- const unmountComponent = (instance, parentSuspense, doRemove) => {
4984
- const { bum, scope, effect, subTree, um, m, a } = instance;
4985
- invalidateMount(m);
4986
- invalidateMount(a);
4987
- if (bum) {
4988
- shared.invokeArrayFns(bum);
4989
- }
4990
- scope.stop();
4991
- if (effect) {
4992
- effect.stop();
4993
- unmount(subTree, instance, parentSuspense, doRemove);
4994
- }
4995
- if (um) {
4996
- queuePostRenderEffect(um, void 0, parentSuspense);
4997
- }
4998
- queuePostRenderEffect(
4999
- () => instance.isUnmounted = true,
5000
- void 0,
5001
- parentSuspense
5002
- );
5003
- };
5004
- const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
5005
- for (let i = start; i < children.length; i++) {
5006
- unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
5007
- }
5008
- };
5009
- const getNextHostNode = (vnode) => {
5010
- if (vnode.shapeFlag & 6) {
5011
- if (vnode.type.__vapor) {
5012
- return hostNextSibling(vnode.anchor);
5036
+ if (c2 !== c1) {
5037
+ hostSetElementText(container, c2);
5038
+ }
5039
+ } else {
5040
+ if (prevShapeFlag & 16) {
5041
+ if (shapeFlag & 16) {
5042
+ patchKeyedChildren(
5043
+ c1,
5044
+ c2,
5045
+ container,
5046
+ anchor,
5047
+ parentComponent,
5048
+ parentSuspense,
5049
+ namespace,
5050
+ slotScopeIds,
5051
+ optimized
5052
+ );
5053
+ } else {
5054
+ unmountChildren(c1, parentComponent, parentSuspense, true);
5055
+ }
5056
+ } else {
5057
+ if (prevShapeFlag & 8) {
5058
+ hostSetElementText(container, "");
5059
+ }
5060
+ if (shapeFlag & 16) {
5061
+ mountChildren(
5062
+ c2,
5063
+ container,
5064
+ anchor,
5065
+ parentComponent,
5066
+ parentSuspense,
5067
+ namespace,
5068
+ slotScopeIds,
5069
+ optimized
5070
+ );
5071
+ }
5013
5072
  }
5014
- return getNextHostNode(vnode.component.subTree);
5015
- }
5016
- if (vnode.shapeFlag & 128) {
5017
- return vnode.suspense.next();
5018
5073
  }
5019
- const el = hostNextSibling(vnode.anchor || vnode.el);
5020
- const teleportEnd = el && el[TeleportEndKey];
5021
- return teleportEnd ? hostNextSibling(teleportEnd) : el;
5022
5074
  };
5023
- const render = (vnode, container, namespace) => {
5024
- if (vnode == null) {
5025
- if (container._vnode) {
5026
- unmount(container._vnode, null, null, true);
5027
- }
5028
- } else {
5075
+ const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
5076
+ c1 = c1 || shared.EMPTY_ARR;
5077
+ c2 = c2 || shared.EMPTY_ARR;
5078
+ const oldLength = c1.length;
5079
+ const newLength = c2.length;
5080
+ const commonLength = Math.min(oldLength, newLength);
5081
+ let i;
5082
+ for (i = 0; i < commonLength; i++) {
5083
+ const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
5029
5084
  patch(
5030
- container._vnode || null,
5031
- vnode,
5085
+ c1[i],
5086
+ nextChild,
5032
5087
  container,
5033
5088
  null,
5034
- null,
5035
- null,
5036
- namespace
5089
+ parentComponent,
5090
+ parentSuspense,
5091
+ namespace,
5092
+ slotScopeIds,
5093
+ optimized
5037
5094
  );
5038
5095
  }
5039
- container._vnode = vnode;
5040
- flushOnAppMount();
5041
- };
5042
- const internals = {
5043
- p: patch,
5044
- um: unmount,
5045
- m: move,
5046
- r: remove,
5047
- mt: mountComponent,
5048
- umt: unmountComponent,
5049
- mc: mountChildren,
5050
- pc: patchChildren,
5051
- pbc: patchBlockChildren,
5052
- n: getNextHostNode,
5053
- o: options
5054
- };
5055
- let hydrate;
5056
- let hydrateNode;
5057
- if (createHydrationFns) {
5058
- [hydrate, hydrateNode] = createHydrationFns(
5059
- internals
5060
- );
5061
- }
5062
- const mountApp = (app, container, isHydrate, namespace) => {
5063
- const vnode = app._ceVNode || createVNode(app._component, app._props);
5064
- vnode.appContext = app._context;
5065
- if (namespace === true) {
5066
- namespace = "svg";
5067
- } else if (namespace === false) {
5068
- namespace = void 0;
5069
- }
5070
- if (isHydrate && hydrate) {
5071
- hydrate(vnode, container);
5096
+ if (oldLength > newLength) {
5097
+ unmountChildren(
5098
+ c1,
5099
+ parentComponent,
5100
+ parentSuspense,
5101
+ true,
5102
+ false,
5103
+ commonLength
5104
+ );
5072
5105
  } else {
5073
- render(vnode, container, namespace);
5106
+ mountChildren(
5107
+ c2,
5108
+ container,
5109
+ anchor,
5110
+ parentComponent,
5111
+ parentSuspense,
5112
+ namespace,
5113
+ slotScopeIds,
5114
+ optimized,
5115
+ commonLength
5116
+ );
5074
5117
  }
5075
- return vnode.component;
5076
- };
5077
- const unmountApp = (app) => {
5078
- render(null, app._container);
5079
- };
5080
- return {
5081
- render,
5082
- hydrate,
5083
- hydrateNode,
5084
- internals,
5085
- createApp: createAppAPI(
5086
- mountApp,
5087
- unmountApp,
5088
- getComponentPublicInstance)
5089
5118
  };
5090
- }
5091
- function resolveChildrenNamespace({ type, props }, currentNamespace) {
5092
- return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
5093
- }
5094
- function toggleRecurse({ effect, job, vapor }, allowed) {
5095
- if (!vapor) {
5096
- if (allowed) {
5097
- effect.flags |= 128;
5098
- job.flags |= 2;
5099
- } else {
5100
- effect.flags &= -129;
5101
- job.flags &= -3;
5119
+ const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
5120
+ let i = 0;
5121
+ const l2 = c2.length;
5122
+ let e1 = c1.length - 1;
5123
+ let e2 = l2 - 1;
5124
+ while (i <= e1 && i <= e2) {
5125
+ const n1 = c1[i];
5126
+ const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
5127
+ if (isSameVNodeType(n1, n2)) {
5128
+ patch(
5129
+ n1,
5130
+ n2,
5131
+ container,
5132
+ null,
5133
+ parentComponent,
5134
+ parentSuspense,
5135
+ namespace,
5136
+ slotScopeIds,
5137
+ optimized
5138
+ );
5139
+ } else {
5140
+ break;
5141
+ }
5142
+ i++;
5102
5143
  }
5103
- }
5104
- }
5105
- function needTransition(parentSuspense, transition) {
5106
- return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5107
- }
5108
- function traverseStaticChildren(n1, n2, shallow = false) {
5109
- const ch1 = n1.children;
5110
- const ch2 = n2.children;
5111
- if (shared.isArray(ch1) && shared.isArray(ch2)) {
5112
- for (let i = 0; i < ch1.length; i++) {
5113
- const c1 = ch1[i];
5114
- let c2 = ch2[i];
5115
- if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
5116
- if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
5117
- c2 = ch2[i] = cloneIfMounted(ch2[i]);
5118
- c2.el = c1.el;
5144
+ while (i <= e1 && i <= e2) {
5145
+ const n1 = c1[e1];
5146
+ const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
5147
+ if (isSameVNodeType(n1, n2)) {
5148
+ patch(
5149
+ n1,
5150
+ n2,
5151
+ container,
5152
+ null,
5153
+ parentComponent,
5154
+ parentSuspense,
5155
+ namespace,
5156
+ slotScopeIds,
5157
+ optimized
5158
+ );
5159
+ } else {
5160
+ break;
5161
+ }
5162
+ e1--;
5163
+ e2--;
5164
+ }
5165
+ if (i > e1) {
5166
+ if (i <= e2) {
5167
+ const nextPos = e2 + 1;
5168
+ const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
5169
+ while (i <= e2) {
5170
+ patch(
5171
+ null,
5172
+ c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
5173
+ container,
5174
+ anchor,
5175
+ parentComponent,
5176
+ parentSuspense,
5177
+ namespace,
5178
+ slotScopeIds,
5179
+ optimized
5180
+ );
5181
+ i++;
5182
+ }
5183
+ }
5184
+ } else if (i > e2) {
5185
+ while (i <= e1) {
5186
+ unmount(c1[i], parentComponent, parentSuspense, true);
5187
+ i++;
5188
+ }
5189
+ } else {
5190
+ const s1 = i;
5191
+ const s2 = i;
5192
+ const keyToNewIndexMap = /* @__PURE__ */ new Map();
5193
+ for (i = s2; i <= e2; i++) {
5194
+ const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
5195
+ if (nextChild.key != null) {
5196
+ keyToNewIndexMap.set(nextChild.key, i);
5197
+ }
5198
+ }
5199
+ let j;
5200
+ let patched = 0;
5201
+ const toBePatched = e2 - s2 + 1;
5202
+ let moved = false;
5203
+ let maxNewIndexSoFar = 0;
5204
+ const newIndexToOldIndexMap = new Array(toBePatched);
5205
+ for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
5206
+ for (i = s1; i <= e1; i++) {
5207
+ const prevChild = c1[i];
5208
+ if (patched >= toBePatched) {
5209
+ unmount(prevChild, parentComponent, parentSuspense, true);
5210
+ continue;
5211
+ }
5212
+ let newIndex;
5213
+ if (prevChild.key != null) {
5214
+ newIndex = keyToNewIndexMap.get(prevChild.key);
5215
+ } else {
5216
+ for (j = s2; j <= e2; j++) {
5217
+ if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
5218
+ newIndex = j;
5219
+ break;
5220
+ }
5221
+ }
5222
+ }
5223
+ if (newIndex === void 0) {
5224
+ unmount(prevChild, parentComponent, parentSuspense, true);
5225
+ } else {
5226
+ newIndexToOldIndexMap[newIndex - s2] = i + 1;
5227
+ if (newIndex >= maxNewIndexSoFar) {
5228
+ maxNewIndexSoFar = newIndex;
5229
+ } else {
5230
+ moved = true;
5231
+ }
5232
+ patch(
5233
+ prevChild,
5234
+ c2[newIndex],
5235
+ container,
5236
+ null,
5237
+ parentComponent,
5238
+ parentSuspense,
5239
+ namespace,
5240
+ slotScopeIds,
5241
+ optimized
5242
+ );
5243
+ patched++;
5119
5244
  }
5120
- if (!shallow && c2.patchFlag !== -2)
5121
- traverseStaticChildren(c1, c2);
5122
- }
5123
- if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
5124
- c2.patchFlag !== -1) {
5125
- c2.el = c1.el;
5126
5245
  }
5127
- if (c2.type === Comment && !c2.el) {
5128
- c2.el = c1.el;
5246
+ const increasingNewIndexSequence = moved ? shared.getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
5247
+ j = increasingNewIndexSequence.length - 1;
5248
+ for (i = toBePatched - 1; i >= 0; i--) {
5249
+ const nextIndex = s2 + i;
5250
+ const nextChild = c2[nextIndex];
5251
+ const anchorVNode = c2[nextIndex + 1];
5252
+ const anchor = nextIndex + 1 < l2 ? (
5253
+ // #13559, fallback to el placeholder for unresolved async component
5254
+ anchorVNode.el || anchorVNode.placeholder
5255
+ ) : parentAnchor;
5256
+ if (newIndexToOldIndexMap[i] === 0) {
5257
+ patch(
5258
+ null,
5259
+ nextChild,
5260
+ container,
5261
+ anchor,
5262
+ parentComponent,
5263
+ parentSuspense,
5264
+ namespace,
5265
+ slotScopeIds,
5266
+ optimized
5267
+ );
5268
+ } else if (moved) {
5269
+ if (j < 0 || i !== increasingNewIndexSequence[j]) {
5270
+ move(
5271
+ nextChild,
5272
+ container,
5273
+ anchor,
5274
+ 2,
5275
+ parentComponent
5276
+ );
5277
+ } else {
5278
+ j--;
5279
+ }
5280
+ }
5129
5281
  }
5130
5282
  }
5131
- }
5132
- }
5133
- function locateNonHydratedAsyncRoot(instance) {
5134
- const subComponent = instance.subTree && instance.subTree.component;
5135
- if (subComponent) {
5136
- if (subComponent.asyncDep && !subComponent.asyncResolved) {
5137
- return subComponent;
5138
- } else {
5139
- return locateNonHydratedAsyncRoot(subComponent);
5283
+ };
5284
+ const move = (vnode, container, anchor, moveType, parentComponent, parentSuspense = null) => {
5285
+ const { el, type, transition, children, shapeFlag } = vnode;
5286
+ if (shapeFlag & 6) {
5287
+ if (type.__vapor) {
5288
+ getVaporInterface(parentComponent, vnode).move(vnode, container, anchor);
5289
+ } else {
5290
+ move(
5291
+ vnode.component.subTree,
5292
+ container,
5293
+ anchor,
5294
+ moveType,
5295
+ parentComponent
5296
+ );
5297
+ }
5298
+ return;
5140
5299
  }
5141
- }
5142
- }
5143
- function invalidateMount(hooks) {
5144
- if (hooks) {
5145
- for (let i = 0; i < hooks.length; i++)
5146
- hooks[i].flags |= 4;
5147
- }
5148
- }
5149
- function performTransitionEnter(el, transition, insert, parentSuspense, force = false) {
5150
- if (force || needTransition(parentSuspense, transition)) {
5151
- transition.beforeEnter(el);
5152
- insert();
5153
- queuePostRenderEffect(() => transition.enter(el), void 0, parentSuspense);
5154
- } else {
5155
- insert();
5156
- }
5157
- }
5158
- function performTransitionLeave(el, transition, remove, isElement = true) {
5159
- const performRemove = () => {
5160
- remove();
5161
- if (transition && !transition.persisted && transition.afterLeave) {
5162
- transition.afterLeave();
5300
+ if (shapeFlag & 128) {
5301
+ vnode.suspense.move(container, anchor, moveType);
5302
+ return;
5163
5303
  }
5164
- };
5165
- if (isElement && transition && !transition.persisted) {
5166
- const { leave, delayLeave } = transition;
5167
- const performLeave = () => leave(el, performRemove);
5168
- if (delayLeave) {
5169
- delayLeave(el, performRemove, performLeave);
5170
- } else {
5171
- performLeave();
5304
+ if (shapeFlag & 64) {
5305
+ type.move(
5306
+ vnode,
5307
+ container,
5308
+ anchor,
5309
+ internals,
5310
+ parentComponent
5311
+ );
5312
+ return;
5172
5313
  }
5173
- } else {
5174
- performRemove();
5175
- }
5176
- }
5177
- function getVaporInterface(instance, vnode) {
5178
- const ctx = instance ? instance.appContext : vnode.appContext;
5179
- const res = ctx && ctx.vapor;
5180
- return res;
5181
- }
5182
- function getInheritedScopeIds(vnode, parentComponent) {
5183
- const inheritedScopeIds = [];
5184
- let currentParent = parentComponent;
5185
- let currentVNode = vnode;
5186
- while (currentParent) {
5187
- let subTree = currentParent.subTree;
5188
- if (!subTree) break;
5189
- if (currentVNode === subTree || isSuspense(subTree.type) && (subTree.ssContent === currentVNode || subTree.ssFallback === currentVNode)) {
5190
- const parentVNode = currentParent.vnode;
5191
- if (parentVNode.scopeId) {
5192
- inheritedScopeIds.push(parentVNode.scopeId);
5193
- }
5194
- if (parentVNode.slotScopeIds) {
5195
- inheritedScopeIds.push(...parentVNode.slotScopeIds);
5314
+ if (type === Fragment) {
5315
+ hostInsert(el, container, anchor);
5316
+ for (let i = 0; i < children.length; i++) {
5317
+ move(
5318
+ children[i],
5319
+ container,
5320
+ anchor,
5321
+ moveType,
5322
+ parentComponent
5323
+ );
5196
5324
  }
5197
- currentVNode = parentVNode;
5198
- currentParent = currentParent.parent;
5199
- } else {
5200
- break;
5325
+ hostInsert(vnode.anchor, container, anchor);
5326
+ return;
5201
5327
  }
5202
- }
5203
- return inheritedScopeIds;
5204
- }
5205
-
5206
- const ssrContextKey = Symbol.for("v-scx");
5207
- const useSSRContext = () => {
5208
- {
5209
- const ctx = inject(ssrContextKey);
5210
- return ctx;
5211
- }
5212
- };
5213
-
5214
- function watchEffect(effect, options) {
5215
- return doWatch(effect, null, options);
5216
- }
5217
- function watchPostEffect(effect, options) {
5218
- return doWatch(
5219
- effect,
5220
- null,
5221
- { flush: "post" }
5222
- );
5223
- }
5224
- function watchSyncEffect(effect, options) {
5225
- return doWatch(
5226
- effect,
5227
- null,
5228
- { flush: "sync" }
5229
- );
5230
- }
5231
- function watch(source, cb, options) {
5232
- return doWatch(source, cb, options);
5233
- }
5234
- class RenderWatcherEffect extends reactivity.WatcherEffect {
5235
- constructor(instance, source, cb, options, flush) {
5236
- super(source, cb, options);
5237
- this.flush = flush;
5238
- const job = () => {
5239
- if (this.dirty) {
5240
- this.run();
5328
+ if (type === Static) {
5329
+ moveStaticNode(vnode, container, anchor);
5330
+ return;
5331
+ }
5332
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
5333
+ if (needTransition2) {
5334
+ if (moveType === 0) {
5335
+ performTransitionEnter(
5336
+ el,
5337
+ transition,
5338
+ () => hostInsert(el, container, anchor),
5339
+ parentSuspense,
5340
+ true
5341
+ );
5342
+ } else {
5343
+ const { leave, delayLeave, afterLeave } = transition;
5344
+ const remove2 = () => {
5345
+ if (vnode.ctx.isUnmounted) {
5346
+ hostRemove(el);
5347
+ } else {
5348
+ hostInsert(el, container, anchor);
5349
+ }
5350
+ };
5351
+ const performLeave = () => {
5352
+ if (el._isLeaving) {
5353
+ el[leaveCbKey](
5354
+ true
5355
+ /* cancelled */
5356
+ );
5357
+ }
5358
+ leave(el, () => {
5359
+ remove2();
5360
+ afterLeave && afterLeave();
5361
+ });
5362
+ };
5363
+ if (delayLeave) {
5364
+ delayLeave(el, remove2, performLeave);
5365
+ } else {
5366
+ performLeave();
5367
+ }
5241
5368
  }
5242
- };
5243
- if (cb) {
5244
- this.flags |= 128;
5245
- job.flags |= 2;
5369
+ } else {
5370
+ hostInsert(el, container, anchor);
5246
5371
  }
5247
- if (instance) {
5248
- job.i = instance;
5372
+ };
5373
+ const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
5374
+ const {
5375
+ type,
5376
+ props,
5377
+ ref,
5378
+ children,
5379
+ dynamicChildren,
5380
+ shapeFlag,
5381
+ patchFlag,
5382
+ dirs,
5383
+ cacheIndex
5384
+ } = vnode;
5385
+ if (patchFlag === -2) {
5386
+ optimized = false;
5249
5387
  }
5250
- this.job = job;
5251
- }
5252
- notify() {
5253
- const flags = this.flags;
5254
- if (!(flags & 256)) {
5255
- const flush = this.flush;
5256
- const job = this.job;
5257
- if (flush === "post") {
5258
- queuePostRenderEffect(job, void 0, job.i ? job.i.suspense : null);
5259
- } else if (flush === "pre") {
5260
- queueJob(job, job.i ? job.i.uid : void 0, true);
5261
- } else {
5262
- job();
5263
- }
5388
+ if (ref != null) {
5389
+ const prevSub = reactivity.setActiveSub();
5390
+ setRef(ref, null, parentSuspense, vnode, true);
5391
+ reactivity.setActiveSub(prevSub);
5264
5392
  }
5265
- }
5266
- }
5267
- function doWatch(source, cb, options = shared.EMPTY_OBJ) {
5268
- const { immediate, deep, flush = "pre", once } = options;
5269
- const baseWatchOptions = shared.extend({}, options);
5270
- const runsImmediately = cb && immediate || !cb && flush !== "post";
5271
- let ssrCleanup;
5272
- if (isInSSRComponentSetup) {
5273
- if (flush === "sync") {
5274
- const ctx = useSSRContext();
5275
- ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
5276
- } else if (!runsImmediately) {
5277
- const watchStopHandle = () => {
5278
- };
5279
- watchStopHandle.stop = shared.NOOP;
5280
- watchStopHandle.resume = shared.NOOP;
5281
- watchStopHandle.pause = shared.NOOP;
5282
- return watchStopHandle;
5393
+ if (cacheIndex != null) {
5394
+ parentComponent.renderCache[cacheIndex] = void 0;
5283
5395
  }
5284
- }
5285
- const instance = currentInstance;
5286
- baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
5287
- const effect = new RenderWatcherEffect(
5288
- instance,
5289
- source,
5290
- cb,
5291
- baseWatchOptions,
5292
- flush
5293
- );
5294
- if (cb) {
5295
- effect.run(true);
5296
- } else if (flush === "post") {
5297
- queuePostRenderEffect(effect.job, void 0, instance && instance.suspense);
5298
- } else {
5299
- effect.run(true);
5300
- }
5301
- const stop = effect.stop.bind(effect);
5302
- stop.pause = effect.pause.bind(effect);
5303
- stop.resume = effect.resume.bind(effect);
5304
- stop.stop = stop;
5305
- if (isInSSRComponentSetup) {
5306
- if (ssrCleanup) {
5307
- ssrCleanup.push(stop);
5308
- } else if (runsImmediately) {
5309
- stop();
5396
+ if (shapeFlag & 256) {
5397
+ if (vnode.type.__vapor) {
5398
+ getVaporInterface(parentComponent, vnode).deactivate(
5399
+ vnode,
5400
+ parentComponent.ctx.getStorageContainer()
5401
+ );
5402
+ } else {
5403
+ parentComponent.ctx.deactivate(vnode);
5404
+ }
5405
+ return;
5310
5406
  }
5311
- }
5312
- return stop;
5313
- }
5314
- function instanceWatch(source, value, options) {
5315
- const publicThis = this.proxy;
5316
- const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
5317
- let cb;
5318
- if (shared.isFunction(value)) {
5319
- cb = value;
5320
- } else {
5321
- cb = value.handler;
5322
- options = value;
5323
- }
5324
- const prev = setCurrentInstance(this);
5325
- const res = doWatch(getter, cb.bind(publicThis), options);
5326
- setCurrentInstance(...prev);
5327
- return res;
5328
- }
5329
- function createPathGetter(ctx, path) {
5330
- const segments = path.split(".");
5331
- return () => {
5332
- let cur = ctx;
5333
- for (let i = 0; i < segments.length && cur; i++) {
5334
- cur = cur[segments[i]];
5407
+ const shouldInvokeDirs = shapeFlag & 1 && dirs;
5408
+ const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
5409
+ let vnodeHook;
5410
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
5411
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
5335
5412
  }
5336
- return cur;
5337
- };
5338
- }
5339
-
5340
- function useModel(props, name, options = shared.EMPTY_OBJ) {
5341
- const i = getCurrentGenericInstance();
5342
- const camelizedName = shared.camelize(name);
5343
- const hyphenatedName = shared.hyphenate(name);
5344
- const modifiers = getModelModifiers(props, camelizedName, defaultPropGetter);
5345
- const res = reactivity.customRef((track, trigger) => {
5346
- let localValue;
5347
- let prevSetValue = shared.EMPTY_OBJ;
5348
- let prevEmittedValue;
5349
- watchSyncEffect(() => {
5350
- const propValue = props[camelizedName];
5351
- if (shared.hasChanged(localValue, propValue)) {
5352
- localValue = propValue;
5353
- trigger();
5413
+ if (shapeFlag & 6) {
5414
+ if (type.__vapor) {
5415
+ getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
5416
+ return;
5417
+ } else {
5418
+ unmountComponent(vnode.component, parentSuspense, doRemove);
5354
5419
  }
5355
- });
5356
- return {
5357
- get() {
5358
- track();
5359
- return options.get ? options.get(localValue) : localValue;
5360
- },
5361
- set(value) {
5362
- const emittedValue = options.set ? options.set(value) : value;
5363
- if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
5364
- return;
5365
- }
5366
- let rawPropKeys;
5367
- let parentPassedModelValue = false;
5368
- let parentPassedModelUpdater = false;
5369
- if (i.rawKeys) {
5370
- rawPropKeys = i.rawKeys();
5371
- } else {
5372
- const rawProps = i.vnode.props;
5373
- rawPropKeys = rawProps && Object.keys(rawProps);
5374
- }
5375
- if (rawPropKeys) {
5376
- for (const key of rawPropKeys) {
5377
- if (key === name || key === camelizedName || key === hyphenatedName) {
5378
- parentPassedModelValue = true;
5379
- } else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) {
5380
- parentPassedModelUpdater = true;
5381
- }
5382
- }
5383
- }
5384
- if (!parentPassedModelValue || !parentPassedModelUpdater) {
5385
- localValue = value;
5386
- trigger();
5387
- }
5388
- i.emit(`update:${name}`, emittedValue);
5389
- if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
5390
- trigger();
5391
- }
5392
- prevSetValue = value;
5393
- prevEmittedValue = emittedValue;
5420
+ } else {
5421
+ if (shapeFlag & 128) {
5422
+ vnode.suspense.unmount(parentSuspense, doRemove);
5423
+ return;
5394
5424
  }
5395
- };
5396
- });
5397
- res[Symbol.iterator] = () => {
5398
- let i2 = 0;
5399
- return {
5400
- next() {
5401
- if (i2 < 2) {
5402
- return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
5403
- } else {
5404
- return { done: true };
5405
- }
5425
+ if (shouldInvokeDirs) {
5426
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
5427
+ }
5428
+ if (shapeFlag & 64) {
5429
+ vnode.type.remove(
5430
+ vnode,
5431
+ parentComponent,
5432
+ parentSuspense,
5433
+ internals,
5434
+ doRemove
5435
+ );
5436
+ } else if (dynamicChildren && // #5154
5437
+ // when v-once is used inside a block, setBlockTracking(-1) marks the
5438
+ // parent block with hasOnce: true
5439
+ // so that it doesn't take the fast path during unmount - otherwise
5440
+ // components nested in v-once are never unmounted.
5441
+ !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
5442
+ (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
5443
+ unmountChildren(
5444
+ dynamicChildren,
5445
+ parentComponent,
5446
+ parentSuspense,
5447
+ false,
5448
+ true
5449
+ );
5450
+ } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
5451
+ unmountChildren(children, parentComponent, parentSuspense);
5452
+ }
5453
+ if (type === VaporSlot) {
5454
+ getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
5455
+ return;
5456
+ }
5457
+ if (doRemove) {
5458
+ remove(vnode);
5406
5459
  }
5407
- };
5408
- };
5409
- return res;
5410
- }
5411
- const getModelModifiers = (props, modelName, getter) => {
5412
- return getter(props, shared.getModifierPropName(modelName)) || getter(props, `${shared.camelize(modelName)}Modifiers`) || getter(props, `${shared.hyphenate(modelName)}Modifiers`);
5413
- };
5414
-
5415
- function emit(instance, event, ...rawArgs) {
5416
- return baseEmit(
5417
- instance,
5418
- instance.vnode.props || shared.EMPTY_OBJ,
5419
- defaultPropGetter,
5420
- event,
5421
- ...rawArgs
5422
- );
5423
- }
5424
- function baseEmit(instance, props, getter, event, ...rawArgs) {
5425
- if (instance.isUnmounted) return;
5426
- let args = rawArgs;
5427
- const isModelListener = event.startsWith("update:");
5428
- const modifiers = isModelListener && getModelModifiers(props, event.slice(7), getter);
5429
- if (modifiers) {
5430
- if (modifiers.trim) {
5431
- args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
5432
5460
  }
5433
- if (modifiers.number) {
5434
- args = rawArgs.map(shared.looseToNumber);
5461
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
5462
+ queuePostRenderEffect(
5463
+ () => {
5464
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
5465
+ shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
5466
+ },
5467
+ void 0,
5468
+ parentSuspense
5469
+ );
5435
5470
  }
5436
- }
5437
- let handlerName;
5438
- let handler = getter(props, handlerName = shared.toHandlerKey(event)) || // also try camelCase event handler (#2249)
5439
- getter(props, handlerName = shared.toHandlerKey(shared.camelize(event)));
5440
- if (!handler && isModelListener) {
5441
- handler = getter(props, handlerName = shared.toHandlerKey(shared.hyphenate(event)));
5442
- }
5443
- if (handler) {
5444
- callWithAsyncErrorHandling(
5445
- handler,
5446
- instance,
5447
- 6,
5448
- args
5449
- );
5450
- }
5451
- const onceHandler = getter(props, handlerName + `Once`);
5452
- if (onceHandler) {
5453
- if (!instance.emitted) {
5454
- instance.emitted = {};
5455
- } else if (instance.emitted[handlerName]) {
5471
+ };
5472
+ const remove = (vnode) => {
5473
+ const { type, el, anchor, transition } = vnode;
5474
+ if (type === Fragment) {
5475
+ {
5476
+ removeFragment(el, anchor);
5477
+ }
5456
5478
  return;
5457
5479
  }
5458
- instance.emitted[handlerName] = true;
5459
- callWithAsyncErrorHandling(
5460
- onceHandler,
5461
- instance,
5462
- 6,
5463
- args
5464
- );
5465
- }
5466
- }
5467
- function defaultPropGetter(props, key) {
5468
- return props[key];
5469
- }
5470
- const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
5471
- function normalizeEmitsOptions(comp, appContext, asMixin = false) {
5472
- const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
5473
- const cached = cache.get(comp);
5474
- if (cached !== void 0) {
5475
- return cached;
5476
- }
5477
- const raw = comp.emits;
5478
- let normalized = {};
5479
- let hasExtends = false;
5480
- if (!shared.isFunction(comp)) {
5481
- const extendEmits = (raw2) => {
5482
- const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
5483
- if (normalizedFromExtend) {
5484
- hasExtends = true;
5485
- shared.extend(normalized, normalizedFromExtend);
5486
- }
5487
- };
5488
- if (!asMixin && appContext.mixins.length) {
5489
- appContext.mixins.forEach(extendEmits);
5480
+ if (type === Static) {
5481
+ removeStaticNode(vnode);
5482
+ return;
5490
5483
  }
5491
- if (comp.extends) {
5492
- extendEmits(comp.extends);
5484
+ if (transition) {
5485
+ performTransitionLeave(
5486
+ el,
5487
+ transition,
5488
+ () => hostRemove(el),
5489
+ !!(vnode.shapeFlag & 1)
5490
+ );
5491
+ } else {
5492
+ hostRemove(el);
5493
5493
  }
5494
- if (comp.mixins) {
5495
- comp.mixins.forEach(extendEmits);
5494
+ };
5495
+ const removeFragment = (cur, end) => {
5496
+ let next;
5497
+ while (cur !== end) {
5498
+ next = hostNextSibling(cur);
5499
+ hostRemove(cur);
5500
+ cur = next;
5496
5501
  }
5497
- }
5498
- if (!raw && !hasExtends) {
5499
- if (shared.isObject(comp)) {
5500
- cache.set(comp, null);
5502
+ hostRemove(end);
5503
+ };
5504
+ const unmountComponent = (instance, parentSuspense, doRemove) => {
5505
+ const { bum, scope, effect, subTree, um, m, a } = instance;
5506
+ invalidateMount(m);
5507
+ invalidateMount(a);
5508
+ if (bum) {
5509
+ shared.invokeArrayFns(bum);
5501
5510
  }
5502
- return null;
5503
- }
5504
- if (shared.isArray(raw)) {
5505
- raw.forEach((key) => normalized[key] = null);
5506
- } else {
5507
- shared.extend(normalized, raw);
5508
- }
5509
- if (shared.isObject(comp)) {
5510
- cache.set(comp, normalized);
5511
- }
5512
- return normalized;
5513
- }
5514
- function isEmitListener(options, key) {
5515
- if (!options || !shared.isOn(key)) {
5516
- return false;
5517
- }
5518
- key = key.slice(2).replace(/Once$/, "");
5519
- return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
5520
- }
5521
-
5522
- function markAttrsAccessed() {
5523
- }
5524
- function renderComponentRoot(instance) {
5525
- const {
5526
- type: Component,
5527
- vnode,
5528
- proxy,
5529
- withProxy,
5530
- propsOptions: [propsOptions],
5531
- slots,
5532
- attrs,
5533
- emit,
5534
- render,
5535
- renderCache,
5536
- props,
5537
- data,
5538
- setupState,
5539
- ctx,
5540
- inheritAttrs
5541
- } = instance;
5542
- const prev = setCurrentRenderingInstance(instance);
5543
- let result;
5544
- let fallthroughAttrs;
5545
- try {
5546
- if (vnode.shapeFlag & 4) {
5547
- const proxyToUse = withProxy || proxy;
5548
- const thisProxy = false ? new Proxy(proxyToUse, {
5549
- get(target, key, receiver) {
5550
- warn(
5551
- `Property '${String(
5552
- key
5553
- )}' was accessed via 'this'. Avoid using 'this' in templates.`
5554
- );
5555
- return Reflect.get(target, key, receiver);
5556
- }
5557
- }) : proxyToUse;
5558
- result = normalizeVNode(
5559
- render.call(
5560
- thisProxy,
5561
- proxyToUse,
5562
- renderCache,
5563
- false ? shallowReadonly(props) : props,
5564
- setupState,
5565
- data,
5566
- ctx
5567
- )
5568
- );
5569
- fallthroughAttrs = attrs;
5570
- } else {
5571
- const render2 = Component;
5572
- if (false) ;
5573
- result = normalizeVNode(
5574
- render2.length > 1 ? render2(
5575
- false ? shallowReadonly(props) : props,
5576
- false ? {
5577
- get attrs() {
5578
- markAttrsAccessed();
5579
- return shallowReadonly(attrs);
5580
- },
5581
- slots,
5582
- emit
5583
- } : { attrs, slots, emit }
5584
- ) : render2(
5585
- false ? shallowReadonly(props) : props,
5586
- null
5587
- )
5588
- );
5589
- fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
5511
+ scope.stop();
5512
+ if (effect) {
5513
+ effect.stop();
5514
+ unmount(subTree, instance, parentSuspense, doRemove);
5590
5515
  }
5591
- } catch (err) {
5592
- blockStack.length = 0;
5593
- handleError(err, instance, 1);
5594
- result = createVNode(Comment);
5595
- }
5596
- let root = result;
5597
- if (fallthroughAttrs && inheritAttrs !== false) {
5598
- const keys = Object.keys(fallthroughAttrs);
5599
- const { shapeFlag } = root;
5600
- if (keys.length) {
5601
- if (shapeFlag & (1 | 6)) {
5602
- if (propsOptions && keys.some(shared.isModelListener)) {
5603
- fallthroughAttrs = filterModelListeners(
5604
- fallthroughAttrs,
5605
- propsOptions
5606
- );
5607
- }
5608
- root = cloneVNode(root, fallthroughAttrs, false, true);
5516
+ if (um) {
5517
+ queuePostRenderEffect(um, void 0, parentSuspense);
5518
+ }
5519
+ queuePostRenderEffect(
5520
+ () => instance.isUnmounted = true,
5521
+ void 0,
5522
+ parentSuspense
5523
+ );
5524
+ };
5525
+ const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
5526
+ for (let i = start; i < children.length; i++) {
5527
+ unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
5528
+ }
5529
+ };
5530
+ const getNextHostNode = (vnode) => {
5531
+ if (vnode.shapeFlag & 6) {
5532
+ if (vnode.type.__vapor) {
5533
+ return hostNextSibling(vnode.anchor);
5534
+ }
5535
+ return getNextHostNode(vnode.component.subTree);
5536
+ }
5537
+ if (vnode.shapeFlag & 128) {
5538
+ return vnode.suspense.next();
5539
+ }
5540
+ const el = hostNextSibling(vnode.anchor || vnode.el);
5541
+ const teleportEnd = el && el[TeleportEndKey];
5542
+ return teleportEnd ? hostNextSibling(teleportEnd) : el;
5543
+ };
5544
+ const render = (vnode, container, namespace) => {
5545
+ if (vnode == null) {
5546
+ if (container._vnode) {
5547
+ unmount(container._vnode, null, null, true);
5609
5548
  }
5549
+ } else {
5550
+ patch(
5551
+ container._vnode || null,
5552
+ vnode,
5553
+ container,
5554
+ null,
5555
+ null,
5556
+ null,
5557
+ namespace
5558
+ );
5610
5559
  }
5560
+ container._vnode = vnode;
5561
+ flushOnAppMount();
5562
+ };
5563
+ const internals = {
5564
+ p: patch,
5565
+ um: unmount,
5566
+ m: move,
5567
+ r: remove,
5568
+ mt: mountComponent,
5569
+ umt: unmountComponent,
5570
+ mc: mountChildren,
5571
+ pc: patchChildren,
5572
+ pbc: patchBlockChildren,
5573
+ n: getNextHostNode,
5574
+ o: options
5575
+ };
5576
+ let hydrate;
5577
+ let hydrateNode;
5578
+ if (createHydrationFns) {
5579
+ [hydrate, hydrateNode] = createHydrationFns(
5580
+ internals
5581
+ );
5611
5582
  }
5612
- if (vnode.dirs) {
5613
- root = cloneVNode(root, null, false, true);
5614
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
5615
- }
5616
- if (vnode.transition) {
5617
- setTransitionHooks(root, vnode.transition);
5618
- }
5619
- {
5620
- result = root;
5583
+ const mountApp = (app, container, isHydrate, namespace) => {
5584
+ const vnode = app._ceVNode || createVNode(app._component, app._props);
5585
+ vnode.appContext = app._context;
5586
+ if (namespace === true) {
5587
+ namespace = "svg";
5588
+ } else if (namespace === false) {
5589
+ namespace = void 0;
5590
+ }
5591
+ if (isHydrate && hydrate) {
5592
+ hydrate(vnode, container);
5593
+ } else {
5594
+ render(vnode, container, namespace);
5595
+ }
5596
+ return vnode.component;
5597
+ };
5598
+ const unmountApp = (app) => {
5599
+ render(null, app._container);
5600
+ };
5601
+ return {
5602
+ render,
5603
+ hydrate,
5604
+ hydrateNode,
5605
+ internals,
5606
+ createApp: createAppAPI(
5607
+ mountApp,
5608
+ unmountApp,
5609
+ getComponentPublicInstance)
5610
+ };
5611
+ }
5612
+ function resolveChildrenNamespace({ type, props }, currentNamespace) {
5613
+ return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
5614
+ }
5615
+ function toggleRecurse({ effect, job, vapor }, allowed) {
5616
+ if (!vapor) {
5617
+ if (allowed) {
5618
+ effect.flags |= 128;
5619
+ job.flags |= 2;
5620
+ } else {
5621
+ effect.flags &= -129;
5622
+ job.flags &= -3;
5623
+ }
5621
5624
  }
5622
- setCurrentRenderingInstance(prev);
5623
- return result;
5624
5625
  }
5625
- function filterSingleRoot(children, recurse = true) {
5626
- let singleRoot;
5627
- for (let i = 0; i < children.length; i++) {
5628
- const child = children[i];
5629
- if (isVNode(child)) {
5630
- if (child.type !== Comment || child.children === "v-if") {
5631
- if (singleRoot) {
5632
- return;
5633
- } else {
5634
- singleRoot = child;
5626
+ function needTransition(parentSuspense, transition) {
5627
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5628
+ }
5629
+ function traverseStaticChildren(n1, n2, shallow = false) {
5630
+ const ch1 = n1.children;
5631
+ const ch2 = n2.children;
5632
+ if (shared.isArray(ch1) && shared.isArray(ch2)) {
5633
+ for (let i = 0; i < ch1.length; i++) {
5634
+ const c1 = ch1[i];
5635
+ let c2 = ch2[i];
5636
+ if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
5637
+ if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
5638
+ c2 = ch2[i] = cloneIfMounted(ch2[i]);
5639
+ c2.el = c1.el;
5635
5640
  }
5641
+ if (!shallow && c2.patchFlag !== -2)
5642
+ traverseStaticChildren(c1, c2);
5643
+ }
5644
+ if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
5645
+ c2.patchFlag !== -1) {
5646
+ c2.el = c1.el;
5647
+ }
5648
+ if (c2.type === Comment && !c2.el) {
5649
+ c2.el = c1.el;
5636
5650
  }
5637
- } else {
5638
- return;
5639
5651
  }
5640
5652
  }
5641
- return singleRoot;
5642
5653
  }
5643
- const getFunctionalFallthrough = (attrs) => {
5644
- let res;
5645
- for (const key in attrs) {
5646
- if (key === "class" || key === "style" || shared.isOn(key)) {
5647
- (res || (res = {}))[key] = attrs[key];
5654
+ function locateNonHydratedAsyncRoot(instance) {
5655
+ const subComponent = instance.subTree && instance.subTree.component;
5656
+ if (subComponent) {
5657
+ if (subComponent.asyncDep && !subComponent.asyncResolved) {
5658
+ return subComponent;
5659
+ } else {
5660
+ return locateNonHydratedAsyncRoot(subComponent);
5648
5661
  }
5649
5662
  }
5650
- return res;
5651
- };
5652
- const filterModelListeners = (attrs, props) => {
5653
- const res = {};
5654
- for (const key in attrs) {
5655
- if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
5656
- res[key] = attrs[key];
5657
- }
5663
+ }
5664
+ function invalidateMount(hooks) {
5665
+ if (hooks) {
5666
+ for (let i = 0; i < hooks.length; i++)
5667
+ hooks[i].flags |= 4;
5658
5668
  }
5659
- return res;
5660
- };
5661
- function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
5662
- const { props: prevProps, children: prevChildren, component } = prevVNode;
5663
- const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
5664
- const emits = component.emitsOptions;
5665
- if (nextVNode.dirs || nextVNode.transition) {
5666
- return true;
5669
+ }
5670
+ function performTransitionEnter(el, transition, insert, parentSuspense, force = false) {
5671
+ if (force || needTransition(parentSuspense, transition)) {
5672
+ transition.beforeEnter(el);
5673
+ insert();
5674
+ queuePostRenderEffect(() => transition.enter(el), void 0, parentSuspense);
5675
+ } else {
5676
+ insert();
5667
5677
  }
5668
- if (optimized && patchFlag >= 0) {
5669
- if (patchFlag & 1024) {
5670
- return true;
5678
+ }
5679
+ function performTransitionLeave(el, transition, remove, isElement = true) {
5680
+ const performRemove = () => {
5681
+ remove();
5682
+ if (transition && !transition.persisted && transition.afterLeave) {
5683
+ transition.afterLeave();
5671
5684
  }
5672
- if (patchFlag & 16) {
5673
- if (!prevProps) {
5674
- return !!nextProps;
5675
- }
5676
- return hasPropsChanged(prevProps, nextProps, emits);
5677
- } else if (patchFlag & 8) {
5678
- const dynamicProps = nextVNode.dynamicProps;
5679
- for (let i = 0; i < dynamicProps.length; i++) {
5680
- const key = dynamicProps[i];
5681
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
5682
- return true;
5683
- }
5684
- }
5685
+ };
5686
+ if (isElement && transition && !transition.persisted) {
5687
+ const { leave, delayLeave } = transition;
5688
+ const performLeave = () => leave(el, performRemove);
5689
+ if (delayLeave) {
5690
+ delayLeave(el, performRemove, performLeave);
5691
+ } else {
5692
+ performLeave();
5685
5693
  }
5686
5694
  } else {
5687
- if (prevChildren || nextChildren) {
5688
- if (!nextChildren || !nextChildren.$stable) {
5689
- return true;
5690
- }
5691
- }
5692
- if (prevProps === nextProps) {
5693
- return false;
5694
- }
5695
- if (!prevProps) {
5696
- return !!nextProps;
5697
- }
5698
- if (!nextProps) {
5699
- return true;
5700
- }
5701
- return hasPropsChanged(prevProps, nextProps, emits);
5695
+ performRemove();
5702
5696
  }
5703
- return false;
5704
5697
  }
5705
- function hasPropsChanged(prevProps, nextProps, emitsOptions) {
5706
- const nextKeys = Object.keys(nextProps);
5707
- if (nextKeys.length !== Object.keys(prevProps).length) {
5708
- return true;
5709
- }
5710
- for (let i = 0; i < nextKeys.length; i++) {
5711
- const key = nextKeys[i];
5712
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
5713
- return true;
5714
- }
5715
- }
5716
- return false;
5698
+ function getVaporInterface(instance, vnode) {
5699
+ const ctx = instance ? instance.appContext : vnode.appContext;
5700
+ const res = ctx && ctx.vapor;
5701
+ return res;
5717
5702
  }
5718
- function updateHOCHostEl({ vnode, parent }, el) {
5719
- while (parent && !parent.vapor) {
5720
- const root = parent.subTree;
5721
- if (root.suspense && root.suspense.activeBranch === vnode) {
5722
- root.el = vnode.el;
5723
- }
5724
- if (root === vnode) {
5725
- (vnode = parent.vnode).el = el;
5726
- parent = parent.parent;
5703
+ function getInheritedScopeIds(vnode, parentComponent) {
5704
+ const inheritedScopeIds = [];
5705
+ let currentParent = parentComponent;
5706
+ let currentVNode = vnode;
5707
+ while (currentParent) {
5708
+ let subTree = currentParent.subTree;
5709
+ if (!subTree) break;
5710
+ if (currentVNode === subTree || isSuspense(subTree.type) && (subTree.ssContent === currentVNode || subTree.ssFallback === currentVNode)) {
5711
+ const parentVNode = currentParent.vnode;
5712
+ if (parentVNode.scopeId) {
5713
+ inheritedScopeIds.push(parentVNode.scopeId);
5714
+ }
5715
+ if (parentVNode.slotScopeIds) {
5716
+ inheritedScopeIds.push(...parentVNode.slotScopeIds);
5717
+ }
5718
+ currentVNode = parentVNode;
5719
+ currentParent = currentParent.parent;
5727
5720
  } else {
5728
5721
  break;
5729
5722
  }
5730
5723
  }
5724
+ return inheritedScopeIds;
5731
5725
  }
5732
5726
 
5733
5727
  const isSuspense = (type) => type.__isSuspense;
@@ -6062,7 +6056,11 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
6062
6056
  }
6063
6057
  unmount(activeBranch, parentComponent2, suspense, true);
6064
6058
  if (!delayEnter && isInFallback && vnode2.ssFallback) {
6065
- vnode2.ssFallback.el = null;
6059
+ queuePostRenderEffect(
6060
+ () => vnode2.ssFallback.el = null,
6061
+ void 0,
6062
+ suspense
6063
+ );
6066
6064
  }
6067
6065
  }
6068
6066
  if (!delayEnter) {
@@ -7011,7 +7009,7 @@ function isMemoSame(cached, memo) {
7011
7009
  return true;
7012
7010
  }
7013
7011
 
7014
- const version = "3.6.0-alpha.4";
7012
+ const version = "3.6.0-alpha.5";
7015
7013
  const warn$1 = shared.NOOP;
7016
7014
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
7017
7015
  const devtools = void 0;