@vue/runtime-core 3.5.24 → 3.5.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.5.24
2
+ * @vue/runtime-core v3.5.25
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2420,7 +2420,6 @@ const PublicInstanceProxyHandlers = {
2420
2420
  return true;
2421
2421
  }
2422
2422
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
2423
- let normalizedProps;
2424
2423
  if (key[0] !== "$") {
2425
2424
  const n = accessCache[key];
2426
2425
  if (n !== void 0) {
@@ -2440,11 +2439,7 @@ const PublicInstanceProxyHandlers = {
2440
2439
  } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
2441
2440
  accessCache[key] = 2 /* DATA */;
2442
2441
  return data[key];
2443
- } else if (
2444
- // only cache other properties when instance has declared (thus stable)
2445
- // props
2446
- (normalizedProps = instance.propsOptions[0]) && shared.hasOwn(normalizedProps, key)
2447
- ) {
2442
+ } else if (shared.hasOwn(props, key)) {
2448
2443
  accessCache[key] = 3 /* PROPS */;
2449
2444
  return props[key];
2450
2445
  } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
@@ -2499,10 +2494,10 @@ const PublicInstanceProxyHandlers = {
2499
2494
  return true;
2500
2495
  },
2501
2496
  has({
2502
- _: { data, setupState, accessCache, ctx, appContext, propsOptions, type }
2497
+ _: { data, setupState, accessCache, ctx, appContext, props, type }
2503
2498
  }, key) {
2504
- let normalizedProps, cssModules;
2505
- 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]);
2499
+ let cssModules;
2500
+ 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]);
2506
2501
  },
