vue 3.2.32 → 3.2.34

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';
@@ -615,10 +620,17 @@ var Vue = (function (exports) {
615
620
  activeEffect = this.parent;
616
621
  shouldTrack = lastShouldTrack;
617
622
  this.parent = undefined;
623
+ if (this.deferStop) {
624
+ this.stop();
625
+ }
618
626
  }
619
627
  }
620
628
  stop() {
621
- if (this.active) {
629
+ // stopped while running itself - defer the cleanup
630
+ if (activeEffect === this) {
631
+ this.deferStop = true;
632
+ }
633
+ else if (this.active) {
622
634
  cleanupEffect(this);
623
635
  if (this.onStop) {
624
636
  this.onStop();
@@ -777,23 +789,40 @@ var Vue = (function (exports) {
777
789
  }
778
790
  function triggerEffects(dep, debuggerEventExtraInfo) {
779
791
  // spread into array for stabilization
780
- for (const effect of isArray(dep) ? dep : [...dep]) {
781
- if (effect !== activeEffect || effect.allowRecurse) {
782
- if (effect.onTrigger) {
783
- effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
784
- }
785
- if (effect.scheduler) {
786
- effect.scheduler();
787
- }
788
- else {
789
- effect.run();
790
- }
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();
791
814
  }
792
815
  }
793
816
  }
794
817
 
795
818
  const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
796
- const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
819
+ const builtInSymbols = new Set(
820
+ /*#__PURE__*/
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')
797
826
  .map(key => Symbol[key])
798
827
  .filter(isSymbol));
799
828
  const get = /*#__PURE__*/ createGetter();
@@ -867,9 +896,8 @@ var Vue = (function (exports) {
867
896
  return res;
868
897
  }
869
898
  if (isRef(res)) {
870
- // ref unwrapping - does not apply for Array + integer key.
871
- const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
872
- return shouldUnwrap ? res.value : res;
899
+ // ref unwrapping - skip unwrap for Array + integer key.
900
+ return targetIsArray && isIntegerKey(key) ? res : res.value;
873
901
  }
874
902
  if (isObject(res)) {
875
903
  // Convert returned value into a proxy as well. we do the isObject check
@@ -945,13 +973,13 @@ var Vue = (function (exports) {
945
973
  get: readonlyGet,
946
974
  set(target, key) {
947
975
  {
948
- console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
976
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
949
977
  }
950
978
  return true;
951
979
  },
952
980
  deleteProperty(target, key) {
953
981
  {
954
- console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
982
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
955
983
  }
956
984
  return true;
957
985
  }
@@ -975,10 +1003,12 @@ var Vue = (function (exports) {
975
1003
  target = target["__v_raw" /* RAW */];
976
1004
  const rawTarget = toRaw(target);
977
1005
  const rawKey = toRaw(key);
978
- if (key !== rawKey) {
979
- !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);
980
1011
  }
981
- !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
982
1012
  const { has } = getProto(rawTarget);
983
1013
  const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
984
1014
  if (has.call(rawTarget, key)) {
@@ -997,10 +1027,12 @@ var Vue = (function (exports) {
997
1027
  const target = this["__v_raw" /* RAW */];
998
1028
  const rawTarget = toRaw(target);
999
1029
  const rawKey = toRaw(key);
1000
- if (key !== rawKey) {
1001
- !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);
1002
1035
  }
1003
- !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
1004
1036
  return key === rawKey
1005
1037
  ? target.has(key)
1006
1038
  : target.has(key) || target.has(rawKey);
@@ -1326,7 +1358,7 @@ var Vue = (function (exports) {
1326
1358
  if (existingProxy) {
1327
1359
  return existingProxy;
1328
1360
  }
1329
- // only a whitelist of value types can be observed.
1361
+ // only specific value types can be observed.
1330
1362
  const targetType = getTargetType(target);
1331
1363
  if (targetType === 0 /* INVALID */) {
1332
1364
  return target;
@@ -1779,7 +1811,7 @@ var Vue = (function (exports) {
1779
1811
  const pendingPostFlushCbs = [];
1780
1812
  let activePostFlushCbs = null;
1781
1813
  let postFlushIndex = 0;
1782
- const resolvedPromise = Promise.resolve();
1814
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
1783
1815
  let currentFlushPromise = null;
1784
1816
  let currentPreFlushParentJob = null;
1785
1817
  const RECURSION_LIMIT = 100;
@@ -1876,6 +1908,8 @@ var Vue = (function (exports) {
1876
1908
  }
1877
1909
  }
1878
1910
  function flushPostFlushCbs(seen) {
1911
+ // flush any pre cbs queued during the flush (e.g. pre watchers)
1912
+ flushPreFlushCbs();
1879
1913
  if (pendingPostFlushCbs.length) {
1880
1914
  const deduped = [...new Set(pendingPostFlushCbs)];
1881
1915
  pendingPostFlushCbs.length = 0;
@@ -2134,7 +2168,6 @@ var Vue = (function (exports) {
2134
2168
  // handle late devtools injection - only do this if we are in an actual
2135
2169
  // browser environment to avoid the timer handle stalling test runner exit
2136
2170
  // (#4815)
2137
- // eslint-disable-next-line no-restricted-globals
2138
2171
  typeof window !== 'undefined' &&
2139
2172
  // some envs mock window but not fully
2140
2173
  window.HTMLElement &&
@@ -2194,6 +2227,8 @@ var Vue = (function (exports) {
2194
2227
  }
2195
2228
 
2196
2229
  function emit$1(instance, event, ...rawArgs) {
2230
+ if (instance.isUnmounted)
2231
+ return;
2197
2232
  const props = instance.vnode.props || EMPTY_OBJ;
2198
2233
  {
2199
2234
  const { emitsOptions, propsOptions: [propsOptions] } = instance;
@@ -2226,7 +2261,7 @@ var Vue = (function (exports) {
2226
2261
  if (trim) {
2227
2262
  args = rawArgs.map(a => a.trim());
2228
2263
  }
2229
- else if (number) {
2264
+ if (number) {
2230
2265
  args = rawArgs.map(toNumber);
2231
2266
  }
2232
2267
  }
@@ -2524,6 +2559,8 @@ var Vue = (function (exports) {
2524
2559
  warn$1(`Runtime directive used on component with non-element root node. ` +
2525
2560
  `The directives will not function as intended.`);
2526
2561
  }
2562
+ // clone before mutating since the root may be a hoisted vnode
2563
+ root = cloneVNode(root);
2527
2564
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2528
2565
  }
2529
2566
  // inherit transition data
@@ -3226,7 +3263,7 @@ var Vue = (function (exports) {
3226
3263
  }
3227
3264
  else if (isArray(source)) {
3228
3265
  isMultiSource = true;
3229
- forceTrigger = source.some(isReactive);
3266
+ forceTrigger = source.some(s => isReactive(s) || isShallow(s));
3230
3267
  getter = () => source.map(s => {
3231
3268
  if (isRef(s)) {
3232
3269
  return s.value;
@@ -3318,16 +3355,7 @@ var Vue = (function (exports) {
3318
3355
  }
3319
3356
  else {
3320
3357
  // default: 'pre'
3321
- scheduler = () => {
3322
- if (!instance || instance.isMounted) {
3323
- queuePreFlushCb(job);
3324
- }
3325
- else {
3326
- // with 'pre' option, the first call must happen before
3327
- // the component is mounted so it is called synchronously.
3328
- job();
3329
- }
3330
- };
3358
+ scheduler = () => queuePreFlushCb(job);
3331
3359
  }
3332
3360
  const effect = new ReactiveEffect(getter, scheduler);
3333
3361
  {
@@ -3470,10 +3498,22 @@ var Vue = (function (exports) {
3470
3498
  if (!children || !children.length) {
3471
3499
  return;
3472
3500
  }
3473
- // warn multiple elements
3501
+ let child = children[0];
3474
3502
  if (children.length > 1) {
3475
- warn$1('<transition> can only be used on a single element or component. Use ' +
3476
- '<transition-group> for lists.');
3503
+ let hasFound = false;
3504
+ // locate first non-comment child
3505
+ for (const c of children) {
3506
+ if (c.type !== Comment) {
3507
+ if (hasFound) {
3508
+ // warn more than one non-comment child
3509
+ warn$1('<transition> can only be used on a single element or component. ' +
3510
+ 'Use <transition-group> for lists.');
3511
+ break;
3512
+ }
3513
+ child = c;
3514
+ hasFound = true;
3515
+ }
3516
+ }
3477
3517
  }
3478
3518
  // there's no need to track reactivity for these props so use the raw
3479
3519
  // props for a bit better perf
@@ -3486,8 +3526,6 @@ var Vue = (function (exports) {
3486
3526
  mode !== 'default') {
3487
3527
  warn$1(`invalid <transition> mode: ${mode}`);
3488
3528
  }
3489
- // at this point children has a guaranteed length of 1.
3490
- const child = children[0];
3491
3529
  if (state.isLeaving) {
3492
3530
  return emptyPlaceholder(child);
3493
3531
  }
@@ -3570,6 +3608,17 @@ var Vue = (function (exports) {
3570
3608
  hook &&
3571
3609
  callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3572
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
+ };
3573
3622
  const hooks = {
3574
3623
  mode,
3575
3624
  persisted,
@@ -3628,10 +3677,7 @@ var Vue = (function (exports) {
3628
3677
  el._enterCb = undefined;
3629
3678
  });
3630
3679
  if (hook) {
3631
- hook(el, done);
3632
- if (hook.length <= 1) {
3633
- done();
3634
- }
3680
+ callAsyncHook(hook, [el, done]);
3635
3681
  }
3636
3682
  else {
3637
3683
  done();
@@ -3665,10 +3711,7 @@ var Vue = (function (exports) {
3665
3711
  });
3666
3712
  leavingVNodesCache[key] = vnode;
3667
3713
  if (onLeave) {
3668
- onLeave(el, done);
3669
- if (onLeave.length <= 1) {
3670
- done();
3671
- }
3714
+ callAsyncHook(onLeave, [el, done]);
3672
3715
  }
3673
3716
  else {
3674
3717
  done();
@@ -3878,7 +3921,7 @@ var Vue = (function (exports) {
3878
3921
  }
3879
3922
  });
3880
3923
  }
3881
- function createInnerComp(comp, { vnode: { ref, props, children } }) {
3924
+ function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3882
3925
  const vnode = createVNode(comp, props, children);
3883
3926
  // ensure inner component inherits the async wrapper's ref owner
3884
3927
  vnode.ref = ref;
@@ -3905,11 +3948,6 @@ var Vue = (function (exports) {
3905
3948
  // The whole point of this is to avoid importing KeepAlive directly in the
3906
3949
  // renderer to facilitate tree-shaking.
3907
3950
  const sharedContext = instance.ctx;
3908
- // if the internal renderer is not registered, it indicates that this is server-side rendering,
3909
- // for KeepAlive, we just need to render its children
3910
- if (!sharedContext.renderer) {
3911
- return slots.default;
3912
- }
3913
3951
  const cache = new Map();
3914
3952
  const keys = new Set();
3915
3953
  let current = null;
@@ -4087,7 +4125,7 @@ var Vue = (function (exports) {
4087
4125
  // avoid vnode being unmounted
4088
4126
  vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
4089
4127
  current = vnode;
4090
- return rawVNode;
4128
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
4091
4129
  };
4092
4130
  }
4093
4131
  };
@@ -4225,1111 +4263,1598 @@ var Vue = (function (exports) {
4225
4263
  injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4226
4264
  }
4227
4265
 
4228
- function createDuplicateChecker() {
4229
- const cache = Object.create(null);
4230
- return (type, key) => {
4231
- if (cache[key]) {
4232
- 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
+ };
4233
4302
  }
4234
- else {
4235
- cache[key] = type;
4303
+ if (dir.deep) {
4304
+ traverse(value);
4236
4305
  }
4237
- };
4238
- }
4239
- let shouldCacheAccess = true;
4240
- function applyOptions(instance) {
4241
- const options = resolveMergedOptions(instance);
4242
- const publicThis = instance.proxy;
4243
- const ctx = instance.ctx;
4244
- // do not cache property access on public proxy during state initialization
4245
- shouldCacheAccess = false;
4246
- // call beforeCreate first before accessing other options since
4247
- // the hook may mutate resolved options (#2791)
4248
- if (options.beforeCreate) {
4249
- 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
+ });
4250
4314
  }
4251
- const {
4252
- // state
4253
- data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4254
- // lifecycle
4255
- created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4256
- // public API
4257
- expose, inheritAttrs,
4258
- // assets
4259
- components, directives, filters } = options;
4260
- const checkDuplicateProperties = createDuplicateChecker() ;
4261
- {
4262
- const [propsOptions] = instance.propsOptions;
4263
- if (propsOptions) {
4264
- for (const key in propsOptions) {
4265
- checkDuplicateProperties("Props" /* PROPS */, key);
4266
- }
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();
4267
4337
  }
4268
4338
  }
4269
- // options initialization order (to be consistent with Vue 2):
4270
- // - props (already done outside of this function)
4271
- // - inject
4272
- // - methods
4273
- // - data (deferred since it relies on `this` access)
4274
- // - computed
4275
- // - watch (deferred since it relies on `this` access)
4276
- if (injectOptions) {
4277
- 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;
4278
4356
  }
4279
- if (methods) {
4280
- for (const key in methods) {
4281
- const methodHandler = methods[key];
4282
- if (isFunction(methodHandler)) {
4283
- // In dev mode, we use the `createRenderContext` function to define
4284
- // methods to the proxy target, and those are read-only but
4285
- // reconfigurable, so it needs to be redefined here
4286
- {
4287
- Object.defineProperty(ctx, key, {
4288
- value: methodHandler.bind(publicThis),
4289
- configurable: true,
4290
- enumerable: true,
4291
- writable: true
4292
- });
4293
- }
4294
- {
4295
- checkDuplicateProperties("Methods" /* METHODS */, key);
4296
- }
4297
- }
4298
- else {
4299
- warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4300
- `Did you reference the function correctly?`);
4301
- }
4302
- }
4357
+ else {
4358
+ // invalid types will fallthrough to createVNode and raise warning
4359
+ return (component || NULL_DYNAMIC_COMPONENT);
4303
4360
  }
4304
- if (dataOptions) {
4305
- if (!isFunction(dataOptions)) {
4306
- warn$1(`The data option must be a function. ` +
4307
- `Plain object usage is no longer supported.`);
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
+ }
4308
4382
  }
4309
- const data = dataOptions.call(publicThis, publicThis);
4310
- if (isPromise(data)) {
4311
- warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4312
- `intend to perform data fetching before component renders, use ` +
4313
- `async setup() + <Suspense>.`);
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;
4314
4392
  }
4315
- if (!isObject(data)) {
4316
- warn$1(`data() should return an object.`);
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}`);
4317
4399
  }
4318
- else {
4319
- instance.data = reactive(data);
4320
- {
4321
- for (const key in data) {
4322
- checkDuplicateProperties("Data" /* DATA */, key);
4323
- // expose data on ctx during dev
4324
- if (key[0] !== '$' && key[0] !== '_') {
4325
- Object.defineProperty(ctx, key, {
4326
- configurable: true,
4327
- enumerable: true,
4328
- get: () => data[key],
4329
- set: NOOP
4330
- });
4331
- }
4332
- }
4333
- }
4334
- }
4335
- }
4336
- // state initialization complete at this point - start caching access
4337
- shouldCacheAccess = true;
4338
- if (computedOptions) {
4339
- for (const key in computedOptions) {
4340
- const opt = computedOptions[key];
4341
- const get = isFunction(opt)
4342
- ? opt.bind(publicThis, publicThis)
4343
- : isFunction(opt.get)
4344
- ? opt.get.bind(publicThis, publicThis)
4345
- : NOOP;
4346
- if (get === NOOP) {
4347
- warn$1(`Computed property "${key}" has no getter.`);
4348
- }
4349
- const set = !isFunction(opt) && isFunction(opt.set)
4350
- ? opt.set.bind(publicThis)
4351
- : () => {
4352
- warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4353
- }
4354
- ;
4355
- const c = computed$1({
4356
- get,
4357
- set
4358
- });
4359
- Object.defineProperty(ctx, key, {
4360
- enumerable: true,
4361
- configurable: true,
4362
- get: () => c.value,
4363
- set: v => (c.value = v)
4364
- });
4365
- {
4366
- checkDuplicateProperties("Computed" /* COMPUTED */, key);
4367
- }
4368
- }
4369
- }
4370
- if (watchOptions) {
4371
- for (const key in watchOptions) {
4372
- createWatcher(watchOptions[key], ctx, publicThis, key);
4373
- }
4374
- }
4375
- if (provideOptions) {
4376
- const provides = isFunction(provideOptions)
4377
- ? provideOptions.call(publicThis)
4378
- : provideOptions;
4379
- Reflect.ownKeys(provides).forEach(key => {
4380
- provide(key, provides[key]);
4381
- });
4382
- }
4383
- if (created) {
4384
- callHook(created, instance, "c" /* CREATED */);
4385
- }
4386
- function registerLifecycleHook(register, hook) {
4387
- if (isArray(hook)) {
4388
- hook.forEach(_hook => register(_hook.bind(publicThis)));
4389
- }
4390
- else if (hook) {
4391
- register(hook.bind(publicThis));
4392
- }
4393
- }
4394
- registerLifecycleHook(onBeforeMount, beforeMount);
4395
- registerLifecycleHook(onMounted, mounted);
4396
- registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4397
- registerLifecycleHook(onUpdated, updated);
4398
- registerLifecycleHook(onActivated, activated);
4399
- registerLifecycleHook(onDeactivated, deactivated);
4400
- registerLifecycleHook(onErrorCaptured, errorCaptured);
4401
- registerLifecycleHook(onRenderTracked, renderTracked);
4402
- registerLifecycleHook(onRenderTriggered, renderTriggered);
4403
- registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4404
- registerLifecycleHook(onUnmounted, unmounted);
4405
- registerLifecycleHook(onServerPrefetch, serverPrefetch);
4406
- if (isArray(expose)) {
4407
- if (expose.length) {
4408
- const exposed = instance.exposed || (instance.exposed = {});
4409
- expose.forEach(key => {
4410
- Object.defineProperty(exposed, key, {
4411
- get: () => publicThis[key],
4412
- set: val => (publicThis[key] = val)
4413
- });
4414
- });
4415
- }
4416
- else if (!instance.exposed) {
4417
- instance.exposed = {};
4418
- }
4419
- }
4420
- // options that are handled when creating the instance but also need to be
4421
- // applied from mixins
4422
- if (render && instance.render === NOOP) {
4423
- instance.render = render;
4400
+ return res;
4424
4401
  }
4425
- if (inheritAttrs != null) {
4426
- instance.inheritAttrs = inheritAttrs;
4402
+ else {
4403
+ warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
4404
+ `can only be used in render() or setup().`);
4427
4405
  }
4428
- // asset options.
4429
- if (components)
4430
- instance.components = components;
4431
- if (directives)
4432
- instance.directives = directives;
4433
4406
  }
4434
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4435
- if (isArray(injectOptions)) {
4436
- injectOptions = normalizeInject(injectOptions);
4437
- }
4438
- for (const key in injectOptions) {
4439
- const opt = injectOptions[key];
4440
- let injected;
4441
- if (isObject(opt)) {
4442
- if ('default' in opt) {
4443
- injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4444
- }
4445
- else {
4446
- injected = inject(opt.from || key);
4447
- }
4448
- }
4449
- else {
4450
- injected = inject(opt);
4451
- }
4452
- if (isRef(injected)) {
4453
- // TODO remove the check in 3.3
4454
- if (unwrapRef) {
4455
- Object.defineProperty(ctx, key, {
4456
- enumerable: true,
4457
- configurable: true,
4458
- get: () => injected.value,
4459
- set: v => (injected.value = v)
4460
- });
4461
- }
4462
- else {
4463
- {
4464
- warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4465
- `and no longer needs \`.value\` in the next minor release. ` +
4466
- `To opt-in to the new behavior now, ` +
4467
- `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4468
- `temporary and will not be needed in the future.)`);
4469
- }
4470
- ctx[key] = injected;
4471
- }
4472
- }
4473
- else {
4474
- ctx[key] = injected;
4475
- }
4476
- {
4477
- checkDuplicateProperties("Inject" /* INJECT */, key);
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]);
4478
4424
  }
4479
4425
  }
4480
- }
4481
- function callHook(hook, instance, type) {
4482
- callWithAsyncErrorHandling(isArray(hook)
4483
- ? hook.map(h => h.bind(instance.proxy))
4484
- : hook.bind(instance.proxy), instance, type);
4485
- }
4486
- function createWatcher(raw, ctx, publicThis, key) {
4487
- const getter = key.includes('.')
4488
- ? createPathGetter(publicThis, key)
4489
- : () => publicThis[key];
4490
- if (isString(raw)) {
4491
- const handler = ctx[raw];
4492
- if (isFunction(handler)) {
4493
- watch(getter, handler);
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}.`);
4494
4429
  }
4495
- else {
4496
- warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4430
+ ret = new Array(source);
4431
+ for (let i = 0; i < source; i++) {
4432
+ ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
4497
4433
  }
4498
4434
  }
4499
- else if (isFunction(raw)) {
4500
- watch(getter, raw.bind(publicThis));
4501
- }
4502
- else if (isObject(raw)) {
4503
- if (isArray(raw)) {
4504
- raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4435
+ else if (isObject(source)) {
4436
+ if (source[Symbol.iterator]) {
4437
+ ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
4505
4438
  }
4506
4439
  else {
4507
- const handler = isFunction(raw.handler)
4508
- ? raw.handler.bind(publicThis)
4509
- : ctx[raw.handler];
4510
- if (isFunction(handler)) {
4511
- watch(getter, handler, raw);
4512
- }
4513
- else {
4514
- warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
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]);
4515
4445
  }
4516
4446
  }
4517
4447
  }
4518
4448
  else {
4519
- warn$1(`Invalid watch option: "${key}"`, raw);
4449
+ ret = [];
4520
4450
  }
4521
- }
4451
+ if (cache) {
4452
+ cache[index] = ret;
4453
+ }
4454
+ return ret;
4455
+ }
4456
+
4522
4457
  /**
4523
- * Resolve merged options and cache it on the component.
4524
- * This is done only once per-component since the merging does not involve
4525
- * instances.
4458
+ * Compiler runtime helper for creating dynamic slots object
4459
+ * @private
4526
4460
  */
4527
- function resolveMergedOptions(instance) {
4528
- const base = instance.type;
4529
- const { mixins, extends: extendsOptions } = base;
4530
- const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4531
- const cached = cache.get(base);
4532
- let resolved;
4533
- if (cached) {
4534
- resolved = cached;
4535
- }
4536
- else if (!globalMixins.length && !mixins && !extendsOptions) {
4537
- {
4538
- resolved = base;
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;
4468
+ }
4539
4469
  }
4540
- }
4541
- else {
4542
- resolved = {};
4543
- if (globalMixins.length) {
4544
- globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4470
+ else if (slot) {
4471
+ // conditional single slot generated by <template v-if="..." #foo>
4472
+ slots[slot.name] = slot.fn;
4545
4473
  }
4546
- mergeOptions(resolved, base, optionMergeStrategies);
4547
4474
  }
4548
- cache.set(base, resolved);
4549
- return resolved;
4550
- }
4551
- function mergeOptions(to, from, strats, asMixin = false) {
4552
- const { mixins, extends: extendsOptions } = from;
4553
- if (extendsOptions) {
4554
- mergeOptions(to, extendsOptions, strats, true);
4555
- }
4556
- if (mixins) {
4557
- mixins.forEach((m) => mergeOptions(to, m, strats, true));
4475
+ return slots;
4476
+ }
4477
+
4478
+ /**
4479
+ * Compiler runtime helper for rendering `<slot/>`
4480
+ * @private
4481
+ */
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());
4558
4491
  }
4559
- for (const key in from) {
4560
- if (asMixin && key === 'expose') {
4561
- warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4562
- `It should only be declared in the base component itself.`);
4563
- }
4564
- else {
4565
- const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4566
- to[key] = strat ? strat(to[key], from[key]) : from[key];
4567
- }
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 = () => [];
4568
4498
  }
4569
- return to;
4570
- }
4571
- const internalOptionMergeStrats = {
4572
- data: mergeDataFn,
4573
- props: mergeObjectOptions,
4574
- emits: mergeObjectOptions,
4575
- // objects
4576
- methods: mergeObjectOptions,
4577
- computed: mergeObjectOptions,
4578
- // lifecycle
4579
- beforeCreate: mergeAsArray,
4580
- created: mergeAsArray,
4581
- beforeMount: mergeAsArray,
4582
- mounted: mergeAsArray,
4583
- beforeUpdate: mergeAsArray,
4584
- updated: mergeAsArray,
4585
- beforeDestroy: mergeAsArray,
4586
- beforeUnmount: mergeAsArray,
4587
- destroyed: mergeAsArray,
4588
- unmounted: mergeAsArray,
4589
- activated: mergeAsArray,
4590
- deactivated: mergeAsArray,
4591
- errorCaptured: mergeAsArray,
4592
- serverPrefetch: mergeAsArray,
4593
- // assets
4594
- components: mergeObjectOptions,
4595
- directives: mergeObjectOptions,
4596
- // watch
4597
- watch: mergeWatchOptions,
4598
- // provide / inject
4599
- provide: mergeDataFn,
4600
- inject: mergeInject
4601
- };
4602
- function mergeDataFn(to, from) {
4603
- if (!from) {
4604
- 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;
4605
4505
  }
4606
- if (!to) {
4607
- 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'];
4608
4513
  }
4609
- return function mergedDataFn() {
4610
- return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4611
- };
4612
- }
4613
- function mergeInject(to, from) {
4614
- return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4615
- }
4616
- function normalizeInject(raw) {
4617
- if (isArray(raw)) {
4618
- const res = {};
4619
- for (let i = 0; i < raw.length; i++) {
4620
- res[raw[i]] = raw[i];
4621
- }
4622
- return res;
4514
+ if (slot && slot._c) {
4515
+ slot._d = true;
4623
4516
  }
4624
- return raw;
4625
- }
4626
- function mergeAsArray(to, from) {
4627
- return to ? [...new Set([].concat(to, from))] : from;
4628
- }
4629
- function mergeObjectOptions(to, from) {
4630
- return to ? extend(extend(Object.create(null), to), from) : from;
4517
+ return rendered;
4631
4518
  }
4632
- function mergeWatchOptions(to, from) {
4633
- if (!to)
4634
- return from;
4635
- if (!from)
4636
- return to;
4637
- const merged = extend(Object.create(null), to);
4638
- for (const key in from) {
4639
- merged[key] = mergeAsArray(to[key], from[key]);
4640
- }
4641
- 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;
4642
4532
  }
4643
4533
 
4644
- function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4645
- isSSR = false) {
4646
- const props = {};
4647
- const attrs = {};
4648
- def(attrs, InternalObjectKey, 1);
4649
- instance.propsDefaults = Object.create(null);
4650
- setFullProps(instance, rawProps, props, attrs);
4651
- // ensure all declared prop keys are present
4652
- for (const key in instance.propsOptions[0]) {
4653
- if (!(key in props)) {
4654
- props[key] = undefined;
4655
- }
4656
- }
4657
- // validation
4658
- {
4659
- 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;
4660
4543
  }
4661
- if (isStateful) {
4662
- // stateful
4663
- instance.props = isSSR ? props : shallowReactive(props);
4544
+ for (const key in obj) {
4545
+ ret[toHandlerKey(key)] = obj[key];
4664
4546
  }
4665
- else {
4666
- if (!instance.type.props) {
4667
- // functional w/ optional props, props === attrs
4668
- 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;
4669
4588
  }
4670
- else {
4671
- // functional w/ declared props
4672
- 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];
4673
4597
  }
4674
- }
4675
- instance.attrs = attrs;
4676
- }
4677
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
4678
- const { props, attrs, vnode: { patchFlag } } = instance;
4679
- const rawCurrentProps = toRaw(props);
4680
- const [options] = instance.propsOptions;
4681
- let hasAttrsChanged = false;
4682
- if (
4683
- // always force full diff in dev
4684
- // - #1942 if hmr is enabled with sfc component
4685
- // - vite#872 non-sfc component used by sfc component
4686
- !((instance.type.__hmrId ||
4687
- (instance.parent && instance.parent.type.__hmrId))) &&
4688
- (optimized || patchFlag > 0) &&
4689
- !(patchFlag & 16 /* FULL_PROPS */)) {
4690
- if (patchFlag & 8 /* PROPS */) {
4691
- // Compiler-generated props & no keys change, just set the updated
4692
- // the props.
4693
- const propsToUpdate = instance.vnode.dynamicProps;
4694
- for (let i = 0; i < propsToUpdate.length; i++) {
4695
- let key = propsToUpdate[i];
4696
- // skip if the prop key is a declared emit event listener
4697
- if (isEmitListener(instance.emitsOptions, key)) {
4698
- continue;
4699
- }
4700
- // PROPS flag guarantees rawProps to be non-null
4701
- const value = rawProps[key];
4702
- if (options) {
4703
- // attr / props separation was done on init and will be consistent
4704
- // in this code path, so just check if attrs have it.
4705
- if (hasOwn(attrs, key)) {
4706
- if (value !== attrs[key]) {
4707
- attrs[key] = value;
4708
- hasAttrsChanged = true;
4709
- }
4710
- }
4711
- else {
4712
- const camelizedKey = camelize(key);
4713
- props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4714
- }
4715
- }
4716
- else {
4717
- if (value !== attrs[key]) {
4718
- attrs[key] = value;
4719
- hasAttrsChanged = true;
4720
- }
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
4721
4618
  }
4722
4619
  }
4723
- }
4724
- }
4725
- else {
4726
- // full props update.
4727
- if (setFullProps(instance, rawProps, props, attrs)) {
4728
- hasAttrsChanged = true;
4729
- }
4730
- // in case of dynamic props, check if we need to delete keys from
4731
- // the props object
4732
- let kebabKey;
4733
- for (const key in rawCurrentProps) {
4734
- if (!rawProps ||
4735
- // for camelCase
4736
- (!hasOwn(rawProps, key) &&
4737
- // it's possible the original props was passed in as kebab-case
4738
- // and converted to camelCase (#955)
4739
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4740
- if (options) {
4741
- if (rawPrevProps &&
4742
- // for camelCase
4743
- (rawPrevProps[key] !== undefined ||
4744
- // for kebab-case
4745
- rawPrevProps[kebabKey] !== undefined)) {
4746
- props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4747
- }
4748
- }
4749
- else {
4750
- delete props[key];
4751
- }
4620
+ else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4621
+ accessCache[key] = 1 /* SETUP */;
4622
+ return setupState[key];
4752
4623
  }
4753
- }
4754
- // in the case of functional component w/o props declaration, props and
4755
- // attrs point to the same object so it should already have been updated.
4756
- if (attrs !== rawCurrentProps) {
4757
- for (const key in attrs) {
4758
- if (!rawProps ||
4759
- (!hasOwn(rawProps, key) &&
4760
- (!false ))) {
4761
- delete attrs[key];
4762
- hasAttrsChanged = true;
4763
- }
4624
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4625
+ accessCache[key] = 2 /* DATA */;
4626
+ return data[key];
4764
4627
  }
4765
- }
4766
- }
4767
- // trigger updates for $attrs in case it's used in component slots
4768
- if (hasAttrsChanged) {
4769
- trigger(instance, "set" /* SET */, '$attrs');
4770
- }
4771
- {
4772
- validateProps(rawProps || {}, props, instance);
4773
- }
4774
- }
4775
- function setFullProps(instance, rawProps, props, attrs) {
4776
- const [options, needCastKeys] = instance.propsOptions;
4777
- let hasAttrsChanged = false;
4778
- let rawCastValues;
4779
- if (rawProps) {
4780
- for (let key in rawProps) {
4781
- // key, ref are reserved and never passed down
4782
- if (isReservedProp(key)) {
4783
- 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];
4784
4635
  }
4785
- const value = rawProps[key];
4786
- // prop option names are camelized during normalization, so to support
4787
- // kebab -> camel conversion here we need to camelize the key.
4788
- let camelKey;
4789
- if (options && hasOwn(options, (camelKey = camelize(key)))) {
4790
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4791
- props[camelKey] = value;
4792
- }
4793
- else {
4794
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4795
- }
4636
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4637
+ accessCache[key] = 4 /* CONTEXT */;
4638
+ return ctx[key];
4796
4639
  }
4797
- else if (!isEmitListener(instance.emitsOptions, key)) {
4798
- if (!(key in attrs) || value !== attrs[key]) {
4799
- attrs[key] = value;
4800
- hasAttrsChanged = true;
4801
- }
4640
+ else if (shouldCacheAccess) {
4641
+ accessCache[key] = 0 /* OTHER */;
4802
4642
  }
4803
4643
  }
4804
- }
4805
- if (needCastKeys) {
4806
- const rawCurrentProps = toRaw(props);
4807
- const castValues = rawCastValues || EMPTY_OBJ;
4808
- for (let i = 0; i < needCastKeys.length; i++) {
4809
- const key = needCastKeys[i];
4810
- props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4811
- }
4812
- }
4813
- return hasAttrsChanged;
4814
- }
4815
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
4816
- const opt = options[key];
4817
- if (opt != null) {
4818
- const hasDefault = hasOwn(opt, 'default');
4819
- // default values
4820
- if (hasDefault && value === undefined) {
4821
- const defaultValue = opt.default;
4822
- if (opt.type !== Function && isFunction(defaultValue)) {
4823
- const { propsDefaults } = instance;
4824
- if (key in propsDefaults) {
4825
- value = propsDefaults[key];
4826
- }
4827
- else {
4828
- setCurrentInstance(instance);
4829
- value = propsDefaults[key] = defaultValue.call(null, props);
4830
- unsetCurrentInstance();
4831
- }
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();
4832
4651
  }
4833
- else {
4834
- 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];
4835
4671
  }
4836
4672
  }
4837
- // boolean casting
4838
- if (opt[0 /* shouldCast */]) {
4839
- if (isAbsent && !hasDefault) {
4840
- 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.`);
4841
4681
  }
4842
- else if (opt[1 /* shouldCastTrue */] &&
4843
- (value === '' || value === hyphenate(key))) {
4844
- 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.`);
4845
4685
  }
4846
4686
  }
4847
- }
4848
- return value;
4849
- }
4850
- function normalizePropsOptions(comp, appContext, asMixin = false) {
4851
- const cache = appContext.propsCache;
4852
- const cached = cache.get(comp);
4853
- if (cached) {
4854
- return cached;
4855
- }
4856
- const raw = comp.props;
4857
- const normalized = {};
4858
- const needCastKeys = [];
4859
- // apply mixin/extends props
4860
- let hasExtends = false;
4861
- if (!isFunction(comp)) {
4862
- const extendProps = (raw) => {
4863
- hasExtends = true;
4864
- const [props, keys] = normalizePropsOptions(raw, appContext, true);
4865
- extend(normalized, props);
4866
- if (keys)
4867
- needCastKeys.push(...keys);
4868
- };
4869
- if (!asMixin && appContext.mixins.length) {
4870
- 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;
4871
4693
  }
4872
- if (comp.extends) {
4873
- extendProps(comp.extends);
4694
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4695
+ data[key] = value;
4696
+ return true;
4874
4697
  }
4875
- if (comp.mixins) {
4876
- 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;
4877
4701
  }
4878
- }
4879
- if (!raw && !hasExtends) {
4880
- cache.set(comp, EMPTY_ARR);
4881
- return EMPTY_ARR;
4882
- }
4883
- if (isArray(raw)) {
4884
- for (let i = 0; i < raw.length; i++) {
4885
- if (!isString(raw[i])) {
4886
- 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
+ });
4887
4714
  }
4888
- const normalizedKey = camelize(raw[i]);
4889
- if (validatePropName(normalizedKey)) {
4890
- normalized[normalizedKey] = EMPTY_OBJ;
4715
+ else {
4716
+ ctx[key] = value;
4891
4717
  }
4892
4718
  }
4893
- }
4894
- else if (raw) {
4895
- if (!isObject(raw)) {
4896
- warn$1(`invalid props options`, raw);
4897
- }
4898
- for (const key in raw) {
4899
- const normalizedKey = camelize(key);
4900
- if (validatePropName(normalizedKey)) {
4901
- const opt = raw[key];
4902
- const prop = (normalized[normalizedKey] =
4903
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4904
- if (prop) {
4905
- const booleanIndex = getTypeIndex(Boolean, prop.type);
4906
- const stringIndex = getTypeIndex(String, prop.type);
4907
- prop[0 /* shouldCast */] = booleanIndex > -1;
4908
- prop[1 /* shouldCastTrue */] =
4909
- stringIndex < 0 || booleanIndex < stringIndex;
4910
- // if the prop needs boolean casting or default value
4911
- if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4912
- needCastKeys.push(normalizedKey);
4913
- }
4914
- }
4915
- }
4916
- }
4917
- }
4918
- const res = [normalized, needCastKeys];
4919
- cache.set(comp, res);
4920
- return res;
4921
- }
4922
- function validatePropName(key) {
4923
- if (key[0] !== '$') {
4924
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;
4735
+ }
4736
+ else if (hasOwn(descriptor, 'value')) {
4737
+ this.set(target, key, descriptor.value, null);
4738
+ }
4739
+ return Reflect.defineProperty(target, key, descriptor);
4925
4740
  }
4926
- else {
4927
- warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4928
- }
4929
- return false;
4930
- }
4931
- // use function string name to check type constructors
4932
- // so that it works across vms / iframes.
4933
- function getType(ctor) {
4934
- const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4935
- return match ? match[1] : ctor === null ? 'null' : '';
4936
- }
4937
- function isSameType(a, b) {
4938
- 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
+ };
4939
4748
  }
4940
- function getTypeIndex(type, expectedTypes) {
4941
- if (isArray(expectedTypes)) {
4942
- return expectedTypes.findIndex(t => isSameType(t, type));
4943
- }
4944
- else if (isFunction(expectedTypes)) {
4945
- 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;
4946
4763
  }
4947
- 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;
4948
4789
  }
4949
- /**
4950
- * dev only
4951
- */
4952
- function validateProps(rawProps, props, instance) {
4953
- const resolvedValues = toRaw(props);
4954
- const options = instance.propsOptions[0];
4955
- for (const key in options) {
4956
- let opt = options[key];
4957
- if (opt == null)
4958
- continue;
4959
- 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
+ });
4960
4802
  }
4961
4803
  }
4962
- /**
4963
- * dev only
4964
- */
4965
- function validateProp(name, value, prop, isAbsent) {
4966
- const { type, required, validator } = prop;
4967
- // required!
4968
- if (required && isAbsent) {
4969
- warn$1('Missing required prop: "' + name + '"');
4970
- return;
4971
- }
4972
- // missing but optional
4973
- if (value == null && !prop.required) {
4974
- return;
4975
- }
4976
- // type check
4977
- if (type != null && type !== true) {
4978
- let isValid = false;
4979
- const types = isArray(type) ? type : [type];
4980
- const expectedTypes = [];
4981
- // value is valid as long as one of the specified types match
4982
- for (let i = 0; i < types.length && !isValid; i++) {
4983
- const { valid, expectedType } = assertType(value, types[i]);
4984
- expectedTypes.push(expectedType || '');
4985
- 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
+ });
4986
4820
  }
4987
- if (!isValid) {
4988
- warn$1(getInvalidTypeMessage(name, value, expectedTypes));
4989
- 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]}.`);
4990
4829
  }
4991
- }
4992
- // custom validator
4993
- if (validator && !validator(value)) {
4994
- warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
4995
- }
4996
- }
4997
- const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
4998
- /**
4999
- * dev only
5000
- */
5001
- function assertType(value, type) {
5002
- let valid;
5003
- const expectedType = getType(type);
5004
- if (isSimpleType(expectedType)) {
5005
- const t = typeof value;
5006
- valid = t === expectedType.toLowerCase();
5007
- // for primitive wrapper objects
5008
- if (!valid && t === 'object') {
5009
- valid = value instanceof type;
4830
+ else {
4831
+ cache[key] = type;
5010
4832
  }
5011
- }
5012
- else if (expectedType === 'Object') {
5013
- valid = isObject(value);
5014
- }
5015
- else if (expectedType === 'Array') {
5016
- valid = isArray(value);
5017
- }
5018
- else if (expectedType === 'null') {
5019
- valid = value === null;
5020
- }
5021
- else {
5022
- valid = value instanceof type;
5023
- }
5024
- return {
5025
- valid,
5026
- expectedType
5027
4833
  };
5028
4834
  }
5029
- /**
5030
- * dev only
5031
- */
5032
- function getInvalidTypeMessage(name, value, expectedTypes) {
5033
- let message = `Invalid prop: type check failed for prop "${name}".` +
5034
- ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
5035
- const expectedType = expectedTypes[0];
5036
- const receivedType = toRawType(value);
5037
- const expectedValue = styleValue(value, expectedType);
5038
- const receivedValue = styleValue(value, receivedType);
5039
- // check if we need to specify expected value
5040
- if (expectedTypes.length === 1 &&
5041
- isExplicable(expectedType) &&
5042
- !isBoolean(expectedType, receivedType)) {
5043
- message += ` with value ${expectedValue}`;
5044
- }
5045
- message += `, got ${receivedType} `;
5046
- // check if we need to specify received value
5047
- if (isExplicable(receivedType)) {
5048
- 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 */);
5049
4846
  }
5050
- return message;
5051
- }
5052
- /**
5053
- * dev only
5054
- */
5055
- function styleValue(value, type) {
5056
- if (type === 'String') {
5057
- return `"${value}"`;
5058
- }
5059
- else if (type === 'Number') {
5060
- 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
+ }
5061
4864
  }
5062
- else {
5063
- 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);
5064
4874
  }
5065
- }
5066
- /**
5067
- * dev only
5068
- */
5069
- function isExplicable(type) {
5070
- const explicitTypes = ['string', 'number', 'boolean'];
5071
- return explicitTypes.some(elem => type.toLowerCase() === elem);
5072
- }
5073
- /**
5074
- * dev only
5075
- */
5076
- function isBoolean(...args) {
5077
- return args.some(elem => elem.toLowerCase() === 'boolean');
5078
- }
5079
-
5080
- const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5081
- const normalizeSlotValue = (value) => isArray(value)
5082
- ? value.map(normalizeVNode)
5083
- : [normalizeVNode(value)];
5084
- const normalizeSlot = (key, rawSlot, ctx) => {
5085
- const normalized = withCtx((...args) => {
5086
- if (currentInstance) {
5087
- warn$1(`Slot "${key}" invoked outside of the render function: ` +
5088
- `this will not track dependencies used in the slot. ` +
5089
- `Invoke the slot function inside the render function instead.`);
5090
- }
5091
- return normalizeSlotValue(rawSlot(...args));
5092
- }, ctx);
5093
- normalized._c = false;
5094
- return normalized;
5095
- };
5096
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
5097
- const ctx = rawSlots._ctx;
5098
- for (const key in rawSlots) {
5099
- if (isInternalKey(key))
5100
- continue;
5101
- const value = rawSlots[key];
5102
- if (isFunction(value)) {
5103
- slots[key] = normalizeSlot(key, value, ctx);
5104
- }
5105
- else if (value != null) {
5106
- {
5107
- warn$1(`Non-function value encountered for slot "${key}". ` +
5108
- `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?`);
5109
4897
  }
5110
- const normalized = normalizeSlotValue(value);
5111
- slots[key] = () => normalized;
5112
4898
  }
5113
4899
  }
5114
- };
5115
- const normalizeVNodeSlots = (instance, children) => {
5116
- if (!isKeepAlive(instance.vnode) &&
5117
- !(false )) {
5118
- warn$1(`Non-function value encountered for default slot. ` +
5119
- `Prefer function slots for better performance.`);
5120
- }
5121
- const normalized = normalizeSlotValue(children);
5122
- instance.slots.default = () => normalized;
5123
- };
5124
- const initSlots = (instance, children) => {
5125
- if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5126
- const type = children._;
5127
- if (type) {
5128
- // users can get the shallow readonly version of the slots object through `this.$slots`,
5129
- // we should avoid the proxy object polluting the slots of the internal instance
5130
- instance.slots = toRaw(children);
5131
- // make compiler marker non-enumerable
5132
- 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.`);
5133
4904
  }
5134
- else {
5135
- 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>.`);
5136
4910
  }
5137
- }
5138
- else {
5139
- instance.slots = {};
5140
- if (children) {
5141
- normalizeVNodeSlots(instance, children);
4911
+ if (!isObject(data)) {
4912
+ warn$1(`data() should return an object.`);
5142
4913
  }
5143
- }
5144
- def(instance.slots, InternalObjectKey, 1);
5145
- };
5146
- const updateSlots = (instance, children, optimized) => {
5147
- const { vnode, slots } = instance;
5148
- let needDeletionCheck = true;
5149
- let deletionComparisonTarget = EMPTY_OBJ;
5150
- if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5151
- const type = children._;
5152
- if (type) {
5153
- // compiled slots.
5154
- if (isHmrUpdating) {
5155
- // Parent was HMR updated so slot content may have changed.
5156
- // force update slots and mark instance for hmr as well
5157
- 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
+ }
5158
4929
  }
5159
- else if (optimized && type === 1 /* STABLE */) {
5160
- // compiled AND stable.
5161
- // no need to update, and skip stale slots removal.
5162
- 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.`);
5163
4944
  }
5164
- else {
5165
- // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5166
- // normalization.
5167
- extend(slots, children);
5168
- // #2893
5169
- // when rendering the optimized slots by manually written render function,
5170
- // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5171
- // i.e. let the `renderSlot` create the bailed Fragment
5172
- if (!optimized && type === 1 /* STABLE */) {
5173
- delete slots._;
5174
- }
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);
5175
4963
  }
5176
4964
  }
5177
- else {
5178
- needDeletionCheck = !children.$stable;
5179
- normalizeObjectSlots(children, slots);
4965
+ }
4966
+ if (watchOptions) {
4967
+ for (const key in watchOptions) {
4968
+ createWatcher(watchOptions[key], ctx, publicThis, key);
5180
4969
  }
5181
- deletionComparisonTarget = children;
5182
4970
  }
5183
- else if (children) {
5184
- // non slot object children (direct value) passed to a component
5185
- normalizeVNodeSlots(instance, children);
5186
- 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
+ });
5187
4978
  }
5188
- // delete stale slots
5189
- if (needDeletionCheck) {
5190
- for (const key in slots) {
5191
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5192
- delete slots[key];
5193
- }
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));
5194
4988
  }
5195
4989
  }
5196
- };
5197
-
5198
- /**
5199
- Runtime helper for applying directives to a vnode. Example usage:
5200
-
5201
- const comp = resolveComponent('comp')
5202
- const foo = resolveDirective('foo')
5203
- const bar = resolveDirective('bar')
5204
-
5205
- return withDirectives(h(comp), [
5206
- [foo, this.x],
5207
- [bar, this.y]
5208
- ])
5209
- */
5210
- function validateDirectiveName(name) {
5211
- if (isBuiltInDirective(name)) {
5212
- 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;
5213
5020
  }
5021
+ if (inheritAttrs != null) {
5022
+ instance.inheritAttrs = inheritAttrs;
5023
+ }
5024
+ // asset options.
5025
+ if (components)
5026
+ instance.components = components;
5027
+ if (directives)
5028
+ instance.directives = directives;
5214
5029
  }
5215
- /**
5216
- * Adds directives to a VNode.
5217
- */
5218
- function withDirectives(vnode, directives) {
5219
- const internalInstance = currentRenderingInstance;
5220
- if (internalInstance === null) {
5221
- warn$1(`withDirectives can only be used inside render functions.`);
5222
- return vnode;
5030
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
5031
+ if (isArray(injectOptions)) {
5032
+ injectOptions = normalizeInject(injectOptions);
5223
5033
  }
5224
- const instance = getExposeProxy(internalInstance) ||
5225
- internalInstance.proxy;
5226
- const bindings = vnode.dirs || (vnode.dirs = []);
5227
- for (let i = 0; i < directives.length; i++) {
5228
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5229
- if (isFunction(dir)) {
5230
- dir = {
5231
- mounted: dir,
5232
- updated: dir
5233
- };
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
+ }
5234
5044
  }
5235
- if (dir.deep) {
5236
- 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);
5237
5074
  }
5238
- bindings.push({
5239
- dir,
5240
- instance,
5241
- value,
5242
- oldValue: void 0,
5243
- arg,
5244
- modifiers
5245
- });
5246
5075
  }
5247
- return vnode;
5248
5076
  }
5249
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5250
- const bindings = vnode.dirs;
5251
- const oldBindings = prevVNode && prevVNode.dirs;
5252
- for (let i = 0; i < bindings.length; i++) {
5253
- const binding = bindings[i];
5254
- if (oldBindings) {
5255
- 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);
5256
5090
  }
5257
- let hook = binding.dir[name];
5258
- if (hook) {
5259
- // disable tracking inside all lifecycle hooks
5260
- // since they can potentially be called inside effects.
5261
- pauseTracking();
5262
- callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5263
- vnode.el,
5264
- binding,
5265
- vnode,
5266
- prevVNode
5267
- ]);
5268
- resetTracking();
5091
+ else {
5092
+ warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5269
5093
  }
5270
5094
  }
5271
- }
5272
-
5273
- function createAppContext() {
5274
- return {
5275
- app: null,
5276
- config: {
5277
- isNativeTag: NO,
5278
- performance: false,
5279
- globalProperties: {},
5280
- optionMergeStrategies: {},
5281
- errorHandler: undefined,
5282
- warnHandler: undefined,
5283
- compilerOptions: {}
5284
- },
5285
- mixins: [],
5286
- components: {},
5287
- directives: {},
5288
- provides: Object.create(null),
5289
- optionsCache: new WeakMap(),
5290
- propsCache: new WeakMap(),
5291
- emitsCache: new WeakMap()
5292
- };
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
+ }
5293
5117
  }
5294
- let uid = 0;
5295
- function createAppAPI(render, hydrate) {
5296
- return function createApp(rootComponent, rootProps = null) {
5297
- if (!isFunction(rootComponent)) {
5298
- 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;
5299
5135
  }
5300
- if (rootProps != null && !isObject(rootProps)) {
5301
- warn$1(`root props passed to app.mount() must be an object.`);
5302
- rootProps = null;
5136
+ }
5137
+ else {
5138
+ resolved = {};
5139
+ if (globalMixins.length) {
5140
+ globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
5303
5141
  }
5304
- const context = createAppContext();
5305
- const installedPlugins = new Set();
5306
- let isMounted = false;
5307
- const app = (context.app = {
5308
- _uid: uid++,
5309
- _component: rootComponent,
5310
- _props: rootProps,
5311
- _container: null,
5312
- _context: context,
5313
- _instance: null,
5314
- version,
5315
- get config() {
5316
- return context.config;
5317
- },
5318
- set config(v) {
5319
- {
5320
- warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5321
- }
5322
- },
5323
- use(plugin, ...options) {
5324
- if (installedPlugins.has(plugin)) {
5325
- warn$1(`Plugin has already been applied to target app.`);
5326
- }
5327
- else if (plugin && isFunction(plugin.install)) {
5328
- installedPlugins.add(plugin);
5329
- plugin.install(app, ...options);
5330
- }
5331
- else if (isFunction(plugin)) {
5332
- installedPlugins.add(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)) {
5857
+ installedPlugins.add(plugin);
5333
5858
  plugin(app, ...options);
5334
5859
  }
5335
5860
  else {
@@ -5378,6 +5903,12 @@ var Vue = (function (exports) {
5378
5903
  },
5379
5904
  mount(rootContainer, isHydrate, isSVG) {
5380
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
+ }
5381
5912
  const vnode = createVNode(rootComponent, rootProps);
5382
5913
  // store app context on the root VNode.
5383
5914
  // this will be set on the root instance on initial mount.
@@ -5428,8 +5959,6 @@ var Vue = (function (exports) {
5428
5959
  warn$1(`App already provides property with key "${String(key)}". ` +
5429
5960
  `It will be overwritten with the new value.`);
5430
5961
  }
5431
- // TypeScript doesn't allow symbols as index type
5432
- // https://github.com/Microsoft/TypeScript/issues/24587
5433
5962
  context.provides[key] = value;
5434
5963
  return app;
5435
5964
  }
@@ -5546,7 +6075,7 @@ var Vue = (function (exports) {
5546
6075
  // Hydration also depends on some renderer internal logic which needs to be
5547
6076
  // passed in via arguments.
5548
6077
  function createHydrationFunctions(rendererInternals) {
5549
- 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;
5550
6079
  const hydrate = (vnode, container) => {
5551
6080
  if (!container.hasChildNodes()) {
5552
6081
  warn$1(`Attempting to hydrate existing markup but container is empty. ` +
@@ -5566,14 +6095,26 @@ var Vue = (function (exports) {
5566
6095
  const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
5567
6096
  const isFragmentStart = isComment(node) && node.data === '[';
5568
6097
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
5569
- const { type, ref, shapeFlag } = vnode;
6098
+ const { type, ref, shapeFlag, patchFlag } = vnode;
5570
6099
  const domType = node.nodeType;
5571
6100
  vnode.el = node;
6101
+ if (patchFlag === -2 /* BAIL */) {
6102
+ optimized = false;
6103
+ vnode.dynamicChildren = null;
6104
+ }
5572
6105
  let nextNode = null;
5573
6106
  switch (type) {
5574
6107
  case Text:
5575
6108
  if (domType !== 3 /* TEXT */) {
5576
- 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('')), node.parentElement, node);
6113
+ nextNode = node;
6114
+ }
6115
+ else {
6116
+ nextNode = onMismatch();
6117
+ }
5577
6118
  }
5578
6119
  else {
5579
6120
  if (node.data !== vnode.children) {
@@ -5647,6 +6188,12 @@ var Vue = (function (exports) {
5647
6188
  nextNode = isFragmentStart
5648
6189
  ? locateClosingAsyncAnchor(node)
5649
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
+ }
5650
6197
  // #3787
5651
6198
  // if component is async, it may get moved / unmounted before its
5652
6199
  // inner component is loaded, so we need to give it a placeholder
@@ -6310,8 +6857,9 @@ var Vue = (function (exports) {
6310
6857
  const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
6311
6858
  const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
6312
6859
  let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
6313
- if (isHmrUpdating) {
6314
- // 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
6315
6863
  patchFlag = 0;
6316
6864
  optimized = false;
6317
6865
  dynamicChildren = null;
@@ -6445,7 +6993,6 @@ var Vue = (function (exports) {
6445
6993
  }
6446
6994
  else {
6447
6995
  // no update needed. just copy over properties
6448
- n2.component = n1.component;
6449
6996
  n2.el = n1.el;
6450
6997
  instance.vnode = n2;
6451
6998
  }
@@ -6528,7 +7075,10 @@ var Vue = (function (exports) {
6528
7075
  // activated hook for keep-alive roots.
6529
7076
  // #1742 activated hook must be accessed after first render
6530
7077
  // since the hook may be injected by a child keep-alive
6531
- 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 */)) {
6532
7082
  instance.a && queuePostRenderEffect(instance.a, parentSuspense);
6533
7083
  }
6534
7084
  instance.isMounted = true;
@@ -6611,9 +7161,9 @@ var Vue = (function (exports) {
6611
7161
  }
6612
7162
  };
6613
7163
  // create reactive effect for rendering
6614
- 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
6615
7165
  ));
6616
- const update = (instance.update = effect.run.bind(effect));
7166
+ const update = (instance.update = () => effect.run());
6617
7167
  update.id = instance.uid;
6618
7168
  // allowRecurse
6619
7169
  // #1801, #2043 component render effects should allow recursive updates
@@ -6625,7 +7175,6 @@ var Vue = (function (exports) {
6625
7175
  effect.onTrigger = instance.rtg
6626
7176
  ? e => invokeArrayFns(instance.rtg, e)
6627
7177
  : void 0;
6628
- // @ts-ignore (for scheduler)
6629
7178
  update.ownerInstance = instance;
6630
7179
  }
6631
7180
  update();
@@ -7009,7 +7558,22 @@ var Vue = (function (exports) {
7009
7558
  const remove = vnode => {
7010
7559
  const { type, el, anchor, transition } = vnode;
7011
7560
  if (type === Fragment) {
7012
- removeFragment(el, anchor);
7561
+ if (vnode.patchFlag > 0 &&
7562
+ vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
7563
+ transition &&
7564
+ !transition.persisted) {
7565
+ vnode.children.forEach(child => {
7566
+ if (child.type === Comment) {
7567
+ hostRemove(child.el);
7568
+ }
7569
+ else {
7570
+ remove(child);
7571
+ }
7572
+ });
7573
+ }
7574
+ else {
7575
+ removeFragment(el, anchor);
7576
+ }
7013
7577
  return;
7014
7578
  }
7015
7579
  if (type === Static) {
@@ -7399,92 +7963,32 @@ var Vue = (function (exports) {
7399
7963
  if (isTeleportDisabled(vnode.props)) {
7400
7964
  vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
7401
7965
  vnode.targetAnchor = targetNode;
7402
- }
7403
- else {
7404
- vnode.anchor = nextSibling(node);
7405
- vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7406
- }
7407
- target._lpa =
7408
- vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7409
- }
7410
- }
7411
- return vnode.anchor && nextSibling(vnode.anchor);
7412
- }
7413
- // Force-casted public typing for h and TSX props inference
7414
- const Teleport = TeleportImpl;
7415
-
7416
- const COMPONENTS = 'components';
7417
- const DIRECTIVES = 'directives';
7418
- /**
7419
- * @private
7420
- */
7421
- function resolveComponent(name, maybeSelfReference) {
7422
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7423
- }
7424
- const NULL_DYNAMIC_COMPONENT = Symbol();
7425
- /**
7426
- * @private
7427
- */
7428
- function resolveDynamicComponent(component) {
7429
- if (isString(component)) {
7430
- return resolveAsset(COMPONENTS, component, false) || component;
7431
- }
7432
- else {
7433
- // invalid types will fallthrough to createVNode and raise warning
7434
- return (component || NULL_DYNAMIC_COMPONENT);
7435
- }
7436
- }
7437
- /**
7438
- * @private
7439
- */
7440
- function resolveDirective(name) {
7441
- return resolveAsset(DIRECTIVES, name);
7442
- }
7443
- // implementation
7444
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7445
- const instance = currentRenderingInstance || currentInstance;
7446
- if (instance) {
7447
- const Component = instance.type;
7448
- // explicit self name has highest priority
7449
- if (type === COMPONENTS) {
7450
- const selfName = getComponentName(Component);
7451
- if (selfName &&
7452
- (selfName === name ||
7453
- selfName === camelize(name) ||
7454
- selfName === capitalize(camelize(name)))) {
7455
- return Component;
7456
- }
7457
- }
7458
- const res =
7459
- // local registration
7460
- // check instance[type] first which is resolved for options API
7461
- resolve(instance[type] || Component[type], name) ||
7462
- // global registration
7463
- resolve(instance.appContext[type], name);
7464
- if (!res && maybeSelfReference) {
7465
- // fallback to implicit self-reference
7466
- return Component;
7467
- }
7468
- if (warnMissing && !res) {
7469
- const extra = type === COMPONENTS
7470
- ? `\nIf this is a native custom element, make sure to exclude it from ` +
7471
- `component resolution via compilerOptions.isCustomElement.`
7472
- : ``;
7473
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
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
+ }
7474
7986
  }
7475
- return res;
7476
- }
7477
- else {
7478
- warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
7479
- `can only be used in render() or setup().`);
7480
7987
  }
7988
+ return vnode.anchor && nextSibling(vnode.anchor);
7481
7989
  }
7482
- function resolve(registry, name) {
7483
- return (registry &&
7484
- (registry[name] ||
7485
- registry[camelize(name)] ||
7486
- registry[capitalize(camelize(name))]));
7487
- }
7990
+ // Force-casted public typing for h and TSX props inference
7991
+ const Teleport = TeleportImpl;
7488
7992
 
7489
7993
  const Fragment = Symbol('Fragment' );
7490
7994
  const Text = Symbol('Text' );
@@ -7688,6 +8192,15 @@ var Vue = (function (exports) {
7688
8192
  if (children) {
7689
8193
  normalizeChildren(cloned, children);
7690
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 */;
7691
8204
  return cloned;
7692
8205
  }
7693
8206
  // class component normalization.
@@ -7767,598 +8280,192 @@ var Vue = (function (exports) {
7767
8280
  : children,
7768
8281
  target: vnode.target,
7769
8282
  targetAnchor: vnode.targetAnchor,
7770
- staticCount: vnode.staticCount,
7771
- shapeFlag: vnode.shapeFlag,
7772
- // if the vnode is cloned with extra props, we can no longer assume its
7773
- // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7774
- // note: preserve flag for fragments since they use the flag for children
7775
- // fast paths only.
7776
- patchFlag: extraProps && vnode.type !== Fragment
7777
- ? patchFlag === -1 // hoisted node
7778
- ? 16 /* FULL_PROPS */
7779
- : patchFlag | 16 /* FULL_PROPS */
7780
- : patchFlag,
7781
- dynamicProps: vnode.dynamicProps,
7782
- dynamicChildren: vnode.dynamicChildren,
7783
- appContext: vnode.appContext,
7784
- dirs: vnode.dirs,
7785
- transition: vnode.transition,
7786
- // These should technically only be non-null on mounted VNodes. However,
7787
- // they *should* be copied for kept-alive vnodes. So we just always copy
7788
- // them since them being non-null during a mount doesn't affect the logic as
7789
- // they will simply be overwritten.
7790
- component: vnode.component,
7791
- suspense: vnode.suspense,
7792
- ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7793
- ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7794
- el: vnode.el,
7795
- anchor: vnode.anchor
7796
- };
7797
- return cloned;
7798
- }
7799
- /**
7800
- * Dev only, for HMR of hoisted vnodes reused in v-for
7801
- * https://github.com/vitejs/vite/issues/2022
7802
- */
7803
- function deepCloneVNode(vnode) {
7804
- const cloned = cloneVNode(vnode);
7805
- if (isArray(vnode.children)) {
7806
- cloned.children = vnode.children.map(deepCloneVNode);
7807
- }
7808
- return cloned;
7809
- }
7810
- /**
7811
- * @private
7812
- */
7813
- function createTextVNode(text = ' ', flag = 0) {
7814
- return createVNode(Text, null, text, flag);
7815
- }
7816
- /**
7817
- * @private
7818
- */
7819
- function createStaticVNode(content, numberOfNodes) {
7820
- // A static vnode can contain multiple stringified elements, and the number
7821
- // of elements is necessary for hydration.
7822
- const vnode = createVNode(Static, null, content);
7823
- vnode.staticCount = numberOfNodes;
7824
- return vnode;
7825
- }
7826
- /**
7827
- * @private
7828
- */
7829
- function createCommentVNode(text = '',
7830
- // when used as the v-else branch, the comment node must be created as a
7831
- // block to ensure correct updates.
7832
- asBlock = false) {
7833
- return asBlock
7834
- ? (openBlock(), createBlock(Comment, null, text))
7835
- : createVNode(Comment, null, text);
7836
- }
7837
- function normalizeVNode(child) {
7838
- if (child == null || typeof child === 'boolean') {
7839
- // empty placeholder
7840
- return createVNode(Comment);
7841
- }
7842
- else if (isArray(child)) {
7843
- // fragment
7844
- return createVNode(Fragment, null,
7845
- // #3666, avoid reference pollution when reusing vnode
7846
- child.slice());
7847
- }
7848
- else if (typeof child === 'object') {
7849
- // already vnode, this should be the most common since compiled templates
7850
- // always produce all-vnode children arrays
7851
- return cloneIfMounted(child);
7852
- }
7853
- else {
7854
- // strings and numbers
7855
- return createVNode(Text, null, String(child));
7856
- }
7857
- }
7858
- // optimized normalization for template-compiled render fns
7859
- function cloneIfMounted(child) {
7860
- return child.el === null || child.memo ? child : cloneVNode(child);
7861
- }
7862
- function normalizeChildren(vnode, children) {
7863
- let type = 0;
7864
- const { shapeFlag } = vnode;
7865
- if (children == null) {
7866
- children = null;
7867
- }
7868
- else if (isArray(children)) {
7869
- type = 16 /* ARRAY_CHILDREN */;
7870
- }
7871
- else if (typeof children === 'object') {
7872
- if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7873
- // Normalize slot to plain children for plain element and Teleport
7874
- const slot = children.default;
7875
- if (slot) {
7876
- // _c marker is added by withCtx() indicating this is a compiled slot
7877
- slot._c && (slot._d = false);
7878
- normalizeChildren(vnode, slot());
7879
- slot._c && (slot._d = true);
7880
- }
7881
- return;
7882
- }
7883
- else {
7884
- type = 32 /* SLOTS_CHILDREN */;
7885
- const slotFlag = children._;
7886
- if (!slotFlag && !(InternalObjectKey in children)) {
7887
- children._ctx = currentRenderingInstance;
7888
- }
7889
- else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7890
- // a child component receives forwarded slots from the parent.
7891
- // its slot type is determined by its parent's slot type.
7892
- if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7893
- children._ = 1 /* STABLE */;
7894
- }
7895
- else {
7896
- children._ = 2 /* DYNAMIC */;
7897
- vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7898
- }
7899
- }
7900
- }
7901
- }
7902
- else if (isFunction(children)) {
7903
- children = { default: children, _ctx: currentRenderingInstance };
7904
- type = 32 /* SLOTS_CHILDREN */;
7905
- }
7906
- else {
7907
- children = String(children);
7908
- // force teleport children to array so it can be moved around
7909
- if (shapeFlag & 64 /* TELEPORT */) {
7910
- type = 16 /* ARRAY_CHILDREN */;
7911
- children = [createTextVNode(children)];
7912
- }
7913
- else {
7914
- type = 8 /* TEXT_CHILDREN */;
7915
- }
7916
- }
7917
- vnode.children = children;
7918
- vnode.shapeFlag |= type;
7919
- }
7920
- function mergeProps(...args) {
7921
- const ret = {};
7922
- for (let i = 0; i < args.length; i++) {
7923
- const toMerge = args[i];
7924
- for (const key in toMerge) {
7925
- if (key === 'class') {
7926
- if (ret.class !== toMerge.class) {
7927
- ret.class = normalizeClass([ret.class, toMerge.class]);
7928
- }
7929
- }
7930
- else if (key === 'style') {
7931
- ret.style = normalizeStyle([ret.style, toMerge.style]);
7932
- }
7933
- else if (isOn(key)) {
7934
- const existing = ret[key];
7935
- const incoming = toMerge[key];
7936
- if (incoming &&
7937
- existing !== incoming &&
7938
- !(isArray(existing) && existing.includes(incoming))) {
7939
- ret[key] = existing
7940
- ? [].concat(existing, incoming)
7941
- : incoming;
7942
- }
7943
- }
7944
- else if (key !== '') {
7945
- ret[key] = toMerge[key];
7946
- }
7947
- }
7948
- }
7949
- return ret;
7950
- }
7951
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7952
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7953
- vnode,
7954
- prevVNode
7955
- ]);
7956
- }
7957
-
7958
- /**
7959
- * Actual implementation
7960
- */
7961
- function renderList(source, renderItem, cache, index) {
7962
- let ret;
7963
- const cached = (cache && cache[index]);
7964
- if (isArray(source) || isString(source)) {
7965
- ret = new Array(source.length);
7966
- for (let i = 0, l = source.length; i < l; i++) {
7967
- ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
7968
- }
7969
- }
7970
- else if (typeof source === 'number') {
7971
- if (!Number.isInteger(source)) {
7972
- warn$1(`The v-for range expect an integer value but got ${source}.`);
7973
- return [];
7974
- }
7975
- ret = new Array(source);
7976
- for (let i = 0; i < source; i++) {
7977
- ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
7978
- }
7979
- }
7980
- else if (isObject(source)) {
7981
- if (source[Symbol.iterator]) {
7982
- ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
7983
- }
7984
- else {
7985
- const keys = Object.keys(source);
7986
- ret = new Array(keys.length);
7987
- for (let i = 0, l = keys.length; i < l; i++) {
7988
- const key = keys[i];
7989
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
7990
- }
7991
- }
7992
- }
7993
- else {
7994
- ret = [];
7995
- }
7996
- if (cache) {
7997
- cache[index] = ret;
7998
- }
7999
- return ret;
8000
- }
8001
-
8283
+ staticCount: vnode.staticCount,
8284
+ shapeFlag: vnode.shapeFlag,
8285
+ // if the vnode is cloned with extra props, we can no longer assume its
8286
+ // existing patch flag to be reliable and need to add the FULL_PROPS flag.
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
+ }
8002
8312
  /**
8003
- * Compiler runtime helper for creating dynamic slots object
8004
- * @private
8313
+ * Dev only, for HMR of hoisted vnodes reused in v-for
8314
+ * https://github.com/vitejs/vite/issues/2022
8005
8315
  */
8006
- function createSlots(slots, dynamicSlots) {
8007
- for (let i = 0; i < dynamicSlots.length; i++) {
8008
- const slot = dynamicSlots[i];
8009
- // array of dynamic slot generated by <template v-for="..." #[...]>
8010
- if (isArray(slot)) {
8011
- for (let j = 0; j < slot.length; j++) {
8012
- slots[slot[j].name] = slot[j].fn;
8013
- }
8014
- }
8015
- else if (slot) {
8016
- // conditional single slot generated by <template v-if="..." #foo>
8017
- slots[slot.name] = slot.fn;
8018
- }
8316
+ function deepCloneVNode(vnode) {
8317
+ const cloned = cloneVNode(vnode);
8318
+ if (isArray(vnode.children)) {
8319
+ cloned.children = vnode.children.map(deepCloneVNode);
8019
8320
  }
8020
- return slots;
8021
- }
8022
-
8321
+ return cloned;
8322
+ }
8023
8323
  /**
8024
- * Compiler runtime helper for rendering `<slot/>`
8025
8324
  * @private
8026
8325
  */
8027
- function renderSlot(slots, name, props = {},
8028
- // this is not a user-facing function, so the fallback is always generated by
8029
- // the compiler and guaranteed to be a function returning an array
8030
- fallback, noSlotted) {
8031
- if (currentRenderingInstance.isCE) {
8032
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
8033
- }
8034
- let slot = slots[name];
8035
- if (slot && slot.length > 1) {
8036
- warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
8037
- `function. You need to mark this component with $dynamic-slots in the ` +
8038
- `parent template.`);
8039
- slot = () => [];
8040
- }
8041
- // a compiled slot disables block tracking by default to avoid manual
8042
- // invocation interfering with template-based block tracking, but in
8043
- // `renderSlot` we can be sure that it's template-based so we can force
8044
- // enable it.
8045
- if (slot && slot._c) {
8046
- slot._d = false;
8047
- }
8048
- openBlock();
8049
- const validSlotContent = slot && ensureValidVNode(slot(props));
8050
- const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
8051
- ? 64 /* STABLE_FRAGMENT */
8052
- : -2 /* BAIL */);
8053
- if (!noSlotted && rendered.scopeId) {
8054
- rendered.slotScopeIds = [rendered.scopeId + '-s'];
8055
- }
8056
- if (slot && slot._c) {
8057
- slot._d = true;
8058
- }
8059
- return rendered;
8326
+ function createTextVNode(text = ' ', flag = 0) {
8327
+ return createVNode(Text, null, text, flag);
8060
8328
  }
8061
- function ensureValidVNode(vnodes) {
8062
- return vnodes.some(child => {
8063
- if (!isVNode(child))
8064
- return true;
8065
- if (child.type === Comment)
8066
- return false;
8067
- if (child.type === Fragment &&
8068
- !ensureValidVNode(child.children))
8069
- return false;
8070
- return true;
8071
- })
8072
- ? vnodes
8073
- : null;
8074
- }
8075
-
8076
8329
  /**
8077
- * For prefixing keys in v-on="obj" with "on"
8078
8330
  * @private
8079
8331
  */
8080
- function toHandlers(obj) {
8081
- const ret = {};
8082
- if (!isObject(obj)) {
8083
- warn$1(`v-on with no argument expects an object value.`);
8084
- return ret;
8085
- }
8086
- for (const key in obj) {
8087
- ret[toHandlerKey(key)] = obj[key];
8088
- }
8089
- return ret;
8090
- }
8091
-
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
+ }
8092
8339
  /**
8093
- * #2437 In Vue 3, functional components do not have a public instance proxy but
8094
- * they exist in the internal parent chain. For code that relies on traversing
8095
- * public $parent chains, skip functional ones and go to the parent instead.
8340
+ * @private
8096
8341
  */
8097
- const getPublicInstance = (i) => {
8098
- if (!i)
8099
- return null;
8100
- if (isStatefulComponent(i))
8101
- return getExposeProxy(i) || i.proxy;
8102
- return getPublicInstance(i.parent);
8103
- };
8104
- const publicPropertiesMap = extend(Object.create(null), {
8105
- $: i => i,
8106
- $el: i => i.vnode.el,
8107
- $data: i => i.data,
8108
- $props: i => (shallowReadonly(i.props) ),
8109
- $attrs: i => (shallowReadonly(i.attrs) ),
8110
- $slots: i => (shallowReadonly(i.slots) ),
8111
- $refs: i => (shallowReadonly(i.refs) ),
8112
- $parent: i => getPublicInstance(i.parent),
8113
- $root: i => getPublicInstance(i.root),
8114
- $emit: i => i.emit,
8115
- $options: i => (resolveMergedOptions(i) ),
8116
- $forceUpdate: i => () => queueJob(i.update),
8117
- $nextTick: i => nextTick.bind(i.proxy),
8118
- $watch: i => (instanceWatch.bind(i) )
8119
- });
8120
- const PublicInstanceProxyHandlers = {
8121
- get({ _: instance }, key) {
8122
- const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
8123
- // for internal formatters to know that this is a Vue instance
8124
- if (key === '__isVue') {
8125
- return true;
8126
- }
8127
- // prioritize <script setup> bindings during dev.
8128
- // this allows even properties that start with _ or $ to be used - so that
8129
- // it aligns with the production behavior where the render fn is inlined and
8130
- // indeed has access to all declared variables.
8131
- if (setupState !== EMPTY_OBJ &&
8132
- setupState.__isScriptSetup &&
8133
- hasOwn(setupState, key)) {
8134
- return setupState[key];
8135
- }
8136
- // data / props / ctx
8137
- // This getter gets called for every property access on the render context
8138
- // during render and is a major hotspot. The most expensive part of this
8139
- // is the multiple hasOwn() calls. It's much faster to do a simple property
8140
- // access on a plain object, so we use an accessCache object (with null
8141
- // prototype) to memoize what access type a key corresponds to.
8142
- let normalizedProps;
8143
- if (key[0] !== '$') {
8144
- const n = accessCache[key];
8145
- if (n !== undefined) {
8146
- switch (n) {
8147
- case 1 /* SETUP */:
8148
- return setupState[key];
8149
- case 2 /* DATA */:
8150
- return data[key];
8151
- case 4 /* CONTEXT */:
8152
- return ctx[key];
8153
- case 3 /* PROPS */:
8154
- return props[key];
8155
- // default: just fallthrough
8156
- }
8157
- }
8158
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8159
- accessCache[key] = 1 /* SETUP */;
8160
- return setupState[key];
8161
- }
8162
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8163
- accessCache[key] = 2 /* DATA */;
8164
- return data[key];
8165
- }
8166
- else if (
8167
- // only cache other properties when instance has declared (thus stable)
8168
- // props
8169
- (normalizedProps = instance.propsOptions[0]) &&
8170
- hasOwn(normalizedProps, key)) {
8171
- accessCache[key] = 3 /* PROPS */;
8172
- return props[key];
8173
- }
8174
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8175
- accessCache[key] = 4 /* CONTEXT */;
8176
- return ctx[key];
8177
- }
8178
- else if (shouldCacheAccess) {
8179
- accessCache[key] = 0 /* OTHER */;
8180
- }
8181
- }
8182
- const publicGetter = publicPropertiesMap[key];
8183
- let cssModule, globalProperties;
8184
- // public $xxx properties
8185
- if (publicGetter) {
8186
- if (key === '$attrs') {
8187
- track(instance, "get" /* GET */, key);
8188
- markAttrsAccessed();
8189
- }
8190
- return publicGetter(instance);
8191
- }
8192
- else if (
8193
- // css module (injected by vue-loader)
8194
- (cssModule = type.__cssModules) &&
8195
- (cssModule = cssModule[key])) {
8196
- return cssModule;
8197
- }
8198
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8199
- // user may set custom properties to `this` that start with `$`
8200
- accessCache[key] = 4 /* CONTEXT */;
8201
- return ctx[key];
8202
- }
8203
- else if (
8204
- // global properties
8205
- ((globalProperties = appContext.config.globalProperties),
8206
- hasOwn(globalProperties, key))) {
8207
- {
8208
- return globalProperties[key];
8209
- }
8210
- }
8211
- else if (currentRenderingInstance &&
8212
- (!isString(key) ||
8213
- // #1091 avoid internal isRef/isVNode checks on component instance leading
8214
- // to infinite warning loop
8215
- key.indexOf('__v') !== 0)) {
8216
- if (data !== EMPTY_OBJ &&
8217
- (key[0] === '$' || key[0] === '_') &&
8218
- hasOwn(data, key)) {
8219
- warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
8220
- `character ("$" or "_") and is not proxied on the render context.`);
8221
- }
8222
- else if (instance === currentRenderingInstance) {
8223
- warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
8224
- `but is not defined on instance.`);
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);
8225
8393
  }
8226
- }
8227
- },
8228
- set({ _: instance }, key, value) {
8229
- const { data, setupState, ctx } = instance;
8230
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8231
- setupState[key] = value;
8232
- return true;
8233
- }
8234
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8235
- data[key] = value;
8236
- return true;
8237
- }
8238
- else if (hasOwn(instance.props, key)) {
8239
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
8240
- return false;
8241
- }
8242
- if (key[0] === '$' && key.slice(1) in instance) {
8243
- warn$1(`Attempting to mutate public property "${key}". ` +
8244
- `Properties starting with $ are reserved and readonly.`, instance);
8245
- return false;
8394
+ return;
8246
8395
  }
8247
8396
  else {
8248
- if (key in instance.appContext.config.globalProperties) {
8249
- Object.defineProperty(ctx, key, {
8250
- enumerable: true,
8251
- configurable: true,
8252
- value
8253
- });
8397
+ type = 32 /* SLOTS_CHILDREN */;
8398
+ const slotFlag = children._;
8399
+ if (!slotFlag && !(InternalObjectKey in children)) {
8400
+ children._ctx = currentRenderingInstance;
8254
8401
  }
8255
- else {
8256
- 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
+ }
8257
8412
  }
8258
8413
  }
8259
- return true;
8260
- },
8261
- has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
8262
- let normalizedProps;
8263
- return (!!accessCache[key] ||
8264
- (data !== EMPTY_OBJ && hasOwn(data, key)) ||
8265
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
8266
- ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
8267
- hasOwn(ctx, key) ||
8268
- hasOwn(publicPropertiesMap, key) ||
8269
- hasOwn(appContext.config.globalProperties, key));
8270
- },
8271
- defineProperty(target, key, descriptor) {
8272
- if (descriptor.get != null) {
8273
- // invalidate key cache of a getter based property #5417
8274
- target.$.accessCache[key] = 0;
8275
- }
8276
- else if (hasOwn(descriptor, 'value')) {
8277
- this.set(target, key, descriptor.value, null);
8278
- }
8279
- return Reflect.defineProperty(target, key, descriptor);
8280
8414
  }
8281
- };
8282
- {
8283
- PublicInstanceProxyHandlers.ownKeys = (target) => {
8284
- warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
8285
- `The keys will be empty in production mode to avoid performance overhead.`);
8286
- return Reflect.ownKeys(target);
8287
- };
8288
- }
8289
- const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
8290
- get(target, key) {
8291
- // fast path for unscopables when using `with` block
8292
- if (key === Symbol.unscopables) {
8293
- 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)];
8294
8425
  }
8295
- return PublicInstanceProxyHandlers.get(target, key, target);
8296
- },
8297
- has(_, key) {
8298
- const has = key[0] !== '_' && !isGloballyWhitelisted(key);
8299
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
8300
- 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 */;
8301
8428
  }
8302
- return has;
8303
- }
8304
- });
8305
- // dev only
8306
- // In dev mode, the proxy target exposes the same properties as seen on `this`
8307
- // for easier console inspection. In prod mode it will be an empty object so
8308
- // these properties definitions can be skipped.
8309
- function createDevRenderContext(instance) {
8310
- const target = {};
8311
- // expose internal instance for proxy handlers
8312
- Object.defineProperty(target, `_`, {
8313
- configurable: true,
8314
- enumerable: false,
8315
- get: () => instance
8316
- });
8317
- // expose public properties
8318
- Object.keys(publicPropertiesMap).forEach(key => {
8319
- Object.defineProperty(target, key, {
8320
- configurable: true,
8321
- enumerable: false,
8322
- get: () => publicPropertiesMap[key](instance),
8323
- // intercepted by the proxy so no need for implementation,
8324
- // but needed to prevent set errors
8325
- set: NOOP
8326
- });
8327
- });
8328
- return target;
8329
- }
8330
- // dev only
8331
- function exposePropsOnRenderContext(instance) {
8332
- const { ctx, propsOptions: [propsOptions] } = instance;
8333
- if (propsOptions) {
8334
- Object.keys(propsOptions).forEach(key => {
8335
- Object.defineProperty(ctx, key, {
8336
- enumerable: true,
8337
- configurable: true,
8338
- get: () => instance.props[key],
8339
- set: NOOP
8340
- });
8341
- });
8342
8429
  }
8430
+ vnode.children = children;
8431
+ vnode.shapeFlag |= type;
8343
8432
  }
8344
- // dev only
8345
- function exposeSetupStateOnRenderContext(instance) {
8346
- const { ctx, setupState } = instance;
8347
- Object.keys(toRaw(setupState)).forEach(key => {
8348
- if (!setupState.__isScriptSetup) {
8349
- if (key[0] === '$' || key[0] === '_') {
8350
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8351
- `which are reserved prefixes for Vue internals.`);
8352
- 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];
8353
8459
  }
8354
- Object.defineProperty(ctx, key, {
8355
- enumerable: true,
8356
- configurable: true,
8357
- get: () => setupState[key],
8358
- set: NOOP
8359
- });
8360
8460
  }
8361
- });
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
+ ]);
8362
8469
  }
