vue 3.2.33 → 3.2.35

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.
@@ -239,6 +239,11 @@ function looseEqual(a, b) {
239
239
  if (aValidType || bValidType) {
240
240
  return aValidType && bValidType ? a.getTime() === b.getTime() : false;
241
241
  }
242
+ aValidType = isSymbol(a);
243
+ bValidType = isSymbol(b);
244
+ if (aValidType || bValidType) {
245
+ return a === b;
246
+ }
242
247
  aValidType = isArray(a);
243
248
  bValidType = isArray(b);
244
249
  if (aValidType || bValidType) {
@@ -334,7 +339,7 @@ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
334
339
  const isArray = Array.isArray;
335
340
  const isMap = (val) => toTypeString(val) === '[object Map]';
336
341
  const isSet = (val) => toTypeString(val) === '[object Set]';
337
- const isDate = (val) => val instanceof Date;
342
+ const isDate = (val) => toTypeString(val) === '[object Date]';
338
343
  const isFunction = (val) => typeof val === 'function';
339
344
  const isString = (val) => typeof val === 'string';
340
345
  const isSymbol = (val) => typeof val === 'symbol';
@@ -781,17 +786,28 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
781
786
  }
782
787
  function triggerEffects(dep, debuggerEventExtraInfo) {
783
788
  // spread into array for stabilization
784
- for (const effect of isArray(dep) ? dep : [...dep]) {
785
- if (effect !== activeEffect || effect.allowRecurse) {
786
- if (effect.onTrigger) {
787
- effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
788
- }
789
- if (effect.scheduler) {
790
- effect.scheduler();
791
- }
792
- else {
793
- effect.run();
794
- }
789
+ const effects = isArray(dep) ? dep : [...dep];
790
+ for (const effect of effects) {
791
+ if (effect.computed) {
792
+ triggerEffect(effect, debuggerEventExtraInfo);
793
+ }
794
+ }
795
+ for (const effect of effects) {
796
+ if (!effect.computed) {
797
+ triggerEffect(effect, debuggerEventExtraInfo);
798
+ }
799
+ }
800
+ }
801
+ function triggerEffect(effect, debuggerEventExtraInfo) {
802
+ if (effect !== activeEffect || effect.allowRecurse) {
803
+ if (effect.onTrigger) {
804
+ effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
805
+ }
806
+ if (effect.scheduler) {
807
+ effect.scheduler();
808
+ }
809
+ else {
810
+ effect.run();
795
811
  }
796
812
  }
797
813
  }
@@ -800,6 +816,10 @@ const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
800
816
  const builtInSymbols = new Set(
801
817
  /*#__PURE__*/
802
818
  Object.getOwnPropertyNames(Symbol)
819
+ // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
820
+ // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
821
+ // function
822
+ .filter(key => key !== 'arguments' && key !== 'caller')
803
823
  .map(key => Symbol[key])
804
824
  .filter(isSymbol));
805
825
  const get = /*#__PURE__*/ createGetter();
@@ -873,9 +893,8 @@ function createGetter(isReadonly = false, shallow = false) {
873
893
  return res;
874
894
  }
875
895
  if (isRef(res)) {
876
- // ref unwrapping - does not apply for Array + integer key.
877
- const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
878
- return shouldUnwrap ? res.value : res;
896
+ // ref unwrapping - skip unwrap for Array + integer key.
897
+ return targetIsArray && isIntegerKey(key) ? res : res.value;
879
898
  }
880
899
  if (isObject(res)) {
881
900
  // Convert returned value into a proxy as well. we do the isObject check
@@ -981,10 +1000,12 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
981
1000
  target = target["__v_raw" /* RAW */];
982
1001
  const rawTarget = toRaw(target);
983
1002
  const rawKey = toRaw(key);
984
- if (key !== rawKey) {
985
- !isReadonly && track(rawTarget, "get" /* GET */, key);
1003
+ if (!isReadonly) {
1004
+ if (key !== rawKey) {
1005
+ track(rawTarget, "get" /* GET */, key);
1006
+ }
1007
+ track(rawTarget, "get" /* GET */, rawKey);
986
1008
  }
987
- !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
988
1009
  const { has } = getProto(rawTarget);
989
1010
  const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
990
1011
  if (has.call(rawTarget, key)) {
@@ -1003,10 +1024,12 @@ function has$1(key, isReadonly = false) {
1003
1024
  const target = this["__v_raw" /* RAW */];
1004
1025
  const rawTarget = toRaw(target);
1005
1026
  const rawKey = toRaw(key);
1006
- if (key !== rawKey) {
1007
- !isReadonly && track(rawTarget, "has" /* HAS */, key);
1027
+ if (!isReadonly) {
1028
+ if (key !== rawKey) {
1029
+ track(rawTarget, "has" /* HAS */, key);
1030
+ }
1031
+ track(rawTarget, "has" /* HAS */, rawKey);
1008
1032
  }
1009
- !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
1010
1033
  return key === rawKey
1011
1034
  ? target.has(key)
1012
1035
  : target.has(key) || target.has(rawKey);
@@ -1332,7 +1355,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1332
1355
  if (existingProxy) {
1333
1356
  return existingProxy;
1334
1357
  }
1335
- // only a whitelist of value types can be observed.
1358
+ // only specific value types can be observed.
1336
1359
  const targetType = getTargetType(target);
1337
1360
  if (targetType === 0 /* INVALID */) {
1338
1361
  return target;
@@ -1882,6 +1905,8 @@ function flushPreFlushCbs(seen, parentJob = null) {
1882
1905
  }
1883
1906
  }
1884
1907
  function flushPostFlushCbs(seen) {
1908
+ // flush any pre cbs queued during the flush (e.g. pre watchers)
1909
+ flushPreFlushCbs();
1885
1910
  if (pendingPostFlushCbs.length) {
1886
1911
  const deduped = [...new Set(pendingPostFlushCbs)];
1887
1912
  pendingPostFlushCbs.length = 0;
@@ -2141,7 +2166,6 @@ function setDevtoolsHook(hook, target) {
2141
2166
  // handle late devtools injection - only do this if we are in an actual
2142
2167
  // browser environment to avoid the timer handle stalling test runner exit
2143
2168
  // (#4815)
2144
- // eslint-disable-next-line no-restricted-globals
2145
2169
  typeof window !== 'undefined' &&
2146
2170
  // some envs mock window but not fully
2147
2171
  window.HTMLElement &&
@@ -2235,7 +2259,7 @@ function emit$1(instance, event, ...rawArgs) {
2235
2259
  if (trim) {
2236
2260
  args = rawArgs.map(a => a.trim());
2237
2261
  }
2238
- else if (number) {
2262
+ if (number) {
2239
2263
  args = rawArgs.map(toNumber);
2240
2264
  }
2241
2265
  }
@@ -2533,6 +2557,8 @@ function renderComponentRoot(instance) {
2533
2557
  warn$1(`Runtime directive used on component with non-element root node. ` +
2534
2558
  `The directives will not function as intended.`);
2535
2559
  }
2560
+ // clone before mutating since the root may be a hoisted vnode
2561
+ root = cloneVNode(root);
2536
2562
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2537
2563
  }
2538
2564
  // inherit transition data
@@ -3235,7 +3261,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3235
3261
  }
3236
3262
  else if (isArray(source)) {
3237
3263
  isMultiSource = true;
3238
- forceTrigger = source.some(isReactive);
3264
+ forceTrigger = source.some(s => isReactive(s) || isShallow(s));
3239
3265
  getter = () => source.map(s => {
3240
3266
  if (isRef(s)) {
3241
3267
  return s.value;
@@ -3327,16 +3353,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3327
3353
  }
3328
3354
  else {
3329
3355
  // default: 'pre'
3330
- scheduler = () => {
3331
- if (!instance || instance.isMounted) {
3332
- queuePreFlushCb(job);
3333
- }
3334
- else {
3335
- // with 'pre' option, the first call must happen before
3336
- // the component is mounted so it is called synchronously.
3337
- job();
3338
- }
3339
- };
3356
+ scheduler = () => queuePreFlushCb(job);
3340
3357
  }
3341
3358
  const effect = new ReactiveEffect(getter, scheduler);
3342
3359
  {
@@ -3589,6 +3606,17 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3589
3606
  hook &&
3590
3607
  callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3591
3608
  };
3609
+ const callAsyncHook = (hook, args) => {
3610
+ const done = args[1];
3611
+ callHook(hook, args);
3612
+ if (isArray(hook)) {
3613
+ if (hook.every(hook => hook.length <= 1))
3614
+ done();
3615
+ }
3616
+ else if (hook.length <= 1) {
3617
+ done();
3618
+ }
3619
+ };
3592
3620
  const hooks = {
3593
3621
  mode,
3594
3622
  persisted,
@@ -3647,10 +3675,7 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3647
3675
  el._enterCb = undefined;
3648
3676
  });
3649
3677
  if (hook) {
3650
- hook(el, done);
3651
- if (hook.length <= 1) {
3652
- done();
3653
- }
3678
+ callAsyncHook(hook, [el, done]);
3654
3679
  }
3655
3680
  else {
3656
3681
  done();
@@ -3684,10 +3709,7 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3684
3709
  });
3685
3710
  leavingVNodesCache[key] = vnode;
3686
3711
  if (onLeave) {
3687
- onLeave(el, done);
3688
- if (onLeave.length <= 1) {
3689
- done();
3690
- }
3712
+ callAsyncHook(onLeave, [el, done]);
3691
3713
  }
3692
3714
  else {
3693
3715
  done();
@@ -3897,7 +3919,7 @@ function defineAsyncComponent(source) {
3897
3919
  }
3898
3920
  });
3899
3921
  }
3900
- function createInnerComp(comp, { vnode: { ref, props, children } }) {
3922
+ function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3901
3923
  const vnode = createVNode(comp, props, children);
3902
3924
  // ensure inner component inherits the async wrapper's ref owner
3903
3925
  vnode.ref = ref;
@@ -3924,11 +3946,6 @@ const KeepAliveImpl = {
3924
3946
  // The whole point of this is to avoid importing KeepAlive directly in the
3925
3947
  // renderer to facilitate tree-shaking.
3926
3948
  const sharedContext = instance.ctx;
3927
- // if the internal renderer is not registered, it indicates that this is server-side rendering,
3928
- // for KeepAlive, we just need to render its children
3929
- if (!sharedContext.renderer) {
3930
- return slots.default;
3931
- }
3932
3949
  const cache = new Map();
3933
3950
  const keys = new Set();
3934
3951
  let current = null;
@@ -4106,7 +4123,7 @@ const KeepAliveImpl = {
4106
4123
  // avoid vnode being unmounted
4107
4124
  vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
4108
4125
  current = vnode;
4109
- return rawVNode;
4126
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
4110
4127
  };
4111
4128
  }
4112
4129
  };
@@ -4244,1110 +4261,1597 @@ function onErrorCaptured(hook, target = currentInstance) {
4244
4261
  injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4245
4262
  }
4246
4263
 
4247
- function createDuplicateChecker() {
4248
- const cache = Object.create(null);
4249
- return (type, key) => {
4250
- if (cache[key]) {
4251
- warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
4264
+ /**
4265
+ Runtime helper for applying directives to a vnode. Example usage:
4266
+
4267
+ const comp = resolveComponent('comp')
4268
+ const foo = resolveDirective('foo')
4269
+ const bar = resolveDirective('bar')
4270
+
4271
+ return withDirectives(h(comp), [
4272
+ [foo, this.x],
4273
+ [bar, this.y]
4274
+ ])
4275
+ */
4276
+ function validateDirectiveName(name) {
4277
+ if (isBuiltInDirective(name)) {
4278
+ warn$1('Do not use built-in directive ids as custom directive id: ' + name);
4279
+ }
4280
+ }
4281
+ /**
4282
+ * Adds directives to a VNode.
4283
+ */
4284
+ function withDirectives(vnode, directives) {
4285
+ const internalInstance = currentRenderingInstance;
4286
+ if (internalInstance === null) {
4287
+ warn$1(`withDirectives can only be used inside render functions.`);
4288
+ return vnode;
4289
+ }
4290
+ const instance = getExposeProxy(internalInstance) ||
4291
+ internalInstance.proxy;
4292
+ const bindings = vnode.dirs || (vnode.dirs = []);
4293
+ for (let i = 0; i < directives.length; i++) {
4294
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4295
+ if (isFunction(dir)) {
4296
+ dir = {
4297
+ mounted: dir,
4298
+ updated: dir
4299
+ };
4252
4300
  }
4253
- else {
4254
- cache[key] = type;
4301
+ if (dir.deep) {
4302
+ traverse(value);
4255
4303
  }
4256
- };
4257
- }
4258
- let shouldCacheAccess = true;
4259
- function applyOptions(instance) {
4260
- const options = resolveMergedOptions(instance);
4261
- const publicThis = instance.proxy;
4262
- const ctx = instance.ctx;
4263
- // do not cache property access on public proxy during state initialization
4264
- shouldCacheAccess = false;
4265
- // call beforeCreate first before accessing other options since
4266
- // the hook may mutate resolved options (#2791)
4267
- if (options.beforeCreate) {
4268
- callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4304
+ bindings.push({
4305
+ dir,
4306
+ instance,
4307
+ value,
4308
+ oldValue: void 0,
4309
+ arg,
4310
+ modifiers
4311
+ });
4269
4312
  }
4270
- const {
4271
- // state
4272
- data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4273
- // lifecycle
4274
- created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4275
- // public API
4276
- expose, inheritAttrs,
4277
- // assets
4278
- components, directives, filters } = options;
4279
- const checkDuplicateProperties = createDuplicateChecker() ;
4280
- {
4281
- const [propsOptions] = instance.propsOptions;
4282
- if (propsOptions) {
4283
- for (const key in propsOptions) {
4284
- checkDuplicateProperties("Props" /* PROPS */, key);
4285
- }
4313
+ return vnode;
4314
+ }
4315
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4316
+ const bindings = vnode.dirs;
4317
+ const oldBindings = prevVNode && prevVNode.dirs;
4318
+ for (let i = 0; i < bindings.length; i++) {
4319
+ const binding = bindings[i];
4320
+ if (oldBindings) {
4321
+ binding.oldValue = oldBindings[i].value;
4322
+ }
4323
+ let hook = binding.dir[name];
4324
+ if (hook) {
4325
+ // disable tracking inside all lifecycle hooks
4326
+ // since they can potentially be called inside effects.
4327
+ pauseTracking();
4328
+ callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
4329
+ vnode.el,
4330
+ binding,
4331
+ vnode,
4332
+ prevVNode
4333
+ ]);
4334
+ resetTracking();
4286
4335
  }
4287
4336
  }
4288
- // options initialization order (to be consistent with Vue 2):
4289
- // - props (already done outside of this function)
4290
- // - inject
4291
- // - methods
4292
- // - data (deferred since it relies on `this` access)
4293
- // - computed
4294
- // - watch (deferred since it relies on `this` access)
4295
- if (injectOptions) {
4296
- resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
4337
+ }
4338
+
4339
+ const COMPONENTS = 'components';
4340
+ const DIRECTIVES = 'directives';
4341
+ /**
4342
+ * @private
4343
+ */
4344
+ function resolveComponent(name, maybeSelfReference) {
4345
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4346
+ }
4347
+ const NULL_DYNAMIC_COMPONENT = Symbol();
4348
+ /**
4349
+ * @private
4350
+ */
4351
+ function resolveDynamicComponent(component) {
4352
+ if (isString(component)) {
4353
+ return resolveAsset(COMPONENTS, component, false) || component;
4297
4354
  }
4298
- if (methods) {
4299
- for (const key in methods) {
4300
- const methodHandler = methods[key];
4301
- if (isFunction(methodHandler)) {
4302
- // In dev mode, we use the `createRenderContext` function to define
4303
- // methods to the proxy target, and those are read-only but
4304
- // reconfigurable, so it needs to be redefined here
4305
- {
4306
- Object.defineProperty(ctx, key, {
4307
- value: methodHandler.bind(publicThis),
4308
- configurable: true,
4309
- enumerable: true,
4310
- writable: true
4311
- });
4312
- }
4313
- {
4314
- checkDuplicateProperties("Methods" /* METHODS */, key);
4315
- }
4316
- }
4317
- else {
4318
- warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4319
- `Did you reference the function correctly?`);
4320
- }
4321
- }
4355
+ else {
4356
+ // invalid types will fallthrough to createVNode and raise warning
4357
+ return (component || NULL_DYNAMIC_COMPONENT);
4322
4358
  }
4323
- if (dataOptions) {
4324
- if (!isFunction(dataOptions)) {
4325
- warn$1(`The data option must be a function. ` +
4326
- `Plain object usage is no longer supported.`);
4327
- }
4328
- const data = dataOptions.call(publicThis, publicThis);
4329
- if (isPromise(data)) {
4330
- warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4331
- `intend to perform data fetching before component renders, use ` +
4332
- `async setup() + <Suspense>.`);
4359
+ }
4360
+ /**
4361
+ * @private
4362
+ */
4363
+ function resolveDirective(name) {
4364
+ return resolveAsset(DIRECTIVES, name);
4365
+ }
4366
+ // implementation
4367
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4368
+ const instance = currentRenderingInstance || currentInstance;
4369
+ if (instance) {
4370
+ const Component = instance.type;
4371
+ // explicit self name has highest priority
4372
+ if (type === COMPONENTS) {
4373
+ const selfName = getComponentName(Component);
4374
+ if (selfName &&
4375
+ (selfName === name ||
4376
+ selfName === camelize(name) ||
4377
+ selfName === capitalize(camelize(name)))) {
4378
+ return Component;
4379
+ }
4333
4380
  }
4334
- if (!isObject(data)) {
4335
- warn$1(`data() should return an object.`);
4381
+ const res =
4382
+ // local registration
4383
+ // check instance[type] first which is resolved for options API
4384
+ resolve(instance[type] || Component[type], name) ||
4385
+ // global registration
4386
+ resolve(instance.appContext[type], name);
4387
+ if (!res && maybeSelfReference) {
4388
+ // fallback to implicit self-reference
4389
+ return Component;
4336
4390
  }
4337
- else {
4338
- instance.data = reactive(data);
4339
- {
4340
- for (const key in data) {
4341
- checkDuplicateProperties("Data" /* DATA */, key);
4342
- // expose data on ctx during dev
4343
- if (key[0] !== '$' && key[0] !== '_') {
4344
- Object.defineProperty(ctx, key, {
4345
- configurable: true,
4346
- enumerable: true,
4347
- get: () => data[key],
4348
- set: NOOP
4349
- });
4350
- }
4351
- }
4352
- }
4391
+ if (warnMissing && !res) {
4392
+ const extra = type === COMPONENTS
4393
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
4394
+ `component resolution via compilerOptions.isCustomElement.`
4395
+ : ``;
4396
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4353
4397
  }
4398
+ return res;
4354
4399
  }
4355
- // state initialization complete at this point - start caching access
4356
- shouldCacheAccess = true;
4357
- if (computedOptions) {
4358
- for (const key in computedOptions) {
4359
- const opt = computedOptions[key];
4360
- const get = isFunction(opt)
4361
- ? opt.bind(publicThis, publicThis)
4362
- : isFunction(opt.get)
4363
- ? opt.get.bind(publicThis, publicThis)
4364
- : NOOP;
4365
- if (get === NOOP) {
4366
- warn$1(`Computed property "${key}" has no getter.`);
4367
- }
4368
- const set = !isFunction(opt) && isFunction(opt.set)
4369
- ? opt.set.bind(publicThis)
4370
- : () => {
4371
- warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4372
- }
4373
- ;
4374
- const c = computed$1({
4375
- get,
4376
- set
4377
- });
4378
- Object.defineProperty(ctx, key, {
4379
- enumerable: true,
4380
- configurable: true,
4381
- get: () => c.value,
4382
- set: v => (c.value = v)
4383
- });
4384
- {
4385
- checkDuplicateProperties("Computed" /* COMPUTED */, key);
4386
- }
4387
- }
4388
- }
4389
- if (watchOptions) {
4390
- for (const key in watchOptions) {
4391
- createWatcher(watchOptions[key], ctx, publicThis, key);
4392
- }
4393
- }
4394
- if (provideOptions) {
4395
- const provides = isFunction(provideOptions)
4396
- ? provideOptions.call(publicThis)
4397
- : provideOptions;
4398
- Reflect.ownKeys(provides).forEach(key => {
4399
- provide(key, provides[key]);
4400
- });
4401
- }
4402
- if (created) {
4403
- callHook(created, instance, "c" /* CREATED */);
4400
+ else {
4401
+ warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
4402
+ `can only be used in render() or setup().`);
4404
4403
  }
4405
- function registerLifecycleHook(register, hook) {
4406
- if (isArray(hook)) {
4407
- hook.forEach(_hook => register(_hook.bind(publicThis)));
4408
- }
4409
- else if (hook) {
4410
- register(hook.bind(publicThis));
4404
+ }
4405
+ function resolve(registry, name) {
4406
+ return (registry &&
4407
+ (registry[name] ||
4408
+ registry[camelize(name)] ||
4409
+ registry[capitalize(camelize(name))]));
4410
+ }
4411
+
4412
+ /**
4413
+ * Actual implementation
4414
+ */
4415
+ function renderList(source, renderItem, cache, index) {
4416
+ let ret;
4417
+ const cached = (cache && cache[index]);
4418
+ if (isArray(source) || isString(source)) {
4419
+ ret = new Array(source.length);
4420
+ for (let i = 0, l = source.length; i < l; i++) {
4421
+ ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
4411
4422
  }
4412
4423
  }
4413
- registerLifecycleHook(onBeforeMount, beforeMount);
4414
- registerLifecycleHook(onMounted, mounted);
4415
- registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4416
- registerLifecycleHook(onUpdated, updated);
4417
- registerLifecycleHook(onActivated, activated);
4418
- registerLifecycleHook(onDeactivated, deactivated);
4419
- registerLifecycleHook(onErrorCaptured, errorCaptured);
4420
- registerLifecycleHook(onRenderTracked, renderTracked);
4421
- registerLifecycleHook(onRenderTriggered, renderTriggered);
4422
- registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4423
- registerLifecycleHook(onUnmounted, unmounted);
4424
- registerLifecycleHook(onServerPrefetch, serverPrefetch);
4425
- if (isArray(expose)) {
4426
- if (expose.length) {
4427
- const exposed = instance.exposed || (instance.exposed = {});
4428
- expose.forEach(key => {
4429
- Object.defineProperty(exposed, key, {
4430
- get: () => publicThis[key],
4431
- set: val => (publicThis[key] = val)
4432
- });
4433
- });
4424
+ else if (typeof source === 'number') {
4425
+ if (!Number.isInteger(source)) {
4426
+ warn$1(`The v-for range expect an integer value but got ${source}.`);
4434
4427
  }
4435
- else if (!instance.exposed) {
4436
- instance.exposed = {};
4428
+ ret = new Array(source);
4429
+ for (let i = 0; i < source; i++) {
4430
+ ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
4437
4431
  }
4438
4432
  }
4439
- // options that are handled when creating the instance but also need to be
4440
- // applied from mixins
4441
- if (render && instance.render === NOOP) {
4442
- instance.render = render;
4443
- }
4444
- if (inheritAttrs != null) {
4445
- instance.inheritAttrs = inheritAttrs;
4446
- }
4447
- // asset options.
4448
- if (components)
4449
- instance.components = components;
4450
- if (directives)
4451
- instance.directives = directives;
4452
- }
4453
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4454
- if (isArray(injectOptions)) {
4455
- injectOptions = normalizeInject(injectOptions);
4456
- }
4457
- for (const key in injectOptions) {
4458
- const opt = injectOptions[key];
4459
- let injected;
4460
- if (isObject(opt)) {
4461
- if ('default' in opt) {
4462
- injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4463
- }
4464
- else {
4465
- injected = inject(opt.from || key);
4466
- }
4433
+ else if (isObject(source)) {
4434
+ if (source[Symbol.iterator]) {
4435
+ ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
4467
4436
  }
4468
4437
  else {
4469
- injected = inject(opt);
4470
- }
4471
- if (isRef(injected)) {
4472
- // TODO remove the check in 3.3
4473
- if (unwrapRef) {
4474
- Object.defineProperty(ctx, key, {
4475
- enumerable: true,
4476
- configurable: true,
4477
- get: () => injected.value,
4478
- set: v => (injected.value = v)
4479
- });
4480
- }
4481
- else {
4482
- {
4483
- warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4484
- `and no longer needs \`.value\` in the next minor release. ` +
4485
- `To opt-in to the new behavior now, ` +
4486
- `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4487
- `temporary and will not be needed in the future.)`);
4488
- }
4489
- ctx[key] = injected;
4438
+ const keys = Object.keys(source);
4439
+ ret = new Array(keys.length);
4440
+ for (let i = 0, l = keys.length; i < l; i++) {
4441
+ const key = keys[i];
4442
+ ret[i] = renderItem(source[key], key, i, cached && cached[i]);
4490
4443
  }
4491
4444
  }
4492
- else {
4493
- ctx[key] = injected;
4494
- }
4495
- {
4496
- checkDuplicateProperties("Inject" /* INJECT */, key);
4497
- }
4498
4445
  }
4499
- }
4500
- function callHook(hook, instance, type) {
4501
- callWithAsyncErrorHandling(isArray(hook)
4502
- ? hook.map(h => h.bind(instance.proxy))
4503
- : hook.bind(instance.proxy), instance, type);
4504
- }
4505
- function createWatcher(raw, ctx, publicThis, key) {
4506
- const getter = key.includes('.')
4507
- ? createPathGetter(publicThis, key)
4508
- : () => publicThis[key];
4509
- if (isString(raw)) {
4510
- const handler = ctx[raw];
4511
- if (isFunction(handler)) {
4512
- watch(getter, handler);
4513
- }
4514
- else {
4515
- warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4516
- }
4446
+ else {
4447
+ ret = [];
4517
4448
  }
4518
- else if (isFunction(raw)) {
4519
- watch(getter, raw.bind(publicThis));
4449
+ if (cache) {
4450
+ cache[index] = ret;
4520
4451
  }
4521
- else if (isObject(raw)) {
4522
- if (isArray(raw)) {
4523
- raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4524
- }
4525
- else {
4526
- const handler = isFunction(raw.handler)
4527
- ? raw.handler.bind(publicThis)
4528
- : ctx[raw.handler];
4529
- if (isFunction(handler)) {
4530
- watch(getter, handler, raw);
4531
- }
4532
- else {
4533
- warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
4452
+ return ret;
4453
+ }
4454
+
4455
+ /**
4456
+ * Compiler runtime helper for creating dynamic slots object
4457
+ * @private
4458
+ */
4459
+ function createSlots(slots, dynamicSlots) {
4460
+ for (let i = 0; i < dynamicSlots.length; i++) {
4461
+ const slot = dynamicSlots[i];
4462
+ // array of dynamic slot generated by <template v-for="..." #[...]>
4463
+ if (isArray(slot)) {
4464
+ for (let j = 0; j < slot.length; j++) {
4465
+ slots[slot[j].name] = slot[j].fn;
4534
4466
  }
4535
4467
  }
4468
+ else if (slot) {
4469
+ // conditional single slot generated by <template v-if="..." #foo>
4470
+ slots[slot.name] = slot.fn;
4471
+ }
4536
4472
  }
4537
- else {
4538
- warn$1(`Invalid watch option: "${key}"`, raw);
4539
- }
4540
- }
4473
+ return slots;
4474
+ }
4475
+
4541
4476
  /**
4542
- * Resolve merged options and cache it on the component.
4543
- * This is done only once per-component since the merging does not involve
4544
- * instances.
4477
+ * Compiler runtime helper for rendering `<slot/>`
4478
+ * @private
4545
4479
  */
4546
- function resolveMergedOptions(instance) {
4547
- const base = instance.type;
4548
- const { mixins, extends: extendsOptions } = base;
4549
- const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4550
- const cached = cache.get(base);
4551
- let resolved;
4552
- if (cached) {
4553
- resolved = cached;
4480
+ function renderSlot(slots, name, props = {},
4481
+ // this is not a user-facing function, so the fallback is always generated by
4482
+ // the compiler and guaranteed to be a function returning an array
4483
+ fallback, noSlotted) {
4484
+ if (currentRenderingInstance.isCE ||
4485
+ (currentRenderingInstance.parent &&
4486
+ isAsyncWrapper(currentRenderingInstance.parent) &&
4487
+ currentRenderingInstance.parent.isCE)) {
4488
+ return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
4554
4489
  }
4555
- else if (!globalMixins.length && !mixins && !extendsOptions) {
4556
- {
4557
- resolved = base;
4558
- }
4490
+ let slot = slots[name];
4491
+ if (slot && slot.length > 1) {
4492
+ warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
4493
+ `function. You need to mark this component with $dynamic-slots in the ` +
4494
+ `parent template.`);
4495
+ slot = () => [];
4559
4496
  }
4560
- else {
4561
- resolved = {};
4562
- if (globalMixins.length) {
4563
- globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4564
- }
4565
- mergeOptions(resolved, base, optionMergeStrategies);
4566
- }
4567
- cache.set(base, resolved);
4568
- return resolved;
4569
- }
4570
- function mergeOptions(to, from, strats, asMixin = false) {
4571
- const { mixins, extends: extendsOptions } = from;
4572
- if (extendsOptions) {
4573
- mergeOptions(to, extendsOptions, strats, true);
4574
- }
4575
- if (mixins) {
4576
- mixins.forEach((m) => mergeOptions(to, m, strats, true));
4577
- }
4578
- for (const key in from) {
4579
- if (asMixin && key === 'expose') {
4580
- warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4581
- `It should only be declared in the base component itself.`);
4582
- }
4583
- else {
4584
- const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4585
- to[key] = strat ? strat(to[key], from[key]) : from[key];
4586
- }
4587
- }
4588
- return to;
4589
- }
4590
- const internalOptionMergeStrats = {
4591
- data: mergeDataFn,
4592
- props: mergeObjectOptions,
4593
- emits: mergeObjectOptions,
4594
- // objects
4595
- methods: mergeObjectOptions,
4596
- computed: mergeObjectOptions,
4597
- // lifecycle
4598
- beforeCreate: mergeAsArray,
4599
- created: mergeAsArray,
4600
- beforeMount: mergeAsArray,
4601
- mounted: mergeAsArray,
4602
- beforeUpdate: mergeAsArray,
4603
- updated: mergeAsArray,
4604
- beforeDestroy: mergeAsArray,
4605
- beforeUnmount: mergeAsArray,
4606
- destroyed: mergeAsArray,
4607
- unmounted: mergeAsArray,
4608
- activated: mergeAsArray,
4609
- deactivated: mergeAsArray,
4610
- errorCaptured: mergeAsArray,
4611
- serverPrefetch: mergeAsArray,
4612
- // assets
4613
- components: mergeObjectOptions,
4614
- directives: mergeObjectOptions,
4615
- // watch
4616
- watch: mergeWatchOptions,
4617
- // provide / inject
4618
- provide: mergeDataFn,
4619
- inject: mergeInject
4620
- };
4621
- function mergeDataFn(to, from) {
4622
- if (!from) {
4623
- return to;
4497
+ // a compiled slot disables block tracking by default to avoid manual
4498
+ // invocation interfering with template-based block tracking, but in
4499
+ // `renderSlot` we can be sure that it's template-based so we can force
4500
+ // enable it.
4501
+ if (slot && slot._c) {
4502
+ slot._d = false;
4624
4503
  }
4625
- if (!to) {
4626
- return from;
4504
+ openBlock();
4505
+ const validSlotContent = slot && ensureValidVNode(slot(props));
4506
+ const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
4507
+ ? 64 /* STABLE_FRAGMENT */
4508
+ : -2 /* BAIL */);
4509
+ if (!noSlotted && rendered.scopeId) {
4510
+ rendered.slotScopeIds = [rendered.scopeId + '-s'];
4627
4511
  }
4628
- return function mergedDataFn() {
4629
- return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4630
- };
4631
- }
4632
- function mergeInject(to, from) {
4633
- return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4634
- }
4635
- function normalizeInject(raw) {
4636
- if (isArray(raw)) {
4637
- const res = {};
4638
- for (let i = 0; i < raw.length; i++) {
4639
- res[raw[i]] = raw[i];
4640
- }
4641
- return res;
4512
+ if (slot && slot._c) {
4513
+ slot._d = true;
4642
4514
  }
4643
- return raw;
4644
- }
4645
- function mergeAsArray(to, from) {
4646
- return to ? [...new Set([].concat(to, from))] : from;
4647
- }
4648
- function mergeObjectOptions(to, from) {
4649
- return to ? extend(extend(Object.create(null), to), from) : from;
4515
+ return rendered;
4650
4516
  }
4651
- function mergeWatchOptions(to, from) {
4652
- if (!to)
4653
- return from;
4654
- if (!from)
4655
- return to;
4656
- const merged = extend(Object.create(null), to);
4657
- for (const key in from) {
4658
- merged[key] = mergeAsArray(to[key], from[key]);
4659
- }
4660
- return merged;
4517
+ function ensureValidVNode(vnodes) {
4518
+ return vnodes.some(child => {
4519
+ if (!isVNode(child))
4520
+ return true;
4521
+ if (child.type === Comment)
4522
+ return false;
4523
+ if (child.type === Fragment &&
4524
+ !ensureValidVNode(child.children))
4525
+ return false;
4526
+ return true;
4527
+ })
4528
+ ? vnodes
4529
+ : null;
4661
4530
  }
4662
4531
 
4663
- function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4664
- isSSR = false) {
4665
- const props = {};
4666
- const attrs = {};
4667
- def(attrs, InternalObjectKey, 1);
4668
- instance.propsDefaults = Object.create(null);
4669
- setFullProps(instance, rawProps, props, attrs);
4670
- // ensure all declared prop keys are present
4671
- for (const key in instance.propsOptions[0]) {
4672
- if (!(key in props)) {
4673
- props[key] = undefined;
4674
- }
4675
- }
4676
- // validation
4677
- {
4678
- validateProps(rawProps || {}, props, instance);
4532
+ /**
4533
+ * For prefixing keys in v-on="obj" with "on"
4534
+ * @private
4535
+ */
4536
+ function toHandlers(obj) {
4537
+ const ret = {};
4538
+ if (!isObject(obj)) {
4539
+ warn$1(`v-on with no argument expects an object value.`);
4540
+ return ret;
4679
4541
  }
4680
- if (isStateful) {
4681
- // stateful
4682
- instance.props = isSSR ? props : shallowReactive(props);
4542
+ for (const key in obj) {
4543
+ ret[toHandlerKey(key)] = obj[key];
4683
4544
  }
4684
- else {
4685
- if (!instance.type.props) {
4686
- // functional w/ optional props, props === attrs
4687
- instance.props = attrs;
4545
+ return ret;
4546
+ }
4547
+
4548
+ /**
4549
+ * #2437 In Vue 3, functional components do not have a public instance proxy but
4550
+ * they exist in the internal parent chain. For code that relies on traversing
4551
+ * public $parent chains, skip functional ones and go to the parent instead.
4552
+ */
4553
+ const getPublicInstance = (i) => {
4554
+ if (!i)
4555
+ return null;
4556
+ if (isStatefulComponent(i))
4557
+ return getExposeProxy(i) || i.proxy;
4558
+ return getPublicInstance(i.parent);
4559
+ };
4560
+ const publicPropertiesMap =
4561
+ // Move PURE marker to new line to workaround compiler discarding it
4562
+ // due to type annotation
4563
+ /*#__PURE__*/ extend(Object.create(null), {
4564
+ $: i => i,
4565
+ $el: i => i.vnode.el,
4566
+ $data: i => i.data,
4567
+ $props: i => (shallowReadonly(i.props) ),
4568
+ $attrs: i => (shallowReadonly(i.attrs) ),
4569
+ $slots: i => (shallowReadonly(i.slots) ),
4570
+ $refs: i => (shallowReadonly(i.refs) ),
4571
+ $parent: i => getPublicInstance(i.parent),
4572
+ $root: i => getPublicInstance(i.root),
4573
+ $emit: i => i.emit,
4574
+ $options: i => (resolveMergedOptions(i) ),
4575
+ $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
4576
+ $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
4577
+ $watch: i => (instanceWatch.bind(i) )
4578
+ });
4579
+ const isReservedPrefix = (key) => key === '_' || key === '$';
4580
+ const PublicInstanceProxyHandlers = {
4581
+ get({ _: instance }, key) {
4582
+ const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
4583
+ // for internal formatters to know that this is a Vue instance
4584
+ if (key === '__isVue') {
4585
+ return true;
4688
4586
  }
4689
- else {
4690
- // functional w/ declared props
4691
- instance.props = props;
4587
+ // prioritize <script setup> bindings during dev.
4588
+ // this allows even properties that start with _ or $ to be used - so that
4589
+ // it aligns with the production behavior where the render fn is inlined and
4590
+ // indeed has access to all declared variables.
4591
+ if (setupState !== EMPTY_OBJ &&
4592
+ setupState.__isScriptSetup &&
4593
+ hasOwn(setupState, key)) {
4594
+ return setupState[key];
4692
4595
  }
4693
- }
4694
- instance.attrs = attrs;
4695
- }
4696
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
4697
- const { props, attrs, vnode: { patchFlag } } = instance;
4698
- const rawCurrentProps = toRaw(props);
4699
- const [options] = instance.propsOptions;
4700
- let hasAttrsChanged = false;
4701
- if (
4702
- // always force full diff in dev
4703
- // - #1942 if hmr is enabled with sfc component
4704
- // - vite#872 non-sfc component used by sfc component
4705
- !((instance.type.__hmrId ||
4706
- (instance.parent && instance.parent.type.__hmrId))) &&
4707
- (optimized || patchFlag > 0) &&
4708
- !(patchFlag & 16 /* FULL_PROPS */)) {
4709
- if (patchFlag & 8 /* PROPS */) {
4710
- // Compiler-generated props & no keys change, just set the updated
4711
- // the props.
4712
- const propsToUpdate = instance.vnode.dynamicProps;
4713
- for (let i = 0; i < propsToUpdate.length; i++) {
4714
- let key = propsToUpdate[i];
4715
- // skip if the prop key is a declared emit event listener
4716
- if (isEmitListener(instance.emitsOptions, key)) {
4717
- continue;
4718
- }
4719
- // PROPS flag guarantees rawProps to be non-null
4720
- const value = rawProps[key];
4721
- if (options) {
4722
- // attr / props separation was done on init and will be consistent
4723
- // in this code path, so just check if attrs have it.
4724
- if (hasOwn(attrs, key)) {
4725
- if (value !== attrs[key]) {
4726
- attrs[key] = value;
4727
- hasAttrsChanged = true;
4728
- }
4729
- }
4730
- else {
4731
- const camelizedKey = camelize(key);
4732
- props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4733
- }
4734
- }
4735
- else {
4736
- if (value !== attrs[key]) {
4737
- attrs[key] = value;
4738
- hasAttrsChanged = true;
4739
- }
4596
+ // data / props / ctx
4597
+ // This getter gets called for every property access on the render context
4598
+ // during render and is a major hotspot. The most expensive part of this
4599
+ // is the multiple hasOwn() calls. It's much faster to do a simple property
4600
+ // access on a plain object, so we use an accessCache object (with null
4601
+ // prototype) to memoize what access type a key corresponds to.
4602
+ let normalizedProps;
4603
+ if (key[0] !== '$') {
4604
+ const n = accessCache[key];
4605
+ if (n !== undefined) {
4606
+ switch (n) {
4607
+ case 1 /* SETUP */:
4608
+ return setupState[key];
4609
+ case 2 /* DATA */:
4610
+ return data[key];
4611
+ case 4 /* CONTEXT */:
4612
+ return ctx[key];
4613
+ case 3 /* PROPS */:
4614
+ return props[key];
4615
+ // default: just fallthrough
4740
4616
  }
4741
4617
  }
4742
- }
4743
- }
4744
- else {
4745
- // full props update.
4746
- if (setFullProps(instance, rawProps, props, attrs)) {
4747
- hasAttrsChanged = true;
4748
- }
4749
- // in case of dynamic props, check if we need to delete keys from
4750
- // the props object
4751
- let kebabKey;
4752
- for (const key in rawCurrentProps) {
4753
- if (!rawProps ||
4754
- // for camelCase
4755
- (!hasOwn(rawProps, key) &&
4756
- // it's possible the original props was passed in as kebab-case
4757
- // and converted to camelCase (#955)
4758
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4759
- if (options) {
4760
- if (rawPrevProps &&
4761
- // for camelCase
4762
- (rawPrevProps[key] !== undefined ||
4763
- // for kebab-case
4764
- rawPrevProps[kebabKey] !== undefined)) {
4765
- props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4766
- }
4767
- }
4768
- else {
4769
- delete props[key];
4770
- }
4618
+ else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4619
+ accessCache[key] = 1 /* SETUP */;
4620
+ return setupState[key];
4771
4621
  }
4772
- }
4773
- // in the case of functional component w/o props declaration, props and
4774
- // attrs point to the same object so it should already have been updated.
4775
- if (attrs !== rawCurrentProps) {
4776
- for (const key in attrs) {
4777
- if (!rawProps ||
4778
- (!hasOwn(rawProps, key) &&
4779
- (!false ))) {
4780
- delete attrs[key];
4781
- hasAttrsChanged = true;
4782
- }
4622
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4623
+ accessCache[key] = 2 /* DATA */;
4624
+ return data[key];
4783
4625
  }
4784
- }
4785
- }
4786
- // trigger updates for $attrs in case it's used in component slots
4787
- if (hasAttrsChanged) {
4788
- trigger(instance, "set" /* SET */, '$attrs');
4789
- }
4790
- {
4791
- validateProps(rawProps || {}, props, instance);
4792
- }
4793
- }
4794
- function setFullProps(instance, rawProps, props, attrs) {
4795
- const [options, needCastKeys] = instance.propsOptions;
4796
- let hasAttrsChanged = false;
4797
- let rawCastValues;
4798
- if (rawProps) {
4799
- for (let key in rawProps) {
4800
- // key, ref are reserved and never passed down
4801
- if (isReservedProp(key)) {
4802
- continue;
4626
+ else if (
4627
+ // only cache other properties when instance has declared (thus stable)
4628
+ // props
4629
+ (normalizedProps = instance.propsOptions[0]) &&
4630
+ hasOwn(normalizedProps, key)) {
4631
+ accessCache[key] = 3 /* PROPS */;
4632
+ return props[key];
4803
4633
  }
4804
- const value = rawProps[key];
4805
- // prop option names are camelized during normalization, so to support
4806
- // kebab -> camel conversion here we need to camelize the key.
4807
- let camelKey;
4808
- if (options && hasOwn(options, (camelKey = camelize(key)))) {
4809
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4810
- props[camelKey] = value;
4811
- }
4812
- else {
4813
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4814
- }
4634
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4635
+ accessCache[key] = 4 /* CONTEXT */;
4636
+ return ctx[key];
4815
4637
  }
4816
- else if (!isEmitListener(instance.emitsOptions, key)) {
4817
- if (!(key in attrs) || value !== attrs[key]) {
4818
- attrs[key] = value;
4819
- hasAttrsChanged = true;
4820
- }
4638
+ else if (shouldCacheAccess) {
4639
+ accessCache[key] = 0 /* OTHER */;
4821
4640
  }
4822
4641
  }
4823
- }
4824
- if (needCastKeys) {
4825
- const rawCurrentProps = toRaw(props);
4826
- const castValues = rawCastValues || EMPTY_OBJ;
4827
- for (let i = 0; i < needCastKeys.length; i++) {
4828
- const key = needCastKeys[i];
4829
- props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4830
- }
4831
- }
4832
- return hasAttrsChanged;
4833
- }
4834
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
4835
- const opt = options[key];
4836
- if (opt != null) {
4837
- const hasDefault = hasOwn(opt, 'default');
4838
- // default values
4839
- if (hasDefault && value === undefined) {
4840
- const defaultValue = opt.default;
4841
- if (opt.type !== Function && isFunction(defaultValue)) {
4842
- const { propsDefaults } = instance;
4843
- if (key in propsDefaults) {
4844
- value = propsDefaults[key];
4845
- }
4846
- else {
4847
- setCurrentInstance(instance);
4848
- value = propsDefaults[key] = defaultValue.call(null, props);
4849
- unsetCurrentInstance();
4850
- }
4642
+ const publicGetter = publicPropertiesMap[key];
4643
+ let cssModule, globalProperties;
4644
+ // public $xxx properties
4645
+ if (publicGetter) {
4646
+ if (key === '$attrs') {
4647
+ track(instance, "get" /* GET */, key);
4648
+ markAttrsAccessed();
4851
4649
  }
4852
- else {
4853
- value = defaultValue;
4650
+ return publicGetter(instance);
4651
+ }
4652
+ else if (
4653
+ // css module (injected by vue-loader)
4654
+ (cssModule = type.__cssModules) &&
4655
+ (cssModule = cssModule[key])) {
4656
+ return cssModule;
4657
+ }
4658
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4659
+ // user may set custom properties to `this` that start with `$`
4660
+ accessCache[key] = 4 /* CONTEXT */;
4661
+ return ctx[key];
4662
+ }
4663
+ else if (
4664
+ // global properties
4665
+ ((globalProperties = appContext.config.globalProperties),
4666
+ hasOwn(globalProperties, key))) {
4667
+ {
4668
+ return globalProperties[key];
4854
4669
  }
4855
4670
  }
4856
- // boolean casting
4857
- if (opt[0 /* shouldCast */]) {
4858
- if (isAbsent && !hasDefault) {
4859
- value = false;
4671
+ else if (currentRenderingInstance &&
4672
+ (!isString(key) ||
4673
+ // #1091 avoid internal isRef/isVNode checks on component instance leading
4674
+ // to infinite warning loop
4675
+ key.indexOf('__v') !== 0)) {
4676
+ if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
4677
+ warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
4678
+ `character ("$" or "_") and is not proxied on the render context.`);
4860
4679
  }
4861
- else if (opt[1 /* shouldCastTrue */] &&
4862
- (value === '' || value === hyphenate(key))) {
4863
- value = true;
4680
+ else if (instance === currentRenderingInstance) {
4681
+ warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
4682
+ `but is not defined on instance.`);
4864
4683
  }
4865
4684
  }
4866
- }
4867
- return value;
4868
- }
4869
- function normalizePropsOptions(comp, appContext, asMixin = false) {
4870
- const cache = appContext.propsCache;
4871
- const cached = cache.get(comp);
4872
- if (cached) {
4873
- return cached;
4874
- }
4875
- const raw = comp.props;
4876
- const normalized = {};
4877
- const needCastKeys = [];
4878
- // apply mixin/extends props
4879
- let hasExtends = false;
4880
- if (!isFunction(comp)) {
4881
- const extendProps = (raw) => {
4882
- hasExtends = true;
4883
- const [props, keys] = normalizePropsOptions(raw, appContext, true);
4884
- extend(normalized, props);
4885
- if (keys)
4886
- needCastKeys.push(...keys);
4887
- };
4888
- if (!asMixin && appContext.mixins.length) {
4889
- appContext.mixins.forEach(extendProps);
4685
+ },
4686
+ set({ _: instance }, key, value) {
4687
+ const { data, setupState, ctx } = instance;
4688
+ if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4689
+ setupState[key] = value;
4690
+ return true;
4890
4691
  }
4891
- if (comp.extends) {
4892
- extendProps(comp.extends);
4692
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4693
+ data[key] = value;
4694
+ return true;
4893
4695
  }
4894
- if (comp.mixins) {
4895
- comp.mixins.forEach(extendProps);
4696
+ else if (hasOwn(instance.props, key)) {
4697
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
4698
+ return false;
4896
4699
  }
4897
- }
4898
- if (!raw && !hasExtends) {
4899
- cache.set(comp, EMPTY_ARR);
4900
- return EMPTY_ARR;
4901
- }
4902
- if (isArray(raw)) {
4903
- for (let i = 0; i < raw.length; i++) {
4904
- if (!isString(raw[i])) {
4905
- warn$1(`props must be strings when using array syntax.`, raw[i]);
4700
+ if (key[0] === '$' && key.slice(1) in instance) {
4701
+ warn$1(`Attempting to mutate public property "${key}". ` +
4702
+ `Properties starting with $ are reserved and readonly.`, instance);
4703
+ return false;
4704
+ }
4705
+ else {
4706
+ if (key in instance.appContext.config.globalProperties) {
4707
+ Object.defineProperty(ctx, key, {
4708
+ enumerable: true,
4709
+ configurable: true,
4710
+ value
4711
+ });
4906
4712
  }
4907
- const normalizedKey = camelize(raw[i]);
4908
- if (validatePropName(normalizedKey)) {
4909
- normalized[normalizedKey] = EMPTY_OBJ;
4713
+ else {
4714
+ ctx[key] = value;
4910
4715
  }
4911
4716
  }
4912
- }
4913
- else if (raw) {
4914
- if (!isObject(raw)) {
4915
- warn$1(`invalid props options`, raw);
4717
+ return true;
4718
+ },
4719
+ has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
4720
+ let normalizedProps;
4721
+ return (!!accessCache[key] ||
4722
+ (data !== EMPTY_OBJ && hasOwn(data, key)) ||
4723
+ (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
4724
+ ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
4725
+ hasOwn(ctx, key) ||
4726
+ hasOwn(publicPropertiesMap, key) ||
4727
+ hasOwn(appContext.config.globalProperties, key));
4728
+ },
4729
+ defineProperty(target, key, descriptor) {
4730
+ if (descriptor.get != null) {
4731
+ // invalidate key cache of a getter based property #5417
4732
+ target._.accessCache[key] = 0;
4916
4733
  }
4917
- for (const key in raw) {
4918
- const normalizedKey = camelize(key);
4919
- if (validatePropName(normalizedKey)) {
4920
- const opt = raw[key];
4921
- const prop = (normalized[normalizedKey] =
4922
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4923
- if (prop) {
4924
- const booleanIndex = getTypeIndex(Boolean, prop.type);
4925
- const stringIndex = getTypeIndex(String, prop.type);
4926
- prop[0 /* shouldCast */] = booleanIndex > -1;
4927
- prop[1 /* shouldCastTrue */] =
4928
- stringIndex < 0 || booleanIndex < stringIndex;
4929
- // if the prop needs boolean casting or default value
4930
- if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4931
- needCastKeys.push(normalizedKey);
4932
- }
4933
- }
4934
- }
4734
+ else if (hasOwn(descriptor, 'value')) {
4735
+ this.set(target, key, descriptor.value, null);
4935
4736
  }
4737
+ return Reflect.defineProperty(target, key, descriptor);
4936
4738
  }
4937
- const res = [normalized, needCastKeys];
4938
- cache.set(comp, res);
4939
- return res;
4940
- }
4941
- function validatePropName(key) {
4942
- if (key[0] !== '$') {
4943
- return true;
4944
- }
4945
- else {
4946
- warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4947
- }
4948
- return false;
4949
- }
4950
- // use function string name to check type constructors
4951
- // so that it works across vms / iframes.
4952
- function getType(ctor) {
4953
- const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4954
- return match ? match[1] : ctor === null ? 'null' : '';
4955
- }
4956
- function isSameType(a, b) {
4957
- return getType(a) === getType(b);
4739
+ };
4740
+ {
4741
+ PublicInstanceProxyHandlers.ownKeys = (target) => {
4742
+ warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
4743
+ `The keys will be empty in production mode to avoid performance overhead.`);
4744
+ return Reflect.ownKeys(target);
4745
+ };
4958
4746
  }
4959
- function getTypeIndex(type, expectedTypes) {
4960
- if (isArray(expectedTypes)) {
4961
- return expectedTypes.findIndex(t => isSameType(t, type));
4962
- }
4963
- else if (isFunction(expectedTypes)) {
4964
- return isSameType(expectedTypes, type) ? 0 : -1;
4747
+ const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
4748
+ get(target, key) {
4749
+ // fast path for unscopables when using `with` block
4750
+ if (key === Symbol.unscopables) {
4751
+ return;
4752
+ }
4753
+ return PublicInstanceProxyHandlers.get(target, key, target);
4754
+ },
4755
+ has(_, key) {
4756
+ const has = key[0] !== '_' && !isGloballyWhitelisted(key);
4757
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
4758
+ warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
4759
+ }
4760
+ return has;
4965
4761
  }
4966
- return -1;
4762
+ });
4763
+ // dev only
4764
+ // In dev mode, the proxy target exposes the same properties as seen on `this`
4765
+ // for easier console inspection. In prod mode it will be an empty object so
4766
+ // these properties definitions can be skipped.
4767
+ function createDevRenderContext(instance) {
4768
+ const target = {};
4769
+ // expose internal instance for proxy handlers
4770
+ Object.defineProperty(target, `_`, {
4771
+ configurable: true,
4772
+ enumerable: false,
4773
+ get: () => instance
4774
+ });
4775
+ // expose public properties
4776
+ Object.keys(publicPropertiesMap).forEach(key => {
4777
+ Object.defineProperty(target, key, {
4778
+ configurable: true,
4779
+ enumerable: false,
4780
+ get: () => publicPropertiesMap[key](instance),
4781
+ // intercepted by the proxy so no need for implementation,
4782
+ // but needed to prevent set errors
4783
+ set: NOOP
4784
+ });
4785
+ });
4786
+ return target;
4967
4787
  }
4968
- /**
4969
- * dev only
4970
- */
4971
- function validateProps(rawProps, props, instance) {
4972
- const resolvedValues = toRaw(props);
4973
- const options = instance.propsOptions[0];
4974
- for (const key in options) {
4975
- let opt = options[key];
4976
- if (opt == null)
4977
- continue;
4978
- validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
4788
+ // dev only
4789
+ function exposePropsOnRenderContext(instance) {
4790
+ const { ctx, propsOptions: [propsOptions] } = instance;
4791
+ if (propsOptions) {
4792
+ Object.keys(propsOptions).forEach(key => {
4793
+ Object.defineProperty(ctx, key, {
4794
+ enumerable: true,
4795
+ configurable: true,
4796
+ get: () => instance.props[key],
4797
+ set: NOOP
4798
+ });
4799
+ });
4979
4800
  }
4980
4801
  }
4981
- /**
4982
- * dev only
4983
- */
4984
- function validateProp(name, value, prop, isAbsent) {
4985
- const { type, required, validator } = prop;
4986
- // required!
4987
- if (required && isAbsent) {
4988
- warn$1('Missing required prop: "' + name + '"');
4989
- return;
4990
- }
4991
- // missing but optional
4992
- if (value == null && !prop.required) {
4993
- return;
4994
- }
4995
- // type check
4996
- if (type != null && type !== true) {
4997
- let isValid = false;
4998
- const types = isArray(type) ? type : [type];
4999
- const expectedTypes = [];
5000
- // value is valid as long as one of the specified types match
5001
- for (let i = 0; i < types.length && !isValid; i++) {
5002
- const { valid, expectedType } = assertType(value, types[i]);
5003
- expectedTypes.push(expectedType || '');
5004
- isValid = valid;
4802
+ // dev only
4803
+ function exposeSetupStateOnRenderContext(instance) {
4804
+ const { ctx, setupState } = instance;
4805
+ Object.keys(toRaw(setupState)).forEach(key => {
4806
+ if (!setupState.__isScriptSetup) {
4807
+ if (isReservedPrefix(key[0])) {
4808
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
4809
+ `which are reserved prefixes for Vue internals.`);
4810
+ return;
4811
+ }
4812
+ Object.defineProperty(ctx, key, {
4813
+ enumerable: true,
4814
+ configurable: true,
4815
+ get: () => setupState[key],
4816
+ set: NOOP
4817
+ });
5005
4818
  }
5006
- if (!isValid) {
5007
- warn$1(getInvalidTypeMessage(name, value, expectedTypes));
5008
- return;
4819
+ });
4820
+ }
4821
+
4822
+ function createDuplicateChecker() {
4823
+ const cache = Object.create(null);
4824
+ return (type, key) => {
4825
+ if (cache[key]) {
4826
+ warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
5009
4827
  }
5010
- }
5011
- // custom validator
5012
- if (validator && !validator(value)) {
5013
- warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
5014
- }
5015
- }
5016
- const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
5017
- /**
5018
- * dev only
5019
- */
5020
- function assertType(value, type) {
5021
- let valid;
5022
- const expectedType = getType(type);
5023
- if (isSimpleType(expectedType)) {
5024
- const t = typeof value;
5025
- valid = t === expectedType.toLowerCase();
5026
- // for primitive wrapper objects
5027
- if (!valid && t === 'object') {
5028
- valid = value instanceof type;
4828
+ else {
4829
+ cache[key] = type;
5029
4830
  }
5030
- }
5031
- else if (expectedType === 'Object') {
5032
- valid = isObject(value);
5033
- }
5034
- else if (expectedType === 'Array') {
5035
- valid = isArray(value);
5036
- }
5037
- else if (expectedType === 'null') {
5038
- valid = value === null;
5039
- }
5040
- else {
5041
- valid = value instanceof type;
5042
- }
5043
- return {
5044
- valid,
5045
- expectedType
5046
4831
  };
5047
4832
  }
5048
- /**
5049
- * dev only
5050
- */
5051
- function getInvalidTypeMessage(name, value, expectedTypes) {
5052
- let message = `Invalid prop: type check failed for prop "${name}".` +
5053
- ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
5054
- const expectedType = expectedTypes[0];
5055
- const receivedType = toRawType(value);
5056
- const expectedValue = styleValue(value, expectedType);
5057
- const receivedValue = styleValue(value, receivedType);
5058
- // check if we need to specify expected value
5059
- if (expectedTypes.length === 1 &&
5060
- isExplicable(expectedType) &&
5061
- !isBoolean(expectedType, receivedType)) {
5062
- message += ` with value ${expectedValue}`;
5063
- }
5064
- message += `, got ${receivedType} `;
5065
- // check if we need to specify received value
5066
- if (isExplicable(receivedType)) {
5067
- message += `with value ${receivedValue}.`;
4833
+ let shouldCacheAccess = true;
4834
+ function applyOptions(instance) {
4835
+ const options = resolveMergedOptions(instance);
4836
+ const publicThis = instance.proxy;
4837
+ const ctx = instance.ctx;
4838
+ // do not cache property access on public proxy during state initialization
4839
+ shouldCacheAccess = false;
4840
+ // call beforeCreate first before accessing other options since
4841
+ // the hook may mutate resolved options (#2791)
4842
+ if (options.beforeCreate) {
4843
+ callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
5068
4844
  }
5069
- return message;
5070
- }
5071
- /**
5072
- * dev only
5073
- */
5074
- function styleValue(value, type) {
5075
- if (type === 'String') {
5076
- return `"${value}"`;
5077
- }
5078
- else if (type === 'Number') {
5079
- return `${Number(value)}`;
4845
+ const {
4846
+ // state
4847
+ data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4848
+ // lifecycle
4849
+ created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4850
+ // public API
4851
+ expose, inheritAttrs,
4852
+ // assets
4853
+ components, directives, filters } = options;
4854
+ const checkDuplicateProperties = createDuplicateChecker() ;
4855
+ {
4856
+ const [propsOptions] = instance.propsOptions;
4857
+ if (propsOptions) {
4858
+ for (const key in propsOptions) {
4859
+ checkDuplicateProperties("Props" /* PROPS */, key);
4860
+ }
4861
+ }
5080
4862
  }
5081
- else {
5082
- return `${value}`;
4863
+ // options initialization order (to be consistent with Vue 2):
4864
+ // - props (already done outside of this function)
4865
+ // - inject
4866
+ // - methods
4867
+ // - data (deferred since it relies on `this` access)
4868
+ // - computed
4869
+ // - watch (deferred since it relies on `this` access)
4870
+ if (injectOptions) {
4871
+ resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
5083
4872
  }
5084
- }
5085
- /**
5086
- * dev only
5087
- */
5088
- function isExplicable(type) {
5089
- const explicitTypes = ['string', 'number', 'boolean'];
5090
- return explicitTypes.some(elem => type.toLowerCase() === elem);
5091
- }
5092
- /**
5093
- * dev only
5094
- */
5095
- function isBoolean(...args) {
5096
- return args.some(elem => elem.toLowerCase() === 'boolean');
5097
- }
5098
-
5099
- const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5100
- const normalizeSlotValue = (value) => isArray(value)
5101
- ? value.map(normalizeVNode)
5102
- : [normalizeVNode(value)];
5103
- const normalizeSlot = (key, rawSlot, ctx) => {
5104
- const normalized = withCtx((...args) => {
5105
- if (currentInstance) {
5106
- warn$1(`Slot "${key}" invoked outside of the render function: ` +
5107
- `this will not track dependencies used in the slot. ` +
5108
- `Invoke the slot function inside the render function instead.`);
5109
- }
5110
- return normalizeSlotValue(rawSlot(...args));
5111
- }, ctx);
5112
- normalized._c = false;
5113
- return normalized;
5114
- };
5115
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
5116
- const ctx = rawSlots._ctx;
5117
- for (const key in rawSlots) {
5118
- if (isInternalKey(key))
5119
- continue;
5120
- const value = rawSlots[key];
5121
- if (isFunction(value)) {
5122
- slots[key] = normalizeSlot(key, value, ctx);
5123
- }
5124
- else if (value != null) {
5125
- {
5126
- warn$1(`Non-function value encountered for slot "${key}". ` +
5127
- `Prefer function slots for better performance.`);
4873
+ if (methods) {
4874
+ for (const key in methods) {
4875
+ const methodHandler = methods[key];
4876
+ if (isFunction(methodHandler)) {
4877
+ // In dev mode, we use the `createRenderContext` function to define
4878
+ // methods to the proxy target, and those are read-only but
4879
+ // reconfigurable, so it needs to be redefined here
4880
+ {
4881
+ Object.defineProperty(ctx, key, {
4882
+ value: methodHandler.bind(publicThis),
4883
+ configurable: true,
4884
+ enumerable: true,
4885
+ writable: true
4886
+ });
4887
+ }
4888
+ {
4889
+ checkDuplicateProperties("Methods" /* METHODS */, key);
4890
+ }
4891
+ }
4892
+ else {
4893
+ warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4894
+ `Did you reference the function correctly?`);
5128
4895
  }
5129
- const normalized = normalizeSlotValue(value);
5130
- slots[key] = () => normalized;
5131
4896
  }
5132
4897
  }
5133
- };
5134
- const normalizeVNodeSlots = (instance, children) => {
5135
- if (!isKeepAlive(instance.vnode) &&
5136
- !(false )) {
5137
- warn$1(`Non-function value encountered for default slot. ` +
5138
- `Prefer function slots for better performance.`);
5139
- }
5140
- const normalized = normalizeSlotValue(children);
5141
- instance.slots.default = () => normalized;
5142
- };
5143
- const initSlots = (instance, children) => {
5144
- if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5145
- const type = children._;
5146
- if (type) {
5147
- // users can get the shallow readonly version of the slots object through `this.$slots`,
5148
- // we should avoid the proxy object polluting the slots of the internal instance
5149
- instance.slots = toRaw(children);
5150
- // make compiler marker non-enumerable
5151
- def(children, '_', type);
4898
+ if (dataOptions) {
4899
+ if (!isFunction(dataOptions)) {
4900
+ warn$1(`The data option must be a function. ` +
4901
+ `Plain object usage is no longer supported.`);
5152
4902
  }
5153
- else {
5154
- normalizeObjectSlots(children, (instance.slots = {}));
4903
+ const data = dataOptions.call(publicThis, publicThis);
4904
+ if (isPromise(data)) {
4905
+ warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4906
+ `intend to perform data fetching before component renders, use ` +
4907
+ `async setup() + <Suspense>.`);
5155
4908
  }
5156
- }
5157
- else {
5158
- instance.slots = {};
5159
- if (children) {
5160
- normalizeVNodeSlots(instance, children);
4909
+ if (!isObject(data)) {
4910
+ warn$1(`data() should return an object.`);
5161
4911
  }
5162
- }
5163
- def(instance.slots, InternalObjectKey, 1);
5164
- };
5165
- const updateSlots = (instance, children, optimized) => {
5166
- const { vnode, slots } = instance;
5167
- let needDeletionCheck = true;
5168
- let deletionComparisonTarget = EMPTY_OBJ;
5169
- if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5170
- const type = children._;
5171
- if (type) {
5172
- // compiled slots.
5173
- if (isHmrUpdating) {
5174
- // Parent was HMR updated so slot content may have changed.
5175
- // force update slots and mark instance for hmr as well
5176
- extend(slots, children);
4912
+ else {
4913
+ instance.data = reactive(data);
4914
+ {
4915
+ for (const key in data) {
4916
+ checkDuplicateProperties("Data" /* DATA */, key);
4917
+ // expose data on ctx during dev
4918
+ if (!isReservedPrefix(key[0])) {
4919
+ Object.defineProperty(ctx, key, {
4920
+ configurable: true,
4921
+ enumerable: true,
4922
+ get: () => data[key],
4923
+ set: NOOP
4924
+ });
4925
+ }
4926
+ }
5177
4927
  }
5178
- else if (optimized && type === 1 /* STABLE */) {
5179
- // compiled AND stable.
5180
- // no need to update, and skip stale slots removal.
5181
- needDeletionCheck = false;
4928
+ }
4929
+ }
4930
+ // state initialization complete at this point - start caching access
4931
+ shouldCacheAccess = true;
4932
+ if (computedOptions) {
4933
+ for (const key in computedOptions) {
4934
+ const opt = computedOptions[key];
4935
+ const get = isFunction(opt)
4936
+ ? opt.bind(publicThis, publicThis)
4937
+ : isFunction(opt.get)
4938
+ ? opt.get.bind(publicThis, publicThis)
4939
+ : NOOP;
4940
+ if (get === NOOP) {
4941
+ warn$1(`Computed property "${key}" has no getter.`);
5182
4942
  }
5183
- else {
5184
- // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5185
- // normalization.
5186
- extend(slots, children);
5187
- // #2893
5188
- // when rendering the optimized slots by manually written render function,
5189
- // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5190
- // i.e. let the `renderSlot` create the bailed Fragment
5191
- if (!optimized && type === 1 /* STABLE */) {
5192
- delete slots._;
5193
- }
4943
+ const set = !isFunction(opt) && isFunction(opt.set)
4944
+ ? opt.set.bind(publicThis)
4945
+ : () => {
4946
+ warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4947
+ }
4948
+ ;
4949
+ const c = computed$1({
4950
+ get,
4951
+ set
4952
+ });
4953
+ Object.defineProperty(ctx, key, {
4954
+ enumerable: true,
4955
+ configurable: true,
4956
+ get: () => c.value,
4957
+ set: v => (c.value = v)
4958
+ });
4959
+ {
4960
+ checkDuplicateProperties("Computed" /* COMPUTED */, key);
5194
4961
  }
5195
4962
  }
5196
- else {
5197
- needDeletionCheck = !children.$stable;
5198
- normalizeObjectSlots(children, slots);
4963
+ }
4964
+ if (watchOptions) {
4965
+ for (const key in watchOptions) {
4966
+ createWatcher(watchOptions[key], ctx, publicThis, key);
5199
4967
  }
5200
- deletionComparisonTarget = children;
5201
4968
  }
5202
- else if (children) {
5203
- // non slot object children (direct value) passed to a component
5204
- normalizeVNodeSlots(instance, children);
5205
- deletionComparisonTarget = { default: 1 };
4969
+ if (provideOptions) {
4970
+ const provides = isFunction(provideOptions)
4971
+ ? provideOptions.call(publicThis)
4972
+ : provideOptions;
4973
+ Reflect.ownKeys(provides).forEach(key => {
4974
+ provide(key, provides[key]);
4975
+ });
5206
4976
  }
5207
- // delete stale slots
5208
- if (needDeletionCheck) {
5209
- for (const key in slots) {
5210
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5211
- delete slots[key];
5212
- }
4977
+ if (created) {
4978
+ callHook(created, instance, "c" /* CREATED */);
4979
+ }
4980
+ function registerLifecycleHook(register, hook) {
4981
+ if (isArray(hook)) {
4982
+ hook.forEach(_hook => register(_hook.bind(publicThis)));
4983
+ }
4984
+ else if (hook) {
4985
+ register(hook.bind(publicThis));
5213
4986
  }
5214
4987
  }
5215
- };
5216
-
5217
- /**
5218
- Runtime helper for applying directives to a vnode. Example usage:
5219
-
5220
- const comp = resolveComponent('comp')
5221
- const foo = resolveDirective('foo')
5222
- const bar = resolveDirective('bar')
5223
-
5224
- return withDirectives(h(comp), [
5225
- [foo, this.x],
5226
- [bar, this.y]
5227
- ])
5228
- */
5229
- function validateDirectiveName(name) {
5230
- if (isBuiltInDirective(name)) {
5231
- warn$1('Do not use built-in directive ids as custom directive id: ' + name);
4988
+ registerLifecycleHook(onBeforeMount, beforeMount);
4989
+ registerLifecycleHook(onMounted, mounted);
4990
+ registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4991
+ registerLifecycleHook(onUpdated, updated);
4992
+ registerLifecycleHook(onActivated, activated);
4993
+ registerLifecycleHook(onDeactivated, deactivated);
4994
+ registerLifecycleHook(onErrorCaptured, errorCaptured);
4995
+ registerLifecycleHook(onRenderTracked, renderTracked);
4996
+ registerLifecycleHook(onRenderTriggered, renderTriggered);
4997
+ registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4998
+ registerLifecycleHook(onUnmounted, unmounted);
4999
+ registerLifecycleHook(onServerPrefetch, serverPrefetch);
5000
+ if (isArray(expose)) {
5001
+ if (expose.length) {
5002
+ const exposed = instance.exposed || (instance.exposed = {});
5003
+ expose.forEach(key => {
5004
+ Object.defineProperty(exposed, key, {
5005
+ get: () => publicThis[key],
5006
+ set: val => (publicThis[key] = val)
5007
+ });
5008
+ });
5009
+ }
5010
+ else if (!instance.exposed) {
5011
+ instance.exposed = {};
5012
+ }
5013
+ }
5014
+ // options that are handled when creating the instance but also need to be
5015
+ // applied from mixins
5016
+ if (render && instance.render === NOOP) {
5017
+ instance.render = render;
5018
+ }
5019
+ if (inheritAttrs != null) {
5020
+ instance.inheritAttrs = inheritAttrs;
5232
5021
  }
5022
+ // asset options.
5023
+ if (components)
5024
+ instance.components = components;
5025
+ if (directives)
5026
+ instance.directives = directives;
5233
5027
  }
5234
- /**
5235
- * Adds directives to a VNode.
5236
- */
5237
- function withDirectives(vnode, directives) {
5238
- const internalInstance = currentRenderingInstance;
5239
- if (internalInstance === null) {
5240
- warn$1(`withDirectives can only be used inside render functions.`);
5241
- return vnode;
5028
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
5029
+ if (isArray(injectOptions)) {
5030
+ injectOptions = normalizeInject(injectOptions);
5242
5031
  }
5243
- const instance = getExposeProxy(internalInstance) ||
5244
- internalInstance.proxy;
5245
- const bindings = vnode.dirs || (vnode.dirs = []);
5246
- for (let i = 0; i < directives.length; i++) {
5247
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5248
- if (isFunction(dir)) {
5249
- dir = {
5250
- mounted: dir,
5251
- updated: dir
5252
- };
5032
+ for (const key in injectOptions) {
5033
+ const opt = injectOptions[key];
5034
+ let injected;
5035
+ if (isObject(opt)) {
5036
+ if ('default' in opt) {
5037
+ injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
5038
+ }
5039
+ else {
5040
+ injected = inject(opt.from || key);
5041
+ }
5253
5042
  }
5254
- if (dir.deep) {
5255
- traverse(value);
5043
+ else {
5044
+ injected = inject(opt);
5045
+ }
5046
+ if (isRef(injected)) {
5047
+ // TODO remove the check in 3.3
5048
+ if (unwrapRef) {
5049
+ Object.defineProperty(ctx, key, {
5050
+ enumerable: true,
5051
+ configurable: true,
5052
+ get: () => injected.value,
5053
+ set: v => (injected.value = v)
5054
+ });
5055
+ }
5056
+ else {
5057
+ {
5058
+ warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
5059
+ `and no longer needs \`.value\` in the next minor release. ` +
5060
+ `To opt-in to the new behavior now, ` +
5061
+ `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
5062
+ `temporary and will not be needed in the future.)`);
5063
+ }
5064
+ ctx[key] = injected;
5065
+ }
5066
+ }
5067
+ else {
5068
+ ctx[key] = injected;
5069
+ }
5070
+ {
5071
+ checkDuplicateProperties("Inject" /* INJECT */, key);
5256
5072
  }
5257
- bindings.push({
5258
- dir,
5259
- instance,
5260
- value,
5261
- oldValue: void 0,
5262
- arg,
5263
- modifiers
5264
- });
5265
5073
  }
5266
- return vnode;
5267
5074
  }
5268
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5269
- const bindings = vnode.dirs;
5270
- const oldBindings = prevVNode && prevVNode.dirs;
5271
- for (let i = 0; i < bindings.length; i++) {
5272
- const binding = bindings[i];
5273
- if (oldBindings) {
5274
- binding.oldValue = oldBindings[i].value;
5075
+ function callHook(hook, instance, type) {
5076
+ callWithAsyncErrorHandling(isArray(hook)
5077
+ ? hook.map(h => h.bind(instance.proxy))
5078
+ : hook.bind(instance.proxy), instance, type);
5079
+ }
5080
+ function createWatcher(raw, ctx, publicThis, key) {
5081
+ const getter = key.includes('.')
5082
+ ? createPathGetter(publicThis, key)
5083
+ : () => publicThis[key];
5084
+ if (isString(raw)) {
5085
+ const handler = ctx[raw];
5086
+ if (isFunction(handler)) {
5087
+ watch(getter, handler);
5275
5088
  }
5276
- let hook = binding.dir[name];
5277
- if (hook) {
5278
- // disable tracking inside all lifecycle hooks
5279
- // since they can potentially be called inside effects.
5280
- pauseTracking();
5281
- callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5282
- vnode.el,
5283
- binding,
5284
- vnode,
5285
- prevVNode
5286
- ]);
5287
- resetTracking();
5089
+ else {
5090
+ warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5288
5091
  }
5289
5092
  }
5290
- }
5291
-
5292
- function createAppContext() {
5293
- return {
5294
- app: null,
5295
- config: {
5296
- isNativeTag: NO,
5297
- performance: false,
5298
- globalProperties: {},
5299
- optionMergeStrategies: {},
5300
- errorHandler: undefined,
5301
- warnHandler: undefined,
5302
- compilerOptions: {}
5303
- },
5304
- mixins: [],
5305
- components: {},
5306
- directives: {},
5307
- provides: Object.create(null),
5308
- optionsCache: new WeakMap(),
5309
- propsCache: new WeakMap(),
5310
- emitsCache: new WeakMap()
5311
- };
5093
+ else if (isFunction(raw)) {
5094
+ watch(getter, raw.bind(publicThis));
5095
+ }
5096
+ else if (isObject(raw)) {
5097
+ if (isArray(raw)) {
5098
+ raw.forEach(r => createWatcher(r, ctx, publicThis, key));
5099
+ }
5100
+ else {
5101
+ const handler = isFunction(raw.handler)
5102
+ ? raw.handler.bind(publicThis)
5103
+ : ctx[raw.handler];
5104
+ if (isFunction(handler)) {
5105
+ watch(getter, handler, raw);
5106
+ }
5107
+ else {
5108
+ warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
5109
+ }
5110
+ }
5111
+ }
5112
+ else {
5113
+ warn$1(`Invalid watch option: "${key}"`, raw);
5114
+ }
5312
5115
  }
5313
- let uid = 0;
5314
- function createAppAPI(render, hydrate) {
5315
- return function createApp(rootComponent, rootProps = null) {
5316
- if (!isFunction(rootComponent)) {
5317
- rootComponent = Object.assign({}, rootComponent);
5116
+ /**
5117
+ * Resolve merged options and cache it on the component.
5118
+ * This is done only once per-component since the merging does not involve
5119
+ * instances.
5120
+ */
5121
+ function resolveMergedOptions(instance) {
5122
+ const base = instance.type;
5123
+ const { mixins, extends: extendsOptions } = base;
5124
+ const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
5125
+ const cached = cache.get(base);
5126
+ let resolved;
5127
+ if (cached) {
5128
+ resolved = cached;
5129
+ }
5130
+ else if (!globalMixins.length && !mixins && !extendsOptions) {
5131
+ {
5132
+ resolved = base;
5318
5133
  }
5319
- if (rootProps != null && !isObject(rootProps)) {
5320
- warn$1(`root props passed to app.mount() must be an object.`);
5321
- rootProps = null;
5134
+ }
5135
+ else {
5136
+ resolved = {};
5137
+ if (globalMixins.length) {
5138
+ globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
5322
5139
  }
5323
- const context = createAppContext();
5324
- const installedPlugins = new Set();
5325
- let isMounted = false;
5326
- const app = (context.app = {
5327
- _uid: uid++,
5328
- _component: rootComponent,
5329
- _props: rootProps,
5330
- _container: null,
5331
- _context: context,
5332
- _instance: null,
5333
- version,
5334
- get config() {
5335
- return context.config;
5336
- },
5337
- set config(v) {
5338
- {
5339
- warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5340
- }
5341
- },
5342
- use(plugin, ...options) {
5343
- if (installedPlugins.has(plugin)) {
5344
- warn$1(`Plugin has already been applied to target app.`);
5345
- }
5346
- else if (plugin && isFunction(plugin.install)) {
5347
- installedPlugins.add(plugin);
5348
- plugin.install(app, ...options);
5349
- }
5350
- else if (isFunction(plugin)) {
5140
+ mergeOptions(resolved, base, optionMergeStrategies);
5141
+ }
5142
+ cache.set(base, resolved);
5143
+ return resolved;
5144
+ }
5145
+ function mergeOptions(to, from, strats, asMixin = false) {
5146
+ const { mixins, extends: extendsOptions } = from;
5147
+ if (extendsOptions) {
5148
+ mergeOptions(to, extendsOptions, strats, true);
5149
+ }
5150
+ if (mixins) {
5151
+ mixins.forEach((m) => mergeOptions(to, m, strats, true));
5152
+ }
5153
+ for (const key in from) {
5154
+ if (asMixin && key === 'expose') {
5155
+ warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
5156
+ `It should only be declared in the base component itself.`);
5157
+ }
5158
+ else {
5159
+ const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
5160
+ to[key] = strat ? strat(to[key], from[key]) : from[key];
5161
+ }
5162
+ }
5163
+ return to;
5164
+ }
5165
+ const internalOptionMergeStrats = {
5166
+ data: mergeDataFn,
5167
+ props: mergeObjectOptions,
5168
+ emits: mergeObjectOptions,
5169
+ // objects
5170
+ methods: mergeObjectOptions,
5171
+ computed: mergeObjectOptions,
5172
+ // lifecycle
5173
+ beforeCreate: mergeAsArray,
5174
+ created: mergeAsArray,
5175
+ beforeMount: mergeAsArray,
5176
+ mounted: mergeAsArray,
5177
+ beforeUpdate: mergeAsArray,
5178
+ updated: mergeAsArray,
5179
+ beforeDestroy: mergeAsArray,
5180
+ beforeUnmount: mergeAsArray,
5181
+ destroyed: mergeAsArray,
5182
+ unmounted: mergeAsArray,
5183
+ activated: mergeAsArray,
5184
+ deactivated: mergeAsArray,
5185
+ errorCaptured: mergeAsArray,
5186
+ serverPrefetch: mergeAsArray,
5187
+ // assets
5188
+ components: mergeObjectOptions,
5189
+ directives: mergeObjectOptions,
5190
+ // watch
5191
+ watch: mergeWatchOptions,
5192
+ // provide / inject
5193
+ provide: mergeDataFn,
5194
+ inject: mergeInject
5195
+ };
5196
+ function mergeDataFn(to, from) {
5197
+ if (!from) {
5198
+ return to;
5199
+ }
5200
+ if (!to) {
5201
+ return from;
5202
+ }
5203
+ return function mergedDataFn() {
5204
+ return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
5205
+ };
5206
+ }
5207
+ function mergeInject(to, from) {
5208
+ return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
5209
+ }
5210
+ function normalizeInject(raw) {
5211
+ if (isArray(raw)) {
5212
+ const res = {};
5213
+ for (let i = 0; i < raw.length; i++) {
5214
+ res[raw[i]] = raw[i];
5215
+ }
5216
+ return res;
5217
+ }
5218
+ return raw;
5219
+ }
5220
+ function mergeAsArray(to, from) {
5221
+ return to ? [...new Set([].concat(to, from))] : from;
5222
+ }
5223
+ function mergeObjectOptions(to, from) {
5224
+ return to ? extend(extend(Object.create(null), to), from) : from;
5225
+ }
5226
+ function mergeWatchOptions(to, from) {
5227
+ if (!to)
5228
+ return from;
5229
+ if (!from)
5230
+ return to;
5231
+ const merged = extend(Object.create(null), to);
5232
+ for (const key in from) {
5233
+ merged[key] = mergeAsArray(to[key], from[key]);
5234
+ }
5235
+ return merged;
5236
+ }
5237
+
5238
+ function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
5239
+ isSSR = false) {
5240
+ const props = {};
5241
+ const attrs = {};
5242
+ def(attrs, InternalObjectKey, 1);
5243
+ instance.propsDefaults = Object.create(null);
5244
+ setFullProps(instance, rawProps, props, attrs);
5245
+ // ensure all declared prop keys are present
5246
+ for (const key in instance.propsOptions[0]) {
5247
+ if (!(key in props)) {
5248
+ props[key] = undefined;
5249
+ }
5250
+ }
5251
+ // validation
5252
+ {
5253
+ validateProps(rawProps || {}, props, instance);
5254
+ }
5255
+ if (isStateful) {
5256
+ // stateful
5257
+ instance.props = isSSR ? props : shallowReactive(props);
5258
+ }
5259
+ else {
5260
+ if (!instance.type.props) {
5261
+ // functional w/ optional props, props === attrs
5262
+ instance.props = attrs;
5263
+ }
5264
+ else {
5265
+ // functional w/ declared props
5266
+ instance.props = props;
5267
+ }
5268
+ }
5269
+ instance.attrs = attrs;
5270
+ }
5271
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
5272
+ const { props, attrs, vnode: { patchFlag } } = instance;
5273
+ const rawCurrentProps = toRaw(props);
5274
+ const [options] = instance.propsOptions;
5275
+ let hasAttrsChanged = false;
5276
+ if (
5277
+ // always force full diff in dev
5278
+ // - #1942 if hmr is enabled with sfc component
5279
+ // - vite#872 non-sfc component used by sfc component
5280
+ !((instance.type.__hmrId ||
5281
+ (instance.parent && instance.parent.type.__hmrId))) &&
5282
+ (optimized || patchFlag > 0) &&
5283
+ !(patchFlag & 16 /* FULL_PROPS */)) {
5284
+ if (patchFlag & 8 /* PROPS */) {
5285
+ // Compiler-generated props & no keys change, just set the updated
5286
+ // the props.
5287
+ const propsToUpdate = instance.vnode.dynamicProps;
5288
+ for (let i = 0; i < propsToUpdate.length; i++) {
5289
+ let key = propsToUpdate[i];
5290
+ // skip if the prop key is a declared emit event listener
5291
+ if (isEmitListener(instance.emitsOptions, key)) {
5292
+ continue;
5293
+ }
5294
+ // PROPS flag guarantees rawProps to be non-null
5295
+ const value = rawProps[key];
5296
+ if (options) {
5297
+ // attr / props separation was done on init and will be consistent
5298
+ // in this code path, so just check if attrs have it.
5299
+ if (hasOwn(attrs, key)) {
5300
+ if (value !== attrs[key]) {
5301
+ attrs[key] = value;
5302
+ hasAttrsChanged = true;
5303
+ }
5304
+ }
5305
+ else {
5306
+ const camelizedKey = camelize(key);
5307
+ props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
5308
+ }
5309
+ }
5310
+ else {
5311
+ if (value !== attrs[key]) {
5312
+ attrs[key] = value;
5313
+ hasAttrsChanged = true;
5314
+ }
5315
+ }
5316
+ }
5317
+ }
5318
+ }
5319
+ else {
5320
+ // full props update.
5321
+ if (setFullProps(instance, rawProps, props, attrs)) {
5322
+ hasAttrsChanged = true;
5323
+ }
5324
+ // in case of dynamic props, check if we need to delete keys from
5325
+ // the props object
5326
+ let kebabKey;
5327
+ for (const key in rawCurrentProps) {
5328
+ if (!rawProps ||
5329
+ // for camelCase
5330
+ (!hasOwn(rawProps, key) &&
5331
+ // it's possible the original props was passed in as kebab-case
5332
+ // and converted to camelCase (#955)
5333
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
5334
+ if (options) {
5335
+ if (rawPrevProps &&
5336
+ // for camelCase
5337
+ (rawPrevProps[key] !== undefined ||
5338
+ // for kebab-case
5339
+ rawPrevProps[kebabKey] !== undefined)) {
5340
+ props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
5341
+ }
5342
+ }
5343
+ else {
5344
+ delete props[key];
5345
+ }
5346
+ }
5347
+ }
5348
+ // in the case of functional component w/o props declaration, props and
5349
+ // attrs point to the same object so it should already have been updated.
5350
+ if (attrs !== rawCurrentProps) {
5351
+ for (const key in attrs) {
5352
+ if (!rawProps ||
5353
+ (!hasOwn(rawProps, key) &&
5354
+ (!false ))) {
5355
+ delete attrs[key];
5356
+ hasAttrsChanged = true;
5357
+ }
5358
+ }
5359
+ }
5360
+ }
5361
+ // trigger updates for $attrs in case it's used in component slots
5362
+ if (hasAttrsChanged) {
5363
+ trigger(instance, "set" /* SET */, '$attrs');
5364
+ }
5365
+ {
5366
+ validateProps(rawProps || {}, props, instance);
5367
+ }
5368
+ }
5369
+ function setFullProps(instance, rawProps, props, attrs) {
5370
+ const [options, needCastKeys] = instance.propsOptions;
5371
+ let hasAttrsChanged = false;
5372
+ let rawCastValues;
5373
+ if (rawProps) {
5374
+ for (let key in rawProps) {
5375
+ // key, ref are reserved and never passed down
5376
+ if (isReservedProp(key)) {
5377
+ continue;
5378
+ }
5379
+ const value = rawProps[key];
5380
+ // prop option names are camelized during normalization, so to support
5381
+ // kebab -> camel conversion here we need to camelize the key.
5382
+ let camelKey;
5383
+ if (options && hasOwn(options, (camelKey = camelize(key)))) {
5384
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
5385
+ props[camelKey] = value;
5386
+ }
5387
+ else {
5388
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
5389
+ }
5390
+ }
5391
+ else if (!isEmitListener(instance.emitsOptions, key)) {
5392
+ if (!(key in attrs) || value !== attrs[key]) {
5393
+ attrs[key] = value;
5394
+ hasAttrsChanged = true;
5395
+ }
5396
+ }
5397
+ }
5398
+ }
5399
+ if (needCastKeys) {
5400
+ const rawCurrentProps = toRaw(props);
5401
+ const castValues = rawCastValues || EMPTY_OBJ;
5402
+ for (let i = 0; i < needCastKeys.length; i++) {
5403
+ const key = needCastKeys[i];
5404
+ props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
5405
+ }
5406
+ }
5407
+ return hasAttrsChanged;
5408
+ }
5409
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5410
+ const opt = options[key];
5411
+ if (opt != null) {
5412
+ const hasDefault = hasOwn(opt, 'default');
5413
+ // default values
5414
+ if (hasDefault && value === undefined) {
5415
+ const defaultValue = opt.default;
5416
+ if (opt.type !== Function && isFunction(defaultValue)) {
5417
+ const { propsDefaults } = instance;
5418
+ if (key in propsDefaults) {
5419
+ value = propsDefaults[key];
5420
+ }
5421
+ else {
5422
+ setCurrentInstance(instance);
5423
+ value = propsDefaults[key] = defaultValue.call(null, props);
5424
+ unsetCurrentInstance();
5425
+ }
5426
+ }
5427
+ else {
5428
+ value = defaultValue;
5429
+ }
5430
+ }
5431
+ // boolean casting
5432
+ if (opt[0 /* shouldCast */]) {
5433
+ if (isAbsent && !hasDefault) {
5434
+ value = false;
5435
+ }
5436
+ else if (opt[1 /* shouldCastTrue */] &&
5437
+ (value === '' || value === hyphenate(key))) {
5438
+ value = true;
5439
+ }
5440
+ }
5441
+ }
5442
+ return value;
5443
+ }
5444
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
5445
+ const cache = appContext.propsCache;
5446
+ const cached = cache.get(comp);
5447
+ if (cached) {
5448
+ return cached;
5449
+ }
5450
+ const raw = comp.props;
5451
+ const normalized = {};
5452
+ const needCastKeys = [];
5453
+ // apply mixin/extends props
5454
+ let hasExtends = false;
5455
+ if (!isFunction(comp)) {
5456
+ const extendProps = (raw) => {
5457
+ hasExtends = true;
5458
+ const [props, keys] = normalizePropsOptions(raw, appContext, true);
5459
+ extend(normalized, props);
5460
+ if (keys)
5461
+ needCastKeys.push(...keys);
5462
+ };
5463
+ if (!asMixin && appContext.mixins.length) {
5464
+ appContext.mixins.forEach(extendProps);
5465
+ }
5466
+ if (comp.extends) {
5467
+ extendProps(comp.extends);
5468
+ }
5469
+ if (comp.mixins) {
5470
+ comp.mixins.forEach(extendProps);
5471
+ }
5472
+ }
5473
+ if (!raw && !hasExtends) {
5474
+ cache.set(comp, EMPTY_ARR);
5475
+ return EMPTY_ARR;
5476
+ }
5477
+ if (isArray(raw)) {
5478
+ for (let i = 0; i < raw.length; i++) {
5479
+ if (!isString(raw[i])) {
5480
+ warn$1(`props must be strings when using array syntax.`, raw[i]);
5481
+ }
5482
+ const normalizedKey = camelize(raw[i]);
5483
+ if (validatePropName(normalizedKey)) {
5484
+ normalized[normalizedKey] = EMPTY_OBJ;
5485
+ }
5486
+ }
5487
+ }
5488
+ else if (raw) {
5489
+ if (!isObject(raw)) {
5490
+ warn$1(`invalid props options`, raw);
5491
+ }
5492
+ for (const key in raw) {
5493
+ const normalizedKey = camelize(key);
5494
+ if (validatePropName(normalizedKey)) {
5495
+ const opt = raw[key];
5496
+ const prop = (normalized[normalizedKey] =
5497
+ isArray(opt) || isFunction(opt) ? { type: opt } : opt);
5498
+ if (prop) {
5499
+ const booleanIndex = getTypeIndex(Boolean, prop.type);
5500
+ const stringIndex = getTypeIndex(String, prop.type);
5501
+ prop[0 /* shouldCast */] = booleanIndex > -1;
5502
+ prop[1 /* shouldCastTrue */] =
5503
+ stringIndex < 0 || booleanIndex < stringIndex;
5504
+ // if the prop needs boolean casting or default value
5505
+ if (booleanIndex > -1 || hasOwn(prop, 'default')) {
5506
+ needCastKeys.push(normalizedKey);
5507
+ }
5508
+ }
5509
+ }
5510
+ }
5511
+ }
5512
+ const res = [normalized, needCastKeys];
5513
+ cache.set(comp, res);
5514
+ return res;
5515
+ }
5516
+ function validatePropName(key) {
5517
+ if (key[0] !== '$') {
5518
+ return true;
5519
+ }
5520
+ else {
5521
+ warn$1(`Invalid prop name: "${key}" is a reserved property.`);
5522
+ }
5523
+ return false;
5524
+ }
5525
+ // use function string name to check type constructors
5526
+ // so that it works across vms / iframes.
5527
+ function getType(ctor) {
5528
+ const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
5529
+ return match ? match[1] : ctor === null ? 'null' : '';
5530
+ }
5531
+ function isSameType(a, b) {
5532
+ return getType(a) === getType(b);
5533
+ }
5534
+ function getTypeIndex(type, expectedTypes) {
5535
+ if (isArray(expectedTypes)) {
5536
+ return expectedTypes.findIndex(t => isSameType(t, type));
5537
+ }
5538
+ else if (isFunction(expectedTypes)) {
5539
+ return isSameType(expectedTypes, type) ? 0 : -1;
5540
+ }
5541
+ return -1;
5542
+ }
5543
+ /**
5544
+ * dev only
5545
+ */
5546
+ function validateProps(rawProps, props, instance) {
5547
+ const resolvedValues = toRaw(props);
5548
+ const options = instance.propsOptions[0];
5549
+ for (const key in options) {
5550
+ let opt = options[key];
5551
+ if (opt == null)
5552
+ continue;
5553
+ validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
5554
+ }
5555
+ }
5556
+ /**
5557
+ * dev only
5558
+ */
5559
+ function validateProp(name, value, prop, isAbsent) {
5560
+ const { type, required, validator } = prop;
5561
+ // required!
5562
+ if (required && isAbsent) {
5563
+ warn$1('Missing required prop: "' + name + '"');
5564
+ return;
5565
+ }
5566
+ // missing but optional
5567
+ if (value == null && !prop.required) {
5568
+ return;
5569
+ }
5570
+ // type check
5571
+ if (type != null && type !== true) {
5572
+ let isValid = false;
5573
+ const types = isArray(type) ? type : [type];
5574
+ const expectedTypes = [];
5575
+ // value is valid as long as one of the specified types match
5576
+ for (let i = 0; i < types.length && !isValid; i++) {
5577
+ const { valid, expectedType } = assertType(value, types[i]);
5578
+ expectedTypes.push(expectedType || '');
5579
+ isValid = valid;
5580
+ }
5581
+ if (!isValid) {
5582
+ warn$1(getInvalidTypeMessage(name, value, expectedTypes));
5583
+ return;
5584
+ }
5585
+ }
5586
+ // custom validator
5587
+ if (validator && !validator(value)) {
5588
+ warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
5589
+ }
5590
+ }
5591
+ const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
5592
+ /**
5593
+ * dev only
5594
+ */
5595
+ function assertType(value, type) {
5596
+ let valid;
5597
+ const expectedType = getType(type);
5598
+ if (isSimpleType(expectedType)) {
5599
+ const t = typeof value;
5600
+ valid = t === expectedType.toLowerCase();
5601
+ // for primitive wrapper objects
5602
+ if (!valid && t === 'object') {
5603
+ valid = value instanceof type;
5604
+ }
5605
+ }
5606
+ else if (expectedType === 'Object') {
5607
+ valid = isObject(value);
5608
+ }
5609
+ else if (expectedType === 'Array') {
5610
+ valid = isArray(value);
5611
+ }
5612
+ else if (expectedType === 'null') {
5613
+ valid = value === null;
5614
+ }
5615
+ else {
5616
+ valid = value instanceof type;
5617
+ }
5618
+ return {
5619
+ valid,
5620
+ expectedType
5621
+ };
5622
+ }
5623
+ /**
5624
+ * dev only
5625
+ */
5626
+ function getInvalidTypeMessage(name, value, expectedTypes) {
5627
+ let message = `Invalid prop: type check failed for prop "${name}".` +
5628
+ ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
5629
+ const expectedType = expectedTypes[0];
5630
+ const receivedType = toRawType(value);
5631
+ const expectedValue = styleValue(value, expectedType);
5632
+ const receivedValue = styleValue(value, receivedType);
5633
+ // check if we need to specify expected value
5634
+ if (expectedTypes.length === 1 &&
5635
+ isExplicable(expectedType) &&
5636
+ !isBoolean(expectedType, receivedType)) {
5637
+ message += ` with value ${expectedValue}`;
5638
+ }
5639
+ message += `, got ${receivedType} `;
5640
+ // check if we need to specify received value
5641
+ if (isExplicable(receivedType)) {
5642
+ message += `with value ${receivedValue}.`;
5643
+ }
5644
+ return message;
5645
+ }
5646
+ /**
5647
+ * dev only
5648
+ */
5649
+ function styleValue(value, type) {
5650
+ if (type === 'String') {
5651
+ return `"${value}"`;
5652
+ }
5653
+ else if (type === 'Number') {
5654
+ return `${Number(value)}`;
5655
+ }
5656
+ else {
5657
+ return `${value}`;
5658
+ }
5659
+ }
5660
+ /**
5661
+ * dev only
5662
+ */
5663
+ function isExplicable(type) {
5664
+ const explicitTypes = ['string', 'number', 'boolean'];
5665
+ return explicitTypes.some(elem => type.toLowerCase() === elem);
5666
+ }
5667
+ /**
5668
+ * dev only
5669
+ */
5670
+ function isBoolean(...args) {
5671
+ return args.some(elem => elem.toLowerCase() === 'boolean');
5672
+ }
5673
+
5674
+ const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5675
+ const normalizeSlotValue = (value) => isArray(value)
5676
+ ? value.map(normalizeVNode)
5677
+ : [normalizeVNode(value)];
5678
+ const normalizeSlot = (key, rawSlot, ctx) => {
5679
+ if (rawSlot._n) {
5680
+ // already normalized - #5353
5681
+ return rawSlot;
5682
+ }
5683
+ const normalized = withCtx((...args) => {
5684
+ if (currentInstance) {
5685
+ warn$1(`Slot "${key}" invoked outside of the render function: ` +
5686
+ `this will not track dependencies used in the slot. ` +
5687
+ `Invoke the slot function inside the render function instead.`);
5688
+ }
5689
+ return normalizeSlotValue(rawSlot(...args));
5690
+ }, ctx);
5691
+ normalized._c = false;
5692
+ return normalized;
5693
+ };
5694
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
5695
+ const ctx = rawSlots._ctx;
5696
+ for (const key in rawSlots) {
5697
+ if (isInternalKey(key))
5698
+ continue;
5699
+ const value = rawSlots[key];
5700
+ if (isFunction(value)) {
5701
+ slots[key] = normalizeSlot(key, value, ctx);
5702
+ }
5703
+ else if (value != null) {
5704
+ {
5705
+ warn$1(`Non-function value encountered for slot "${key}". ` +
5706
+ `Prefer function slots for better performance.`);
5707
+ }
5708
+ const normalized = normalizeSlotValue(value);
5709
+ slots[key] = () => normalized;
5710
+ }
5711
+ }
5712
+ };
5713
+ const normalizeVNodeSlots = (instance, children) => {
5714
+ if (!isKeepAlive(instance.vnode) &&
5715
+ !(false )) {
5716
+ warn$1(`Non-function value encountered for default slot. ` +
5717
+ `Prefer function slots for better performance.`);
5718
+ }
5719
+ const normalized = normalizeSlotValue(children);
5720
+ instance.slots.default = () => normalized;
5721
+ };
5722
+ const initSlots = (instance, children) => {
5723
+ if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5724
+ const type = children._;
5725
+ if (type) {
5726
+ // users can get the shallow readonly version of the slots object through `this.$slots`,
5727
+ // we should avoid the proxy object polluting the slots of the internal instance
5728
+ instance.slots = toRaw(children);
5729
+ // make compiler marker non-enumerable
5730
+ def(children, '_', type);
5731
+ }
5732
+ else {
5733
+ normalizeObjectSlots(children, (instance.slots = {}));
5734
+ }
5735
+ }
5736
+ else {
5737
+ instance.slots = {};
5738
+ if (children) {
5739
+ normalizeVNodeSlots(instance, children);
5740
+ }
5741
+ }
5742
+ def(instance.slots, InternalObjectKey, 1);
5743
+ };
5744
+ const updateSlots = (instance, children, optimized) => {
5745
+ const { vnode, slots } = instance;
5746
+ let needDeletionCheck = true;
5747
+ let deletionComparisonTarget = EMPTY_OBJ;
5748
+ if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5749
+ const type = children._;
5750
+ if (type) {
5751
+ // compiled slots.
5752
+ if (isHmrUpdating) {
5753
+ // Parent was HMR updated so slot content may have changed.
5754
+ // force update slots and mark instance for hmr as well
5755
+ extend(slots, children);
5756
+ }
5757
+ else if (optimized && type === 1 /* STABLE */) {
5758
+ // compiled AND stable.
5759
+ // no need to update, and skip stale slots removal.
5760
+ needDeletionCheck = false;
5761
+ }
5762
+ else {
5763
+ // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5764
+ // normalization.
5765
+ extend(slots, children);
5766
+ // #2893
5767
+ // when rendering the optimized slots by manually written render function,
5768
+ // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5769
+ // i.e. let the `renderSlot` create the bailed Fragment
5770
+ if (!optimized && type === 1 /* STABLE */) {
5771
+ delete slots._;
5772
+ }
5773
+ }
5774
+ }
5775
+ else {
5776
+ needDeletionCheck = !children.$stable;
5777
+ normalizeObjectSlots(children, slots);
5778
+ }
5779
+ deletionComparisonTarget = children;
5780
+ }
5781
+ else if (children) {
5782
+ // non slot object children (direct value) passed to a component
5783
+ normalizeVNodeSlots(instance, children);
5784
+ deletionComparisonTarget = { default: 1 };
5785
+ }
5786
+ // delete stale slots
5787
+ if (needDeletionCheck) {
5788
+ for (const key in slots) {
5789
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5790
+ delete slots[key];
5791
+ }
5792
+ }
5793
+ }
5794
+ };
5795
+
5796
+ function createAppContext() {
5797
+ return {
5798
+ app: null,
5799
+ config: {
5800
+ isNativeTag: NO,
5801
+ performance: false,
5802
+ globalProperties: {},
5803
+ optionMergeStrategies: {},
5804
+ errorHandler: undefined,
5805
+ warnHandler: undefined,
5806
+ compilerOptions: {}
5807
+ },
5808
+ mixins: [],
5809
+ components: {},
5810
+ directives: {},
5811
+ provides: Object.create(null),
5812
+ optionsCache: new WeakMap(),
5813
+ propsCache: new WeakMap(),
5814
+ emitsCache: new WeakMap()
5815
+ };
5816
+ }
5817
+ let uid = 0;
5818
+ function createAppAPI(render, hydrate) {
5819
+ return function createApp(rootComponent, rootProps = null) {
5820
+ if (!isFunction(rootComponent)) {
5821
+ rootComponent = Object.assign({}, rootComponent);
5822
+ }
5823
+ if (rootProps != null && !isObject(rootProps)) {
5824
+ warn$1(`root props passed to app.mount() must be an object.`);
5825
+ rootProps = null;
5826
+ }
5827
+ const context = createAppContext();
5828
+ const installedPlugins = new Set();
5829
+ let isMounted = false;
5830
+ const app = (context.app = {
5831
+ _uid: uid++,
5832
+ _component: rootComponent,
5833
+ _props: rootProps,
5834
+ _container: null,
5835
+ _context: context,
5836
+ _instance: null,
5837
+ version,
5838
+ get config() {
5839
+ return context.config;
5840
+ },
5841
+ set config(v) {
5842
+ {
5843
+ warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5844
+ }
5845
+ },
5846
+ use(plugin, ...options) {
5847
+ if (installedPlugins.has(plugin)) {
5848
+ warn$1(`Plugin has already been applied to target app.`);
5849
+ }
5850
+ else if (plugin && isFunction(plugin.install)) {
5851
+ installedPlugins.add(plugin);
5852
+ plugin.install(app, ...options);
5853
+ }
5854
+ else if (isFunction(plugin)) {
5351
5855
  installedPlugins.add(plugin);
5352
5856
  plugin(app, ...options);
5353
5857
  }
@@ -5397,6 +5901,12 @@ function createAppAPI(render, hydrate) {
5397
5901
  },
5398
5902
  mount(rootContainer, isHydrate, isSVG) {
5399
5903
  if (!isMounted) {
5904
+ // #5571
5905
+ if (rootContainer.__vue_app__) {
5906
+ warn$1(`There is already an app instance mounted on the host container.\n` +
5907
+ ` If you want to mount another app on the same host container,` +
5908
+ ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
5909
+ }
5400
5910
  const vnode = createVNode(rootComponent, rootProps);
5401
5911
  // store app context on the root VNode.
5402
5912
  // this will be set on the root instance on initial mount.
@@ -5447,8 +5957,6 @@ function createAppAPI(render, hydrate) {
5447
5957
  warn$1(`App already provides property with key "${String(key)}". ` +
5448
5958
  `It will be overwritten with the new value.`);
5449
5959
  }
5450
- // TypeScript doesn't allow symbols as index type
5451
- // https://github.com/Microsoft/TypeScript/issues/24587
5452
5960
  context.provides[key] = value;
5453
5961
  return app;
5454
5962
  }
@@ -5565,7 +6073,7 @@ const isComment = (node) => node.nodeType === 8 /* COMMENT */;
5565
6073
  // Hydration also depends on some renderer internal logic which needs to be
5566
6074
  // passed in via arguments.
5567
6075
  function createHydrationFunctions(rendererInternals) {
5568
- const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
6076
+ const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
5569
6077
  const hydrate = (vnode, container) => {
5570
6078
  if (!container.hasChildNodes()) {
5571
6079
  warn$1(`Attempting to hydrate existing markup but container is empty. ` +
@@ -5585,14 +6093,26 @@ function createHydrationFunctions(rendererInternals) {
5585
6093
  const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
5586
6094
  const isFragmentStart = isComment(node) && node.data === '[';
5587
6095
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
5588
- const { type, ref, shapeFlag } = vnode;
6096
+ const { type, ref, shapeFlag, patchFlag } = vnode;
5589
6097
  const domType = node.nodeType;
5590
6098
  vnode.el = node;
6099
+ if (patchFlag === -2 /* BAIL */) {
6100
+ optimized = false;
6101
+ vnode.dynamicChildren = null;
6102
+ }
5591
6103
  let nextNode = null;
5592
6104
  switch (type) {
5593
6105
  case Text:
5594
6106
  if (domType !== 3 /* TEXT */) {
5595
- nextNode = onMismatch();
6107
+ // #5728 empty text node inside a slot can cause hydration failure
6108
+ // because the server rendered HTML won't contain a text node
6109
+ if (vnode.children === '') {
6110
+ insert((vnode.el = createText('')), parentNode(node), node);
6111
+ nextNode = node;
6112
+ }
6113
+ else {
6114
+ nextNode = onMismatch();
6115
+ }
5596
6116
  }
5597
6117
  else {
5598
6118
  if (node.data !== vnode.children) {
@@ -5666,6 +6186,12 @@ function createHydrationFunctions(rendererInternals) {
5666
6186
  nextNode = isFragmentStart
5667
6187
  ? locateClosingAsyncAnchor(node)
5668
6188
  : nextSibling(node);
6189
+ // #4293 teleport as component root
6190
+ if (nextNode &&
6191
+ isComment(nextNode) &&
6192
+ nextNode.data === 'teleport end') {
6193
+ nextNode = nextSibling(nextNode);
6194
+ }
5669
6195
  // #3787
5670
6196
  // if component is async, it may get moved / unmounted before its
5671
6197
  // inner component is loaded, so we need to give it a placeholder
@@ -6329,8 +6855,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6329
6855
  const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
6330
6856
  const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
6331
6857
  let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
6332
- if (isHmrUpdating) {
6333
- // HMR updated, force full diff
6858
+ if (// #5523 dev root fragment may inherit directives
6859
+ (isHmrUpdating || patchFlag & 2048 /* DEV_ROOT_FRAGMENT */)) {
6860
+ // HMR updated / Dev root fragment (w/ comments), force full diff
6334
6861
  patchFlag = 0;
6335
6862
  optimized = false;
6336
6863
  dynamicChildren = null;
@@ -6464,7 +6991,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6464
6991
  }
6465
6992
  else {
6466
6993
  // no update needed. just copy over properties
6467
- n2.component = n1.component;
6468
6994
  n2.el = n1.el;
6469
6995
  instance.vnode = n2;
6470
6996
  }
@@ -6547,7 +7073,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6547
7073
  // activated hook for keep-alive roots.
6548
7074
  // #1742 activated hook must be accessed after first render
6549
7075
  // since the hook may be injected by a child keep-alive
6550
- if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
7076
+ if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */ ||
7077
+ (parent &&
7078
+ isAsyncWrapper(parent.vnode) &&
7079
+ parent.vnode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */)) {
6551
7080
  instance.a && queuePostRenderEffect(instance.a, parentSuspense);
6552
7081
  }
6553
7082
  instance.isMounted = true;
@@ -6630,9 +7159,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6630
7159
  }
6631
7160
  };
6632
7161
  // create reactive effect for rendering
6633
- const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7162
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
6634
7163
  ));
6635
- const update = (instance.update = effect.run.bind(effect));
7164
+ const update = (instance.update = () => effect.run());
6636
7165
  update.id = instance.uid;
6637
7166
  // allowRecurse
6638
7167
  // #1801, #2043 component render effects should allow recursive updates
@@ -6644,7 +7173,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6644
7173
  effect.onTrigger = instance.rtg
6645
7174
  ? e => invokeArrayFns(instance.rtg, e)
6646
7175
  : void 0;
6647
- // @ts-ignore (for scheduler)
6648
7176
  update.ownerInstance = instance;
6649
7177
  }
6650
7178
  update();
@@ -7429,96 +7957,36 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
7429
7957
  // if multiple teleports rendered to the same target element, we need to
7430
7958
  // pick up from where the last teleport finished instead of the first node
7431
7959
  const targetNode = target._lpa || target.firstChild;
7432
- if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
7433
- if (isTeleportDisabled(vnode.props)) {
7434
- vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
7435
- vnode.targetAnchor = targetNode;
7436
- }
7437
- else {
7438
- vnode.anchor = nextSibling(node);
7439
- vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7440
- }
7441
- target._lpa =
7442
- vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7443
- }
7444
- }
7445
- return vnode.anchor && nextSibling(vnode.anchor);
7446
- }
7447
- // Force-casted public typing for h and TSX props inference
7448
- const Teleport = TeleportImpl;
7449
-
7450
- const COMPONENTS = 'components';
7451
- const DIRECTIVES = 'directives';
7452
- /**
7453
- * @private
7454
- */
7455
- function resolveComponent(name, maybeSelfReference) {
7456
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7457
- }
7458
- const NULL_DYNAMIC_COMPONENT = Symbol();
7459
- /**
7460
- * @private
7461
- */
7462
- function resolveDynamicComponent(component) {
7463
- if (isString(component)) {
7464
- return resolveAsset(COMPONENTS, component, false) || component;
7465
- }
7466
- else {
7467
- // invalid types will fallthrough to createVNode and raise warning
7468
- return (component || NULL_DYNAMIC_COMPONENT);
7469
- }
7470
- }
7471
- /**
7472
- * @private
7473
- */
7474
- function resolveDirective(name) {
7475
- return resolveAsset(DIRECTIVES, name);
7476
- }
7477
- // implementation
7478
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7479
- const instance = currentRenderingInstance || currentInstance;
7480
- if (instance) {
7481
- const Component = instance.type;
7482
- // explicit self name has highest priority
7483
- if (type === COMPONENTS) {
7484
- const selfName = getComponentName(Component);
7485
- if (selfName &&
7486
- (selfName === name ||
7487
- selfName === camelize(name) ||
7488
- selfName === capitalize(camelize(name)))) {
7489
- return Component;
7490
- }
7491
- }
7492
- const res =
7493
- // local registration
7494
- // check instance[type] first which is resolved for options API
7495
- resolve(instance[type] || Component[type], name) ||
7496
- // global registration
7497
- resolve(instance.appContext[type], name);
7498
- if (!res && maybeSelfReference) {
7499
- // fallback to implicit self-reference
7500
- return Component;
7501
- }
7502
- if (warnMissing && !res) {
7503
- const extra = type === COMPONENTS
7504
- ? `\nIf this is a native custom element, make sure to exclude it from ` +
7505
- `component resolution via compilerOptions.isCustomElement.`
7506
- : ``;
7507
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7960
+ if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
7961
+ if (isTeleportDisabled(vnode.props)) {
7962
+ vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
7963
+ vnode.targetAnchor = targetNode;
7964
+ }
7965
+ else {
7966
+ vnode.anchor = nextSibling(node);
7967
+ // lookahead until we find the target anchor
7968
+ // we cannot rely on return value of hydrateChildren() because there
7969
+ // could be nested teleports
7970
+ let targetAnchor = targetNode;
7971
+ while (targetAnchor) {
7972
+ targetAnchor = nextSibling(targetAnchor);
7973
+ if (targetAnchor &&
7974
+ targetAnchor.nodeType === 8 &&
7975
+ targetAnchor.data === 'teleport anchor') {
7976
+ vnode.targetAnchor = targetAnchor;
7977
+ target._lpa =
7978
+ vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7979
+ break;
7980
+ }
7981
+ }
7982
+ hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7983
+ }
7508
7984
  }
7509
- return res;
7510
- }
7511
- else {
7512
- warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
7513
- `can only be used in render() or setup().`);
7514
7985
  }
7986
+ return vnode.anchor && nextSibling(vnode.anchor);
7515
7987
  }
7516
- function resolve(registry, name) {
7517
- return (registry &&
7518
- (registry[name] ||
7519
- registry[camelize(name)] ||
7520
- registry[capitalize(camelize(name))]));
7521
- }
7988
+ // Force-casted public typing for h and TSX props inference
7989
+ const Teleport = TeleportImpl;
7522
7990
 
7523
7991
  const Fragment = Symbol('Fragment' );
7524
7992
  const Text = Symbol('Text' );
@@ -7722,6 +8190,15 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
7722
8190
  if (children) {
7723
8191
  normalizeChildren(cloned, children);
7724
8192
  }
8193
+ if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
8194
+ if (cloned.shapeFlag & 6 /* COMPONENT */) {
8195
+ currentBlock[currentBlock.indexOf(type)] = cloned;
8196
+ }
8197
+ else {
8198
+ currentBlock.push(cloned);
8199
+ }
8200
+ }
8201
+ cloned.patchFlag |= -2 /* BAIL */;
7725
8202
  return cloned;
7726
8203
  }
7727
8204
  // class component normalization.
@@ -7805,600 +8282,188 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
7805
8282
  shapeFlag: vnode.shapeFlag,
7806
8283
  // if the vnode is cloned with extra props, we can no longer assume its
7807
8284
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7808
- // note: preserve flag for fragments since they use the flag for children
7809
- // fast paths only.
7810
- patchFlag: extraProps && vnode.type !== Fragment
7811
- ? patchFlag === -1 // hoisted node
7812
- ? 16 /* FULL_PROPS */
7813
- : patchFlag | 16 /* FULL_PROPS */
7814
- : patchFlag,
7815
- dynamicProps: vnode.dynamicProps,
7816
- dynamicChildren: vnode.dynamicChildren,
7817
- appContext: vnode.appContext,
7818
- dirs: vnode.dirs,
7819
- transition: vnode.transition,
7820
- // These should technically only be non-null on mounted VNodes. However,
7821
- // they *should* be copied for kept-alive vnodes. So we just always copy
7822
- // them since them being non-null during a mount doesn't affect the logic as
7823
- // they will simply be overwritten.
7824
- component: vnode.component,
7825
- suspense: vnode.suspense,
7826
- ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7827
- ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7828
- el: vnode.el,
7829
- anchor: vnode.anchor
7830
- };
7831
- return cloned;
7832
- }
7833
- /**
7834
- * Dev only, for HMR of hoisted vnodes reused in v-for
7835
- * https://github.com/vitejs/vite/issues/2022
7836
- */
7837
- function deepCloneVNode(vnode) {
7838
- const cloned = cloneVNode(vnode);
7839
- if (isArray(vnode.children)) {
7840
- cloned.children = vnode.children.map(deepCloneVNode);
7841
- }
7842
- return cloned;
7843
- }
7844
- /**
7845
- * @private
7846
- */
7847
- function createTextVNode(text = ' ', flag = 0) {
7848
- return createVNode(Text, null, text, flag);
7849
- }
7850
- /**
7851
- * @private
7852
- */
7853
- function createStaticVNode(content, numberOfNodes) {
7854
- // A static vnode can contain multiple stringified elements, and the number
7855
- // of elements is necessary for hydration.
7856
- const vnode = createVNode(Static, null, content);
7857
- vnode.staticCount = numberOfNodes;
7858
- return vnode;
7859
- }
7860
- /**
7861
- * @private
7862
- */
7863
- function createCommentVNode(text = '',
7864
- // when used as the v-else branch, the comment node must be created as a
7865
- // block to ensure correct updates.
7866
- asBlock = false) {
7867
- return asBlock
7868
- ? (openBlock(), createBlock(Comment, null, text))
7869
- : createVNode(Comment, null, text);
7870
- }
7871
- function normalizeVNode(child) {
7872
- if (child == null || typeof child === 'boolean') {
7873
- // empty placeholder
7874
- return createVNode(Comment);
7875
- }
7876
- else if (isArray(child)) {
7877
- // fragment
7878
- return createVNode(Fragment, null,
7879
- // #3666, avoid reference pollution when reusing vnode
7880
- child.slice());
7881
- }
7882
- else if (typeof child === 'object') {
7883
- // already vnode, this should be the most common since compiled templates
7884
- // always produce all-vnode children arrays
7885
- return cloneIfMounted(child);
7886
- }
7887
- else {
7888
- // strings and numbers
7889
- return createVNode(Text, null, String(child));
7890
- }
7891
- }
7892
- // optimized normalization for template-compiled render fns
7893
- function cloneIfMounted(child) {
7894
- return child.el === null || child.memo ? child : cloneVNode(child);
7895
- }
7896
- function normalizeChildren(vnode, children) {
7897
- let type = 0;
7898
- const { shapeFlag } = vnode;
7899
- if (children == null) {
7900
- children = null;
7901
- }
7902
- else if (isArray(children)) {
7903
- type = 16 /* ARRAY_CHILDREN */;
7904
- }
7905
- else if (typeof children === 'object') {
7906
- if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7907
- // Normalize slot to plain children for plain element and Teleport
7908
- const slot = children.default;
7909
- if (slot) {
7910
- // _c marker is added by withCtx() indicating this is a compiled slot
7911
- slot._c && (slot._d = false);
7912
- normalizeChildren(vnode, slot());
7913
- slot._c && (slot._d = true);
7914
- }
7915
- return;
7916
- }
7917
- else {
7918
- type = 32 /* SLOTS_CHILDREN */;
7919
- const slotFlag = children._;
7920
- if (!slotFlag && !(InternalObjectKey in children)) {
7921
- children._ctx = currentRenderingInstance;
7922
- }
7923
- else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7924
- // a child component receives forwarded slots from the parent.
7925
- // its slot type is determined by its parent's slot type.
7926
- if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7927
- children._ = 1 /* STABLE */;
7928
- }
7929
- else {
7930
- children._ = 2 /* DYNAMIC */;
7931
- vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7932
- }
7933
- }
7934
- }
7935
- }
7936
- else if (isFunction(children)) {
7937
- children = { default: children, _ctx: currentRenderingInstance };
7938
- type = 32 /* SLOTS_CHILDREN */;
7939
- }
7940
- else {
7941
- children = String(children);
7942
- // force teleport children to array so it can be moved around
7943
- if (shapeFlag & 64 /* TELEPORT */) {
7944
- type = 16 /* ARRAY_CHILDREN */;
7945
- children = [createTextVNode(children)];
7946
- }
7947
- else {
7948
- type = 8 /* TEXT_CHILDREN */;
7949
- }
7950
- }
7951
- vnode.children = children;
7952
- vnode.shapeFlag |= type;
7953
- }
7954
- function mergeProps(...args) {
7955
- const ret = {};
7956
- for (let i = 0; i < args.length; i++) {
7957
- const toMerge = args[i];
7958
- for (const key in toMerge) {
7959
- if (key === 'class') {
7960
- if (ret.class !== toMerge.class) {
7961
- ret.class = normalizeClass([ret.class, toMerge.class]);
7962
- }
7963
- }
7964
- else if (key === 'style') {
7965
- ret.style = normalizeStyle([ret.style, toMerge.style]);
7966
- }
7967
- else if (isOn(key)) {
7968
- const existing = ret[key];
7969
- const incoming = toMerge[key];
7970
- if (incoming &&
7971
- existing !== incoming &&
7972
- !(isArray(existing) && existing.includes(incoming))) {
7973
- ret[key] = existing
7974
- ? [].concat(existing, incoming)
7975
- : incoming;
7976
- }
7977
- }
7978
- else if (key !== '') {
7979
- ret[key] = toMerge[key];
7980
- }
7981
- }
7982
- }
7983
- return ret;
7984
- }
7985
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7986
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7987
- vnode,
7988
- prevVNode
7989
- ]);
7990
- }
7991
-
7992
- /**
7993
- * Actual implementation
7994
- */
7995
- function renderList(source, renderItem, cache, index) {
7996
- let ret;
7997
- const cached = (cache && cache[index]);
7998
- if (isArray(source) || isString(source)) {
7999
- ret = new Array(source.length);
8000
- for (let i = 0, l = source.length; i < l; i++) {
8001
- ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
8002
- }
8003
- }
8004
- else if (typeof source === 'number') {
8005
- if (!Number.isInteger(source)) {
8006
- warn$1(`The v-for range expect an integer value but got ${source}.`);
8007
- return [];
8008
- }
8009
- ret = new Array(source);
8010
- for (let i = 0; i < source; i++) {
8011
- ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
8012
- }
8013
- }
8014
- else if (isObject(source)) {
8015
- if (source[Symbol.iterator]) {
8016
- ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
8017
- }
8018
- else {
8019
- const keys = Object.keys(source);
8020
- ret = new Array(keys.length);
8021
- for (let i = 0, l = keys.length; i < l; i++) {
8022
- const key = keys[i];
8023
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
8024
- }
8025
- }
8026
- }
8027
- else {
8028
- ret = [];
8029
- }
8030
- if (cache) {
8031
- cache[index] = ret;
8032
- }
8033
- return ret;
8034
- }
8035
-
8285
+ // note: preserve flag for fragments since they use the flag for children
8286
+ // fast paths only.
8287
+ patchFlag: extraProps && vnode.type !== Fragment
8288
+ ? patchFlag === -1 // hoisted node
8289
+ ? 16 /* FULL_PROPS */
8290
+ : patchFlag | 16 /* FULL_PROPS */
8291
+ : patchFlag,
8292
+ dynamicProps: vnode.dynamicProps,
8293
+ dynamicChildren: vnode.dynamicChildren,
8294
+ appContext: vnode.appContext,
8295
+ dirs: vnode.dirs,
8296
+ transition: vnode.transition,
8297
+ // These should technically only be non-null on mounted VNodes. However,
8298
+ // they *should* be copied for kept-alive vnodes. So we just always copy
8299
+ // them since them being non-null during a mount doesn't affect the logic as
8300
+ // they will simply be overwritten.
8301
+ component: vnode.component,
8302
+ suspense: vnode.suspense,
8303
+ ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
8304
+ ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
8305
+ el: vnode.el,
8306
+ anchor: vnode.anchor
8307
+ };
8308
+ return cloned;
8309
+ }
8036
8310
  /**
8037
- * Compiler runtime helper for creating dynamic slots object
8038
- * @private
8311
+ * Dev only, for HMR of hoisted vnodes reused in v-for
8312
+ * https://github.com/vitejs/vite/issues/2022
8039
8313
  */
8040
- function createSlots(slots, dynamicSlots) {
8041
- for (let i = 0; i < dynamicSlots.length; i++) {
8042
- const slot = dynamicSlots[i];
8043
- // array of dynamic slot generated by <template v-for="..." #[...]>
8044
- if (isArray(slot)) {
8045
- for (let j = 0; j < slot.length; j++) {
8046
- slots[slot[j].name] = slot[j].fn;
8047
- }
8048
- }
8049
- else if (slot) {
8050
- // conditional single slot generated by <template v-if="..." #foo>
8051
- slots[slot.name] = slot.fn;
8052
- }
8314
+ function deepCloneVNode(vnode) {
8315
+ const cloned = cloneVNode(vnode);
8316
+ if (isArray(vnode.children)) {
8317
+ cloned.children = vnode.children.map(deepCloneVNode);
8053
8318
  }
8054
- return slots;
8055
- }
8056
-
8319
+ return cloned;
8320
+ }
8057
8321
  /**
8058
- * Compiler runtime helper for rendering `<slot/>`
8059
8322
  * @private
8060
8323
  */
8061
- function renderSlot(slots, name, props = {},
8062
- // this is not a user-facing function, so the fallback is always generated by
8063
- // the compiler and guaranteed to be a function returning an array
8064
- fallback, noSlotted) {
8065
- if (currentRenderingInstance.isCE ||
8066
- (currentRenderingInstance.parent &&
8067
- isAsyncWrapper(currentRenderingInstance.parent) &&
8068
- currentRenderingInstance.parent.isCE)) {
8069
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
8070
- }
8071
- let slot = slots[name];
8072
- if (slot && slot.length > 1) {
8073
- warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
8074
- `function. You need to mark this component with $dynamic-slots in the ` +
8075
- `parent template.`);
8076
- slot = () => [];
8077
- }
8078
- // a compiled slot disables block tracking by default to avoid manual
8079
- // invocation interfering with template-based block tracking, but in
8080
- // `renderSlot` we can be sure that it's template-based so we can force
8081
- // enable it.
8082
- if (slot && slot._c) {
8083
- slot._d = false;
8084
- }
8085
- openBlock();
8086
- const validSlotContent = slot && ensureValidVNode(slot(props));
8087
- const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
8088
- ? 64 /* STABLE_FRAGMENT */
8089
- : -2 /* BAIL */);
8090
- if (!noSlotted && rendered.scopeId) {
8091
- rendered.slotScopeIds = [rendered.scopeId + '-s'];
8092
- }
8093
- if (slot && slot._c) {
8094
- slot._d = true;
8095
- }
8096
- return rendered;
8324
+ function createTextVNode(text = ' ', flag = 0) {
8325
+ return createVNode(Text, null, text, flag);
8097
8326
  }
8098
- function ensureValidVNode(vnodes) {
8099
- return vnodes.some(child => {
8100
- if (!isVNode(child))
8101
- return true;
8102
- if (child.type === Comment)
8103
- return false;
8104
- if (child.type === Fragment &&
8105
- !ensureValidVNode(child.children))
8106
- return false;
8107
- return true;
8108
- })
8109
- ? vnodes
8110
- : null;
8111
- }
8112
-
8113
8327
  /**
8114
- * For prefixing keys in v-on="obj" with "on"
8115
8328
  * @private
8116
8329
  */
8117
- function toHandlers(obj) {
8118
- const ret = {};
8119
- if (!isObject(obj)) {
8120
- warn$1(`v-on with no argument expects an object value.`);
8121
- return ret;
8122
- }
8123
- for (const key in obj) {
8124
- ret[toHandlerKey(key)] = obj[key];
8125
- }
8126
- return ret;
8127
- }
8128
-
8129
- /**
8130
- * #2437 In Vue 3, functional components do not have a public instance proxy but
8131
- * they exist in the internal parent chain. For code that relies on traversing
8132
- * public $parent chains, skip functional ones and go to the parent instead.
8133
- */
8134
- const getPublicInstance = (i) => {
8135
- if (!i)
8136
- return null;
8137
- if (isStatefulComponent(i))
8138
- return getExposeProxy(i) || i.proxy;
8139
- return getPublicInstance(i.parent);
8140
- };
8141
- const publicPropertiesMap =
8142
- // Move PURE marker to new line to workaround compiler discarding it
8143
- // due to type annotation
8144
- /*#__PURE__*/ extend(Object.create(null), {
8145
- $: i => i,
8146
- $el: i => i.vnode.el,
8147
- $data: i => i.data,
8148
- $props: i => (shallowReadonly(i.props) ),
8149
- $attrs: i => (shallowReadonly(i.attrs) ),
8150
- $slots: i => (shallowReadonly(i.slots) ),
8151
- $refs: i => (shallowReadonly(i.refs) ),
8152
- $parent: i => getPublicInstance(i.parent),
8153
- $root: i => getPublicInstance(i.root),
8154
- $emit: i => i.emit,
8155
- $options: i => (resolveMergedOptions(i) ),
8156
- $forceUpdate: i => () => queueJob(i.update),
8157
- $nextTick: i => nextTick.bind(i.proxy),
8158
- $watch: i => (instanceWatch.bind(i) )
8159
- });
8160
- const PublicInstanceProxyHandlers = {
8161
- get({ _: instance }, key) {
8162
- const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
8163
- // for internal formatters to know that this is a Vue instance
8164
- if (key === '__isVue') {
8165
- return true;
8166
- }
8167
- // prioritize <script setup> bindings during dev.
8168
- // this allows even properties that start with _ or $ to be used - so that
8169
- // it aligns with the production behavior where the render fn is inlined and
8170
- // indeed has access to all declared variables.
8171
- if (setupState !== EMPTY_OBJ &&
8172
- setupState.__isScriptSetup &&
8173
- hasOwn(setupState, key)) {
8174
- return setupState[key];
8175
- }
8176
- // data / props / ctx
8177
- // This getter gets called for every property access on the render context
8178
- // during render and is a major hotspot. The most expensive part of this
8179
- // is the multiple hasOwn() calls. It's much faster to do a simple property
8180
- // access on a plain object, so we use an accessCache object (with null
8181
- // prototype) to memoize what access type a key corresponds to.
8182
- let normalizedProps;
8183
- if (key[0] !== '$') {
8184
- const n = accessCache[key];
8185
- if (n !== undefined) {
8186
- switch (n) {
8187
- case 1 /* SETUP */:
8188
- return setupState[key];
8189
- case 2 /* DATA */:
8190
- return data[key];
8191
- case 4 /* CONTEXT */:
8192
- return ctx[key];
8193
- case 3 /* PROPS */:
8194
- return props[key];
8195
- // default: just fallthrough
8196
- }
8197
- }
8198
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8199
- accessCache[key] = 1 /* SETUP */;
8200
- return setupState[key];
8201
- }
8202
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8203
- accessCache[key] = 2 /* DATA */;
8204
- return data[key];
8205
- }
8206
- else if (
8207
- // only cache other properties when instance has declared (thus stable)
8208
- // props
8209
- (normalizedProps = instance.propsOptions[0]) &&
8210
- hasOwn(normalizedProps, key)) {
8211
- accessCache[key] = 3 /* PROPS */;
8212
- return props[key];
8213
- }
8214
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8215
- accessCache[key] = 4 /* CONTEXT */;
8216
- return ctx[key];
8217
- }
8218
- else if (shouldCacheAccess) {
8219
- accessCache[key] = 0 /* OTHER */;
8220
- }
8221
- }
8222
- const publicGetter = publicPropertiesMap[key];
8223
- let cssModule, globalProperties;
8224
- // public $xxx properties
8225
- if (publicGetter) {
8226
- if (key === '$attrs') {
8227
- track(instance, "get" /* GET */, key);
8228
- markAttrsAccessed();
8229
- }
8230
- return publicGetter(instance);
8231
- }
8232
- else if (
8233
- // css module (injected by vue-loader)
8234
- (cssModule = type.__cssModules) &&
8235
- (cssModule = cssModule[key])) {
8236
- return cssModule;
8237
- }
8238
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8239
- // user may set custom properties to `this` that start with `$`
8240
- accessCache[key] = 4 /* CONTEXT */;
8241
- return ctx[key];
8242
- }
8243
- else if (
8244
- // global properties
8245
- ((globalProperties = appContext.config.globalProperties),
8246
- hasOwn(globalProperties, key))) {
8247
- {
8248
- return globalProperties[key];
8249
- }
8250
- }
8251
- else if (currentRenderingInstance &&
8252
- (!isString(key) ||
8253
- // #1091 avoid internal isRef/isVNode checks on component instance leading
8254
- // to infinite warning loop
8255
- key.indexOf('__v') !== 0)) {
8256
- if (data !== EMPTY_OBJ &&
8257
- (key[0] === '$' || key[0] === '_') &&
8258
- hasOwn(data, key)) {
8259
- warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
8260
- `character ("$" or "_") and is not proxied on the render context.`);
8261
- }
8262
- else if (instance === currentRenderingInstance) {
8263
- warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
8264
- `but is not defined on instance.`);
8330
+ function createStaticVNode(content, numberOfNodes) {
8331
+ // A static vnode can contain multiple stringified elements, and the number
8332
+ // of elements is necessary for hydration.
8333
+ const vnode = createVNode(Static, null, content);
8334
+ vnode.staticCount = numberOfNodes;
8335
+ return vnode;
8336
+ }
8337
+ /**
8338
+ * @private
8339
+ */
8340
+ function createCommentVNode(text = '',
8341
+ // when used as the v-else branch, the comment node must be created as a
8342
+ // block to ensure correct updates.
8343
+ asBlock = false) {
8344
+ return asBlock
8345
+ ? (openBlock(), createBlock(Comment, null, text))
8346
+ : createVNode(Comment, null, text);
8347
+ }
8348
+ function normalizeVNode(child) {
8349
+ if (child == null || typeof child === 'boolean') {
8350
+ // empty placeholder
8351
+ return createVNode(Comment);
8352
+ }
8353
+ else if (isArray(child)) {
8354
+ // fragment
8355
+ return createVNode(Fragment, null,
8356
+ // #3666, avoid reference pollution when reusing vnode
8357
+ child.slice());
8358
+ }
8359
+ else if (typeof child === 'object') {
8360
+ // already vnode, this should be the most common since compiled templates
8361
+ // always produce all-vnode children arrays
8362
+ return cloneIfMounted(child);
8363
+ }
8364
+ else {
8365
+ // strings and numbers
8366
+ return createVNode(Text, null, String(child));
8367
+ }
8368
+ }
8369
+ // optimized normalization for template-compiled render fns
8370
+ function cloneIfMounted(child) {
8371
+ return child.el === null || child.memo ? child : cloneVNode(child);
8372
+ }
8373
+ function normalizeChildren(vnode, children) {
8374
+ let type = 0;
8375
+ const { shapeFlag } = vnode;
8376
+ if (children == null) {
8377
+ children = null;
8378
+ }
8379
+ else if (isArray(children)) {
8380
+ type = 16 /* ARRAY_CHILDREN */;
8381
+ }
8382
+ else if (typeof children === 'object') {
8383
+ if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
8384
+ // Normalize slot to plain children for plain element and Teleport
8385
+ const slot = children.default;
8386
+ if (slot) {
8387
+ // _c marker is added by withCtx() indicating this is a compiled slot
8388
+ slot._c && (slot._d = false);
8389
+ normalizeChildren(vnode, slot());
8390
+ slot._c && (slot._d = true);
8265
8391
  }
8266
- }
8267
- },
8268
- set({ _: instance }, key, value) {
8269
- const { data, setupState, ctx } = instance;
8270
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8271
- setupState[key] = value;
8272
- return true;
8273
- }
8274
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8275
- data[key] = value;
8276
- return true;
8277
- }
8278
- else if (hasOwn(instance.props, key)) {
8279
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
8280
- return false;
8281
- }
8282
- if (key[0] === '$' && key.slice(1) in instance) {
8283
- warn$1(`Attempting to mutate public property "${key}". ` +
8284
- `Properties starting with $ are reserved and readonly.`, instance);
8285
- return false;
8392
+ return;
8286
8393
  }
8287
8394
  else {
8288
- if (key in instance.appContext.config.globalProperties) {
8289
- Object.defineProperty(ctx, key, {
8290
- enumerable: true,
8291
- configurable: true,
8292
- value
8293
- });
8395
+ type = 32 /* SLOTS_CHILDREN */;
8396
+ const slotFlag = children._;
8397
+ if (!slotFlag && !(InternalObjectKey in children)) {
8398
+ children._ctx = currentRenderingInstance;
8294
8399
  }
8295
- else {
8296
- ctx[key] = value;
8400
+ else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
8401
+ // a child component receives forwarded slots from the parent.
8402
+ // its slot type is determined by its parent's slot type.
8403
+ if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
8404
+ children._ = 1 /* STABLE */;
8405
+ }
8406
+ else {
8407
+ children._ = 2 /* DYNAMIC */;
8408
+ vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
8409
+ }
8297
8410
  }
8298
8411
  }
8299
- return true;
8300
- },
8301
- has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
8302
- let normalizedProps;
8303
- return (!!accessCache[key] ||
8304
- (data !== EMPTY_OBJ && hasOwn(data, key)) ||
8305
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
8306
- ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
8307
- hasOwn(ctx, key) ||
8308
- hasOwn(publicPropertiesMap, key) ||
8309
- hasOwn(appContext.config.globalProperties, key));
8310
- },
8311
- defineProperty(target, key, descriptor) {
8312
- if (descriptor.get != null) {
8313
- // invalidate key cache of a getter based property #5417
8314
- target._.accessCache[key] = 0;
8315
- }
8316
- else if (hasOwn(descriptor, 'value')) {
8317
- this.set(target, key, descriptor.value, null);
8318
- }
8319
- return Reflect.defineProperty(target, key, descriptor);
8320
8412
  }
8321
- };
8322
- {
8323
- PublicInstanceProxyHandlers.ownKeys = (target) => {
8324
- warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
8325
- `The keys will be empty in production mode to avoid performance overhead.`);
8326
- return Reflect.ownKeys(target);
8327
- };
8328
- }
8329
- const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
8330
- get(target, key) {
8331
- // fast path for unscopables when using `with` block
8332
- if (key === Symbol.unscopables) {
8333
- return;
8413
+ else if (isFunction(children)) {
8414
+ children = { default: children, _ctx: currentRenderingInstance };
8415
+ type = 32 /* SLOTS_CHILDREN */;
8416
+ }
8417
+ else {
8418
+ children = String(children);
8419
+ // force teleport children to array so it can be moved around
8420
+ if (shapeFlag & 64 /* TELEPORT */) {
8421
+ type = 16 /* ARRAY_CHILDREN */;
8422
+ children = [createTextVNode(children)];
8334
8423
  }
8335
- return PublicInstanceProxyHandlers.get(target, key, target);
8336
- },
8337
- has(_, key) {
8338
- const has = key[0] !== '_' && !isGloballyWhitelisted(key);
8339
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
8340
- warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
8424
+ else {
8425
+ type = 8 /* TEXT_CHILDREN */;
8341
8426
  }
8342
- return has;
8343
- }
8344
- });
8345
- // dev only
8346
- // In dev mode, the proxy target exposes the same properties as seen on `this`
8347
- // for easier console inspection. In prod mode it will be an empty object so
8348
- // these properties definitions can be skipped.
8349
- function createDevRenderContext(instance) {
8350
- const target = {};
8351
- // expose internal instance for proxy handlers
8352
- Object.defineProperty(target, `_`, {
8353
- configurable: true,
8354
- enumerable: false,
8355
- get: () => instance
8356
- });
8357
- // expose public properties
8358
- Object.keys(publicPropertiesMap).forEach(key => {
8359
- Object.defineProperty(target, key, {
8360
- configurable: true,
8361
- enumerable: false,
8362
- get: () => publicPropertiesMap[key](instance),
8363
- // intercepted by the proxy so no need for implementation,
8364
- // but needed to prevent set errors
8365
- set: NOOP
8366
- });
8367
- });
8368
- return target;
8369
- }
8370
- // dev only
8371
- function exposePropsOnRenderContext(instance) {
8372
- const { ctx, propsOptions: [propsOptions] } = instance;
8373
- if (propsOptions) {
8374
- Object.keys(propsOptions).forEach(key => {
8375
- Object.defineProperty(ctx, key, {
8376
- enumerable: true,
8377
- configurable: true,
8378
- get: () => instance.props[key],
8379
- set: NOOP
8380
- });
8381
- });
8382
8427
  }
8428
+ vnode.children = children;
8429
+ vnode.shapeFlag |= type;
8383
8430
  }
8384
- // dev only
8385
- function exposeSetupStateOnRenderContext(instance) {
8386
- const { ctx, setupState } = instance;
8387
- Object.keys(toRaw(setupState)).forEach(key => {
8388
- if (!setupState.__isScriptSetup) {
8389
- if (key[0] === '$' || key[0] === '_') {
8390
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8391
- `which are reserved prefixes for Vue internals.`);
8392
- return;
8431
+ function mergeProps(...args) {
8432
+ const ret = {};
8433
+ for (let i = 0; i < args.length; i++) {
8434
+ const toMerge = args[i];
8435
+ for (const key in toMerge) {
8436
+ if (key === 'class') {
8437
+ if (ret.class !== toMerge.class) {
8438
+ ret.class = normalizeClass([ret.class, toMerge.class]);
8439
+ }
8440
+ }
8441
+ else if (key === 'style') {
8442
+ ret.style = normalizeStyle([ret.style, toMerge.style]);
8443
+ }
8444
+ else if (isOn(key)) {
8445
+ const existing = ret[key];
8446
+ const incoming = toMerge[key];
8447
+ if (incoming &&
8448
+ existing !== incoming &&
8449
+ !(isArray(existing) && existing.includes(incoming))) {
8450
+ ret[key] = existing
8451
+ ? [].concat(existing, incoming)
8452
+ : incoming;
8453
+ }
8454
+ }
8455
+ else if (key !== '') {
8456
+ ret[key] = toMerge[key];
8393
8457
  }
8394
- Object.defineProperty(ctx, key, {
8395
- enumerable: true,
8396
- configurable: true,
8397
- get: () => setupState[key],
8398
- set: NOOP
8399
- });
8400
8458
  }
8401
- });
8459
+ }
8460
+ return ret;
8461
+ }
8462
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8463
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8464
+ vnode,
8465
+ prevVNode
8466
+ ]);
8402
8467
  }
8403
8468
 
8404
8469
  const emptyAppContext = createAppContext();
@@ -8427,7 +8492,7 @@ function createComponentInstance(vnode, parent, suspense) {
8427
8492
  provides: parent ? parent.provides : Object.create(appContext.provides),
8428
8493
  accessCache: null,
8429
8494
  renderCache: [],
8430
- // local resovled assets
8495
+ // local resolved assets
8431
8496
  components: null,
8432
8497
  directives: null,
8433
8498
  // resolved props and emits options
@@ -9188,7 +9253,7 @@ function isMemoSame(cached, memo) {
9188
9253
  return false;
9189
9254
  }
9190
9255
  for (let i = 0; i < prev.length; i++) {
9191
- if (prev[i] !== memo[i]) {
9256
+ if (hasChanged(prev[i], memo[i])) {
9192
9257
  return false;
9193
9258
  }
9194
9259
  }
@@ -9200,7 +9265,7 @@ function isMemoSame(cached, memo) {
9200
9265
  }
9201
9266
 
9202
9267
  // Core API ------------------------------------------------------------------
9203
- const version = "3.2.33";
9268
+ const version = "3.2.35";
9204
9269
  /**
9205
9270
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9206
9271
  * @internal
@@ -9677,11 +9742,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
9677
9742
  return key in el;
9678
9743
  }
9679
9744
 
9680
- function defineCustomElement(options, hydate) {
9745
+ function defineCustomElement(options, hydrate) {
9681
9746
  const Comp = defineComponent(options);
9682
9747
  class VueCustomElement extends VueElement {
9683
9748
  constructor(initialProps) {
9684
- super(Comp, initialProps, hydate);
9749
+ super(Comp, initialProps, hydrate);
9685
9750
  }
9686
9751
  }
9687
9752
  VueCustomElement.def = Comp;
@@ -10041,7 +10106,10 @@ function resolveTransitionProps(rawProps) {
10041
10106
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
10042
10107
  done && done();
10043
10108
  };
10109
+ let isLeaving = false;
10044
10110
  const finishLeave = (el, done) => {
10111
+ isLeaving = false;
10112
+ removeTransitionClass(el, leaveFromClass);
10045
10113
  removeTransitionClass(el, leaveToClass);
10046
10114
  removeTransitionClass(el, leaveActiveClass);
10047
10115
  done && done();
@@ -10074,12 +10142,17 @@ function resolveTransitionProps(rawProps) {
10074
10142
  onEnter: makeEnterHook(false),
10075
10143
  onAppear: makeEnterHook(true),
10076
10144
  onLeave(el, done) {
10145
+ isLeaving = true;
10077
10146
  const resolve = () => finishLeave(el, done);
10078
10147
  addTransitionClass(el, leaveFromClass);
10079
10148
  // force reflow so *-leave-from classes immediately take effect (#2593)
10080
10149
  forceReflow();
10081
10150
  addTransitionClass(el, leaveActiveClass);
10082
10151
  nextFrame(() => {
10152
+ if (!isLeaving) {
10153
+ // cancelled
10154
+ return;
10155
+ }
10083
10156
  removeTransitionClass(el, leaveFromClass);
10084
10157
  addTransitionClass(el, leaveToClass);
10085
10158
  if (!hasExplicitCallback(onLeave)) {
@@ -10371,7 +10444,8 @@ function hasCSSTransform(el, root, moveClass) {
10371
10444
  }
10372
10445
 
10373
10446
  const getModelAssigner = (vnode) => {
10374
- const fn = vnode.props['onUpdate:modelValue'];
10447
+ const fn = vnode.props['onUpdate:modelValue'] ||
10448
+ (false );
10375
10449
  return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10376
10450
  };
10377
10451
  function onCompositionStart(e) {
@@ -10381,14 +10455,9 @@ function onCompositionEnd(e) {
10381
10455
  const target = e.target;
10382
10456
  if (target.composing) {
10383
10457
  target.composing = false;
10384
- trigger$1(target, 'input');
10458
+ target.dispatchEvent(new Event('input'));
10385
10459
  }
10386
10460
  }
10387
- function trigger$1(el, type) {
10388
- const e = document.createEvent('HTMLEvents');
10389
- e.initEvent(type, true, true);
10390
- el.dispatchEvent(e);
10391
- }
10392
10461
  // We are exporting the v-model runtime directly as vnode hooks so that it can
10393
10462
  // be tree-shaken in case v-model is never used.
10394
10463
  const vModelText = {
@@ -10402,7 +10471,7 @@ const vModelText = {
10402
10471
  if (trim) {
10403
10472
  domValue = domValue.trim();
10404
10473
  }
10405
- else if (castToNumber) {
10474
+ if (castToNumber) {
10406
10475
  domValue = toNumber(domValue);
10407
10476
  }
10408
10477
  el._assign(domValue);
@@ -10431,7 +10500,7 @@ const vModelText = {
10431
10500
  // avoid clearing unresolved text. #2302
10432
10501
  if (el.composing)
10433
10502
  return;
10434
- if (document.activeElement === el) {
10503
+ if (document.activeElement === el && el.type !== 'range') {
10435
10504
  if (lazy) {
10436
10505
  return;
10437
10506
  }
@@ -10601,27 +10670,25 @@ const vModelDynamic = {
10601
10670
  callModelHook(el, binding, vnode, prevVNode, 'updated');
10602
10671
  }
10603
10672
  };
10604
- function callModelHook(el, binding, vnode, prevVNode, hook) {
10605
- let modelToUse;
10606
- switch (el.tagName) {
10673
+ function resolveDynamicModel(tagName, type) {
10674
+ switch (tagName) {
10607
10675
  case 'SELECT':
10608
- modelToUse = vModelSelect;
10609
- break;
10676
+ return vModelSelect;
10610
10677
  case 'TEXTAREA':
10611
- modelToUse = vModelText;
10612
- break;
10678
+ return vModelText;
10613
10679
  default:
10614
- switch (vnode.props && vnode.props.type) {
10680
+ switch (type) {
10615
10681
  case 'checkbox':
10616
- modelToUse = vModelCheckbox;
10617
- break;
10682
+ return vModelCheckbox;
10618
10683
  case 'radio':
10619
- modelToUse = vModelRadio;
10620
- break;
10684
+ return vModelRadio;
10621
10685
  default:
10622
- modelToUse = vModelText;
10686
+ return vModelText;
10623
10687
  }
10624
10688
  }
10689
+ }
10690
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
10691
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
10625
10692
  const fn = modelToUse[hook];
10626
10693
  fn && fn(el, binding, vnode, prevVNode);
10627
10694
  }
@@ -13035,6 +13102,7 @@ function createStructuralDirectiveTransform(name, fn) {
13035
13102
  }
13036
13103
 
13037
13104
  const PURE_ANNOTATION = `/*#__PURE__*/`;
13105
+ const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
13038
13106
  function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
13039
13107
  const context = {
13040
13108
  mode,
@@ -13111,9 +13179,7 @@ function generate(ast, options = {}) {
13111
13179
  // function mode const declarations should be inside with block
13112
13180
  // also they should be renamed to avoid collision with user properties
13113
13181
  if (hasHelpers) {
13114
- push(`const { ${ast.helpers
13115
- .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
13116
- .join(', ')} } = _Vue`);
13182
+ push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
13117
13183
  push(`\n`);
13118
13184
  newline();
13119
13185
  }
@@ -13168,7 +13234,6 @@ function generate(ast, options = {}) {
13168
13234
  function genFunctionPreamble(ast, context) {
13169
13235
  const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
13170
13236
  const VueBinding = runtimeGlobalName;
13171
- const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
13172
13237
  // Generate const declaration for helpers
13173
13238
  // In prefix mode, we place the const declaration at top so it's done
13174
13239
  // only once; But if we not prefixing, we place the declaration inside the
@@ -13781,14 +13846,14 @@ function processIf(node, dir, context, processCodegen) {
13781
13846
  }
13782
13847
  }
13783
13848
  function createIfBranch(node, dir) {
13849
+ const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
13784
13850
  return {
13785
13851
  type: 10 /* IF_BRANCH */,
13786
13852
  loc: node.loc,
13787
13853
  condition: dir.name === 'else' ? undefined : dir.exp,
13788
- children: node.tagType === 3 /* TEMPLATE */ && !findDir(node, 'for')
13789
- ? node.children
13790
- : [node],
13791
- userKey: findProp(node, `key`)
13854
+ children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
13855
+ userKey: findProp(node, `key`),
13856
+ isTemplateIf
13792
13857
  };
13793
13858
  }
13794
13859
  function createCodegenNodeForBranch(branch, keyIndex, context) {
@@ -13823,7 +13888,8 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
13823
13888
  let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
13824
13889
  // check if the fragment actually contains a single valid child with
13825
13890
  // the rest being comments
13826
- if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
13891
+ if (!branch.isTemplateIf &&
13892
+ children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
13827
13893
  patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
13828
13894
  patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
13829
13895
  }
@@ -14374,7 +14440,7 @@ const transformElement = (node, context) => {
14374
14440
  (tag === 'svg' || tag === 'foreignObject'));
14375
14441
  // props
14376
14442
  if (props.length > 0) {
14377
- const propsBuildResult = buildProps(node, context);
14443
+ const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
14378
14444
  vnodeProps = propsBuildResult.props;
14379
14445
  patchFlag = propsBuildResult.patchFlag;
14380
14446
  dynamicPropNames = propsBuildResult.dynamicPropNames;
@@ -14513,9 +14579,8 @@ function resolveComponentType(node, context, ssr = false) {
14513
14579
  context.components.add(tag);
14514
14580
  return toValidAssetId(tag, `component`);
14515
14581
  }
14516
- function buildProps(node, context, props = node.props, ssr = false) {
14582
+ function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
14517
14583
  const { tag, loc: elementLoc, children } = node;
14518
- const isComponent = node.tagType === 1 /* COMPONENT */;
14519
14584
  let properties = [];
14520
14585
  const mergeArgs = [];
14521
14586
  const runtimeDirectives = [];
@@ -14534,8 +14599,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
14534
14599
  if (isStaticExp(key)) {
14535
14600
  const name = key.content;
14536
14601
  const isEventHandler = isOn(name);
14537
- if (!isComponent &&
14538
- isEventHandler &&
14602
+ if (isEventHandler &&
14603
+ (!isComponent || isDynamicComponent) &&
14539
14604
  // omit the flag for click handlers because hydration gives click
14540
14605
  // dedicated fast path.
14541
14606
  name.toLowerCase() !== 'onclick' &&
@@ -14761,10 +14826,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
14761
14826
  classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
14762
14827
  }
14763
14828
  if (styleProp &&
14764
- !isStaticExp(styleProp.value) &&
14765
14829
  // the static style is compiled into an object,
14766
14830
  // so use `hasStyleBinding` to ensure that it is a dynamic style binding
14767
14831
  (hasStyleBinding ||
14832
+ (styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
14833
+ styleProp.value.content.trim()[0] === `[`) ||
14768
14834
  // v-bind:style and style both exist,
14769
14835
  // v-bind:style with static literal object
14770
14836
  styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
@@ -14943,7 +15009,7 @@ function processSlotOutlet(node, context) {
14943
15009
  }
14944
15010
  }
14945
15011
  if (nonNameProps.length > 0) {
14946
- const { props, directives } = buildProps(node, context, nonNameProps);
15012
+ const { props, directives } = buildProps(node, context, nonNameProps, false, false);
14947
15013
  slotProps = props;
14948
15014
  if (directives.length) {
14949
15015
  context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
@@ -15114,11 +15180,7 @@ const transformText = (node, context) => {
15114
15180
  const next = children[j];
15115
15181
  if (isText(next)) {
15116
15182
  if (!currentContainer) {
15117
- currentContainer = children[i] = {
15118
- type: 8 /* COMPOUND_EXPRESSION */,
15119
- loc: child.loc,
15120
- children: [child]
15121
- };
15183
+ currentContainer = children[i] = createCompoundExpression([child], child.loc);
15122
15184
  }
15123
15185
  // merge adjacent text node into current
15124
15186
  currentContainer.children.push(` + `, next);
@@ -15525,7 +15587,9 @@ const transformVText = (dir, node, context) => {
15525
15587
  return {
15526
15588
  props: [
15527
15589
  createObjectProperty(createSimpleExpression(`textContent`, true), exp
15528
- ? createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
15590
+ ? getConstantType(exp, context) > 0
15591
+ ? exp
15592
+ : createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
15529
15593
  : createSimpleExpression('', true))
15530
15594
  ]
15531
15595
  };
@@ -15733,19 +15797,38 @@ const transformShow = (dir, node, context) => {
15733
15797
  };
15734
15798
  };
15735
15799
 
15736
- const warnTransitionChildren = (node, context) => {
15800
+ const transformTransition = (node, context) => {
15737
15801
  if (node.type === 1 /* ELEMENT */ &&
15738
15802
  node.tagType === 1 /* COMPONENT */) {
15739
15803
  const component = context.isBuiltInComponent(node.tag);
15740
15804
  if (component === TRANSITION$1) {
15741
15805
  return () => {
15742
- if (node.children.length && hasMultipleChildren(node)) {
15806
+ if (!node.children.length) {
15807
+ return;
15808
+ }
15809
+ // warn multiple transition children
15810
+ if (hasMultipleChildren(node)) {
15743
15811
  context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
15744
15812
  start: node.children[0].loc.start,
15745
15813
  end: node.children[node.children.length - 1].loc.end,
15746
15814
  source: ''
15747
15815
  }));
15748
15816
  }
15817
+ // check if it's s single child w/ v-show
15818
+ // if yes, inject "persisted: true" to the transition props
15819
+ const child = node.children[0];
15820
+ if (child.type === 1 /* ELEMENT */) {
15821
+ for (const p of child.props) {
15822
+ if (p.type === 7 /* DIRECTIVE */ && p.name === 'show') {
15823
+ node.props.push({
15824
+ type: 6 /* ATTRIBUTE */,
15825
+ name: 'persisted',
15826
+ value: undefined,
15827
+ loc: node.loc
15828
+ });
15829
+ }
15830
+ }
15831
+ }
15749
15832
  };
15750
15833
  }
15751
15834
  }
@@ -15771,7 +15854,7 @@ const ignoreSideEffectTags = (node, context) => {
15771
15854
 
15772
15855
  const DOMNodeTransforms = [
15773
15856
  transformStyle,
15774
- ...([warnTransitionChildren] )
15857
+ ...([transformTransition] )
15775
15858
  ];
15776
15859
  const DOMDirectiveTransforms = {
15777
15860
  cloak: noopDirectiveTransform,