@vue/runtime-core 3.5.24 → 3.5.26

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