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