8363
8470
 
8364
8471
  const emptyAppContext = createAppContext();
@@ -8387,7 +8494,7 @@ var Vue = (function (exports) {
8387
8494
  provides: parent ? parent.provides : Object.create(appContext.provides),
8388
8495
  accessCache: null,
8389
8496
  renderCache: [],
8390
- // local resovled assets
8497
+ // local resolved assets
8391
8498
  components: null,
8392
8499
  directives: null,
8393
8500
  // resolved props and emits options
@@ -8479,6 +8586,7 @@ var Vue = (function (exports) {
8479
8586
  return setupResult;
8480
8587
  }
8481
8588
  function setupStatefulComponent(instance, isSSR) {
8589
+ var _a;
8482
8590
  const Component = instance.type;
8483
8591
  {
8484
8592
  if (Component.name) {
@@ -8536,6 +8644,13 @@ var Vue = (function (exports) {
8536
8644
  // async setup returned Promise.
8537
8645
  // bail here and wait for re-entry.
8538
8646
  instance.asyncDep = setupResult;
8647
+ if (!instance.suspense) {
8648
+ const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
8649
+ warn$1(`Component <${name}>: setup function returned a promise, but no ` +
8650
+ `<Suspense> boundary was found in the parent component tree. ` +
8651
+ `A component with async setup() must be nested in a <Suspense> ` +
8652
+ `in order to be rendered.`);
8653
+ }
8539
8654
  }
8540
8655
  }
8541
8656
  else {
@@ -9135,7 +9250,7 @@ var Vue = (function (exports) {
9135
9250
  return false;
9136
9251
  }
9137
9252
  for (let i = 0; i < prev.length; i++) {
9138
- if (prev[i] !== memo[i]) {
9253
+ if (hasChanged(prev[i], memo[i])) {
9139
9254
  return false;
9140
9255
  }
9141
9256
  }
@@ -9147,7 +9262,7 @@ var Vue = (function (exports) {
9147
9262
  }
9148
9263
 
9149
9264
  // Core API ------------------------------------------------------------------
9150
- const version = "3.2.32";
9265
+ const version = "3.2.34";
9151
9266
  /**
9152
9267
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9153
9268
  * @internal
@@ -9164,7 +9279,7 @@ var Vue = (function (exports) {
9164
9279
 
9165
9280
  const svgNS = 'http://www.w3.org/2000/svg';
9166
9281
  const doc = (typeof document !== 'undefined' ? document : null);
9167
- const templateContainer = doc && doc.createElement('template');
9282
+ const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
9168
9283
  const nodeOps = {
9169
9284
  insert: (child, parent, anchor) => {
9170
9285
  parent.insertBefore(child, anchor || null);
@@ -9315,6 +9430,8 @@ var Vue = (function (exports) {
9315
9430
  val.forEach(v => setStyle(style, name, v));
9316
9431
  }
9317
9432
  else {
9433
+ if (val == null)
9434
+ val = '';
9318
9435
  if (name.startsWith('--')) {
9319
9436
  // custom property definition
9320
9437
  style.setProperty(name, val);
@@ -9409,31 +9526,28 @@ var Vue = (function (exports) {
9409
9526
  }
9410
9527
  return;
9411
9528
  }
9529
+ let needRemove = false;
9412
9530
  if (value === '' || value == null) {
9413
9531
  const type = typeof el[key];
9414
9532
  if (type === 'boolean') {
9415
9533
  // e.g. <select multiple> compiles to { multiple: '' }
9416
- el[key] = includeBooleanAttr(value);
9417
- return;
9534
+ value = includeBooleanAttr(value);
9418
9535
  }
9419
9536
  else if (value == null && type === 'string') {
9420
9537
  // e.g. <div :id="null">
9421
- el[key] = '';
9422
- el.removeAttribute(key);
9423
- return;
9538
+ value = '';
9539
+ needRemove = true;
9424
9540
  }
9425
9541
  else if (type === 'number') {
9426
9542
  // e.g. <img :width="null">
9427
9543
  // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9428
- try {
9429
- el[key] = 0;
9430
- }
9431
- catch (_a) { }
9432
- el.removeAttribute(key);
9433
- return;
9544
+ value = 0;
9545
+ needRemove = true;
9434
9546
  }
9435
9547
  }
9436
- // some properties perform value validation and throw
9548
+ // some properties perform value validation and throw,
9549
+ // some properties has getter, no setter, will error in 'use strict'
9550
+ // eg. <select :type="null"></select> <select :willValidate="null"></select>
9437
9551
  try {
9438
9552
  el[key] = value;
9439
9553
  }
@@ -9443,31 +9557,35 @@ var Vue = (function (exports) {
9443
9557
  `value ${value} is invalid.`, e);
9444
9558
  }
9445
9559
  }
9560
+ needRemove && el.removeAttribute(key);
9446
9561
  }
9447
9562
 
9448
9563
  // Async edge case fix requires storing an event listener's attach timestamp.
9449
- let _getNow = Date.now;
9450
- let skipTimestampCheck = false;
9451
- if (typeof window !== 'undefined') {
9452
- // Determine what event timestamp the browser is using. Annoyingly, the
9453
- // timestamp can either be hi-res (relative to page load) or low-res
9454
- // (relative to UNIX epoch), so in order to compare time we have to use the
9455
- // same timestamp type when saving the flush timestamp.
9456
- if (_getNow() > document.createEvent('Event').timeStamp) {
9457
- // if the low-res timestamp which is bigger than the event timestamp
9458
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9459
- // and we need to use the hi-res version for event listeners as well.
9460
- _getNow = () => performance.now();
9461
- }
9462
- // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9463
- // and does not fire microtasks in between event propagation, so safe to exclude.
9464
- const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9465
- skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9466
- }
9564
+ const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
9565
+ let _getNow = Date.now;
9566
+ let skipTimestampCheck = false;
9567
+ if (typeof window !== 'undefined') {
9568
+ // Determine what event timestamp the browser is using. Annoyingly, the
9569
+ // timestamp can either be hi-res (relative to page load) or low-res
9570
+ // (relative to UNIX epoch), so in order to compare time we have to use the
9571
+ // same timestamp type when saving the flush timestamp.
9572
+ if (Date.now() > document.createEvent('Event').timeStamp) {
9573
+ // if the low-res timestamp which is bigger than the event timestamp
9574
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9575
+ // and we need to use the hi-res version for event listeners as well.
9576
+ _getNow = () => performance.now();
9577
+ }
9578
+ // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9579
+ // and does not fire microtasks in between event propagation, so safe to exclude.
9580
+ const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9581
+ skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9582
+ }
9583
+ return [_getNow, skipTimestampCheck];
9584
+ })();
9467
9585
  // To avoid the overhead of repeatedly calling performance.now(), we cache
9468
9586
  // and use the same timestamp for all event listeners attached in the same tick.
9469
9587
  let cachedNow = 0;
9470
- const p = Promise.resolve();
9588
+ const p = /*#__PURE__*/ Promise.resolve();
9471
9589
  const reset = () => {
9472
9590
  cachedNow = 0;
9473
9591
  };
@@ -9592,13 +9710,13 @@ var Vue = (function (exports) {
9592
9710
  }
9593
9711
  return false;
9594
9712
  }
9595
- // spellcheck and draggable are numerated attrs, however their
9596
- // corresponding DOM properties are actually booleans - this leads to
9597
- // setting it with a string "false" value leading it to be coerced to
9598
- // `true`, so we need to always treat them as attributes.
9713
+ // these are enumerated attrs, however their corresponding DOM properties
9714
+ // are actually booleans - this leads to setting it with a string "false"
9715
+ // value leading it to be coerced to `true`, so we need to always treat
9716
+ // them as attributes.
9599
9717
  // Note that `contentEditable` doesn't have this problem: its DOM
9600
9718
  // property is also enumerated string values.
9601
- if (key === 'spellcheck' || key === 'draggable') {
9719
+ if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
9602
9720
  return false;
9603
9721
  }
9604
9722
  // #1787, #2840 form property on form elements is readonly and must be set as
@@ -9621,11 +9739,11 @@ var Vue = (function (exports) {
9621
9739
  return key in el;
9622
9740
  }
9623
9741
 
9624
- function defineCustomElement(options, hydate) {
9742
+ function defineCustomElement(options, hydrate) {
9625
9743
  const Comp = defineComponent(options);
9626
9744
  class VueCustomElement extends VueElement {
9627
9745
  constructor(initialProps) {
9628
- super(Comp, initialProps, hydate);
9746
+ super(Comp, initialProps, hydrate);
9629
9747
  }
9630
9748
  }
9631
9749
  VueCustomElement.def = Comp;
@@ -9973,7 +10091,10 @@ var Vue = (function (exports) {
9973
10091
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
9974
10092
  done && done();
9975
10093
  };
10094
+ let isLeaving = false;
9976
10095
  const finishLeave = (el, done) => {
10096
+ isLeaving = false;
10097
+ removeTransitionClass(el, leaveFromClass);
9977
10098
  removeTransitionClass(el, leaveToClass);
9978
10099
  removeTransitionClass(el, leaveActiveClass);
9979
10100
  done && done();
@@ -10006,12 +10127,17 @@ var Vue = (function (exports) {
10006
10127
  onEnter: makeEnterHook(false),
10007
10128
  onAppear: makeEnterHook(true),
10008
10129
  onLeave(el, done) {
10130
+ isLeaving = true;
10009
10131
  const resolve = () => finishLeave(el, done);
10010
10132
  addTransitionClass(el, leaveFromClass);
10011
10133
  // force reflow so *-leave-from classes immediately take effect (#2593)
10012
10134
  forceReflow();
10013
10135
  addTransitionClass(el, leaveActiveClass);
10014
10136
  nextFrame(() => {
10137
+ if (!isLeaving) {
10138
+ // cancelled
10139
+ return;
10140
+ }
10015
10141
  removeTransitionClass(el, leaveFromClass);
10016
10142
  addTransitionClass(el, leaveToClass);
10017
10143
  if (!hasExplicitCallback(onLeave)) {
@@ -10303,7 +10429,8 @@ var Vue = (function (exports) {
10303
10429
  }
10304
10430
 
10305
10431
  const getModelAssigner = (vnode) => {
10306
- const fn = vnode.props['onUpdate:modelValue'];
10432
+ const fn = vnode.props['onUpdate:modelValue'] ||
10433
+ (false );
10307
10434
  return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10308
10435
  };
10309
10436
  function onCompositionStart(e) {
@@ -10313,14 +10440,9 @@ var Vue = (function (exports) {
10313
10440
  const target = e.target;
10314
10441
  if (target.composing) {
10315
10442
  target.composing = false;
10316
- trigger$1(target, 'input');
10443
+ target.dispatchEvent(new Event('input'));
10317
10444
  }
10318
10445
  }
10319
- function trigger$1(el, type) {
10320
- const e = document.createEvent('HTMLEvents');
10321
- e.initEvent(type, true, true);
10322
- el.dispatchEvent(e);
10323
- }
10324
10446
  // We are exporting the v-model runtime directly as vnode hooks so that it can
10325
10447
  // be tree-shaken in case v-model is never used.
10326
10448
  const vModelText = {
@@ -10334,7 +10456,7 @@ var Vue = (function (exports) {
10334
10456
  if (trim) {
10335
10457
  domValue = domValue.trim();
10336
10458
  }
10337
- else if (castToNumber) {
10459
+ if (castToNumber) {
10338
10460
  domValue = toNumber(domValue);
10339
10461
  }
10340
10462
  el._assign(domValue);
@@ -10363,7 +10485,7 @@ var Vue = (function (exports) {
10363
10485
  // avoid clearing unresolved text. #2302
10364
10486
  if (el.composing)
10365
10487
  return;
10366
- if (document.activeElement === el) {
10488
+ if (document.activeElement === el && el.type !== 'range') {
10367
10489
  if (lazy) {
10368
10490
  return;
10369
10491
  }
@@ -10533,27 +10655,25 @@ var Vue = (function (exports) {
10533
10655
  callModelHook(el, binding, vnode, prevVNode, 'updated');
10534
10656
  }
10535
10657
  };
10536
- function callModelHook(el, binding, vnode, prevVNode, hook) {
10537
- let modelToUse;
10538
- switch (el.tagName) {
10658
+ function resolveDynamicModel(tagName, type) {
10659
+ switch (tagName) {
10539
10660
  case 'SELECT':
10540
- modelToUse = vModelSelect;
10541
- break;
10661
+ return vModelSelect;
10542
10662
  case 'TEXTAREA':
10543
- modelToUse = vModelText;
10544
- break;
10663
+ return vModelText;
10545
10664
  default:
10546
- switch (vnode.props && vnode.props.type) {
10665
+ switch (type) {
10547
10666
  case 'checkbox':
10548
- modelToUse = vModelCheckbox;
10549
- break;
10667
+ return vModelCheckbox;
10550
10668
  case 'radio':
10551
- modelToUse = vModelRadio;
10552
- break;
10669
+ return vModelRadio;
10553
10670
  default:
10554
- modelToUse = vModelText;
10671
+ return vModelText;
10555
10672
  }
10556
10673
  }
10674
+ }
10675
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
10676
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
10557
10677
  const fn = modelToUse[hook];
10558
10678
  fn && fn(el, binding, vnode, prevVNode);
10559
10679
  }
@@ -10653,7 +10773,7 @@ var Vue = (function (exports) {
10653
10773
  el.style.display = value ? el._vod : 'none';
10654
10774
  }
10655
10775
 
10656
- const rendererOptions = extend({ patchProp }, nodeOps);
10776
+ const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
10657
10777
  // lazy create the renderer - this makes core renderer logic tree-shakable
10658
10778
  // in case the user only imports reactivity utilities from Vue.
10659
10779
  let renderer;
@@ -12819,6 +12939,7 @@ var Vue = (function (exports) {
12819
12939
  }
12820
12940
 
12821
12941
  const PURE_ANNOTATION = `/*#__PURE__*/`;
12942
+ const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
12822
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 }) {
12823
12944
  const context = {
12824
12945
  mode,
@@ -12895,9 +13016,7 @@ var Vue = (function (exports) {
12895
13016
  // function mode const declarations should be inside with block
12896
13017
  // also they should be renamed to avoid collision with user properties
12897
13018
  if (hasHelpers) {
12898
- push(`const { ${ast.helpers
12899
- .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
12900
- .join(', ')} } = _Vue`);
13019
+ push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
12901
13020
  push(`\n`);
12902
13021
  newline();
12903
13022
  }
@@ -12952,7 +13071,6 @@ var Vue = (function (exports) {
12952
13071
  function genFunctionPreamble(ast, context) {
12953
13072
  const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
12954
13073
  const VueBinding = runtimeGlobalName;
12955
- const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
12956
13074
  // Generate const declaration for helpers
12957
13075
  // In prefix mode, we place the const declaration at top so it's done
12958
13076
  // only once; But if we not prefixing, we place the declaration inside the
@@ -13565,14 +13683,14 @@ var Vue = (function (exports) {
13565
13683
  }
13566
13684
  }
13567
13685
  function createIfBranch(node, dir) {
13686
+ const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
13568
13687
  return {
13569
13688
  type: 10 /* IF_BRANCH */,
13570
13689
  loc: node.loc,
13571
13690
  condition: dir.name === 'else' ? undefined : dir.exp,
13572
- children: node.tagType === 3 /* TEMPLATE */ && !findDir(node, 'for')
13573
- ? node.children
13574
- : [node],
13575
- userKey: findProp(node, `key`)
13691
+ children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
13692
+ userKey: findProp(node, `key`),
13693
+ isTemplateIf
13576
13694
  };
13577
13695
  }
13578
13696
  function createCodegenNodeForBranch(branch, keyIndex, context) {
@@ -13607,7 +13725,8 @@ var Vue = (function (exports) {
13607
13725
  let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
13608
13726
  // check if the fragment actually contains a single valid child with
13609
13727
  // the rest being comments
13610
- if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
13728
+ if (!branch.isTemplateIf &&
13729
+ children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
13611
13730
  patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
13612
13731
  patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
13613
13732
  }
@@ -14158,7 +14277,7 @@ var Vue = (function (exports) {
14158
14277
  (tag === 'svg' || tag === 'foreignObject'));
14159
14278
  // props
14160
14279
  if (props.length > 0) {
14161
- const propsBuildResult = buildProps(node, context);
14280
+ const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
14162
14281
  vnodeProps = propsBuildResult.props;
14163
14282
  patchFlag = propsBuildResult.patchFlag;
14164
14283
  dynamicPropNames = propsBuildResult.dynamicPropNames;
@@ -14297,9 +14416,8 @@ var Vue = (function (exports) {
14297
14416
  context.components.add(tag);
14298
14417
  return toValidAssetId(tag, `component`);
14299
14418
  }
14300
- function buildProps(node, context, props = node.props, ssr = false) {
14419
+ function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
14301
14420
  const { tag, loc: elementLoc, children } = node;
14302
- const isComponent = node.tagType === 1 /* COMPONENT */;
14303
14421
  let properties = [];
14304
14422
  const mergeArgs = [];
14305
14423
  const runtimeDirectives = [];
@@ -14318,8 +14436,8 @@ var Vue = (function (exports) {
14318
14436
  if (isStaticExp(key)) {
14319
14437
  const name = key.content;
14320
14438
  const isEventHandler = isOn(name);
14321
- if (!isComponent &&
14322
- isEventHandler &&
14439
+ if (isEventHandler &&
14440
+ (!isComponent || isDynamicComponent) &&
14323
14441
  // omit the flag for click handlers because hydration gives click
14324
14442
  // dedicated fast path.
14325
14443
  name.toLowerCase() !== 'onclick' &&
@@ -14545,10 +14663,11 @@ var Vue = (function (exports) {
14545
14663
  classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
14546
14664
  }
14547
14665
  if (styleProp &&
14548
- !isStaticExp(styleProp.value) &&
14549
14666
  // the static style is compiled into an object,
14550
14667
  // so use `hasStyleBinding` to ensure that it is a dynamic style binding
14551
14668
  (hasStyleBinding ||
14669
+ (styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
14670
+ styleProp.value.content.trim()[0] === `[`) ||
14552
14671
  // v-bind:style and style both exist,
14553
14672
  // v-bind:style with static literal object
14554
14673
  styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
@@ -14727,7 +14846,7 @@ var Vue = (function (exports) {
14727
14846
  }
14728
14847
  }
14729
14848
  if (nonNameProps.length > 0) {
14730
- const { props, directives } = buildProps(node, context, nonNameProps);
14849
+ const { props, directives } = buildProps(node, context, nonNameProps, false, false);
14731
14850
  slotProps = props;
14732
14851
  if (directives.length) {
14733
14852
  context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
@@ -14898,11 +15017,7 @@ var Vue = (function (exports) {
14898
15017
  const next = children[j];
14899
15018
  if (isText(next)) {
14900
15019
  if (!currentContainer) {
14901
- currentContainer = children[i] = {
14902
- type: 8 /* COMPOUND_EXPRESSION */,
14903
- loc: child.loc,
14904
- children: [child]
14905
- };
15020
+ currentContainer = children[i] = createCompoundExpression([child], child.loc);
14906
15021
  }
14907
15022
  // merge adjacent text node into current
14908
15023
  currentContainer.children.push(` + `, next);
@@ -15309,7 +15424,9 @@ var Vue = (function (exports) {
15309
15424
  return {
15310
15425
  props: [
15311
15426
  createObjectProperty(createSimpleExpression(`textContent`, true), exp
15312
- ? createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
15427
+ ? getConstantType(exp, context) > 0
15428
+ ? exp
15429
+ : createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
15313
15430
  : createSimpleExpression('', true))
15314
15431
  ]
15315
15432
  };
@@ -15517,19 +15634,38 @@ var Vue = (function (exports) {
15517
15634
  };
15518
15635
  };
15519
15636
 
15520
- const warnTransitionChildren = (node, context) => {
15637
+ const transformTransition = (node, context) => {
15521
15638
  if (node.type === 1 /* ELEMENT */ &&
15522
15639
  node.tagType === 1 /* COMPONENT */) {
15523
15640
  const component = context.isBuiltInComponent(node.tag);
15524
15641
  if (component === TRANSITION$1) {
15525
15642
  return () => {
15526
- if (node.children.length && hasMultipleChildren(node)) {
15643
+ if (!node.children.length) {
15644
+ return;
15645
+ }
15646
+ // warn multiple transition children
15647
+ if (hasMultipleChildren(node)) {
15527
15648
  context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
15528
15649
  start: node.children[0].loc.start,
15529
15650
  end: node.children[node.children.length - 1].loc.end,
15530
15651
  source: ''
15531
15652
  }));
15532
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
+ }
15533
15669
  };
15534
15670
  }
15535
15671
  }
@@ -15555,7 +15691,7 @@ var Vue = (function (exports) {
15555
15691
 
15556
15692
  const DOMNodeTransforms = [
15557
15693
  transformStyle,
15558
- ...([warnTransitionChildren] )
15694
+ ...([transformTransition] )
15559
15695
  ];
15560
15696
  const DOMDirectiveTransforms = {
15561
15697
  cloak: noopDirectiveTransform,