2507
2502
  defineProperty(target, key, descriptor) {
2508
2503
  if (descriptor.get != null) {
@@ -3081,7 +3076,7 @@ function createAppAPI(render, hydrate) {
3081
3076
  let currentApp = null;
3082
3077
 
3083
3078
  function provide(key, value) {
3084
- if (!currentInstance) ; else {
3079
+ if (currentInstance) {
3085
3080
  let provides = currentInstance.provides;
3086
3081
  const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3087
3082
  if (parentProvides === provides) {
@@ -3105,1114 +3100,896 @@ function hasInjectionContext() {
3105
3100
  return !!(getCurrentInstance() || currentApp);
3106
3101
  }
3107
3102
 
3108
- const internalObjectProto = {};
3109
- const createInternalObject = () => Object.create(internalObjectProto);
3110
- const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
3111
-
3112
- function initProps(instance, rawProps, isStateful, isSSR = false) {
3113
- const props = {};
3114
- const attrs = createInternalObject();
3115
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3116
- setFullProps(instance, rawProps, props, attrs);
3117
- for (const key in instance.propsOptions[0]) {
3118
- if (!(key in props)) {
3119
- props[key] = void 0;
3120
- }
3103
+ const ssrContextKey = Symbol.for("v-scx");
3104
+ const useSSRContext = () => {
3105
+ {
3106
+ const ctx = inject(ssrContextKey);
3107
+ return ctx;
3121
3108
  }
3122
- if (isStateful) {
3123
- instance.props = isSSR ? props : reactivity.shallowReactive(props);
3124
- } else {
3125
- if (!instance.type.props) {
3126
- instance.props = attrs;
3127
- } else {
3128
- instance.props = props;
3109
+ };
3110
+
3111
+ function watchEffect(effect, options) {
3112
+ return doWatch(effect, null, options);
3113
+ }
3114
+ function watchPostEffect(effect, options) {
3115
+ return doWatch(
3116
+ effect,
3117
+ null,
3118
+ { flush: "post" }
3119
+ );
3120
+ }
3121
+ function watchSyncEffect(effect, options) {
3122
+ return doWatch(
3123
+ effect,
3124
+ null,
3125
+ { flush: "sync" }
3126
+ );
3127
+ }
3128
+ function watch(source, cb, options) {
3129
+ return doWatch(source, cb, options);
3130
+ }
3131
+ function doWatch(source, cb, options = shared.EMPTY_OBJ) {
3132
+ const { immediate, deep, flush, once } = options;
3133
+ const baseWatchOptions = shared.extend({}, options);
3134
+ const runsImmediately = cb && immediate || !cb && flush !== "post";
3135
+ let ssrCleanup;
3136
+ if (isInSSRComponentSetup) {
3137
+ if (flush === "sync") {
3138
+ const ctx = useSSRContext();
3139
+ ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
3140
+ } else if (!runsImmediately) {
3141
+ const watchStopHandle = () => {
3142
+ };
3143
+ watchStopHandle.stop = shared.NOOP;
3144
+ watchStopHandle.resume = shared.NOOP;
3145
+ watchStopHandle.pause = shared.NOOP;
3146
+ return watchStopHandle;
3129
3147
  }
3130
3148
  }
3131
- instance.attrs = attrs;
3132
- }
3133
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
3134
- const {
3135
- props,
3136
- attrs,
3137
- vnode: { patchFlag }
3138
- } = instance;
3139
- const rawCurrentProps = reactivity.toRaw(props);
3140
- const [options] = instance.propsOptions;
3141
- let hasAttrsChanged = false;
3142
- if (
3143
- // always force full diff in dev
3144
- // - #1942 if hmr is enabled with sfc component
3145
- // - vite#872 non-sfc component used by sfc component
3146
- (optimized || patchFlag > 0) && !(patchFlag & 16)
3147
- ) {
3148
- if (patchFlag & 8) {
3149
- const propsToUpdate = instance.vnode.dynamicProps;
3150
- for (let i = 0; i < propsToUpdate.length; i++) {
3151
- let key = propsToUpdate[i];
3152
- if (isEmitListener(instance.emitsOptions, key)) {
3153
- continue;
3154
- }
3155
- const value = rawProps[key];
3156
- if (options) {
3157
- if (shared.hasOwn(attrs, key)) {
3158
- if (value !== attrs[key]) {
3159
- attrs[key] = value;
3160
- hasAttrsChanged = true;
3161
- }
3162
- } else {
3163
- const camelizedKey = shared.camelize(key);
3164
- props[camelizedKey] = resolvePropValue(
3165
- options,
3166
- rawCurrentProps,
3167
- camelizedKey,
3168
- value,
3169
- instance,
3170
- false
3171
- );
3172
- }
3173
- } else {
3174
- if (value !== attrs[key]) {
3175
- attrs[key] = value;
3176
- hasAttrsChanged = true;
3177
- }
3178
- }
3149
+ const instance = currentInstance;
3150
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
3151
+ let isPre = false;
3152
+ if (flush === "post") {
3153
+ baseWatchOptions.scheduler = (job) => {
3154
+ queuePostRenderEffect(job, instance && instance.suspense);
3155
+ };
3156
+ } else if (flush !== "sync") {
3157
+ isPre = true;
3158
+ baseWatchOptions.scheduler = (job, isFirstRun) => {
3159
+ if (isFirstRun) {
3160
+ job();
3161
+ } else {
3162
+ queueJob(job);
3179
3163
  }
3164
+ };
3165
+ }
3166
+ baseWatchOptions.augmentJob = (job) => {
3167
+ if (cb) {
3168
+ job.flags |= 4;
3180
3169
  }
3181
- } else {
3182
- if (setFullProps(instance, rawProps, props, attrs)) {
3183
- hasAttrsChanged = true;
3184
- }
3185
- let kebabKey;
3186
- for (const key in rawCurrentProps) {
3187
- if (!rawProps || // for camelCase
3188
- !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
3189
- // and converted to camelCase (#955)
3190
- ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
3191
- if (options) {
3192
- if (rawPrevProps && // for camelCase
3193
- (rawPrevProps[key] !== void 0 || // for kebab-case
3194
- rawPrevProps[kebabKey] !== void 0)) {
3195
- props[key] = resolvePropValue(
3196
- options,
3197
- rawCurrentProps,
3198
- key,
3199
- void 0,
3200
- instance,
3201
- true
3202
- );
3203
- }
3204
- } else {
3205
- delete props[key];
3206
- }
3170
+ if (isPre) {
3171
+ job.flags |= 2;
3172
+ if (instance) {
3173
+ job.id = instance.uid;
3174
+ job.i = instance;
3207
3175
  }
3208
3176
  }
3209
- if (attrs !== rawCurrentProps) {
3210
- for (const key in attrs) {
3211
- if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
3212
- delete attrs[key];
3213
- hasAttrsChanged = true;
3214
- }
3215
- }
3177
+ };
3178
+ const watchHandle = reactivity.watch(source, cb, baseWatchOptions);
3179
+ if (isInSSRComponentSetup) {
3180
+ if (ssrCleanup) {
3181
+ ssrCleanup.push(watchHandle);
3182
+ } else if (runsImmediately) {
3183
+ watchHandle();
3216
3184
  }
3217
3185
  }
3218
- if (hasAttrsChanged) {
3219
- reactivity.trigger(instance.attrs, "set", "");
3186
+ return watchHandle;
3187
+ }
3188
+ function instanceWatch(source, value, options) {
3189
+ const publicThis = this.proxy;
3190
+ const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
3191
+ let cb;
3192
+ if (shared.isFunction(value)) {
3193
+ cb = value;
3194
+ } else {
3195
+ cb = value.handler;
3196
+ options = value;
3220
3197
  }
3198
+ const reset = setCurrentInstance(this);
3199
+ const res = doWatch(getter, cb.bind(publicThis), options);
3200
+ reset();
3201
+ return res;
3221
3202
  }
3222
- function setFullProps(instance, rawProps, props, attrs) {
3223
- const [options, needCastKeys] = instance.propsOptions;
3224
- let hasAttrsChanged = false;
3225
- let rawCastValues;
3226
- if (rawProps) {
3227
- for (let key in rawProps) {
3228
- if (shared.isReservedProp(key)) {
3229
- continue;
3203
+ function createPathGetter(ctx, path) {
3204
+ const segments = path.split(".");
3205
+ return () => {
3206
+ let cur = ctx;
3207
+ for (let i = 0; i < segments.length && cur; i++) {
3208
+ cur = cur[segments[i]];
3209
+ }
3210
+ return cur;
3211
+ };
3212
+ }
3213
+
3214
+ function useModel(props, name, options = shared.EMPTY_OBJ) {
3215
+ const i = getCurrentInstance();
3216
+ const camelizedName = shared.camelize(name);
3217
+ const hyphenatedName = shared.hyphenate(name);
3218
+ const modifiers = getModelModifiers(props, camelizedName);
3219
+ const res = reactivity.customRef((track, trigger) => {
3220
+ let localValue;
3221
+ let prevSetValue = shared.EMPTY_OBJ;
3222
+ let prevEmittedValue;
3223
+ watchSyncEffect(() => {
3224
+ const propValue = props[camelizedName];
3225
+ if (shared.hasChanged(localValue, propValue)) {
3226
+ localValue = propValue;
3227
+ trigger();
3230
3228
  }
3231
- const value = rawProps[key];
3232
- let camelKey;
3233
- if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
3234
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
3235
- props[camelKey] = value;
3236
- } else {
3237
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
3229
+ });
3230
+ return {
3231
+ get() {
3232
+ track();
3233
+ return options.get ? options.get(localValue) : localValue;
3234
+ },
3235
+ set(value) {
3236
+ const emittedValue = options.set ? options.set(value) : value;
3237
+ if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
3238
+ return;
3238
3239
  }
3239
- } else if (!isEmitListener(instance.emitsOptions, key)) {
3240
- if (!(key in attrs) || value !== attrs[key]) {
3241
- attrs[key] = value;
3242
- hasAttrsChanged = true;
3240
+ const rawProps = i.vnode.props;
3241
+ if (!(rawProps && // check if parent has passed v-model
3242
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
3243
+ localValue = value;
3244
+ trigger();
3243
3245
  }
3244
- }
3245
- }
3246
- }
3247
- if (needCastKeys) {
3248
- const rawCurrentProps = reactivity.toRaw(props);
3249
- const castValues = rawCastValues || shared.EMPTY_OBJ;
3250
- for (let i = 0; i < needCastKeys.length; i++) {
3251
- const key = needCastKeys[i];
3252
- props[key] = resolvePropValue(
3253
- options,
3254
- rawCurrentProps,
3255
- key,
3256
- castValues[key],
3257
- instance,
3258
- !shared.hasOwn(castValues, key)
3259
- );
3260
- }
3261
- }
3262
- return hasAttrsChanged;
3263
- }
3264
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
3265
- const opt = options[key];
3266
- if (opt != null) {
3267
- const hasDefault = shared.hasOwn(opt, "default");
3268
- if (hasDefault && value === void 0) {
3269
- const defaultValue = opt.default;
3270
- if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
3271
- const { propsDefaults } = instance;
3272
- if (key in propsDefaults) {
3273
- value = propsDefaults[key];
3274
- } else {
3275
- const reset = setCurrentInstance(instance);
3276
- value = propsDefaults[key] = defaultValue.call(
3277
- null,
3278
- props
3279
- );
3280
- reset();
3246
+ i.emit(`update:${name}`, emittedValue);
3247
+ if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
3248
+ trigger();
3281
3249
  }
3282
- } else {
3283
- value = defaultValue;
3250
+ prevSetValue = value;
3251
+ prevEmittedValue = emittedValue;
3284
3252
  }
3285
- if (instance.ce) {
3286
- instance.ce._setProp(key, value);
3253
+ };
3254
+ });
3255
+ res[Symbol.iterator] = () => {
3256
+ let i2 = 0;
3257
+ return {
3258
+ next() {
3259
+ if (i2 < 2) {
3260
+ return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
3261
+ } else {
3262
+ return { done: true };
3263
+ }
3287
3264
  }
3265
+ };
3266
+ };
3267
+ return res;
3268
+ }
3269
+ const getModelModifiers = (props, modelName) => {
3270
+ return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${shared.camelize(modelName)}Modifiers`] || props[`${shared.hyphenate(modelName)}Modifiers`];
3271
+ };
3272
+
3273
+ function emit(instance, event, ...rawArgs) {
3274
+ if (instance.isUnmounted) return;
3275
+ const props = instance.vnode.props || shared.EMPTY_OBJ;
3276
+ let args = rawArgs;
3277
+ const isModelListener = event.startsWith("update:");
3278
+ const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
3279
+ if (modifiers) {
3280
+ if (modifiers.trim) {
3281
+ args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
3288
3282
  }
3289
- if (opt[0 /* shouldCast */]) {
3290
- if (isAbsent && !hasDefault) {
3291
- value = false;
3292
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
3293
- value = true;
3294
- }
3283
+ if (modifiers.number) {
3284
+ args = rawArgs.map(shared.looseToNumber);
3295
3285
  }
3296
3286
  }
3297
- return value;
3287
+ let handlerName;
3288
+ let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
3289
+ props[handlerName = shared.toHandlerKey(shared.camelize(event))];
3290
+ if (!handler && isModelListener) {
3291
+ handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
3292
+ }
3293
+ if (handler) {
3294
+ callWithAsyncErrorHandling(
3295
+ handler,
3296
+ instance,
3297
+ 6,
3298
+ args
3299
+ );
3300
+ }
3301
+ const onceHandler = props[handlerName + `Once`];
3302
+ if (onceHandler) {
3303
+ if (!instance.emitted) {
3304
+ instance.emitted = {};
3305
+ } else if (instance.emitted[handlerName]) {
3306
+ return;
3307
+ }
3308
+ instance.emitted[handlerName] = true;
3309
+ callWithAsyncErrorHandling(
3310
+ onceHandler,
3311
+ instance,
3312
+ 6,
3313
+ args
3314
+ );
3315
+ }
3298
3316
  }
3299
- const mixinPropsCache = /* @__PURE__ */ new WeakMap();
3300
- function normalizePropsOptions(comp, appContext, asMixin = false) {
3301
- const cache = asMixin ? mixinPropsCache : appContext.propsCache;
3317
+ const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
3318
+ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
3319
+ const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
3302
3320
  const cached = cache.get(comp);
3303
- if (cached) {
3321
+ if (cached !== void 0) {
3304
3322
  return cached;
3305
3323
  }
3306
- const raw = comp.props;
3307
- const normalized = {};
3308
- const needCastKeys = [];
3324
+ const raw = comp.emits;
3325
+ let normalized = {};
3309
3326
  let hasExtends = false;
3310
3327
  if (!shared.isFunction(comp)) {
3311
- const extendProps = (raw2) => {
3312
- hasExtends = true;
3313
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
3314
- shared.extend(normalized, props);
3315
- if (keys) needCastKeys.push(...keys);
3328
+ const extendEmits = (raw2) => {
3329
+ const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
3330
+ if (normalizedFromExtend) {
3331
+ hasExtends = true;
3332
+ shared.extend(normalized, normalizedFromExtend);
3333
+ }
3316
3334
  };
3317
3335
  if (!asMixin && appContext.mixins.length) {
3318
- appContext.mixins.forEach(extendProps);
3336
+ appContext.mixins.forEach(extendEmits);
3319
3337
  }
3320
3338
  if (comp.extends) {
3321
- extendProps(comp.extends);
3339
+ extendEmits(comp.extends);
3322
3340
  }
3323
3341
  if (comp.mixins) {
3324
- comp.mixins.forEach(extendProps);
3342
+ comp.mixins.forEach(extendEmits);
3325
3343
  }
3326
3344
  }
3327
3345
  if (!raw && !hasExtends) {
3328
3346
  if (shared.isObject(comp)) {
3329
- cache.set(comp, shared.EMPTY_ARR);
3347
+ cache.set(comp, null);
3330
3348
  }
3331
- return shared.EMPTY_ARR;
3349
+ return null;
3332
3350
  }
3333
3351
  if (shared.isArray(raw)) {
3334
- for (let i = 0; i < raw.length; i++) {
3335
- const normalizedKey = shared.camelize(raw[i]);
3336
- if (validatePropName(normalizedKey)) {
3337
- normalized[normalizedKey] = shared.EMPTY_OBJ;
3338
- }
3339
- }
3340
- } else if (raw) {
3341
- for (const key in raw) {
3342
- const normalizedKey = shared.camelize(key);
3343
- if (validatePropName(normalizedKey)) {
3344
- const opt = raw[key];
3345
- const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
3346
- const propType = prop.type;
3347
- let shouldCast = false;
3348
- let shouldCastTrue = true;
3349
- if (shared.isArray(propType)) {
3350
- for (let index = 0; index < propType.length; ++index) {
3351
- const type = propType[index];
3352
- const typeName = shared.isFunction(type) && type.name;
3353
- if (typeName === "Boolean") {
3354
- shouldCast = true;
3355
- break;
3356
- } else if (typeName === "String") {
3357
- shouldCastTrue = false;
3358
- }
3359
- }
3360
- } else {
3361
- shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
3362
- }
3363
- prop[0 /* shouldCast */] = shouldCast;
3364
- prop[1 /* shouldCastTrue */] = shouldCastTrue;
3365
- if (shouldCast || shared.hasOwn(prop, "default")) {
3366
- needCastKeys.push(normalizedKey);
3367
- }
3368
- }
3369
- }
3352
+ raw.forEach((key) => normalized[key] = null);
3353
+ } else {
3354
+ shared.extend(normalized, raw);
3370
3355
  }
3371
- const res = [normalized, needCastKeys];
3372
3356
  if (shared.isObject(comp)) {
3373
- cache.set(comp, res);
3357
+ cache.set(comp, normalized);
3374
3358
  }
3375
- return res;
3359
+ return normalized;
3376
3360
  }
3377
- function validatePropName(key) {
3378
- if (key[0] !== "$" && !shared.isReservedProp(key)) {
3379
- return true;
3361
+ function isEmitListener(options, key) {
3362
+ if (!options || !shared.isOn(key)) {
3363
+ return false;
3380
3364
  }
3381
- return false;
3365
+ key = key.slice(2).replace(/Once$/, "");
3366
+ return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
3382
3367
  }
3383
3368
 
3384
- const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
3385
- const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
3386
- const normalizeSlot = (key, rawSlot, ctx) => {
3387
- if (rawSlot._n) {
3388
- return rawSlot;
3389
- }
3390
- const normalized = withCtx((...args) => {
3391
- if (false) ;
3392
- return normalizeSlotValue(rawSlot(...args));
3393
- }, ctx);
3394
- normalized._c = false;
3395
- return normalized;
3396
- };
3397
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
3398
- const ctx = rawSlots._ctx;
3399
- for (const key in rawSlots) {
3400
- if (isInternalKey(key)) continue;
3401
- const value = rawSlots[key];
3402
- if (shared.isFunction(value)) {
3403
- slots[key] = normalizeSlot(key, value, ctx);
3404
- } else if (value != null) {
3405
- const normalized = normalizeSlotValue(value);
3406
- slots[key] = () => normalized;
3407
- }
3408
- }
3409
- };
3410
- const normalizeVNodeSlots = (instance, children) => {
3411
- const normalized = normalizeSlotValue(children);
3412
- instance.slots.default = () => normalized;
3413
- };
3414
- const assignSlots = (slots, children, optimized) => {
3415
- for (const key in children) {
3416
- if (optimized || !isInternalKey(key)) {
3417
- slots[key] = children[key];
3418
- }
3419
- }
3420
- };
3421
- const initSlots = (instance, children, optimized) => {
3422
- const slots = instance.slots = createInternalObject();
3423
- if (instance.vnode.shapeFlag & 32) {
3424
- const type = children._;
3425
- if (type) {
3426
- assignSlots(slots, children, optimized);
3427
- if (optimized) {
3428
- shared.def(slots, "_", type, true);
3429
- }
3430
- } else {
3431
- normalizeObjectSlots(children, slots);
3432
- }
3433
- } else if (children) {
3434
- normalizeVNodeSlots(instance, children);
3435
- }
3436
- };
3437
- const updateSlots = (instance, children, optimized) => {
3438
- const { vnode, slots } = instance;
3439
- let needDeletionCheck = true;
3440
- let deletionComparisonTarget = shared.EMPTY_OBJ;
3441
- if (vnode.shapeFlag & 32) {
3442
- const type = children._;
3443
- if (type) {
3444
- if (optimized && type === 1) {
3445
- needDeletionCheck = false;
3446
- } else {
3447
- assignSlots(slots, children, optimized);
3448
- }
3369
+ function markAttrsAccessed() {
3370
+ }
3371
+ function renderComponentRoot(instance) {
3372
+ const {
3373
+ type: Component,
3374
+ vnode,
3375
+ proxy,
3376
+ withProxy,
3377
+ propsOptions: [propsOptions],
3378
+ slots,
3379
+ attrs,
3380
+ emit,
3381
+ render,
3382
+ renderCache,
3383
+ props,
3384
+ data,
3385
+ setupState,
3386
+ ctx,
3387
+ inheritAttrs
3388
+ } = instance;
3389
+ const prev = setCurrentRenderingInstance(instance);
3390
+ let result;
3391
+ let fallthroughAttrs;
3392
+ try {
3393
+ if (vnode.shapeFlag & 4) {
3394
+ const proxyToUse = withProxy || proxy;
3395
+ const thisProxy = false ? new Proxy(proxyToUse, {
3396
+ get(target, key, receiver) {
3397
+ warn(
3398
+ `Property '${String(
3399
+ key
3400
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
3401
+ );
3402
+ return Reflect.get(target, key, receiver);
3403
+ }
3404
+ }) : proxyToUse;
3405
+ result = normalizeVNode(
3406
+ render.call(
3407
+ thisProxy,
3408
+ proxyToUse,
3409
+ renderCache,
3410
+ false ? shallowReadonly(props) : props,
3411
+ setupState,
3412
+ data,
3413
+ ctx
3414
+ )
3415
+ );
3416
+ fallthroughAttrs = attrs;
3449
3417
  } else {
3450
- needDeletionCheck = !children.$stable;
3451
- normalizeObjectSlots(children, slots);
3418
+ const render2 = Component;
3419
+ if (false) ;
3420
+ result = normalizeVNode(
3421
+ render2.length > 1 ? render2(
3422
+ false ? shallowReadonly(props) : props,
3423
+ false ? {
3424
+ get attrs() {
3425
+ markAttrsAccessed();
3426
+ return shallowReadonly(attrs);
3427
+ },
3428
+ slots,
3429
+ emit
3430
+ } : { attrs, slots, emit }
3431
+ ) : render2(
3432
+ false ? shallowReadonly(props) : props,
3433
+ null
3434
+ )
3435
+ );
3436
+ fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
3452
3437
  }
3453
- deletionComparisonTarget = children;
3454
- } else if (children) {
3455
- normalizeVNodeSlots(instance, children);
3456
- deletionComparisonTarget = { default: 1 };
3438
+ } catch (err) {
3439
+ blockStack.length = 0;
3440
+ handleError(err, instance, 1);
3441
+ result = createVNode(Comment);
3457
3442
  }
3458
- if (needDeletionCheck) {
3459
- for (const key in slots) {
3460
- if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
3461
- delete slots[key];
3443
+ let root = result;
3444
+ if (fallthroughAttrs && inheritAttrs !== false) {
3445
+ const keys = Object.keys(fallthroughAttrs);
3446
+ const { shapeFlag } = root;
3447
+ if (keys.length) {
3448
+ if (shapeFlag & (1 | 6)) {
3449
+ if (propsOptions && keys.some(shared.isModelListener)) {
3450
+ fallthroughAttrs = filterModelListeners(
3451
+ fallthroughAttrs,
3452
+ propsOptions
3453
+ );
3454
+ }
3455
+ root = cloneVNode(root, fallthroughAttrs, false, true);
3462
3456
  }
3463
3457
  }
3464
3458
  }
3465
- };
3466
-
3467
- const queuePostRenderEffect = queueEffectWithSuspense ;
3468
- function createRenderer(options) {
3469
- return baseCreateRenderer(options);
3470
- }
3471
- function createHydrationRenderer(options) {
3472
- return baseCreateRenderer(options, createHydrationFunctions);
3459
+ if (vnode.dirs) {
3460
+ root = cloneVNode(root, null, false, true);
3461
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3462
+ }
3463
+ if (vnode.transition) {
3464
+ setTransitionHooks(root, vnode.transition);
3465
+ }
3466
+ {
3467
+ result = root;
3468
+ }
3469
+ setCurrentRenderingInstance(prev);
3470
+ return result;
3473
3471
  }
3474
- function baseCreateRenderer(options, createHydrationFns) {
3475
- const target = shared.getGlobalThis();
3476
- target.__VUE__ = true;
3477
- const {
3478
- insert: hostInsert,
3479
- remove: hostRemove,
3480
- patchProp: hostPatchProp,
3481
- createElement: hostCreateElement,
3482
- createText: hostCreateText,
3483
- createComment: hostCreateComment,
3484
- setText: hostSetText,
3485
- setElementText: hostSetElementText,
3486
- parentNode: hostParentNode,
3487
- nextSibling: hostNextSibling,
3488
- setScopeId: hostSetScopeId = shared.NOOP,
3489
- insertStaticContent: hostInsertStaticContent
3490
- } = options;
3491
- const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
3492
- if (n1 === n2) {
3472
+ function filterSingleRoot(children, recurse = true) {
3473
+ let singleRoot;
3474
+ for (let i = 0; i < children.length; i++) {
3475
+ const child = children[i];
3476
+ if (isVNode(child)) {
3477
+ if (child.type !== Comment || child.children === "v-if") {
3478
+ if (singleRoot) {
3479
+ return;
3480
+ } else {
3481
+ singleRoot = child;
3482
+ }
3483
+ }
3484
+ } else {
3493
3485
  return;
3494
3486
  }
3495
- if (n1 && !isSameVNodeType(n1, n2)) {
3496
- anchor = getNextHostNode(n1);
3497
- unmount(n1, parentComponent, parentSuspense, true);
3498
- n1 = null;
3487
+ }
3488
+ return singleRoot;
3489
+ }
3490
+ const getFunctionalFallthrough = (attrs) => {
3491
+ let res;
3492
+ for (const key in attrs) {
3493
+ if (key === "class" || key === "style" || shared.isOn(key)) {
3494
+ (res || (res = {}))[key] = attrs[key];
3499
3495
  }
3500
- if (n2.patchFlag === -2) {
3501
- optimized = false;
3502
- n2.dynamicChildren = null;
3496
+ }
3497
+ return res;
3498
+ };
3499
+ const filterModelListeners = (attrs, props) => {
3500
+ const res = {};
3501
+ for (const key in attrs) {
3502
+ if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
3503
+ res[key] = attrs[key];
3503
3504
  }
3504
- const { type, ref, shapeFlag } = n2;
3505
- switch (type) {
3506
- case Text:
3507
- processText(n1, n2, container, anchor);
3508
- break;
3509
- case Comment:
3510
- processCommentNode(n1, n2, container, anchor);
3511
- break;
3512
- case Static:
3513
- if (n1 == null) {
3514
- mountStaticNode(n2, container, anchor, namespace);
3505
+ }
3506
+ return res;
3507
+ };
3508
+ function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
3509
+ const { props: prevProps, children: prevChildren, component } = prevVNode;
3510
+ const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
3511
+ const emits = component.emitsOptions;
3512
+ if (nextVNode.dirs || nextVNode.transition) {
3513
+ return true;
3514
+ }
3515
+ if (optimized && patchFlag >= 0) {
3516
+ if (patchFlag & 1024) {
3517
+ return true;
3518
+ }
3519
+ if (patchFlag & 16) {
3520
+ if (!prevProps) {
3521
+ return !!nextProps;
3522
+ }
3523
+ return hasPropsChanged(prevProps, nextProps, emits);
3524
+ } else if (patchFlag & 8) {
3525
+ const dynamicProps = nextVNode.dynamicProps;
3526
+ for (let i = 0; i < dynamicProps.length; i++) {
3527
+ const key = dynamicProps[i];
3528
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
3529
+ return true;
3515
3530
  }
3516
- break;
3517
- case Fragment:
3518
- processFragment(
3519
- n1,
3520
- n2,
3521
- container,
3522
- anchor,
3523
- parentComponent,
3524
- parentSuspense,
3525
- namespace,
3526
- slotScopeIds,
3527
- optimized
3528
- );
3529
- break;
3530
- default:
3531
- if (shapeFlag & 1) {
3532
- processElement(
3533
- n1,
3534
- n2,
3535
- container,
3536
- anchor,
3537
- parentComponent,
3538
- parentSuspense,
3539
- namespace,
3540
- slotScopeIds,
3541
- optimized
3542
- );
3543
- } else if (shapeFlag & 6) {
3544
- processComponent(
3545
- n1,
3546
- n2,
3547
- container,
3548
- anchor,
3549
- parentComponent,
3550
- parentSuspense,
3551
- namespace,
3552
- slotScopeIds,
3553
- optimized
3554
- );
3555
- } else if (shapeFlag & 64) {
3556
- type.process(
3557
- n1,
3558
- n2,
3559
- container,
3560
- anchor,
3561
- parentComponent,
3562
- parentSuspense,
3563
- namespace,
3564
- slotScopeIds,
3565
- optimized,
3566
- internals
3567
- );
3568
- } else if (shapeFlag & 128) {
3569
- type.process(
3570
- n1,
3571
- n2,
3572
- container,
3573
- anchor,
3574
- parentComponent,
3575
- parentSuspense,
3576
- namespace,
3577
- slotScopeIds,
3578
- optimized,
3579
- internals
3580
- );
3581
- } else ;
3582
- }
3583
- if (ref != null && parentComponent) {
3584
- setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
3585
- } else if (ref == null && n1 && n1.ref != null) {
3586
- setRef(n1.ref, null, parentSuspense, n1, true);
3531
+ }
3587
3532
  }
3588
- };
3589
- const processText = (n1, n2, container, anchor) => {
3590
- if (n1 == null) {
3591
- hostInsert(
3592
- n2.el = hostCreateText(n2.children),
3593
- container,
3594
- anchor
3595
- );
3596
- } else {
3597
- const el = n2.el = n1.el;
3598
- if (n2.children !== n1.children) {
3599
- hostSetText(el, n2.children);
3533
+ } else {
3534
+ if (prevChildren || nextChildren) {
3535
+ if (!nextChildren || !nextChildren.$stable) {
3536
+ return true;
3600
3537
  }
3601
3538
  }
3602
- };
3603
- const processCommentNode = (n1, n2, container, anchor) => {
3604
- if (n1 == null) {
3605
- hostInsert(
3606
- n2.el = hostCreateComment(n2.children || ""),
3607
- container,
3608
- anchor
3609
- );
3610
- } else {
3611
- n2.el = n1.el;
3539
+ if (prevProps === nextProps) {
3540
+ return false;
3612
3541
  }
3613
- };
3614
- const mountStaticNode = (n2, container, anchor, namespace) => {
3615
- [n2.el, n2.anchor] = hostInsertStaticContent(
3616
- n2.children,
3617
- container,
3618
- anchor,
3619
- namespace,
3620
- n2.el,
3621
- n2.anchor
3622
- );
3623
- };
3624
- const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
3625
- let next;
3626
- while (el && el !== anchor) {
3627
- next = hostNextSibling(el);
3628
- hostInsert(el, container, nextSibling);
3629
- el = next;
3542
+ if (!prevProps) {
3543
+ return !!nextProps;
3630
3544
  }
3631
- hostInsert(anchor, container, nextSibling);
3632
- };
3633
- const removeStaticNode = ({ el, anchor }) => {
3634
- let next;
3635
- while (el && el !== anchor) {
3636
- next = hostNextSibling(el);
3637
- hostRemove(el);
3638
- el = next;
3545
+ if (!nextProps) {
3546
+ return true;
3639
3547
  }
3640
- hostRemove(anchor);
3641
- };
3642
- const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3643
- if (n2.type === "svg") {
3644
- namespace = "svg";
3645
- } else if (n2.type === "math") {
3646
- namespace = "mathml";
3548
+ return hasPropsChanged(prevProps, nextProps, emits);
3549
+ }
3550
+ return false;
3551
+ }
3552
+ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
3553
+ const nextKeys = Object.keys(nextProps);
3554
+ if (nextKeys.length !== Object.keys(prevProps).length) {
3555
+ return true;
3556
+ }
3557
+ for (let i = 0; i < nextKeys.length; i++) {
3558
+ const key = nextKeys[i];
3559
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
3560
+ return true;
3647
3561
  }
3648
- if (n1 == null) {
3649
- mountElement(
3650
- n2,
3651
- container,
3652
- anchor,
3653
- parentComponent,
3654
- parentSuspense,
3655
- namespace,
3656
- slotScopeIds,
3657
- optimized
3658
- );
3562
+ }
3563
+ return false;
3564
+ }
3565
+ function updateHOCHostEl({ vnode, parent }, el) {
3566
+ while (parent) {
3567
+ const root = parent.subTree;
3568
+ if (root.suspense && root.suspense.activeBranch === vnode) {
3569
+ root.el = vnode.el;
3570
+ }
3571
+ if (root === vnode) {
3572
+ (vnode = parent.vnode).el = el;
3573
+ parent = parent.parent;
3659
3574
  } else {
3660
- const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
3661
- try {
3662
- if (customElement) {
3663
- customElement._beginPatch();
3664
- }
3665
- patchElement(
3666
- n1,
3667
- n2,
3668
- parentComponent,
3669
- parentSuspense,
3670
- namespace,
3671
- slotScopeIds,
3672
- optimized
3673
- );
3674
- } finally {
3675
- if (customElement) {
3676
- customElement._endPatch();
3677
- }
3678
- }
3575
+ break;
3679
3576
  }
3680
- };
3681
- const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3682
- let el;
3683
- let vnodeHook;
3684
- const { props, shapeFlag, transition, dirs } = vnode;
3685
- el = vnode.el = hostCreateElement(
3686
- vnode.type,
3687
- namespace,
3688
- props && props.is,
3689
- props
3690
- );
3691
- if (shapeFlag & 8) {
3692
- hostSetElementText(el, vnode.children);
3693
- } else if (shapeFlag & 16) {
3694
- mountChildren(
3695
- vnode.children,
3696
- el,
3697
- null,
3698
- parentComponent,
3699
- parentSuspense,
3700
- resolveChildrenNamespace(vnode, namespace),
3701
- slotScopeIds,
3702
- optimized
3703
- );
3577
+ }
3578
+ }
3579
+
3580
+ const internalObjectProto = {};
3581
+ const createInternalObject = () => Object.create(internalObjectProto);
3582
+ const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
3583
+
3584
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
3585
+ const props = {};
3586
+ const attrs = createInternalObject();
3587
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3588
+ setFullProps(instance, rawProps, props, attrs);
3589
+ for (const key in instance.propsOptions[0]) {
3590
+ if (!(key in props)) {
3591
+ props[key] = void 0;
3704
3592
  }
3705
- if (dirs) {
3706
- invokeDirectiveHook(vnode, null, parentComponent, "created");
3593
+ }
3594
+ if (isStateful) {
3595
+ instance.props = isSSR ? props : reactivity.shallowReactive(props);
3596
+ } else {
3597
+ if (!instance.type.props) {
3598
+ instance.props = attrs;
3599
+ } else {
3600
+ instance.props = props;
3707
3601
  }
3708
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
3709
- if (props) {
3710
- for (const key in props) {
3711
- if (key !== "value" && !shared.isReservedProp(key)) {
3712
- hostPatchProp(el, key, null, props[key], namespace, parentComponent);
3602
+ }
3603
+ instance.attrs = attrs;
3604
+ }
3605
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3606
+ const {
3607
+ props,
3608
+ attrs,
3609
+ vnode: { patchFlag }
3610
+ } = instance;
3611
+ const rawCurrentProps = reactivity.toRaw(props);
3612
+ const [options] = instance.propsOptions;
3613
+ let hasAttrsChanged = false;
3614
+ if (
3615
+ // always force full diff in dev
3616
+ // - #1942 if hmr is enabled with sfc component
3617
+ // - vite#872 non-sfc component used by sfc component
3618
+ (optimized || patchFlag > 0) && !(patchFlag & 16)
3619
+ ) {
3620
+ if (patchFlag & 8) {
3621
+ const propsToUpdate = instance.vnode.dynamicProps;
3622
+ for (let i = 0; i < propsToUpdate.length; i++) {
3623
+ let key = propsToUpdate[i];
3624
+ if (isEmitListener(instance.emitsOptions, key)) {
3625
+ continue;
3626
+ }
3627
+ const value = rawProps[key];
3628
+ if (options) {
3629
+ if (shared.hasOwn(attrs, key)) {
3630
+ if (value !== attrs[key]) {
3631
+ attrs[key] = value;
3632
+ hasAttrsChanged = true;
3633
+ }
3634
+ } else {
3635
+ const camelizedKey = shared.camelize(key);
3636
+ props[camelizedKey] = resolvePropValue(
3637
+ options,
3638
+ rawCurrentProps,
3639
+ camelizedKey,
3640
+ value,
3641
+ instance,
3642
+ false
3643
+ );
3644
+ }
3645
+ } else {
3646
+ if (value !== attrs[key]) {
3647
+ attrs[key] = value;
3648
+ hasAttrsChanged = true;
3649
+ }
3713
3650
  }
3714
- }
3715
- if ("value" in props) {
3716
- hostPatchProp(el, "value", null, props.value, namespace);
3717
- }
3718
- if (vnodeHook = props.onVnodeBeforeMount) {
3719
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
3720
3651
  }
3721
3652
  }
3722
- if (dirs) {
3723
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
3724
- }
3725
- const needCallTransitionHooks = needTransition(parentSuspense, transition);
3726
- if (needCallTransitionHooks) {
3727
- transition.beforeEnter(el);
3728
- }
3729
- hostInsert(el, container, anchor);
3730
- if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
3731
- queuePostRenderEffect(() => {
3732
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
3733
- needCallTransitionHooks && transition.enter(el);
3734
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
3735
- }, parentSuspense);
3653
+ } else {
3654
+ if (setFullProps(instance, rawProps, props, attrs)) {
3655
+ hasAttrsChanged = true;
3736
3656
  }
3737
- };
3738
- const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
3739
- if (scopeId) {
3740
- hostSetScopeId(el, scopeId);
3657
+ let kebabKey;
3658
+ for (const key in rawCurrentProps) {
3659
+ if (!rawProps || // for camelCase
3660
+ !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
3661
+ // and converted to camelCase (#955)
3662
+ ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
3663
+ if (options) {
3664
+ if (rawPrevProps && // for camelCase
3665
+ (rawPrevProps[key] !== void 0 || // for kebab-case
3666
+ rawPrevProps[kebabKey] !== void 0)) {
3667
+ props[key] = resolvePropValue(
3668
+ options,
3669
+ rawCurrentProps,
3670
+ key,
3671
+ void 0,
3672
+ instance,
3673
+ true
3674
+ );
3675
+ }
3676
+ } else {
3677
+ delete props[key];
3678
+ }
3679
+ }
3741
3680
  }
3742
- if (slotScopeIds) {
3743
- for (let i = 0; i < slotScopeIds.length; i++) {
3744
- hostSetScopeId(el, slotScopeIds[i]);
3681
+ if (attrs !== rawCurrentProps) {
3682
+ for (const key in attrs) {
3683
+ if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
3684
+ delete attrs[key];
3685
+ hasAttrsChanged = true;
3686
+ }
3745
3687
  }
3746
3688
  }
3747
- if (parentComponent) {
3748
- let subTree = parentComponent.subTree;
3749
- if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
3750
- const parentVNode = parentComponent.vnode;
3751
- setScopeId(
3752
- el,
3753
- parentVNode,
3754
- parentVNode.scopeId,
3755
- parentVNode.slotScopeIds,
3756
- parentComponent.parent
3757
- );
3689
+ }
3690
+ if (hasAttrsChanged) {
3691
+ reactivity.trigger(instance.attrs, "set", "");
3692
+ }
3693
+ }
3694
+ function setFullProps(instance, rawProps, props, attrs) {
3695
+ const [options, needCastKeys] = instance.propsOptions;
3696
+ let hasAttrsChanged = false;
3697
+ let rawCastValues;
3698
+ if (rawProps) {
3699
+ for (let key in rawProps) {
3700
+ if (shared.isReservedProp(key)) {
3701
+ continue;
3702
+ }
3703
+ const value = rawProps[key];
3704
+ let camelKey;
3705
+ if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
3706
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
3707
+ props[camelKey] = value;
3708
+ } else {
3709
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
3710
+ }
3711
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
3712
+ if (!(key in attrs) || value !== attrs[key]) {
3713
+ attrs[key] = value;
3714
+ hasAttrsChanged = true;
3715
+ }
3758
3716
  }
3759
3717
  }
3760
- };
3761
- const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
3762
- for (let i = start; i < children.length; i++) {
3763
- const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
3764
- patch(
3765
- null,
3766
- child,
3767
- container,
3768
- anchor,
3769
- parentComponent,
3770
- parentSuspense,
3771
- namespace,
3772
- slotScopeIds,
3773
- optimized
3718
+ }
3719
+ if (needCastKeys) {
3720
+ const rawCurrentProps = reactivity.toRaw(props);
3721
+ const castValues = rawCastValues || shared.EMPTY_OBJ;
3722
+ for (let i = 0; i < needCastKeys.length; i++) {
3723
+ const key = needCastKeys[i];
3724
+ props[key] = resolvePropValue(
3725
+ options,
3726
+ rawCurrentProps,
3727
+ key,
3728
+ castValues[key],
3729
+ instance,
3730
+ !shared.hasOwn(castValues, key)
3774
3731
  );
3775
3732
  }
3776
- };
3777
- const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3778
- const el = n2.el = n1.el;
3779
- let { patchFlag, dynamicChildren, dirs } = n2;
3780
- patchFlag |= n1.patchFlag & 16;
3781
- const oldProps = n1.props || shared.EMPTY_OBJ;
3782
- const newProps = n2.props || shared.EMPTY_OBJ;
3783
- let vnodeHook;
3784
- parentComponent && toggleRecurse(parentComponent, false);
3785
- if (vnodeHook = newProps.onVnodeBeforeUpdate) {
3786
- invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3733
+ }
3734
+ return hasAttrsChanged;
3735
+ }
3736
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
3737
+ const opt = options[key];
3738
+ if (opt != null) {
3739
+ const hasDefault = shared.hasOwn(opt, "default");
3740
+ if (hasDefault && value === void 0) {
3741
+ const defaultValue = opt.default;
3742
+ if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
3743
+ const { propsDefaults } = instance;
3744
+ if (key in propsDefaults) {
3745
+ value = propsDefaults[key];
3746
+ } else {
3747
+ const reset = setCurrentInstance(instance);
3748
+ value = propsDefaults[key] = defaultValue.call(
3749
+ null,
3750
+ props
3751
+ );
3752
+ reset();
3753
+ }
3754
+ } else {
3755
+ value = defaultValue;
3756
+ }
3757
+ if (instance.ce) {
3758
+ instance.ce._setProp(key, value);
3759
+ }
3787
3760
  }
3788
- if (dirs) {
3789
- invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
3761
+ if (opt[0 /* shouldCast */]) {
3762
+ if (isAbsent && !hasDefault) {
3763
+ value = false;
3764
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
3765
+ value = true;
3766
+ }
3790
3767
  }
3791
- parentComponent && toggleRecurse(parentComponent, true);
3792
- if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
3793
- hostSetElementText(el, "");
3768
+ }
3769
+ return value;
3770
+ }
3771
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
3772
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
3773
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
3774
+ const cached = cache.get(comp);
3775
+ if (cached) {
3776
+ return cached;
3777
+ }
3778
+ const raw = comp.props;
3779
+ const normalized = {};
3780
+ const needCastKeys = [];
3781
+ let hasExtends = false;
3782
+ if (!shared.isFunction(comp)) {
3783
+ const extendProps = (raw2) => {
3784
+ hasExtends = true;
3785
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
3786
+ shared.extend(normalized, props);
3787
+ if (keys) needCastKeys.push(...keys);
3788
+ };
3789
+ if (!asMixin && appContext.mixins.length) {
3790
+ appContext.mixins.forEach(extendProps);
3794
3791
  }
3795
- if (dynamicChildren) {
3796
- patchBlockChildren(
3797
- n1.dynamicChildren,
3798
- dynamicChildren,
3799
- el,
3800
- parentComponent,
3801
- parentSuspense,
3802
- resolveChildrenNamespace(n2, namespace),
3803
- slotScopeIds
3804
- );
3805
- } else if (!optimized) {
3806
- patchChildren(
3807
- n1,
3808
- n2,
3809
- el,
3810
- null,
3811
- parentComponent,
3812
- parentSuspense,
3813
- resolveChildrenNamespace(n2, namespace),
3814
- slotScopeIds,
3815
- false
3816
- );
3792
+ if (comp.extends) {
3793
+ extendProps(comp.extends);
3817
3794
  }
3818
- if (patchFlag > 0) {
3819
- if (patchFlag & 16) {
3820
- patchProps(el, oldProps, newProps, parentComponent, namespace);
3821
- } else {
3822
- if (patchFlag & 2) {
3823
- if (oldProps.class !== newProps.class) {
3824
- hostPatchProp(el, "class", null, newProps.class, namespace);
3825
- }
3826
- }
3827
- if (patchFlag & 4) {
3828
- hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
3829
- }
3830
- if (patchFlag & 8) {
3831
- const propsToUpdate = n2.dynamicProps;
3832
- for (let i = 0; i < propsToUpdate.length; i++) {
3833
- const key = propsToUpdate[i];
3834
- const prev = oldProps[key];
3835
- const next = newProps[key];
3836
- if (next !== prev || key === "value") {
3837
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
3838
- }
3839
- }
3840
- }
3841
- }
3842
- if (patchFlag & 1) {
3843
- if (n1.children !== n2.children) {
3844
- hostSetElementText(el, n2.children);
3845
- }
3846
- }
3847
- } else if (!optimized && dynamicChildren == null) {
3848
- patchProps(el, oldProps, newProps, parentComponent, namespace);
3795
+ if (comp.mixins) {
3796
+ comp.mixins.forEach(extendProps);
3849
3797
  }
3850
- if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
3851
- queuePostRenderEffect(() => {
3852
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3853
- dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
3854
- }, parentSuspense);
3798
+ }
3799
+ if (!raw && !hasExtends) {
3800
+ if (shared.isObject(comp)) {
3801
+ cache.set(comp, shared.EMPTY_ARR);
3855
3802
  }
3856
- };
3857
- const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
3858
- for (let i = 0; i < newChildren.length; i++) {
3859
- const oldVNode = oldChildren[i];
3860
- const newVNode = newChildren[i];
3861
- const container = (
3862
- // oldVNode may be an errored async setup() component inside Suspense
3863
- // which will not have a mounted element
3864
- oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
3865
- // of the Fragment itself so it can move its children.
3866
- (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
3867
- // which also requires the correct parent container
3868
- !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
3869
- oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
3870
- // In other cases, the parent container is not actually used so we
3871
- // just pass the block element here to avoid a DOM parentNode call.
3872
- fallbackContainer
3873
- )
3874
- );
3875
- patch(
3876
- oldVNode,
3877
- newVNode,
3878
- container,
3879
- null,
3880
- parentComponent,
3881
- parentSuspense,
3882
- namespace,
3883
- slotScopeIds,
3884
- true
3885
- );
3803
+ return shared.EMPTY_ARR;
3804
+ }
3805
+ if (shared.isArray(raw)) {
3806
+ for (let i = 0; i < raw.length; i++) {
3807
+ const normalizedKey = shared.camelize(raw[i]);
3808
+ if (validatePropName(normalizedKey)) {
3809
+ normalized[normalizedKey] = shared.EMPTY_OBJ;
3810
+ }
3886
3811
  }
3887
- };
3888
- const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
3889
- if (oldProps !== newProps) {
3890
- if (oldProps !== shared.EMPTY_OBJ) {
3891
- for (const key in oldProps) {
3892
- if (!shared.isReservedProp(key) && !(key in newProps)) {
3893
- hostPatchProp(
3894
- el,
3895
- key,
3896
- oldProps[key],
3897
- null,
3898
- namespace,
3899
- parentComponent
3900
- );
3812
+ } else if (raw) {
3813
+ for (const key in raw) {
3814
+ const normalizedKey = shared.camelize(key);
3815
+ if (validatePropName(normalizedKey)) {
3816
+ const opt = raw[key];
3817
+ const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
3818
+ const propType = prop.type;
3819
+ let shouldCast = false;
3820
+ let shouldCastTrue = true;
3821
+ if (shared.isArray(propType)) {
3822
+ for (let index = 0; index < propType.length; ++index) {
3823
+ const type = propType[index];
3824
+ const typeName = shared.isFunction(type) && type.name;
3825
+ if (typeName === "Boolean") {
3826
+ shouldCast = true;
3827
+ break;
3828
+ } else if (typeName === "String") {
3829
+ shouldCastTrue = false;
3830
+ }
3901
3831
  }
3832
+ } else {
3833
+ shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
3902
3834
  }
3903
- }
3904
- for (const key in newProps) {
3905
- if (shared.isReservedProp(key)) continue;
3906
- const next = newProps[key];
3907
- const prev = oldProps[key];
3908
- if (next !== prev && key !== "value") {
3909
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
3835
+ prop[0 /* shouldCast */] = shouldCast;
3836
+ prop[1 /* shouldCastTrue */] = shouldCastTrue;
3837
+ if (shouldCast || shared.hasOwn(prop, "default")) {
3838
+ needCastKeys.push(normalizedKey);
3910
3839
  }
3911
3840
  }
3912
- if ("value" in newProps) {
3913
- hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
3914
- }
3915
3841
  }
3916
- };
3917
- const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3918
- const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
3919
- const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
3920
- let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
3921
- if (fragmentSlotScopeIds) {
3922
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
3842
+ }
3843
+ const res = [normalized, needCastKeys];
3844
+ if (shared.isObject(comp)) {
3845
+ cache.set(comp, res);
3846
+ }
3847
+ return res;
3848
+ }
3849
+ function validatePropName(key) {
3850
+ if (key[0] !== "$" && !shared.isReservedProp(key)) {
3851
+ return true;
3852
+ }
3853
+ return false;
3854
+ }
3855
+
3856
+ const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
3857
+ const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
3858
+ const normalizeSlot = (key, rawSlot, ctx) => {
3859
+ if (rawSlot._n) {
3860
+ return rawSlot;
3861
+ }
3862
+ const normalized = withCtx((...args) => {
3863
+ if (false) ;
3864
+ return normalizeSlotValue(rawSlot(...args));
3865
+ }, ctx);
3866
+ normalized._c = false;
3867
+ return normalized;
3868
+ };
3869
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
3870
+ const ctx = rawSlots._ctx;
3871
+ for (const key in rawSlots) {
3872
+ if (isInternalKey(key)) continue;
3873
+ const value = rawSlots[key];
3874
+ if (shared.isFunction(value)) {
3875
+ slots[key] = normalizeSlot(key, value, ctx);
3876
+ } else if (value != null) {
3877
+ const normalized = normalizeSlotValue(value);
3878
+ slots[key] = () => normalized;
3923
3879
  }
3924
- if (n1 == null) {
3925
- hostInsert(fragmentStartAnchor, container, anchor);
3926
- hostInsert(fragmentEndAnchor, container, anchor);
3927
- mountChildren(
3928
- // #10007
3929
- // such fragment like `<></>` will be compiled into
3930
- // a fragment which doesn't have a children.
3931
- // In this case fallback to an empty array
3932
- n2.children || [],
3933
- container,
3934
- fragmentEndAnchor,
3935
- parentComponent,
3936
- parentSuspense,
3937
- namespace,
3938
- slotScopeIds,
3939
- optimized
3940
- );
3941
- } else {
3942
- if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
3943
- // of renderSlot() with no valid children
3944
- n1.dynamicChildren) {
3945
- patchBlockChildren(
3946
- n1.dynamicChildren,
3947
- dynamicChildren,
3948
- container,
3949
- parentComponent,
3950
- parentSuspense,
3951
- namespace,
3952
- slotScopeIds
3953
- );
3954
- if (
3955
- // #2080 if the stable fragment has a key, it's a <template v-for> that may
3956
- // get moved around. Make sure all root level vnodes inherit el.
3957
- // #2134 or if it's a component root, it may also get moved around
3958
- // as the component is being moved.
3959
- n2.key != null || parentComponent && n2 === parentComponent.subTree
3960
- ) {
3961
- traverseStaticChildren(
3962
- n1,
3963
- n2,
3964
- true
3965
- /* shallow */
3966
- );
3967
- }
3968
- } else {
3969
- patchChildren(
3970
- n1,
3971
- n2,
3972
- container,
3973
- fragmentEndAnchor,
3974
- parentComponent,
3975
- parentSuspense,
3976
- namespace,
3977
- slotScopeIds,
3978
- optimized
3979
- );
3880
+ }
3881
+ };
3882
+ const normalizeVNodeSlots = (instance, children) => {
3883
+ const normalized = normalizeSlotValue(children);
3884
+ instance.slots.default = () => normalized;
3885
+ };
3886
+ const assignSlots = (slots, children, optimized) => {
3887
+ for (const key in children) {
3888
+ if (optimized || !isInternalKey(key)) {
3889
+ slots[key] = children[key];
3890
+ }
3891
+ }
3892
+ };
3893
+ const initSlots = (instance, children, optimized) => {
3894
+ const slots = instance.slots = createInternalObject();
3895
+ if (instance.vnode.shapeFlag & 32) {
3896
+ const type = children._;
3897
+ if (type) {
3898
+ assignSlots(slots, children, optimized);
3899
+ if (optimized) {
3900
+ shared.def(slots, "_", type, true);
3980
3901
  }
3902
+ } else {
3903
+ normalizeObjectSlots(children, slots);
3981
3904
  }
3982
- };
3983
- const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3984
- n2.slotScopeIds = slotScopeIds;
3985
- if (n1 == null) {
3986
- if (n2.shapeFlag & 512) {
3987
- parentComponent.ctx.activate(
3988
- n2,
3989
- container,
3990
- anchor,
3991
- namespace,
3992
- optimized
3993
- );
3905
+ } else if (children) {
3906
+ normalizeVNodeSlots(instance, children);
3907
+ }
3908
+ };
3909
+ const updateSlots = (instance, children, optimized) => {
3910
+ const { vnode, slots } = instance;
3911
+ let needDeletionCheck = true;
3912
+ let deletionComparisonTarget = shared.EMPTY_OBJ;
3913
+ if (vnode.shapeFlag & 32) {
3914
+ const type = children._;
3915
+ if (type) {
3916
+ if (optimized && type === 1) {
3917
+ needDeletionCheck = false;
3994
3918
  } else {
3995
- mountComponent(
3996
- n2,
3997
- container,
3998
- anchor,
3999
- parentComponent,
4000
- parentSuspense,
4001
- namespace,
4002
- optimized
4003
- );
3919
+ assignSlots(slots, children, optimized);
4004
3920
  }
4005
3921
  } else {
4006
- updateComponent(n1, n2, optimized);
4007
- }
4008
- };
4009
- const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
4010
- const instance = (initialVNode.component = createComponentInstance(
4011
- initialVNode,
4012
- parentComponent,
4013
- parentSuspense
4014
- ));
4015
- if (isKeepAlive(initialVNode)) {
4016
- instance.ctx.renderer = internals;
3922
+ needDeletionCheck = !children.$stable;
3923
+ normalizeObjectSlots(children, slots);
4017
3924
  }
4018
- {
4019
- setupComponent(instance, false, optimized);
4020
- }
4021
- if (instance.asyncDep) {
4022
- parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
4023
- if (!initialVNode.el) {
4024
- const placeholder = instance.subTree = createVNode(Comment);
4025
- processCommentNode(null, placeholder, container, anchor);
4026
- initialVNode.placeholder = placeholder.el;
3925
+ deletionComparisonTarget = children;
3926
+ } else if (children) {
3927
+ normalizeVNodeSlots(instance, children);
3928
+ deletionComparisonTarget = { default: 1 };
3929
+ }
3930
+ if (needDeletionCheck) {
3931
+ for (const key in slots) {
3932
+ if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
3933
+ delete slots[key];
4027
3934
  }
4028
- } else {
4029
- setupRenderEffect(
4030
- instance,
4031
- initialVNode,
4032
- container,
4033
- anchor,
4034
- parentSuspense,
4035
- namespace,
4036
- optimized
4037
- );
4038
3935
  }
4039
- };
4040
- const updateComponent = (n1, n2, optimized) => {
4041
- const instance = n2.component = n1.component;
4042
- if (shouldUpdateComponent(n1, n2, optimized)) {
4043
- if (instance.asyncDep && !instance.asyncResolved) {
4044
- updateComponentPreRender(instance, n2, optimized);
4045
- return;
4046
- } else {
4047
- instance.next = n2;
4048
- instance.update();
4049
- }
4050
- } else {
4051
- n2.el = n1.el;
4052
- instance.vnode = n2;
3936
+ }
3937
+ };
3938
+
3939
+ const queuePostRenderEffect = queueEffectWithSuspense ;
3940
+ function createRenderer(options) {
3941
+ return baseCreateRenderer(options);
3942
+ }
3943
+ function createHydrationRenderer(options) {
3944
+ return baseCreateRenderer(options, createHydrationFunctions);
3945
+ }
3946
+ function baseCreateRenderer(options, createHydrationFns) {
3947
+ const target = shared.getGlobalThis();
3948
+ target.__VUE__ = true;
3949
+ const {
3950
+ insert: hostInsert,
3951
+ remove: hostRemove,
3952
+ patchProp: hostPatchProp,
3953
+ createElement: hostCreateElement,
3954
+ createText: hostCreateText,
3955
+ createComment: hostCreateComment,
3956
+ setText: hostSetText,
3957
+ setElementText: hostSetElementText,
3958
+ parentNode: hostParentNode,
3959
+ nextSibling: hostNextSibling,
3960
+ setScopeId: hostSetScopeId = shared.NOOP,
3961
+ insertStaticContent: hostInsertStaticContent
3962
+ } = options;
3963
+ const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
3964
+ if (n1 === n2) {
3965
+ return;
4053
3966
  }
4054
- };
4055
- const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
4056
- const componentUpdateFn = () => {
4057
- if (!instance.isMounted) {
4058
- let vnodeHook;
4059
- const { el, props } = initialVNode;
4060
- const { bm, m, parent, root, type } = instance;
4061
- const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4062
- toggleRecurse(instance, false);
4063
- if (bm) {
4064
- shared.invokeArrayFns(bm);
4065
- }
4066
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
4067
- invokeVNodeHook(vnodeHook, parent, initialVNode);
4068
- }
4069
- toggleRecurse(instance, true);
4070
- if (el && hydrateNode) {
4071
- const hydrateSubTree = () => {
4072
- instance.subTree = renderComponentRoot(instance);
4073
- hydrateNode(
4074
- el,
4075
- instance.subTree,
4076
- instance,
4077
- parentSuspense,
4078
- null
4079
- );
4080
- };
4081
- if (isAsyncWrapperVNode && type.__asyncHydrate) {
4082
- type.__asyncHydrate(
4083
- el,
4084
- instance,
4085
- hydrateSubTree
4086
- );
4087
- } else {
4088
- hydrateSubTree();
4089
- }
4090
- } else {
4091
- if (root.ce && // @ts-expect-error _def is private
4092
- root.ce._def.shadowRoot !== false) {
4093
- root.ce._injectChildStyle(type);
4094
- }
4095
- const subTree = instance.subTree = renderComponentRoot(instance);
4096
- patch(
4097
- null,
4098
- subTree,
4099
- container,
4100
- anchor,
4101
- instance,
4102
- parentSuspense,
4103
- namespace
4104
- );
4105
- initialVNode.el = subTree.el;
4106
- }
4107
- if (m) {
4108
- queuePostRenderEffect(m, parentSuspense);
4109
- }
4110
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
4111
- const scopedInitialVNode = initialVNode;
4112
- queuePostRenderEffect(
4113
- () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
4114
- parentSuspense
4115
- );
4116
- }
4117
- if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
4118
- instance.a && queuePostRenderEffect(instance.a, parentSuspense);
4119
- }
4120
- instance.isMounted = true;
4121
- initialVNode = container = anchor = null;
4122
- } else {
4123
- let { next, bu, u, parent, vnode } = instance;
4124
- {
4125
- const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
4126
- if (nonHydratedAsyncRoot) {
4127
- if (next) {
4128
- next.el = vnode.el;
4129
- updateComponentPreRender(instance, next, optimized);
4130
- }
4131
- nonHydratedAsyncRoot.asyncDep.then(() => {
4132
- if (!instance.isUnmounted) {
4133
- componentUpdateFn();
4134
- }
4135
- });
4136
- return;
4137
- }
4138
- }
4139
- let originNext = next;
4140
- let vnodeHook;
4141
- toggleRecurse(instance, false);
4142
- if (next) {
4143
- next.el = vnode.el;
4144
- updateComponentPreRender(instance, next, optimized);
4145
- } else {
4146
- next = vnode;
4147
- }
4148
- if (bu) {
4149
- shared.invokeArrayFns(bu);
4150
- }
4151
- if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
4152
- invokeVNodeHook(vnodeHook, parent, next, vnode);
4153
- }
4154
- toggleRecurse(instance, true);
4155
- const nextTree = renderComponentRoot(instance);
4156
- const prevTree = instance.subTree;
4157
- instance.subTree = nextTree;
4158
- patch(
4159
- prevTree,
4160
- nextTree,
4161
- // parent may have changed if it's in a teleport
4162
- hostParentNode(prevTree.el),
4163
- // anchor may have changed if it's in a fragment
4164
- getNextHostNode(prevTree),
4165
- instance,
4166
- parentSuspense,
4167
- namespace
4168
- );
4169
- next.el = nextTree.el;
4170
- if (originNext === null) {
4171
- updateHOCHostEl(instance, nextTree.el);
4172
- }
4173
- if (u) {
4174
- queuePostRenderEffect(u, parentSuspense);
4175
- }
4176
- if (vnodeHook = next.props && next.props.onVnodeUpdated) {
4177
- queuePostRenderEffect(
4178
- () => invokeVNodeHook(vnodeHook, parent, next, vnode),
4179
- parentSuspense
4180
- );
3967
+ if (n1 && !isSameVNodeType(n1, n2)) {
3968
+ anchor = getNextHostNode(n1);
3969
+ unmount(n1, parentComponent, parentSuspense, true);
3970
+ n1 = null;
3971
+ }
3972
+ if (n2.patchFlag === -2) {
3973
+ optimized = false;
3974
+ n2.dynamicChildren = null;
3975
+ }
3976
+ const { type, ref, shapeFlag } = n2;
3977
+ switch (type) {
3978
+ case Text:
3979
+ processText(n1, n2, container, anchor);
3980
+ break;
3981
+ case Comment:
3982
+ processCommentNode(n1, n2, container, anchor);
3983
+ break;
3984
+ case Static:
3985
+ if (n1 == null) {
3986
+ mountStaticNode(n2, container, anchor, namespace);
4181
3987
  }
4182
- }
4183
- };
4184
- instance.scope.on();
4185
- const effect = instance.effect = new reactivity.ReactiveEffect(componentUpdateFn);
4186
- instance.scope.off();
4187
- const update = instance.update = effect.run.bind(effect);
4188
- const job = instance.job = effect.runIfDirty.bind(effect);
4189
- job.i = instance;
4190
- job.id = instance.uid;
4191
- effect.scheduler = () => queueJob(job);
4192
- toggleRecurse(instance, true);
4193
- update();
4194
- };
4195
- const updateComponentPreRender = (instance, nextVNode, optimized) => {
4196
- nextVNode.component = instance;
4197
- const prevProps = instance.vnode.props;
4198
- instance.vnode = nextVNode;
4199
- instance.next = null;
4200
- updateProps(instance, nextVNode.props, prevProps, optimized);
4201
- updateSlots(instance, nextVNode.children, optimized);
4202
- reactivity.pauseTracking();
4203
- flushPreFlushCbs(instance);
4204
- reactivity.resetTracking();
4205
- };
4206
- const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
4207
- const c1 = n1 && n1.children;
4208
- const prevShapeFlag = n1 ? n1.shapeFlag : 0;
4209
- const c2 = n2.children;
4210
- const { patchFlag, shapeFlag } = n2;
4211
- if (patchFlag > 0) {
4212
- if (patchFlag & 128) {
4213
- patchKeyedChildren(
4214
- c1,
4215
- c2,
3988
+ break;
3989
+ case Fragment:
3990
+ processFragment(
3991
+ n1,
3992
+ n2,
4216
3993
  container,
4217
3994
  anchor,
4218
3995
  parentComponent,
@@ -4221,35 +3998,12 @@ function baseCreateRenderer(options, createHydrationFns) {
4221
3998
  slotScopeIds,
4222
3999
  optimized
4223
4000
  );
4224
- return;
4225
- } else if (patchFlag & 256) {
4226
- patchUnkeyedChildren(
4227
- c1,
4228
- c2,
4229
- container,
4230
- anchor,
4231
- parentComponent,
4232
- parentSuspense,
4233
- namespace,
4234
- slotScopeIds,
4235
- optimized
4236
- );
4237
- return;
4238
- }
4239
- }
4240
- if (shapeFlag & 8) {
4241
- if (prevShapeFlag & 16) {
4242
- unmountChildren(c1, parentComponent, parentSuspense);
4243
- }
4244
- if (c2 !== c1) {
4245
- hostSetElementText(container, c2);
4246
- }
4247
- } else {
4248
- if (prevShapeFlag & 16) {
4249
- if (shapeFlag & 16) {
4250
- patchKeyedChildren(
4251
- c1,
4252
- c2,
4001
+ break;
4002
+ default:
4003
+ if (shapeFlag & 1) {
4004
+ processElement(
4005
+ n1,
4006
+ n2,
4253
4007
  container,
4254
4008
  anchor,
4255
4009
  parentComponent,
@@ -4258,16 +4012,10 @@ function baseCreateRenderer(options, createHydrationFns) {
4258
4012
  slotScopeIds,
4259
4013
  optimized
4260
4014
  );
4261
- } else {
4262
- unmountChildren(c1, parentComponent, parentSuspense, true);
4263
- }
4264
- } else {
4265
- if (prevShapeFlag & 8) {
4266
- hostSetElementText(container, "");
4267
- }
4268
- if (shapeFlag & 16) {
4269
- mountChildren(
4270
- c2,
4015
+ } else if (shapeFlag & 6) {
4016
+ processComponent(
4017
+ n1,
4018
+ n2,
4271
4019
  container,
4272
4020
  anchor,
4273
4021
  parentComponent,
@@ -4276,1052 +4024,1299 @@ function baseCreateRenderer(options, createHydrationFns) {
4276
4024
  slotScopeIds,
4277
4025
  optimized
4278
4026
  );
4279
- }
4280
- }
4027
+ } else if (shapeFlag & 64) {
4028
+ type.process(
4029
+ n1,
4030
+ n2,
4031
+ container,
4032
+ anchor,
4033
+ parentComponent,
4034
+ parentSuspense,
4035
+ namespace,
4036
+ slotScopeIds,
4037
+ optimized,
4038
+ internals
4039
+ );
4040
+ } else if (shapeFlag & 128) {
4041
+ type.process(
4042
+ n1,
4043
+ n2,
4044
+ container,
4045
+ anchor,
4046
+ parentComponent,
4047
+ parentSuspense,
4048
+ namespace,
4049
+ slotScopeIds,
4050
+ optimized,
4051
+ internals
4052
+ );
4053
+ } else ;
4054
+ }
4055
+ if (ref != null && parentComponent) {
4056
+ setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
4057
+ } else if (ref == null && n1 && n1.ref != null) {
4058
+ setRef(n1.ref, null, parentSuspense, n1, true);
4281
4059
  }
4282
4060
  };
4283
- const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4284
- c1 = c1 || shared.EMPTY_ARR;
4285
- c2 = c2 || shared.EMPTY_ARR;
4286
- const oldLength = c1.length;
4287
- const newLength = c2.length;
4288
- const commonLength = Math.min(oldLength, newLength);
4289
- let i;
4290
- for (i = 0; i < commonLength; i++) {
4291
- const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4292
- patch(
4293
- c1[i],
4294
- nextChild,
4061
+ const processText = (n1, n2, container, anchor) => {
4062
+ if (n1 == null) {
4063
+ hostInsert(
4064
+ n2.el = hostCreateText(n2.children),
4295
4065
  container,
4296
- null,
4297
- parentComponent,
4298
- parentSuspense,
4299
- namespace,
4300
- slotScopeIds,
4301
- optimized
4066
+ anchor
4302
4067
  );
4068
+ } else {
4069
+ const el = n2.el = n1.el;
4070
+ if (n2.children !== n1.children) {
4071
+ hostSetText(el, n2.children);
4072
+ }
4303
4073
  }
4304
- if (oldLength > newLength) {
4305
- unmountChildren(
4306
- c1,
4307
- parentComponent,
4308
- parentSuspense,
4309
- true,
4310
- false,
4311
- commonLength
4074
+ };
4075
+ const processCommentNode = (n1, n2, container, anchor) => {
4076
+ if (n1 == null) {
4077
+ hostInsert(
4078
+ n2.el = hostCreateComment(n2.children || ""),
4079
+ container,
4080
+ anchor
4312
4081
  );
4313
4082
  } else {
4314
- mountChildren(
4315
- c2,
4083
+ n2.el = n1.el;
4084
+ }
4085
+ };
4086
+ const mountStaticNode = (n2, container, anchor, namespace) => {
4087
+ [n2.el, n2.anchor] = hostInsertStaticContent(
4088
+ n2.children,
4089
+ container,
4090
+ anchor,
4091
+ namespace,
4092
+ n2.el,
4093
+ n2.anchor
4094
+ );
4095
+ };
4096
+ const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
4097
+ let next;
4098
+ while (el && el !== anchor) {
4099
+ next = hostNextSibling(el);
4100
+ hostInsert(el, container, nextSibling);
4101
+ el = next;
4102
+ }
4103
+ hostInsert(anchor, container, nextSibling);
4104
+ };
4105
+ const removeStaticNode = ({ el, anchor }) => {
4106
+ let next;
4107
+ while (el && el !== anchor) {
4108
+ next = hostNextSibling(el);
4109
+ hostRemove(el);
4110
+ el = next;
4111
+ }
4112
+ hostRemove(anchor);
4113
+ };
4114
+ const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4115
+ if (n2.type === "svg") {
4116
+ namespace = "svg";
4117
+ } else if (n2.type === "math") {
4118
+ namespace = "mathml";
4119
+ }
4120
+ if (n1 == null) {
4121
+ mountElement(
4122
+ n2,
4316
4123
  container,
4317
4124
  anchor,
4318
4125
  parentComponent,
4319
4126
  parentSuspense,
4320
4127
  namespace,
4321
4128
  slotScopeIds,
4322
- optimized,
4323
- commonLength
4129
+ optimized
4324
4130
  );
4325
- }
4326
- };
4327
- const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4328
- let i = 0;
4329
- const l2 = c2.length;
4330
- let e1 = c1.length - 1;
4331
- let e2 = l2 - 1;
4332
- while (i <= e1 && i <= e2) {
4333
- const n1 = c1[i];
4334
- const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4335
- if (isSameVNodeType(n1, n2)) {
4336
- patch(
4131
+ } else {
4132
+ const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
4133
+ try {
4134
+ if (customElement) {
4135
+ customElement._beginPatch();
4136
+ }
4137
+ patchElement(
4337
4138
  n1,
4338
4139
  n2,
4339
- container,
4340
- null,
4341
4140
  parentComponent,
4342
4141
  parentSuspense,
4343
4142
  namespace,
4344
4143
  slotScopeIds,
4345
4144
  optimized
4346
4145
  );
4347
- } else {
4348
- break;
4146
+ } finally {
4147
+ if (customElement) {
4148
+ customElement._endPatch();
4149
+ }
4349
4150
  }
4350
- i++;
4351
4151
  }
4352
- while (i <= e1 && i <= e2) {
4353
- const n1 = c1[e1];
4354
- const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
4355
- if (isSameVNodeType(n1, n2)) {
4356
- patch(
4357
- n1,
4358
- n2,
4359
- container,
4360
- null,
4361
- parentComponent,
4362
- parentSuspense,
4363
- namespace,
4364
- slotScopeIds,
4365
- optimized
4366
- );
4367
- } else {
4368
- break;
4369
- }
4370
- e1--;
4371
- e2--;
4152
+ };
4153
+ const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4154
+ let el;
4155
+ let vnodeHook;
4156
+ const { props, shapeFlag, transition, dirs } = vnode;
4157
+ el = vnode.el = hostCreateElement(
4158
+ vnode.type,
4159
+ namespace,
4160
+ props && props.is,
4161
+ props
4162
+ );
4163
+ if (shapeFlag & 8) {
4164
+ hostSetElementText(el, vnode.children);
4165
+ } else if (shapeFlag & 16) {
4166
+ mountChildren(
4167
+ vnode.children,
4168
+ el,
4169
+ null,
4170
+ parentComponent,
4171
+ parentSuspense,
4172
+ resolveChildrenNamespace(vnode, namespace),
4173
+ slotScopeIds,
4174
+ optimized
4175
+ );
4372
4176
  }
4373
- if (i > e1) {
4374
- if (i <= e2) {
4375
- const nextPos = e2 + 1;
4376
- const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
4377
- while (i <= e2) {
4378
- patch(
4379
- null,
4380
- c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
4381
- container,
4382
- anchor,
4383
- parentComponent,
4384
- parentSuspense,
4385
- namespace,
4386
- slotScopeIds,
4387
- optimized
4388
- );
4389
- i++;
4390
- }
4391
- }
4392
- } else if (i > e2) {
4393
- while (i <= e1) {
4394
- unmount(c1[i], parentComponent, parentSuspense, true);
4395
- i++;
4396
- }
4397
- } else {
4398
- const s1 = i;
4399
- const s2 = i;
4400
- const keyToNewIndexMap = /* @__PURE__ */ new Map();
4401
- for (i = s2; i <= e2; i++) {
4402
- const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4403
- if (nextChild.key != null) {
4404
- keyToNewIndexMap.set(nextChild.key, i);
4177
+ if (dirs) {
4178
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
4179
+ }
4180
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
4181
+ if (props) {
4182
+ for (const key in props) {
4183
+ if (key !== "value" && !shared.isReservedProp(key)) {
4184
+ hostPatchProp(el, key, null, props[key], namespace, parentComponent);
4405
4185
  }
4406
4186
  }
4407
- let j;
4408
- let patched = 0;
4409
- const toBePatched = e2 - s2 + 1;
4410
- let moved = false;
4411
- let maxNewIndexSoFar = 0;
4412
- const newIndexToOldIndexMap = new Array(toBePatched);
4413
- for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
4414
- for (i = s1; i <= e1; i++) {
4415
- const prevChild = c1[i];
4416
- if (patched >= toBePatched) {
4417
- unmount(prevChild, parentComponent, parentSuspense, true);
4418
- continue;
4419
- }
4420
- let newIndex;
4421
- if (prevChild.key != null) {
4422
- newIndex = keyToNewIndexMap.get(prevChild.key);
4423
- } else {
4424
- for (j = s2; j <= e2; j++) {
4425
- if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
4426
- newIndex = j;
4427
- break;
4428
- }
4429
- }
4430
- }
4431
- if (newIndex === void 0) {
4432
- unmount(prevChild, parentComponent, parentSuspense, true);
4433
- } else {
4434
- newIndexToOldIndexMap[newIndex - s2] = i + 1;
4435
- if (newIndex >= maxNewIndexSoFar) {
4436
- maxNewIndexSoFar = newIndex;
4437
- } else {
4438
- moved = true;
4439
- }
4440
- patch(
4441
- prevChild,
4442
- c2[newIndex],
4443
- container,
4444
- null,
4445
- parentComponent,
4446
- parentSuspense,
4447
- namespace,
4448
- slotScopeIds,
4449
- optimized
4450
- );
4451
- patched++;
4452
- }
4187
+ if ("value" in props) {
4188
+ hostPatchProp(el, "value", null, props.value, namespace);
4453
4189
  }
4454
- const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
4455
- j = increasingNewIndexSequence.length - 1;
4456
- for (i = toBePatched - 1; i >= 0; i--) {
4457
- const nextIndex = s2 + i;
4458
- const nextChild = c2[nextIndex];
4459
- const anchorVNode = c2[nextIndex + 1];
4460
- const anchor = nextIndex + 1 < l2 ? (
4461
- // #13559, fallback to el placeholder for unresolved async component
4462
- anchorVNode.el || anchorVNode.placeholder
4463
- ) : parentAnchor;
4464
- if (newIndexToOldIndexMap[i] === 0) {
4465
- patch(
4466
- null,
4467
- nextChild,
4468
- container,
4469
- anchor,
4470
- parentComponent,
4471
- parentSuspense,
4472
- namespace,
4473
- slotScopeIds,
4474
- optimized
4475
- );
4476
- } else if (moved) {
4477
- if (j < 0 || i !== increasingNewIndexSequence[j]) {
4478
- move(nextChild, container, anchor, 2);
4479
- } else {
4480
- j--;
4481
- }
4482
- }
4190
+ if (vnodeHook = props.onVnodeBeforeMount) {
4191
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
4483
4192
  }
4484
4193
  }
4485
- };
4486
- const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
4487
- const { el, type, transition, children, shapeFlag } = vnode;
4488
- if (shapeFlag & 6) {
4489
- move(vnode.component.subTree, container, anchor, moveType);
4490
- return;
4194
+ if (dirs) {
4195
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4491
4196
  }
4492
- if (shapeFlag & 128) {
4493
- vnode.suspense.move(container, anchor, moveType);
4494
- return;
4197
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
4198
+ if (needCallTransitionHooks) {
4199
+ transition.beforeEnter(el);
4495
4200
  }
4496
- if (shapeFlag & 64) {
4497
- type.move(vnode, container, anchor, internals);
4498
- return;
4201
+ hostInsert(el, container, anchor);
4202
+ if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
4203
+ queuePostRenderEffect(() => {
4204
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4205
+ needCallTransitionHooks && transition.enter(el);
4206
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4207
+ }, parentSuspense);
4499
4208
  }
4500
- if (type === Fragment) {
4501
- hostInsert(el, container, anchor);
4502
- for (let i = 0; i < children.length; i++) {
4503
- move(children[i], container, anchor, moveType);
4504
- }
4505
- hostInsert(vnode.anchor, container, anchor);
4506
- return;
4209
+ };
4210
+ const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
4211
+ if (scopeId) {
4212
+ hostSetScopeId(el, scopeId);
4507
4213
  }
4508
- if (type === Static) {
4509
- moveStaticNode(vnode, container, anchor);
4510
- return;
4214
+ if (slotScopeIds) {
4215
+ for (let i = 0; i < slotScopeIds.length; i++) {
4216
+ hostSetScopeId(el, slotScopeIds[i]);
4217
+ }
4511
4218
  }
4512
- const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
4513
- if (needTransition2) {
4514
- if (moveType === 0) {
4515
- transition.beforeEnter(el);
4516
- hostInsert(el, container, anchor);
4517
- queuePostRenderEffect(() => transition.enter(el), parentSuspense);
4518
- } else {
4519
- const { leave, delayLeave, afterLeave } = transition;
4520
- const remove2 = () => {
4521
- if (vnode.ctx.isUnmounted) {
4522
- hostRemove(el);
4523
- } else {
4524
- hostInsert(el, container, anchor);
4525
- }
4526
- };
4527
- const performLeave = () => {
4528
- if (el._isLeaving) {
4529
- el[leaveCbKey](
4530
- true
4531
- /* cancelled */
4532
- );
4533
- }
4534
- leave(el, () => {
4535
- remove2();
4536
- afterLeave && afterLeave();
4537
- });
4538
- };
4539
- if (delayLeave) {
4540
- delayLeave(el, remove2, performLeave);
4541
- } else {
4542
- performLeave();
4543
- }
4219
+ if (parentComponent) {
4220
+ let subTree = parentComponent.subTree;
4221
+ if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
4222
+ const parentVNode = parentComponent.vnode;
4223
+ setScopeId(
4224
+ el,
4225
+ parentVNode,
4226
+ parentVNode.scopeId,
4227
+ parentVNode.slotScopeIds,
4228
+ parentComponent.parent
4229
+ );
4544
4230
  }
4545
- } else {
4546
- hostInsert(el, container, anchor);
4547
4231
  }
4548
4232
  };
4549
- const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
4550
- const {
4551
- type,
4552
- props,
4553
- ref,
4554
- children,
4555
- dynamicChildren,
4556
- shapeFlag,
4557
- patchFlag,
4558
- dirs,
4559
- cacheIndex
4560
- } = vnode;
4561
- if (patchFlag === -2) {
4562
- optimized = false;
4563
- }
4564
- if (ref != null) {
4565
- reactivity.pauseTracking();
4566
- setRef(ref, null, parentSuspense, vnode, true);
4567
- reactivity.resetTracking();
4233
+ const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
4234
+ for (let i = start; i < children.length; i++) {
4235
+ const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
4236
+ patch(
4237
+ null,
4238
+ child,
4239
+ container,
4240
+ anchor,
4241
+ parentComponent,
4242
+ parentSuspense,
4243
+ namespace,
4244
+ slotScopeIds,
4245
+ optimized
4246
+ );
4568
4247
  }
4569
- if (cacheIndex != null) {
4570
- parentComponent.renderCache[cacheIndex] = void 0;
4248
+ };
4249
+ const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4250
+ const el = n2.el = n1.el;
4251
+ let { patchFlag, dynamicChildren, dirs } = n2;
4252
+ patchFlag |= n1.patchFlag & 16;
4253
+ const oldProps = n1.props || shared.EMPTY_OBJ;
4254
+ const newProps = n2.props || shared.EMPTY_OBJ;
4255
+ let vnodeHook;
4256
+ parentComponent && toggleRecurse(parentComponent, false);
4257
+ if (vnodeHook = newProps.onVnodeBeforeUpdate) {
4258
+ invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4571
4259
  }
4572
- if (shapeFlag & 256) {
4573
- parentComponent.ctx.deactivate(vnode);
4574
- return;
4260
+ if (dirs) {
4261
+ invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
4575
4262
  }
4576
- const shouldInvokeDirs = shapeFlag & 1 && dirs;
4577
- const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
4578
- let vnodeHook;
4579
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
4580
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
4263
+ parentComponent && toggleRecurse(parentComponent, true);
4264
+ if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
4265
+ hostSetElementText(el, "");
4581
4266
  }
4582
- if (shapeFlag & 6) {
4583
- unmountComponent(vnode.component, parentSuspense, doRemove);
4584
- } else {
4585
- if (shapeFlag & 128) {
4586
- vnode.suspense.unmount(parentSuspense, doRemove);
4587
- return;
4588
- }
4589
- if (shouldInvokeDirs) {
4590
- invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
4591
- }
4592
- if (shapeFlag & 64) {
4593
- vnode.type.remove(
4594
- vnode,
4595
- parentComponent,
4596
- parentSuspense,
4597
- internals,
4598
- doRemove
4599
- );
4600
- } else if (dynamicChildren && // #5154
4601
- // when v-once is used inside a block, setBlockTracking(-1) marks the
4602
- // parent block with hasOnce: true
4603
- // so that it doesn't take the fast path during unmount - otherwise
4604
- // components nested in v-once are never unmounted.
4605
- !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
4606
- (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
4607
- unmountChildren(
4608
- dynamicChildren,
4609
- parentComponent,
4610
- parentSuspense,
4611
- false,
4612
- true
4613
- );
4614
- } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
4615
- unmountChildren(children, parentComponent, parentSuspense);
4267
+ if (dynamicChildren) {
4268
+ patchBlockChildren(
4269
+ n1.dynamicChildren,
4270
+ dynamicChildren,
4271
+ el,
4272
+ parentComponent,
4273
+ parentSuspense,
4274
+ resolveChildrenNamespace(n2, namespace),
4275
+ slotScopeIds
4276
+ );
4277
+ } else if (!optimized) {
4278
+ patchChildren(
4279
+ n1,
4280
+ n2,
4281
+ el,
4282
+ null,
4283
+ parentComponent,
4284
+ parentSuspense,
4285
+ resolveChildrenNamespace(n2, namespace),
4286
+ slotScopeIds,
4287
+ false
4288
+ );
4289
+ }
4290
+ if (patchFlag > 0) {
4291
+ if (patchFlag & 16) {
4292
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4293
+ } else {
4294
+ if (patchFlag & 2) {
4295
+ if (oldProps.class !== newProps.class) {
4296
+ hostPatchProp(el, "class", null, newProps.class, namespace);
4297
+ }
4298
+ }
4299
+ if (patchFlag & 4) {
4300
+ hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
4301
+ }
4302
+ if (patchFlag & 8) {
4303
+ const propsToUpdate = n2.dynamicProps;
4304
+ for (let i = 0; i < propsToUpdate.length; i++) {
4305
+ const key = propsToUpdate[i];
4306
+ const prev = oldProps[key];
4307
+ const next = newProps[key];
4308
+ if (next !== prev || key === "value") {
4309
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4310
+ }
4311
+ }
4312
+ }
4616
4313
  }
4617
- if (doRemove) {
4618
- remove(vnode);
4314
+ if (patchFlag & 1) {
4315
+ if (n1.children !== n2.children) {
4316
+ hostSetElementText(el, n2.children);
4317
+ }
4619
4318
  }
4319
+ } else if (!optimized && dynamicChildren == null) {
4320
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4620
4321
  }
4621
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
4322
+ if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
4622
4323
  queuePostRenderEffect(() => {
4623
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4624
- shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
4324
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4325
+ dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
4625
4326
  }, parentSuspense);
4626
4327
  }
4627
4328
  };
4628
- const remove = (vnode) => {
4629
- const { type, el, anchor, transition } = vnode;
4630
- if (type === Fragment) {
4631
- {
4632
- removeFragment(el, anchor);
4329
+ const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
4330
+ for (let i = 0; i < newChildren.length; i++) {
4331
+ const oldVNode = oldChildren[i];
4332
+ const newVNode = newChildren[i];
4333
+ const container = (
4334
+ // oldVNode may be an errored async setup() component inside Suspense
4335
+ // which will not have a mounted element
4336
+ oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
4337
+ // of the Fragment itself so it can move its children.
4338
+ (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
4339
+ // which also requires the correct parent container
4340
+ !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
4341
+ oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
4342
+ // In other cases, the parent container is not actually used so we
4343
+ // just pass the block element here to avoid a DOM parentNode call.
4344
+ fallbackContainer
4345
+ )
4346
+ );
4347
+ patch(
4348
+ oldVNode,
4349
+ newVNode,
4350
+ container,
4351
+ null,
4352
+ parentComponent,
4353
+ parentSuspense,
4354
+ namespace,
4355
+ slotScopeIds,
4356
+ true
4357
+ );
4358
+ }
4359
+ };
4360
+ const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
4361
+ if (oldProps !== newProps) {
4362
+ if (oldProps !== shared.EMPTY_OBJ) {
4363
+ for (const key in oldProps) {
4364
+ if (!shared.isReservedProp(key) && !(key in newProps)) {
4365
+ hostPatchProp(
4366
+ el,
4367
+ key,
4368
+ oldProps[key],
4369
+ null,
4370
+ namespace,
4371
+ parentComponent
4372
+ );
4373
+ }
4374
+ }
4375
+ }
4376
+ for (const key in newProps) {
4377
+ if (shared.isReservedProp(key)) continue;
4378
+ const next = newProps[key];
4379
+ const prev = oldProps[key];
4380
+ if (next !== prev && key !== "value") {
4381
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4382
+ }
4383
+ }
4384
+ if ("value" in newProps) {
4385
+ hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
4633
4386
  }
4634
- return;
4635
4387
  }
4636
- if (type === Static) {
4637
- removeStaticNode(vnode);
4638
- return;
4388
+ };
4389
+ const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4390
+ const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
4391
+ const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
4392
+ let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
4393
+ if (fragmentSlotScopeIds) {
4394
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
4639
4395
  }
4640
- const performRemove = () => {
4641
- hostRemove(el);
4642
- if (transition && !transition.persisted && transition.afterLeave) {
4643
- transition.afterLeave();
4396
+ if (n1 == null) {
4397
+ hostInsert(fragmentStartAnchor, container, anchor);
4398
+ hostInsert(fragmentEndAnchor, container, anchor);
4399
+ mountChildren(
4400
+ // #10007
4401
+ // such fragment like `<></>` will be compiled into
4402
+ // a fragment which doesn't have a children.
4403
+ // In this case fallback to an empty array
4404
+ n2.children || [],
4405
+ container,
4406
+ fragmentEndAnchor,
4407
+ parentComponent,
4408
+ parentSuspense,
4409
+ namespace,
4410
+ slotScopeIds,
4411
+ optimized
4412
+ );
4413
+ } else {
4414
+ if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
4415
+ // of renderSlot() with no valid children
4416
+ n1.dynamicChildren) {
4417
+ patchBlockChildren(
4418
+ n1.dynamicChildren,
4419
+ dynamicChildren,
4420
+ container,
4421
+ parentComponent,
4422
+ parentSuspense,
4423
+ namespace,
4424
+ slotScopeIds
4425
+ );
4426
+ if (
4427
+ // #2080 if the stable fragment has a key, it's a <template v-for> that may
4428
+ // get moved around. Make sure all root level vnodes inherit el.
4429
+ // #2134 or if it's a component root, it may also get moved around
4430
+ // as the component is being moved.
4431
+ n2.key != null || parentComponent && n2 === parentComponent.subTree
4432
+ ) {
4433
+ traverseStaticChildren(
4434
+ n1,
4435
+ n2,
4436
+ true
4437
+ /* shallow */
4438
+ );
4439
+ }
4440
+ } else {
4441
+ patchChildren(
4442
+ n1,
4443
+ n2,
4444
+ container,
4445
+ fragmentEndAnchor,
4446
+ parentComponent,
4447
+ parentSuspense,
4448
+ namespace,
4449
+ slotScopeIds,
4450
+ optimized
4451
+ );
4644
4452
  }
4645
- };
4646
- if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
4647
- const { leave, delayLeave } = transition;
4648
- const performLeave = () => leave(el, performRemove);
4649
- if (delayLeave) {
4650
- delayLeave(vnode.el, performRemove, performLeave);
4453
+ }
4454
+ };
4455
+ const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4456
+ n2.slotScopeIds = slotScopeIds;
4457
+ if (n1 == null) {
4458
+ if (n2.shapeFlag & 512) {
4459
+ parentComponent.ctx.activate(
4460
+ n2,
4461
+ container,
4462
+ anchor,
4463
+ namespace,
4464
+ optimized
4465
+ );
4651
4466
  } else {
4652
- performLeave();
4467
+ mountComponent(
4468
+ n2,
4469
+ container,
4470
+ anchor,
4471
+ parentComponent,
4472
+ parentSuspense,
4473
+ namespace,
4474
+ optimized
4475
+ );
4653
4476
  }
4654
4477
  } else {
4655
- performRemove();
4478
+ updateComponent(n1, n2, optimized);
4656
4479
  }
4657
4480
  };
4658
- const removeFragment = (cur, end) => {
4659
- let next;
4660
- while (cur !== end) {
4661
- next = hostNextSibling(cur);
4662
- hostRemove(cur);
4663
- cur = next;
4664
- }
4665
- hostRemove(end);
4666
- };
4667
- const unmountComponent = (instance, parentSuspense, doRemove) => {
4668
- const { bum, scope, job, subTree, um, m, a } = instance;
4669
- invalidateMount(m);
4670
- invalidateMount(a);
4671
- if (bum) {
4672
- shared.invokeArrayFns(bum);
4673
- }
4674
- scope.stop();
4675
- if (job) {
4676
- job.flags |= 8;
4677
- unmount(subTree, instance, parentSuspense, doRemove);
4678
- }
4679
- if (um) {
4680
- queuePostRenderEffect(um, parentSuspense);
4681
- }
4682
- queuePostRenderEffect(() => {
4683
- instance.isUnmounted = true;
4684
- }, parentSuspense);
4685
- };
4686
- const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
4687
- for (let i = start; i < children.length; i++) {
4688
- unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
4689
- }
4690
- };
4691
- const getNextHostNode = (vnode) => {
4692
- if (vnode.shapeFlag & 6) {
4693
- return getNextHostNode(vnode.component.subTree);
4481
+ const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
4482
+ const instance = (initialVNode.component = createComponentInstance(
4483
+ initialVNode,
4484
+ parentComponent,
4485
+ parentSuspense
4486
+ ));
4487
+ if (isKeepAlive(initialVNode)) {
4488
+ instance.ctx.renderer = internals;
4694
4489
  }
4695
- if (vnode.shapeFlag & 128) {
4696
- return vnode.suspense.next();
4490
+ {
4491
+ setupComponent(instance, false, optimized);
4697
4492
  }
4698
- const el = hostNextSibling(vnode.anchor || vnode.el);
4699
- const teleportEnd = el && el[TeleportEndKey];
4700
- return teleportEnd ? hostNextSibling(teleportEnd) : el;
4701
- };
4702
- let isFlushing = false;
4703
- const render = (vnode, container, namespace) => {
4704
- if (vnode == null) {
4705
- if (container._vnode) {
4706
- unmount(container._vnode, null, null, true);
4493
+ if (instance.asyncDep) {
4494
+ parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
4495
+ if (!initialVNode.el) {
4496
+ const placeholder = instance.subTree = createVNode(Comment);
4497
+ processCommentNode(null, placeholder, container, anchor);
4498
+ initialVNode.placeholder = placeholder.el;
4707
4499
  }
4708
4500
  } else {
4709
- patch(
4710
- container._vnode || null,
4711
- vnode,
4501
+ setupRenderEffect(
4502
+ instance,
4503
+ initialVNode,
4712
4504
  container,
4713
- null,
4714
- null,
4715
- null,
4716
- namespace
4505
+ anchor,
4506
+ parentSuspense,
4507
+ namespace,
4508
+ optimized
4717
4509
  );
4718
4510
  }
4719
- container._vnode = vnode;
4720
- if (!isFlushing) {
4721
- isFlushing = true;
4722
- flushPreFlushCbs();
4723
- flushPostFlushCbs();
4724
- isFlushing = false;
4725
- }
4726
- };
4727
- const internals = {
4728
- p: patch,
4729
- um: unmount,
4730
- m: move,
4731
- r: remove,
4732
- mt: mountComponent,
4733
- mc: mountChildren,
4734
- pc: patchChildren,
4735
- pbc: patchBlockChildren,
4736
- n: getNextHostNode,
4737
- o: options
4738
- };
4739
- let hydrate;
4740
- let hydrateNode;
4741
- if (createHydrationFns) {
4742
- [hydrate, hydrateNode] = createHydrationFns(
4743
- internals
4744
- );
4745
- }
4746
- return {
4747
- render,
4748
- hydrate,
4749
- createApp: createAppAPI(render, hydrate)
4750
4511
  };
4751
- }
4752
- function resolveChildrenNamespace({ type, props }, currentNamespace) {
4753
- return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
4754
- }
4755
- function toggleRecurse({ effect, job }, allowed) {
4756
- if (allowed) {
4757
- effect.flags |= 32;
4758
- job.flags |= 4;
4759
- } else {
4760
- effect.flags &= -33;
4761
- job.flags &= -5;
4762
- }
4763
- }
4764
- function needTransition(parentSuspense, transition) {
4765
- return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
4766
- }
4767
- function traverseStaticChildren(n1, n2, shallow = false) {
4768
- const ch1 = n1.children;
4769
- const ch2 = n2.children;
4770
- if (shared.isArray(ch1) && shared.isArray(ch2)) {
4771
- for (let i = 0; i < ch1.length; i++) {
4772
- const c1 = ch1[i];
4773
- let c2 = ch2[i];
4774
- if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
4775
- if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
4776
- c2 = ch2[i] = cloneIfMounted(ch2[i]);
4777
- c2.el = c1.el;
4778
- }
4779
- if (!shallow && c2.patchFlag !== -2)
4780
- traverseStaticChildren(c1, c2);
4781
- }
4782
- if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
4783
- c2.patchFlag !== -1) {
4784
- c2.el = c1.el;
4785
- }
4786
- if (c2.type === Comment && !c2.el) {
4787
- c2.el = c1.el;
4512
+ const updateComponent = (n1, n2, optimized) => {
4513
+ const instance = n2.component = n1.component;
4514
+ if (shouldUpdateComponent(n1, n2, optimized)) {
4515
+ if (instance.asyncDep && !instance.asyncResolved) {
4516
+ updateComponentPreRender(instance, n2, optimized);
4517
+ return;
4518
+ } else {
4519
+ instance.next = n2;
4520
+ instance.update();
4788
4521
  }
4522
+ } else {
4523
+ n2.el = n1.el;
4524
+ instance.vnode = n2;
4789
4525
  }
4790
- }
4791
- }
4792
- function getSequence(arr) {
4793
- const p = arr.slice();
4794
- const result = [0];
4795
- let i, j, u, v, c;
4796
- const len = arr.length;
4797
- for (i = 0; i < len; i++) {
4798
- const arrI = arr[i];
4799
- if (arrI !== 0) {
4800
- j = result[result.length - 1];
4801
- if (arr[j] < arrI) {
4802
- p[i] = j;
4803
- result.push(i);
4804
- continue;
4526
+ };
4527
+ const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
4528
+ const componentUpdateFn = () => {
4529
+ if (!instance.isMounted) {
4530
+ let vnodeHook;
4531
+ const { el, props } = initialVNode;
4532
+ const { bm, m, parent, root, type } = instance;
4533
+ const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4534
+ toggleRecurse(instance, false);
4535
+ if (bm) {
4536
+ shared.invokeArrayFns(bm);
4537
+ }
4538
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
4539
+ invokeVNodeHook(vnodeHook, parent, initialVNode);
4540
+ }
4541
+ toggleRecurse(instance, true);
4542
+ if (el && hydrateNode) {
4543
+ const hydrateSubTree = () => {
4544
+ instance.subTree = renderComponentRoot(instance);
4545
+ hydrateNode(
4546
+ el,
4547
+ instance.subTree,
4548
+ instance,
4549
+ parentSuspense,
4550
+ null
4551
+ );
4552
+ };
4553
+ if (isAsyncWrapperVNode && type.__asyncHydrate) {
4554
+ type.__asyncHydrate(
4555
+ el,
4556
+ instance,
4557
+ hydrateSubTree
4558
+ );
4559
+ } else {
4560
+ hydrateSubTree();
4561
+ }
4562
+ } else {
4563
+ if (root.ce && // @ts-expect-error _def is private
4564
+ root.ce._def.shadowRoot !== false) {
4565
+ root.ce._injectChildStyle(type);
4566
+ }
4567
+ const subTree = instance.subTree = renderComponentRoot(instance);
4568
+ patch(
4569
+ null,
4570
+ subTree,
4571
+ container,
4572
+ anchor,
4573
+ instance,
4574
+ parentSuspense,
4575
+ namespace
4576
+ );
4577
+ initialVNode.el = subTree.el;
4578
+ }
4579
+ if (m) {
4580
+ queuePostRenderEffect(m, parentSuspense);
4581
+ }
4582
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
4583
+ const scopedInitialVNode = initialVNode;
4584
+ queuePostRenderEffect(
4585
+ () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
4586
+ parentSuspense
4587
+ );
4588
+ }
4589
+ if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
4590
+ instance.a && queuePostRenderEffect(instance.a, parentSuspense);
4591
+ }
4592
+ instance.isMounted = true;
4593
+ initialVNode = container = anchor = null;
4594
+ } else {
4595
+ let { next, bu, u, parent, vnode } = instance;
4596
+ {
4597
+ const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
4598
+ if (nonHydratedAsyncRoot) {
4599
+ if (next) {
4600
+ next.el = vnode.el;
4601
+ updateComponentPreRender(instance, next, optimized);
4602
+ }
4603
+ nonHydratedAsyncRoot.asyncDep.then(() => {
4604
+ if (!instance.isUnmounted) {
4605
+ componentUpdateFn();
4606
+ }
4607
+ });
4608
+ return;
4609
+ }
4610
+ }
4611
+ let originNext = next;
4612
+ let vnodeHook;
4613
+ toggleRecurse(instance, false);
4614
+ if (next) {
4615
+ next.el = vnode.el;
4616
+ updateComponentPreRender(instance, next, optimized);
4617
+ } else {
4618
+ next = vnode;
4619
+ }
4620
+ if (bu) {
4621
+ shared.invokeArrayFns(bu);
4622
+ }
4623
+ if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
4624
+ invokeVNodeHook(vnodeHook, parent, next, vnode);
4625
+ }
4626
+ toggleRecurse(instance, true);
4627
+ const nextTree = renderComponentRoot(instance);
4628
+ const prevTree = instance.subTree;
4629
+ instance.subTree = nextTree;
4630
+ patch(
4631
+ prevTree,
4632
+ nextTree,
4633
+ // parent may have changed if it's in a teleport
4634
+ hostParentNode(prevTree.el),
4635
+ // anchor may have changed if it's in a fragment
4636
+ getNextHostNode(prevTree),
4637
+ instance,
4638
+ parentSuspense,
4639
+ namespace
4640
+ );
4641
+ next.el = nextTree.el;
4642
+ if (originNext === null) {
4643
+ updateHOCHostEl(instance, nextTree.el);
4644
+ }
4645
+ if (u) {
4646
+ queuePostRenderEffect(u, parentSuspense);
4647
+ }
4648
+ if (vnodeHook = next.props && next.props.onVnodeUpdated) {
4649
+ queuePostRenderEffect(
4650
+ () => invokeVNodeHook(vnodeHook, parent, next, vnode),
4651
+ parentSuspense
4652
+ );
4653
+ }
4654
+ }
4655
+ };
4656
+ instance.scope.on();
4657
+ const effect = instance.effect = new reactivity.ReactiveEffect(componentUpdateFn);
4658
+ instance.scope.off();
4659
+ const update = instance.update = effect.run.bind(effect);
4660
+ const job = instance.job = effect.runIfDirty.bind(effect);
4661
+ job.i = instance;
4662
+ job.id = instance.uid;
4663
+ effect.scheduler = () => queueJob(job);
4664
+ toggleRecurse(instance, true);
4665
+ update();
4666
+ };
4667
+ const updateComponentPreRender = (instance, nextVNode, optimized) => {
4668
+ nextVNode.component = instance;
4669
+ const prevProps = instance.vnode.props;
4670
+ instance.vnode = nextVNode;
4671
+ instance.next = null;
4672
+ updateProps(instance, nextVNode.props, prevProps, optimized);
4673
+ updateSlots(instance, nextVNode.children, optimized);
4674
+ reactivity.pauseTracking();
4675
+ flushPreFlushCbs(instance);
4676
+ reactivity.resetTracking();
4677
+ };
4678
+ const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
4679
+ const c1 = n1 && n1.children;
4680
+ const prevShapeFlag = n1 ? n1.shapeFlag : 0;
4681
+ const c2 = n2.children;
4682
+ const { patchFlag, shapeFlag } = n2;
4683
+ if (patchFlag > 0) {
4684
+ if (patchFlag & 128) {
4685
+ patchKeyedChildren(
4686
+ c1,
4687
+ c2,
4688
+ container,
4689
+ anchor,
4690
+ parentComponent,
4691
+ parentSuspense,
4692
+ namespace,
4693
+ slotScopeIds,
4694
+ optimized
4695
+ );
4696
+ return;
4697
+ } else if (patchFlag & 256) {
4698
+ patchUnkeyedChildren(
4699
+ c1,
4700
+ c2,
4701
+ container,
4702
+ anchor,
4703
+ parentComponent,
4704
+ parentSuspense,
4705
+ namespace,
4706
+ slotScopeIds,
4707
+ optimized
4708
+ );
4709
+ return;
4710
+ }
4711
+ }
4712
+ if (shapeFlag & 8) {
4713
+ if (prevShapeFlag & 16) {
4714
+ unmountChildren(c1, parentComponent, parentSuspense);
4715
+ }
4716
+ if (c2 !== c1) {
4717
+ hostSetElementText(container, c2);
4718
+ }
4719
+ } else {
4720
+ if (prevShapeFlag & 16) {
4721
+ if (shapeFlag & 16) {
4722
+ patchKeyedChildren(
4723
+ c1,
4724
+ c2,
4725
+ container,
4726
+ anchor,
4727
+ parentComponent,
4728
+ parentSuspense,
4729
+ namespace,
4730
+ slotScopeIds,
4731
+ optimized
4732
+ );
4733
+ } else {
4734
+ unmountChildren(c1, parentComponent, parentSuspense, true);
4735
+ }
4736
+ } else {
4737
+ if (prevShapeFlag & 8) {
4738
+ hostSetElementText(container, "");
4739
+ }
4740
+ if (shapeFlag & 16) {
4741
+ mountChildren(
4742
+ c2,
4743
+ container,
4744
+ anchor,
4745
+ parentComponent,
4746
+ parentSuspense,
4747
+ namespace,
4748
+ slotScopeIds,
4749
+ optimized
4750
+ );
4751
+ }
4752
+ }
4753
+ }
4754
+ };
4755
+ const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4756
+ c1 = c1 || shared.EMPTY_ARR;
4757
+ c2 = c2 || shared.EMPTY_ARR;
4758
+ const oldLength = c1.length;
4759
+ const newLength = c2.length;
4760
+ const commonLength = Math.min(oldLength, newLength);
4761
+ let i;
4762
+ for (i = 0; i < commonLength; i++) {
4763
+ const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4764
+ patch(
4765
+ c1[i],
4766
+ nextChild,
4767
+ container,
4768
+ null,
4769
+ parentComponent,
4770
+ parentSuspense,
4771
+ namespace,
4772
+ slotScopeIds,
4773
+ optimized
4774
+ );
4775
+ }
4776
+ if (oldLength > newLength) {
4777
+ unmountChildren(
4778
+ c1,
4779
+ parentComponent,
4780
+ parentSuspense,
4781
+ true,
4782
+ false,
4783
+ commonLength
4784
+ );
4785
+ } else {
4786
+ mountChildren(
4787
+ c2,
4788
+ container,
4789
+ anchor,
4790
+ parentComponent,
4791
+ parentSuspense,
4792
+ namespace,
4793
+ slotScopeIds,
4794
+ optimized,
4795
+ commonLength
4796
+ );
4797
+ }
4798
+ };
4799
+ const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4800
+ let i = 0;
4801
+ const l2 = c2.length;
4802
+ let e1 = c1.length - 1;
4803
+ let e2 = l2 - 1;
4804
+ while (i <= e1 && i <= e2) {
4805
+ const n1 = c1[i];
4806
+ const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4807
+ if (isSameVNodeType(n1, n2)) {
4808
+ patch(
4809
+ n1,
4810
+ n2,
4811
+ container,
4812
+ null,
4813
+ parentComponent,
4814
+ parentSuspense,
4815
+ namespace,
4816
+ slotScopeIds,
4817
+ optimized
4818
+ );
4819
+ } else {
4820
+ break;
4821
+ }
4822
+ i++;
4823
+ }
4824
+ while (i <= e1 && i <= e2) {
4825
+ const n1 = c1[e1];
4826
+ const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
4827
+ if (isSameVNodeType(n1, n2)) {
4828
+ patch(
4829
+ n1,
4830
+ n2,
4831
+ container,
4832
+ null,
4833
+ parentComponent,
4834
+ parentSuspense,
4835
+ namespace,
4836
+ slotScopeIds,
4837
+ optimized
4838
+ );
4839
+ } else {
4840
+ break;
4841
+ }
4842
+ e1--;
4843
+ e2--;
4844
+ }
4845
+ if (i > e1) {
4846
+ if (i <= e2) {
4847
+ const nextPos = e2 + 1;
4848
+ const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
4849
+ while (i <= e2) {
4850
+ patch(
4851
+ null,
4852
+ c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
4853
+ container,
4854
+ anchor,
4855
+ parentComponent,
4856
+ parentSuspense,
4857
+ namespace,
4858
+ slotScopeIds,
4859
+ optimized
4860
+ );
4861
+ i++;
4862
+ }
4863
+ }
4864
+ } else if (i > e2) {
4865
+ while (i <= e1) {
4866
+ unmount(c1[i], parentComponent, parentSuspense, true);
4867
+ i++;
4868
+ }
4869
+ } else {
4870
+ const s1 = i;
4871
+ const s2 = i;
4872
+ const keyToNewIndexMap = /* @__PURE__ */ new Map();
4873
+ for (i = s2; i <= e2; i++) {
4874
+ const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4875
+ if (nextChild.key != null) {
4876
+ keyToNewIndexMap.set(nextChild.key, i);
4877
+ }
4878
+ }
4879
+ let j;
4880
+ let patched = 0;
4881
+ const toBePatched = e2 - s2 + 1;
4882
+ let moved = false;
4883
+ let maxNewIndexSoFar = 0;
4884
+ const newIndexToOldIndexMap = new Array(toBePatched);
4885
+ for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
4886
+ for (i = s1; i <= e1; i++) {
4887
+ const prevChild = c1[i];
4888
+ if (patched >= toBePatched) {
4889
+ unmount(prevChild, parentComponent, parentSuspense, true);
4890
+ continue;
4891
+ }
4892
+ let newIndex;
4893
+ if (prevChild.key != null) {
4894
+ newIndex = keyToNewIndexMap.get(prevChild.key);
4895
+ } else {
4896
+ for (j = s2; j <= e2; j++) {
4897
+ if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
4898
+ newIndex = j;
4899
+ break;
4900
+ }
4901
+ }
4902
+ }
4903
+ if (newIndex === void 0) {
4904
+ unmount(prevChild, parentComponent, parentSuspense, true);
4905
+ } else {
4906
+ newIndexToOldIndexMap[newIndex - s2] = i + 1;
4907
+ if (newIndex >= maxNewIndexSoFar) {
4908
+ maxNewIndexSoFar = newIndex;
4909
+ } else {
4910
+ moved = true;
4911
+ }
4912
+ patch(
4913
+ prevChild,
4914
+ c2[newIndex],
4915
+ container,
4916
+ null,
4917
+ parentComponent,
4918
+ parentSuspense,
4919
+ namespace,
4920
+ slotScopeIds,
4921
+ optimized
4922
+ );
4923
+ patched++;
4924
+ }
4925
+ }
4926
+ const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
4927
+ j = increasingNewIndexSequence.length - 1;
4928
+ for (i = toBePatched - 1; i >= 0; i--) {
4929
+ const nextIndex = s2 + i;
4930
+ const nextChild = c2[nextIndex];
4931
+ const anchorVNode = c2[nextIndex + 1];
4932
+ const anchor = nextIndex + 1 < l2 ? (
4933
+ // #13559, fallback to el placeholder for unresolved async component
4934
+ anchorVNode.el || anchorVNode.placeholder
4935
+ ) : parentAnchor;
4936
+ if (newIndexToOldIndexMap[i] === 0) {
4937
+ patch(
4938
+ null,
4939
+ nextChild,
4940
+ container,
4941
+ anchor,
4942
+ parentComponent,
4943
+ parentSuspense,
4944
+ namespace,
4945
+ slotScopeIds,
4946
+ optimized
4947
+ );
4948
+ } else if (moved) {
4949
+ if (j < 0 || i !== increasingNewIndexSequence[j]) {
4950
+ move(nextChild, container, anchor, 2);
4951
+ } else {
4952
+ j--;
4953
+ }
4954
+ }
4955
+ }
4956
+ }
4957
+ };
4958
+ const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
4959
+ const { el, type, transition, children, shapeFlag } = vnode;
4960
+ if (shapeFlag & 6) {
4961
+ move(vnode.component.subTree, container, anchor, moveType);
4962
+ return;
4963
+ }
4964
+ if (shapeFlag & 128) {
4965
+ vnode.suspense.move(container, anchor, moveType);
4966
+ return;
4967
+ }
4968
+ if (shapeFlag & 64) {
4969
+ type.move(vnode, container, anchor, internals);
4970
+ return;
4971
+ }
4972
+ if (type === Fragment) {
4973
+ hostInsert(el, container, anchor);
4974
+ for (let i = 0; i < children.length; i++) {
4975
+ move(children[i], container, anchor, moveType);
4805
4976
  }
4806
- u = 0;
4807
- v = result.length - 1;
4808
- while (u < v) {
4809
- c = u + v >> 1;
4810
- if (arr[result[c]] < arrI) {
4811
- u = c + 1;
4977
+ hostInsert(vnode.anchor, container, anchor);
4978
+ return;
4979
+ }
4980
+ if (type === Static) {
4981
+ moveStaticNode(vnode, container, anchor);
4982
+ return;
4983
+ }
4984
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
4985
+ if (needTransition2) {
4986
+ if (moveType === 0) {
4987
+ transition.beforeEnter(el);
4988
+ hostInsert(el, container, anchor);
4989
+ queuePostRenderEffect(() => transition.enter(el), parentSuspense);
4990
+ } else {
4991
+ const { leave, delayLeave, afterLeave } = transition;
4992
+ const remove2 = () => {
4993
+ if (vnode.ctx.isUnmounted) {
4994
+ hostRemove(el);
4995
+ } else {
4996
+ hostInsert(el, container, anchor);
4997
+ }
4998
+ };
4999
+ const performLeave = () => {
5000
+ if (el._isLeaving) {
5001
+ el[leaveCbKey](
5002
+ true
5003
+ /* cancelled */
5004
+ );
5005
+ }
5006
+ leave(el, () => {
5007
+ remove2();
5008
+ afterLeave && afterLeave();
5009
+ });
5010
+ };
5011
+ if (delayLeave) {
5012
+ delayLeave(el, remove2, performLeave);
4812
5013
  } else {
4813
- v = c;
4814
- }
4815
- }
4816
- if (arrI < arr[result[u]]) {
4817
- if (u > 0) {
4818
- p[i] = result[u - 1];
5014
+ performLeave();
4819
5015
  }
4820
- result[u] = i;
4821
5016
  }
4822
- }
4823
- }
4824
- u = result.length;
4825
- v = result[u - 1];
4826
- while (u-- > 0) {
4827
- result[u] = v;
4828
- v = p[v];
4829
- }
4830
- return result;
4831
- }
4832
- function locateNonHydratedAsyncRoot(instance) {
4833
- const subComponent = instance.subTree.component;
4834
- if (subComponent) {
4835
- if (subComponent.asyncDep && !subComponent.asyncResolved) {
4836
- return subComponent;
4837
5017
  } else {
4838
- return locateNonHydratedAsyncRoot(subComponent);
5018
+ hostInsert(el, container, anchor);
4839
5019
  }
4840
- }
4841
- }
4842
- function invalidateMount(hooks) {
4843
- if (hooks) {
4844
- for (let i = 0; i < hooks.length; i++)
4845
- hooks[i].flags |= 8;
4846
- }
4847
- }
4848
-
4849
- const ssrContextKey = Symbol.for("v-scx");
4850
- const useSSRContext = () => {
4851
- {
4852
- const ctx = inject(ssrContextKey);
4853
- return ctx;
4854
- }
4855
- };
4856
-
4857
- function watchEffect(effect, options) {
4858
- return doWatch(effect, null, options);
4859
- }
4860
- function watchPostEffect(effect, options) {
4861
- return doWatch(
4862
- effect,
4863
- null,
4864
- { flush: "post" }
4865
- );
4866
- }
4867
- function watchSyncEffect(effect, options) {
4868
- return doWatch(
4869
- effect,
4870
- null,
4871
- { flush: "sync" }
4872
- );
4873
- }
4874
- function watch(source, cb, options) {
4875
- return doWatch(source, cb, options);
4876
- }
4877
- function doWatch(source, cb, options = shared.EMPTY_OBJ) {
4878
- const { immediate, deep, flush, once } = options;
4879
- const baseWatchOptions = shared.extend({}, options);
4880
- const runsImmediately = cb && immediate || !cb && flush !== "post";
4881
- let ssrCleanup;
4882
- if (isInSSRComponentSetup) {
4883
- if (flush === "sync") {
4884
- const ctx = useSSRContext();
4885
- ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
4886
- } else if (!runsImmediately) {
4887
- const watchStopHandle = () => {
4888
- };
4889
- watchStopHandle.stop = shared.NOOP;
4890
- watchStopHandle.resume = shared.NOOP;
4891
- watchStopHandle.pause = shared.NOOP;
4892
- return watchStopHandle;
5020
+ };
5021
+ const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
5022
+ const {
5023
+ type,
5024
+ props,
5025
+ ref,
5026
+ children,
5027
+ dynamicChildren,
5028
+ shapeFlag,
5029
+ patchFlag,
5030
+ dirs,
5031
+ cacheIndex
5032
+ } = vnode;
5033
+ if (patchFlag === -2) {
5034
+ optimized = false;
4893
5035
  }
4894
- }
4895
- const instance = currentInstance;
4896
- baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
4897
- let isPre = false;
4898
- if (flush === "post") {
4899
- baseWatchOptions.scheduler = (job) => {
4900
- queuePostRenderEffect(job, instance && instance.suspense);
4901
- };
4902
- } else if (flush !== "sync") {
4903
- isPre = true;
4904
- baseWatchOptions.scheduler = (job, isFirstRun) => {
4905
- if (isFirstRun) {
4906
- job();
4907
- } else {
4908
- queueJob(job);
4909
- }
4910
- };
4911
- }
4912
- baseWatchOptions.augmentJob = (job) => {
4913
- if (cb) {
4914
- job.flags |= 4;
5036
+ if (ref != null) {
5037
+ reactivity.pauseTracking();
5038
+ setRef(ref, null, parentSuspense, vnode, true);
5039
+ reactivity.resetTracking();
4915
5040
  }
4916
- if (isPre) {
4917
- job.flags |= 2;
4918
- if (instance) {
4919
- job.id = instance.uid;
4920
- job.i = instance;
4921
- }
5041
+ if (cacheIndex != null) {
5042
+ parentComponent.renderCache[cacheIndex] = void 0;
4922
5043
  }
4923
- };
4924
- const watchHandle = reactivity.watch(source, cb, baseWatchOptions);
4925
- if (isInSSRComponentSetup) {
4926
- if (ssrCleanup) {
4927
- ssrCleanup.push(watchHandle);
4928
- } else if (runsImmediately) {
4929
- watchHandle();
5044
+ if (shapeFlag & 256) {
5045
+ parentComponent.ctx.deactivate(vnode);
5046
+ return;
4930
5047
  }
4931
- }
4932
- return watchHandle;
4933
- }
4934
- function instanceWatch(source, value, options) {
4935
- const publicThis = this.proxy;
4936
- const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
4937
- let cb;
4938
- if (shared.isFunction(value)) {
4939
- cb = value;
4940
- } else {
4941
- cb = value.handler;
4942
- options = value;
4943
- }
4944
- const reset = setCurrentInstance(this);
4945
- const res = doWatch(getter, cb.bind(publicThis), options);
4946
- reset();
4947
- return res;
4948
- }
4949
- function createPathGetter(ctx, path) {
4950
- const segments = path.split(".");
4951
- return () => {
4952
- let cur = ctx;
4953
- for (let i = 0; i < segments.length && cur; i++) {
4954
- cur = cur[segments[i]];
5048
+ const shouldInvokeDirs = shapeFlag & 1 && dirs;
5049
+ const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
5050
+ let vnodeHook;
5051
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
5052
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
4955
5053
  }
4956
- return cur;
4957
- };
4958
- }
4959
-
4960
- function useModel(props, name, options = shared.EMPTY_OBJ) {
4961
- const i = getCurrentInstance();
4962
- const camelizedName = shared.camelize(name);
4963
- const hyphenatedName = shared.hyphenate(name);
4964
- const modifiers = getModelModifiers(props, camelizedName);
4965
- const res = reactivity.customRef((track, trigger) => {
4966
- let localValue;
4967
- let prevSetValue = shared.EMPTY_OBJ;
4968
- let prevEmittedValue;
4969
- watchSyncEffect(() => {
4970
- const propValue = props[camelizedName];
4971
- if (shared.hasChanged(localValue, propValue)) {
4972
- localValue = propValue;
4973
- trigger();
5054
+ if (shapeFlag & 6) {
5055
+ unmountComponent(vnode.component, parentSuspense, doRemove);
5056
+ } else {
5057
+ if (shapeFlag & 128) {
5058
+ vnode.suspense.unmount(parentSuspense, doRemove);
5059
+ return;
4974
5060
  }
4975
- });
4976
- return {
4977
- get() {
4978
- track();
4979
- return options.get ? options.get(localValue) : localValue;
4980
- },
4981
- set(value) {
4982
- const emittedValue = options.set ? options.set(value) : value;
4983
- if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
4984
- return;
4985
- }
4986
- const rawProps = i.vnode.props;
4987
- if (!(rawProps && // check if parent has passed v-model
4988
- (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
4989
- localValue = value;
4990
- trigger();
4991
- }
4992
- i.emit(`update:${name}`, emittedValue);
4993
- if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
4994
- trigger();
4995
- }
4996
- prevSetValue = value;
4997
- prevEmittedValue = emittedValue;
5061
+ if (shouldInvokeDirs) {
5062
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
4998
5063
  }
4999
- };
5000
- });
5001
- res[Symbol.iterator] = () => {
5002
- let i2 = 0;
5003
- return {
5004
- next() {
5005
- if (i2 < 2) {
5006
- return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
5007
- } else {
5008
- return { done: true };
5009
- }
5064
+ if (shapeFlag & 64) {
5065
+ vnode.type.remove(
5066
+ vnode,
5067
+ parentComponent,
5068
+ parentSuspense,
5069
+ internals,
5070
+ doRemove
5071
+ );
5072
+ } else if (dynamicChildren && // #5154
5073
+ // when v-once is used inside a block, setBlockTracking(-1) marks the
5074
+ // parent block with hasOnce: true
5075
+ // so that it doesn't take the fast path during unmount - otherwise
5076
+ // components nested in v-once are never unmounted.
5077
+ !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
5078
+ (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
5079
+ unmountChildren(
5080
+ dynamicChildren,
5081
+ parentComponent,
5082
+ parentSuspense,
5083
+ false,
5084
+ true
5085
+ );
5086
+ } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
5087
+ unmountChildren(children, parentComponent, parentSuspense);
5088
+ }
5089
+ if (doRemove) {
5090
+ remove(vnode);
5010
5091
  }
5011
- };
5012
- };
5013
- return res;
5014
- }
5015
- const getModelModifiers = (props, modelName) => {
5016
- return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${shared.camelize(modelName)}Modifiers`] || props[`${shared.hyphenate(modelName)}Modifiers`];
5017
- };
5018
-
5019
- function emit(instance, event, ...rawArgs) {
5020
- if (instance.isUnmounted) return;
5021
- const props = instance.vnode.props || shared.EMPTY_OBJ;
5022
- let args = rawArgs;
5023
- const isModelListener = event.startsWith("update:");
5024
- const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
5025
- if (modifiers) {
5026
- if (modifiers.trim) {
5027
- args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
5028
5092
  }
5029
- if (modifiers.number) {
5030
- args = rawArgs.map(shared.looseToNumber);
5093
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
5094
+ queuePostRenderEffect(() => {
5095
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
5096
+ shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
5097
+ }, parentSuspense);
5031
5098
  }
5032
- }
5033
- let handlerName;
5034
- let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
5035
- props[handlerName = shared.toHandlerKey(shared.camelize(event))];
5036
- if (!handler && isModelListener) {
5037
- handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
5038
- }
5039
- if (handler) {
5040
- callWithAsyncErrorHandling(
5041
- handler,
5042
- instance,
5043
- 6,
5044
- args
5045
- );
5046
- }
5047
- const onceHandler = props[handlerName + `Once`];
5048
- if (onceHandler) {
5049
- if (!instance.emitted) {
5050
- instance.emitted = {};
5051
- } else if (instance.emitted[handlerName]) {
5099
+ };
5100
+ const remove = (vnode) => {
5101
+ const { type, el, anchor, transition } = vnode;
5102
+ if (type === Fragment) {
5103
+ {
5104
+ removeFragment(el, anchor);
5105
+ }
5052
5106
  return;
5053
5107
  }
5054
- instance.emitted[handlerName] = true;
5055
- callWithAsyncErrorHandling(
5056
- onceHandler,
5057
- instance,
5058
- 6,
5059
- args
5060
- );
5061
- }
5062
- }
5063
- const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
5064
- function normalizeEmitsOptions(comp, appContext, asMixin = false) {
5065
- const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
5066
- const cached = cache.get(comp);
5067
- if (cached !== void 0) {
5068
- return cached;
5069
- }
5070
- const raw = comp.emits;
5071
- let normalized = {};
5072
- let hasExtends = false;
5073
- if (!shared.isFunction(comp)) {
5074
- const extendEmits = (raw2) => {
5075
- const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
5076
- if (normalizedFromExtend) {
5077
- hasExtends = true;
5078
- shared.extend(normalized, normalizedFromExtend);
5108
+ if (type === Static) {
5109
+ removeStaticNode(vnode);
5110
+ return;
5111
+ }
5112
+ const performRemove = () => {
5113
+ hostRemove(el);
5114
+ if (transition && !transition.persisted && transition.afterLeave) {
5115
+ transition.afterLeave();
5079
5116
  }
5080
5117
  };
5081
- if (!asMixin && appContext.mixins.length) {
5082
- appContext.mixins.forEach(extendEmits);
5118
+ if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
5119
+ const { leave, delayLeave } = transition;
5120
+ const performLeave = () => leave(el, performRemove);
5121
+ if (delayLeave) {
5122
+ delayLeave(vnode.el, performRemove, performLeave);
5123
+ } else {
5124
+ performLeave();
5125
+ }
5126
+ } else {
5127
+ performRemove();
5083
5128
  }
5084
- if (comp.extends) {
5085
- extendEmits(comp.extends);
5129
+ };
5130
+ const removeFragment = (cur, end) => {
5131
+ let next;
5132
+ while (cur !== end) {
5133
+ next = hostNextSibling(cur);
5134
+ hostRemove(cur);
5135
+ cur = next;
5086
5136
  }
5087
- if (comp.mixins) {
5088
- comp.mixins.forEach(extendEmits);
5137
+ hostRemove(end);
5138
+ };
5139
+ const unmountComponent = (instance, parentSuspense, doRemove) => {
5140
+ const { bum, scope, job, subTree, um, m, a } = instance;
5141
+ invalidateMount(m);
5142
+ invalidateMount(a);
5143
+ if (bum) {
5144
+ shared.invokeArrayFns(bum);
5089
5145
  }
5090
- }
5091
- if (!raw && !hasExtends) {
5092
- if (shared.isObject(comp)) {
5093
- cache.set(comp, null);
5146
+ scope.stop();
5147
+ if (job) {
5148
+ job.flags |= 8;
5149
+ unmount(subTree, instance, parentSuspense, doRemove);
5094
5150
  }
5095
- return null;
5096
- }
5097
- if (shared.isArray(raw)) {
5098
- raw.forEach((key) => normalized[key] = null);
5099
- } else {
5100
- shared.extend(normalized, raw);
5101
- }
5102
- if (shared.isObject(comp)) {
5103
- cache.set(comp, normalized);
5104
- }
5105
- return normalized;
5106
- }
5107
- function isEmitListener(options, key) {
5108
- if (!options || !shared.isOn(key)) {
5109
- return false;
5110
- }
5111
- key = key.slice(2).replace(/Once$/, "");
5112
- return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
5113
- }
5114
-
5115
- function markAttrsAccessed() {
5116
- }
5117
- function renderComponentRoot(instance) {
5118
- const {
5119
- type: Component,
5120
- vnode,
5121
- proxy,
5122
- withProxy,
5123
- propsOptions: [propsOptions],
5124
- slots,
5125
- attrs,
5126
- emit,
5127
- render,
5128
- renderCache,
5129
- props,
5130
- data,
5131
- setupState,
5132
- ctx,
5133
- inheritAttrs
5134
- } = instance;
5135
- const prev = setCurrentRenderingInstance(instance);
5136
- let result;
5137
- let fallthroughAttrs;
5138
- try {
5139
- if (vnode.shapeFlag & 4) {
5140
- const proxyToUse = withProxy || proxy;
5141
- const thisProxy = false ? new Proxy(proxyToUse, {
5142
- get(target, key, receiver) {
5143
- warn(
5144
- `Property '${String(
5145
- key
5146
- )}' was accessed via 'this'. Avoid using 'this' in templates.`
5147
- );
5148
- return Reflect.get(target, key, receiver);
5149
- }
5150
- }) : proxyToUse;
5151
- result = normalizeVNode(
5152
- render.call(
5153
- thisProxy,
5154
- proxyToUse,
5155
- renderCache,
5156
- false ? shallowReadonly(props) : props,
5157
- setupState,
5158
- data,
5159
- ctx
5160
- )
5161
- );
5162
- fallthroughAttrs = attrs;
5151
+ if (um) {
5152
+ queuePostRenderEffect(um, parentSuspense);
5153
+ }
5154
+ queuePostRenderEffect(() => {
5155
+ instance.isUnmounted = true;
5156
+ }, parentSuspense);
5157
+ };
5158
+ const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
5159
+ for (let i = start; i < children.length; i++) {
5160
+ unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
5161
+ }
5162
+ };
5163
+ const getNextHostNode = (vnode) => {
5164
+ if (vnode.shapeFlag & 6) {
5165
+ return getNextHostNode(vnode.component.subTree);
5166
+ }
5167
+ if (vnode.shapeFlag & 128) {
5168
+ return vnode.suspense.next();
5169
+ }
5170
+ const el = hostNextSibling(vnode.anchor || vnode.el);
5171
+ const teleportEnd = el && el[TeleportEndKey];
5172
+ return teleportEnd ? hostNextSibling(teleportEnd) : el;
5173
+ };
5174
+ let isFlushing = false;
5175
+ const render = (vnode, container, namespace) => {
5176
+ if (vnode == null) {
5177
+ if (container._vnode) {
5178
+ unmount(container._vnode, null, null, true);
5179
+ }
5163
5180
  } else {
5164
- const render2 = Component;
5165
- if (false) ;
5166
- result = normalizeVNode(
5167
- render2.length > 1 ? render2(
5168
- false ? shallowReadonly(props) : props,
5169
- false ? {
5170
- get attrs() {
5171
- markAttrsAccessed();
5172
- return shallowReadonly(attrs);
5173
- },
5174
- slots,
5175
- emit
5176
- } : { attrs, slots, emit }
5177
- ) : render2(
5178
- false ? shallowReadonly(props) : props,
5179
- null
5180
- )
5181
+ patch(
5182
+ container._vnode || null,
5183
+ vnode,
5184
+ container,
5185
+ null,
5186
+ null,
5187
+ null,
5188
+ namespace
5181
5189
  );
5182
- fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
5183
5190
  }
5184
- } catch (err) {
5185
- blockStack.length = 0;
5186
- handleError(err, instance, 1);
5187
- result = createVNode(Comment);
5188
- }
5189
- let root = result;
5190
- if (fallthroughAttrs && inheritAttrs !== false) {
5191
- const keys = Object.keys(fallthroughAttrs);
5192
- const { shapeFlag } = root;
5193
- if (keys.length) {
5194
- if (shapeFlag & (1 | 6)) {
5195
- if (propsOptions && keys.some(shared.isModelListener)) {
5196
- fallthroughAttrs = filterModelListeners(
5197
- fallthroughAttrs,
5198
- propsOptions
5199
- );
5200
- }
5201
- root = cloneVNode(root, fallthroughAttrs, false, true);
5202
- }
5191
+ container._vnode = vnode;
5192
+ if (!isFlushing) {
5193
+ isFlushing = true;
5194
+ flushPreFlushCbs();
5195
+ flushPostFlushCbs();
5196
+ isFlushing = false;
5203
5197
  }
5198
+ };
5199
+ const internals = {
5200
+ p: patch,
5201
+ um: unmount,
5202
+ m: move,
5203
+ r: remove,
5204
+ mt: mountComponent,
5205
+ mc: mountChildren,
5206
+ pc: patchChildren,
5207
+ pbc: patchBlockChildren,
5208
+ n: getNextHostNode,
5209
+ o: options
5210
+ };
5211
+ let hydrate;
5212
+ let hydrateNode;
5213
+ if (createHydrationFns) {
5214
+ [hydrate, hydrateNode] = createHydrationFns(
5215
+ internals
5216
+ );
5204
5217
  }
5205
- if (vnode.dirs) {
5206
- root = cloneVNode(root, null, false, true);
5207
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
5208
- }
5209
- if (vnode.transition) {
5210
- setTransitionHooks(root, vnode.transition);
5211
- }
5212
- {
5213
- result = root;
5218
+ return {
5219
+ render,
5220
+ hydrate,
5221
+ createApp: createAppAPI(render, hydrate)
5222
+ };
5223
+ }
5224
+ function resolveChildrenNamespace({ type, props }, currentNamespace) {
5225
+ return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
5226
+ }
5227
+ function toggleRecurse({ effect, job }, allowed) {
5228
+ if (allowed) {
5229
+ effect.flags |= 32;
5230
+ job.flags |= 4;
5231
+ } else {
5232
+ effect.flags &= -33;
5233
+ job.flags &= -5;
5214
5234
  }
5215
- setCurrentRenderingInstance(prev);
5216
- return result;
5217
5235
  }
5218
- function filterSingleRoot(children, recurse = true) {
5219
- let singleRoot;
5220
- for (let i = 0; i < children.length; i++) {
5221
- const child = children[i];
5222
- if (isVNode(child)) {
5223
- if (child.type !== Comment || child.children === "v-if") {
5224
- if (singleRoot) {
5225
- return;
5226
- } else {
5227
- singleRoot = child;
5236
+ function needTransition(parentSuspense, transition) {
5237
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5238
+ }
5239
+ function traverseStaticChildren(n1, n2, shallow = false) {
5240
+ const ch1 = n1.children;
5241
+ const ch2 = n2.children;
5242
+ if (shared.isArray(ch1) && shared.isArray(ch2)) {
5243
+ for (let i = 0; i < ch1.length; i++) {
5244
+ const c1 = ch1[i];
5245
+ let c2 = ch2[i];
5246
+ if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
5247
+ if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
5248
+ c2 = ch2[i] = cloneIfMounted(ch2[i]);
5249
+ c2.el = c1.el;
5228
5250
  }
5251
+ if (!shallow && c2.patchFlag !== -2)
5252
+ traverseStaticChildren(c1, c2);
5253
+ }
5254
+ if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
5255
+ c2.patchFlag !== -1) {
5256
+ c2.el = c1.el;
5257
+ }
5258
+ if (c2.type === Comment && !c2.el) {
5259
+ c2.el = c1.el;
5229
5260
  }
5230
- } else {
5231
- return;
5232
5261
  }
5233
5262
  }
5234
- return singleRoot;
5235
5263
  }
5236
- const getFunctionalFallthrough = (attrs) => {
5237
- let res;
5238
- for (const key in attrs) {
5239
- if (key === "class" || key === "style" || shared.isOn(key)) {
5240
- (res || (res = {}))[key] = attrs[key];
5241
- }
5242
- }
5243
- return res;
5244
- };
5245
- const filterModelListeners = (attrs, props) => {
5246
- const res = {};
5247
- for (const key in attrs) {
5248
- if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
5249
- res[key] = attrs[key];
5250
- }
5251
- }
5252
- return res;
5253
- };
5254
- function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
5255
- const { props: prevProps, children: prevChildren, component } = prevVNode;
5256
- const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
5257
- const emits = component.emitsOptions;
5258
- if (nextVNode.dirs || nextVNode.transition) {
5259
- return true;
5260
- }
5261
- if (optimized && patchFlag >= 0) {
5262
- if (patchFlag & 1024) {
5263
- return true;
5264
- }
5265
- if (patchFlag & 16) {
5266
- if (!prevProps) {
5267
- return !!nextProps;
5264
+ function getSequence(arr) {
5265
+ const p = arr.slice();
5266
+ const result = [0];
5267
+ let i, j, u, v, c;
5268
+ const len = arr.length;
5269
+ for (i = 0; i < len; i++) {
5270
+ const arrI = arr[i];
5271
+ if (arrI !== 0) {
5272
+ j = result[result.length - 1];
5273
+ if (arr[j] < arrI) {
5274
+ p[i] = j;
5275
+ result.push(i);
5276
+ continue;
5268
5277
  }
5269
- return hasPropsChanged(prevProps, nextProps, emits);
5270
- } else if (patchFlag & 8) {
5271
- const dynamicProps = nextVNode.dynamicProps;
5272
- for (let i = 0; i < dynamicProps.length; i++) {
5273
- const key = dynamicProps[i];
5274
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
5275
- return true;
5278
+ u = 0;
5279
+ v = result.length - 1;
5280
+ while (u < v) {
5281
+ c = u + v >> 1;
5282
+ if (arr[result[c]] < arrI) {
5283
+ u = c + 1;
5284
+ } else {
5285
+ v = c;
5276
5286
  }
5277
5287
  }
5278
- }
5279
- } else {
5280
- if (prevChildren || nextChildren) {
5281
- if (!nextChildren || !nextChildren.$stable) {
5282
- return true;
5288
+ if (arrI < arr[result[u]]) {
5289
+ if (u > 0) {
5290
+ p[i] = result[u - 1];
5291
+ }
5292
+ result[u] = i;
5283
5293
  }
5284
5294
  }
5285
- if (prevProps === nextProps) {
5286
- return false;
5287
- }
5288
- if (!prevProps) {
5289
- return !!nextProps;
5290
- }
5291
- if (!nextProps) {
5292
- return true;
5293
- }
5294
- return hasPropsChanged(prevProps, nextProps, emits);
5295
- }
5296
- return false;
5297
- }
5298
- function hasPropsChanged(prevProps, nextProps, emitsOptions) {
5299
- const nextKeys = Object.keys(nextProps);
5300
- if (nextKeys.length !== Object.keys(prevProps).length) {
5301
- return true;
5302
5295
  }
5303
- for (let i = 0; i < nextKeys.length; i++) {
5304
- const key = nextKeys[i];
5305
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
5306
- return true;
5307
- }
5296
+ u = result.length;
5297
+ v = result[u - 1];
5298
+ while (u-- > 0) {
5299
+ result[u] = v;
5300
+ v = p[v];
5308
5301
  }
5309
- return false;
5302
+ return result;
5310
5303
  }
5311
- function updateHOCHostEl({ vnode, parent }, el) {
5312
- while (parent) {
5313
- const root = parent.subTree;
5314
- if (root.suspense && root.suspense.activeBranch === vnode) {
5315
- root.el = vnode.el;
5316
- }
5317
- if (root === vnode) {
5318
- (vnode = parent.vnode).el = el;
5319
- parent = parent.parent;
5304
+ function locateNonHydratedAsyncRoot(instance) {
5305
+ const subComponent = instance.subTree.component;
5306
+ if (subComponent) {
5307
+ if (subComponent.asyncDep && !subComponent.asyncResolved) {
5308
+ return subComponent;
5320
5309
  } else {
5321
- break;
5310
+ return locateNonHydratedAsyncRoot(subComponent);
5322
5311
  }
5323
5312
  }
5324
5313
  }
5314
+ function invalidateMount(hooks) {
5315
+ if (hooks) {
5316
+ for (let i = 0; i < hooks.length; i++)
5317
+ hooks[i].flags |= 8;
5318
+ }
5319
+ }
5325
5320
 
5326
5321
  const isSuspense = (type) => type.__isSuspense;
5327
5322
  let suspenseId = 0;
@@ -5654,7 +5649,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
5654
5649
  }
5655
5650
  unmount(activeBranch, parentComponent2, suspense, true);
5656
5651
  if (!delayEnter && isInFallback && vnode2.ssFallback) {
5657
- vnode2.ssFallback.el = null;
5652
+ queuePostRenderEffect(() => vnode2.ssFallback.el = null, suspense);
5658
5653
  }
5659
5654
  }
5660
5655
  if (!delayEnter) {
@@ -6585,7 +6580,7 @@ function isMemoSame(cached, memo) {
6585
6580
  return true;
6586
6581
  }
6587
6582
 
6588
- const version = "3.5.24";
6583
+ const version = "3.5.25";
6589
6584
  const warn$1 = shared.NOOP;
6590
6585
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
6591
6586
  const devtools = void 0;