@vue/runtime-dom 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.
@@ -160,6 +160,11 @@ function looseEqual(a, b) {
160
160
  if (aValidType || bValidType) {
161
161
  return aValidType && bValidType ? a.getTime() === b.getTime() : false;
162
162
  }
163
+ aValidType = isSymbol(a);
164
+ bValidType = isSymbol(b);
165
+ if (aValidType || bValidType) {
166
+ return a === b;
167
+ }
163
168
  aValidType = isArray(a);
164
169
  bValidType = isArray(b);
165
170
  if (aValidType || bValidType) {
@@ -255,7 +260,7 @@ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
255
260
  const isArray = Array.isArray;
256
261
  const isMap = (val) => toTypeString(val) === '[object Map]';
257
262
  const isSet = (val) => toTypeString(val) === '[object Set]';
258
- const isDate = (val) => val instanceof Date;
263
+ const isDate = (val) => toTypeString(val) === '[object Date]';
259
264
  const isFunction = (val) => typeof val === 'function';
260
265
  const isString = (val) => typeof val === 'string';
261
266
  const isSymbol = (val) => typeof val === 'symbol';
@@ -533,10 +538,17 @@ class ReactiveEffect {
533
538
  activeEffect = this.parent;
534
539
  shouldTrack = lastShouldTrack;
535
540
  this.parent = undefined;
541
+ if (this.deferStop) {
542
+ this.stop();
543
+ }
536
544
  }
537
545
  }
538
546
  stop() {
539
- if (this.active) {
547
+ // stopped while running itself - defer the cleanup
548
+ if (activeEffect === this) {
549
+ this.deferStop = true;
550
+ }
551
+ else if (this.active) {
540
552
  cleanupEffect(this);
541
553
  if (this.onStop) {
542
554
  this.onStop();
@@ -695,23 +707,40 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
695
707
  }
696
708
  function triggerEffects(dep, debuggerEventExtraInfo) {
697
709
  // spread into array for stabilization
698
- for (const effect of isArray(dep) ? dep : [...dep]) {
699
- if (effect !== activeEffect || effect.allowRecurse) {
700
- if (effect.onTrigger) {
701
- effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
702
- }
703
- if (effect.scheduler) {
704
- effect.scheduler();
705
- }
706
- else {
707
- effect.run();
708
- }
710
+ const effects = isArray(dep) ? dep : [...dep];
711
+ for (const effect of effects) {
712
+ if (effect.computed) {
713
+ triggerEffect(effect, debuggerEventExtraInfo);
714
+ }
715
+ }
716
+ for (const effect of effects) {
717
+ if (!effect.computed) {
718
+ triggerEffect(effect, debuggerEventExtraInfo);
719
+ }
720
+ }
721
+ }
722
+ function triggerEffect(effect, debuggerEventExtraInfo) {
723
+ if (effect !== activeEffect || effect.allowRecurse) {
724
+ if (effect.onTrigger) {
725
+ effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
726
+ }
727
+ if (effect.scheduler) {
728
+ effect.scheduler();
729
+ }
730
+ else {
731
+ effect.run();
709
732
  }
710
733
  }
711
734
  }
712
735
 
713
736
  const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
714
- const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
737
+ const builtInSymbols = new Set(
738
+ /*#__PURE__*/
739
+ Object.getOwnPropertyNames(Symbol)
740
+ // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
741
+ // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
742
+ // function
743
+ .filter(key => key !== 'arguments' && key !== 'caller')
715
744
  .map(key => Symbol[key])
716
745
  .filter(isSymbol));
717
746
  const get = /*#__PURE__*/ createGetter();
@@ -785,9 +814,8 @@ function createGetter(isReadonly = false, shallow = false) {
785
814
  return res;
786
815
  }
787
816
  if (isRef(res)) {
788
- // ref unwrapping - does not apply for Array + integer key.
789
- const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
790
- return shouldUnwrap ? res.value : res;
817
+ // ref unwrapping - skip unwrap for Array + integer key.
818
+ return targetIsArray && isIntegerKey(key) ? res : res.value;
791
819
  }
792
820
  if (isObject(res)) {
793
821
  // Convert returned value into a proxy as well. we do the isObject check
@@ -863,13 +891,13 @@ const readonlyHandlers = {
863
891
  get: readonlyGet,
864
892
  set(target, key) {
865
893
  {
866
- console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
894
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
867
895
  }
868
896
  return true;
869
897
  },
870
898
  deleteProperty(target, key) {
871
899
  {
872
- console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
900
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
873
901
  }
874
902
  return true;
875
903
  }
@@ -893,10 +921,12 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
893
921
  target = target["__v_raw" /* RAW */];
894
922
  const rawTarget = toRaw(target);
895
923
  const rawKey = toRaw(key);
896
- if (key !== rawKey) {
897
- !isReadonly && track(rawTarget, "get" /* GET */, key);
924
+ if (!isReadonly) {
925
+ if (key !== rawKey) {
926
+ track(rawTarget, "get" /* GET */, key);
927
+ }
928
+ track(rawTarget, "get" /* GET */, rawKey);
898
929
  }
899
- !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
900
930
  const { has } = getProto(rawTarget);
901
931
  const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
902
932
  if (has.call(rawTarget, key)) {
@@ -915,10 +945,12 @@ function has$1(key, isReadonly = false) {
915
945
  const target = this["__v_raw" /* RAW */];
916
946
  const rawTarget = toRaw(target);
917
947
  const rawKey = toRaw(key);
918
- if (key !== rawKey) {
919
- !isReadonly && track(rawTarget, "has" /* HAS */, key);
948
+ if (!isReadonly) {
949
+ if (key !== rawKey) {
950
+ track(rawTarget, "has" /* HAS */, key);
951
+ }
952
+ track(rawTarget, "has" /* HAS */, rawKey);
920
953
  }
921
- !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
922
954
  return key === rawKey
923
955
  ? target.has(key)
924
956
  : target.has(key) || target.has(rawKey);
@@ -1244,7 +1276,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1244
1276
  if (existingProxy) {
1245
1277
  return existingProxy;
1246
1278
  }
1247
- // only a whitelist of value types can be observed.
1279
+ // only specific value types can be observed.
1248
1280
  const targetType = getTargetType(target);
1249
1281
  if (targetType === 0 /* INVALID */) {
1250
1282
  return target;
@@ -1697,7 +1729,7 @@ let preFlushIndex = 0;
1697
1729
  const pendingPostFlushCbs = [];
1698
1730
  let activePostFlushCbs = null;
1699
1731
  let postFlushIndex = 0;
1700
- const resolvedPromise = Promise.resolve();
1732
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
1701
1733
  let currentFlushPromise = null;
1702
1734
  let currentPreFlushParentJob = null;
1703
1735
  const RECURSION_LIMIT = 100;
@@ -1794,6 +1826,8 @@ function flushPreFlushCbs(seen, parentJob = null) {
1794
1826
  }
1795
1827
  }
1796
1828
  function flushPostFlushCbs(seen) {
1829
+ // flush any pre cbs queued during the flush (e.g. pre watchers)
1830
+ flushPreFlushCbs();
1797
1831
  if (pendingPostFlushCbs.length) {
1798
1832
  const deduped = [...new Set(pendingPostFlushCbs)];
1799
1833
  pendingPostFlushCbs.length = 0;
@@ -2053,7 +2087,6 @@ function setDevtoolsHook(hook, target) {
2053
2087
  // handle late devtools injection - only do this if we are in an actual
2054
2088
  // browser environment to avoid the timer handle stalling test runner exit
2055
2089
  // (#4815)
2056
- // eslint-disable-next-line no-restricted-globals
2057
2090
  typeof window !== 'undefined' &&
2058
2091
  // some envs mock window but not fully
2059
2092
  window.HTMLElement &&
@@ -2113,6 +2146,8 @@ function devtoolsComponentEmit(component, event, params) {
2113
2146
  }
2114
2147
 
2115
2148
  function emit$1(instance, event, ...rawArgs) {
2149
+ if (instance.isUnmounted)
2150
+ return;
2116
2151
  const props = instance.vnode.props || EMPTY_OBJ;
2117
2152
  {
2118
2153
  const { emitsOptions, propsOptions: [propsOptions] } = instance;
@@ -2145,7 +2180,7 @@ function emit$1(instance, event, ...rawArgs) {
2145
2180
  if (trim) {
2146
2181
  args = rawArgs.map(a => a.trim());
2147
2182
  }
2148
- else if (number) {
2183
+ if (number) {
2149
2184
  args = rawArgs.map(toNumber);
2150
2185
  }
2151
2186
  }
@@ -2443,6 +2478,8 @@ function renderComponentRoot(instance) {
2443
2478
  warn$1(`Runtime directive used on component with non-element root node. ` +
2444
2479
  `The directives will not function as intended.`);
2445
2480
  }
2481
+ // clone before mutating since the root may be a hoisted vnode
2482
+ root = cloneVNode(root);
2446
2483
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2447
2484
  }
2448
2485
  // inherit transition data
@@ -3145,7 +3182,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3145
3182
  }
3146
3183
  else if (isArray(source)) {
3147
3184
  isMultiSource = true;
3148
- forceTrigger = source.some(isReactive);
3185
+ forceTrigger = source.some(s => isReactive(s) || isShallow(s));
3149
3186
  getter = () => source.map(s => {
3150
3187
  if (isRef(s)) {
3151
3188
  return s.value;
@@ -3237,16 +3274,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3237
3274
  }
3238
3275
  else {
3239
3276
  // default: 'pre'
3240
- scheduler = () => {
3241
- if (!instance || instance.isMounted) {
3242
- queuePreFlushCb(job);
3243
- }
3244
- else {
3245
- // with 'pre' option, the first call must happen before
3246
- // the component is mounted so it is called synchronously.
3247
- job();
3248
- }
3249
- };
3277
+ scheduler = () => queuePreFlushCb(job);
3250
3278
  }
3251
3279
  const effect = new ReactiveEffect(getter, scheduler);
3252
3280
  {
@@ -3389,10 +3417,22 @@ const BaseTransitionImpl = {
3389
3417
  if (!children || !children.length) {
3390
3418
  return;
3391
3419
  }
3392
- // warn multiple elements
3420
+ let child = children[0];
3393
3421
  if (children.length > 1) {
3394
- warn$1('<transition> can only be used on a single element or component. Use ' +
3395
- '<transition-group> for lists.');
3422
+ let hasFound = false;
3423
+ // locate first non-comment child
3424
+ for (const c of children) {
3425
+ if (c.type !== Comment) {
3426
+ if (hasFound) {
3427
+ // warn more than one non-comment child
3428
+ warn$1('<transition> can only be used on a single element or component. ' +
3429
+ 'Use <transition-group> for lists.');
3430
+ break;
3431
+ }
3432
+ child = c;
3433
+ hasFound = true;
3434
+ }
3435
+ }
3396
3436
  }
3397
3437
  // there's no need to track reactivity for these props so use the raw
3398
3438
  // props for a bit better perf
@@ -3405,8 +3445,6 @@ const BaseTransitionImpl = {
3405
3445
  mode !== 'default') {
3406
3446
  warn$1(`invalid <transition> mode: ${mode}`);
3407
3447
  }
3408
- // at this point children has a guaranteed length of 1.
3409
- const child = children[0];
3410
3448
  if (state.isLeaving) {
3411
3449
  return emptyPlaceholder(child);
3412
3450
  }
@@ -3489,6 +3527,17 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3489
3527
  hook &&
3490
3528
  callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3491
3529
  };
3530
+ const callAsyncHook = (hook, args) => {
3531
+ const done = args[1];
3532
+ callHook(hook, args);
3533
+ if (isArray(hook)) {
3534
+ if (hook.every(hook => hook.length <= 1))
3535
+ done();
3536
+ }
3537
+ else if (hook.length <= 1) {
3538
+ done();
3539
+ }
3540
+ };
3492
3541
  const hooks = {
3493
3542
  mode,
3494
3543
  persisted,
@@ -3547,10 +3596,7 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3547
3596
  el._enterCb = undefined;
3548
3597
  });
3549
3598
  if (hook) {
3550
- hook(el, done);
3551
- if (hook.length <= 1) {
3552
- done();
3553
- }
3599
+ callAsyncHook(hook, [el, done]);
3554
3600
  }
3555
3601
  else {
3556
3602
  done();
@@ -3584,10 +3630,7 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3584
3630
  });
3585
3631
  leavingVNodesCache[key] = vnode;
3586
3632
  if (onLeave) {
3587
- onLeave(el, done);
3588
- if (onLeave.length <= 1) {
3589
- done();
3590
- }
3633
+ callAsyncHook(onLeave, [el, done]);
3591
3634
  }
3592
3635
  else {
3593
3636
  done();
@@ -3797,7 +3840,7 @@ function defineAsyncComponent(source) {
3797
3840
  }
3798
3841
  });
3799
3842
  }
3800
- function createInnerComp(comp, { vnode: { ref, props, children } }) {
3843
+ function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3801
3844
  const vnode = createVNode(comp, props, children);
3802
3845
  // ensure inner component inherits the async wrapper's ref owner
3803
3846
  vnode.ref = ref;
@@ -3824,11 +3867,6 @@ const KeepAliveImpl = {
3824
3867
  // The whole point of this is to avoid importing KeepAlive directly in the
3825
3868
  // renderer to facilitate tree-shaking.
3826
3869
  const sharedContext = instance.ctx;
3827
- // if the internal renderer is not registered, it indicates that this is server-side rendering,
3828
- // for KeepAlive, we just need to render its children
3829
- if (!sharedContext.renderer) {
3830
- return slots.default;
3831
- }
3832
3870
  const cache = new Map();
3833
3871
  const keys = new Set();
3834
3872
  let current = null;
@@ -4006,7 +4044,7 @@ const KeepAliveImpl = {
4006
4044
  // avoid vnode being unmounted
4007
4045
  vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
4008
4046
  current = vnode;
4009
- return rawVNode;
4047
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
4010
4048
  };
4011
4049
  }
4012
4050
  };
@@ -4144,1111 +4182,1598 @@ function onErrorCaptured(hook, target = currentInstance) {
4144
4182
  injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4145
4183
  }
4146
4184
 
4147
- function createDuplicateChecker() {
4148
- const cache = Object.create(null);
4149
- return (type, key) => {
4150
- if (cache[key]) {
4151
- warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
4185
+ /**
4186
+ Runtime helper for applying directives to a vnode. Example usage:
4187
+
4188
+ const comp = resolveComponent('comp')
4189
+ const foo = resolveDirective('foo')
4190
+ const bar = resolveDirective('bar')
4191
+
4192
+ return withDirectives(h(comp), [
4193
+ [foo, this.x],
4194
+ [bar, this.y]
4195
+ ])
4196
+ */
4197
+ function validateDirectiveName(name) {
4198
+ if (isBuiltInDirective(name)) {
4199
+ warn$1('Do not use built-in directive ids as custom directive id: ' + name);
4200
+ }
4201
+ }
4202
+ /**
4203
+ * Adds directives to a VNode.
4204
+ */
4205
+ function withDirectives(vnode, directives) {
4206
+ const internalInstance = currentRenderingInstance;
4207
+ if (internalInstance === null) {
4208
+ warn$1(`withDirectives can only be used inside render functions.`);
4209
+ return vnode;
4210
+ }
4211
+ const instance = getExposeProxy(internalInstance) ||
4212
+ internalInstance.proxy;
4213
+ const bindings = vnode.dirs || (vnode.dirs = []);
4214
+ for (let i = 0; i < directives.length; i++) {
4215
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4216
+ if (isFunction(dir)) {
4217
+ dir = {
4218
+ mounted: dir,
4219
+ updated: dir
4220
+ };
4152
4221
  }
4153
- else {
4154
- cache[key] = type;
4222
+ if (dir.deep) {
4223
+ traverse(value);
4155
4224
  }
4156
- };
4157
- }
4158
- let shouldCacheAccess = true;
4159
- function applyOptions(instance) {
4160
- const options = resolveMergedOptions(instance);
4161
- const publicThis = instance.proxy;
4162
- const ctx = instance.ctx;
4163
- // do not cache property access on public proxy during state initialization
4164
- shouldCacheAccess = false;
4165
- // call beforeCreate first before accessing other options since
4166
- // the hook may mutate resolved options (#2791)
4167
- if (options.beforeCreate) {
4168
- callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4225
+ bindings.push({
4226
+ dir,
4227
+ instance,
4228
+ value,
4229
+ oldValue: void 0,
4230
+ arg,
4231
+ modifiers
4232
+ });
4169
4233
  }
4170
- const {
4171
- // state
4172
- data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4173
- // lifecycle
4174
- created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4175
- // public API
4176
- expose, inheritAttrs,
4177
- // assets
4178
- components, directives, filters } = options;
4179
- const checkDuplicateProperties = createDuplicateChecker() ;
4180
- {
4181
- const [propsOptions] = instance.propsOptions;
4182
- if (propsOptions) {
4183
- for (const key in propsOptions) {
4184
- checkDuplicateProperties("Props" /* PROPS */, key);
4185
- }
4234
+ return vnode;
4235
+ }
4236
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4237
+ const bindings = vnode.dirs;
4238
+ const oldBindings = prevVNode && prevVNode.dirs;
4239
+ for (let i = 0; i < bindings.length; i++) {
4240
+ const binding = bindings[i];
4241
+ if (oldBindings) {
4242
+ binding.oldValue = oldBindings[i].value;
4243
+ }
4244
+ let hook = binding.dir[name];
4245
+ if (hook) {
4246
+ // disable tracking inside all lifecycle hooks
4247
+ // since they can potentially be called inside effects.
4248
+ pauseTracking();
4249
+ callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
4250
+ vnode.el,
4251
+ binding,
4252
+ vnode,
4253
+ prevVNode
4254
+ ]);
4255
+ resetTracking();
4186
4256
  }
4187
4257
  }
4188
- // options initialization order (to be consistent with Vue 2):
4189
- // - props (already done outside of this function)
4190
- // - inject
4191
- // - methods
4192
- // - data (deferred since it relies on `this` access)
4193
- // - computed
4194
- // - watch (deferred since it relies on `this` access)
4195
- if (injectOptions) {
4196
- resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
4258
+ }
4259
+
4260
+ const COMPONENTS = 'components';
4261
+ const DIRECTIVES = 'directives';
4262
+ /**
4263
+ * @private
4264
+ */
4265
+ function resolveComponent(name, maybeSelfReference) {
4266
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4267
+ }
4268
+ const NULL_DYNAMIC_COMPONENT = Symbol();
4269
+ /**
4270
+ * @private
4271
+ */
4272
+ function resolveDynamicComponent(component) {
4273
+ if (isString(component)) {
4274
+ return resolveAsset(COMPONENTS, component, false) || component;
4197
4275
  }
4198
- if (methods) {
4199
- for (const key in methods) {
4200
- const methodHandler = methods[key];
4201
- if (isFunction(methodHandler)) {
4202
- // In dev mode, we use the `createRenderContext` function to define
4203
- // methods to the proxy target, and those are read-only but
4204
- // reconfigurable, so it needs to be redefined here
4205
- {
4206
- Object.defineProperty(ctx, key, {
4207
- value: methodHandler.bind(publicThis),
4208
- configurable: true,
4209
- enumerable: true,
4210
- writable: true
4211
- });
4212
- }
4213
- {
4214
- checkDuplicateProperties("Methods" /* METHODS */, key);
4215
- }
4216
- }
4217
- else {
4218
- warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4219
- `Did you reference the function correctly?`);
4220
- }
4221
- }
4276
+ else {
4277
+ // invalid types will fallthrough to createVNode and raise warning
4278
+ return (component || NULL_DYNAMIC_COMPONENT);
4222
4279
  }
4223
- if (dataOptions) {
4224
- if (!isFunction(dataOptions)) {
4225
- warn$1(`The data option must be a function. ` +
4226
- `Plain object usage is no longer supported.`);
4280
+ }
4281
+ /**
4282
+ * @private
4283
+ */
4284
+ function resolveDirective(name) {
4285
+ return resolveAsset(DIRECTIVES, name);
4286
+ }
4287
+ // implementation
4288
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4289
+ const instance = currentRenderingInstance || currentInstance;
4290
+ if (instance) {
4291
+ const Component = instance.type;
4292
+ // explicit self name has highest priority
4293
+ if (type === COMPONENTS) {
4294
+ const selfName = getComponentName(Component);
4295
+ if (selfName &&
4296
+ (selfName === name ||
4297
+ selfName === camelize(name) ||
4298
+ selfName === capitalize(camelize(name)))) {
4299
+ return Component;
4300
+ }
4227
4301
  }
4228
- const data = dataOptions.call(publicThis, publicThis);
4229
- if (isPromise(data)) {
4230
- warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4231
- `intend to perform data fetching before component renders, use ` +
4232
- `async setup() + <Suspense>.`);
4302
+ const res =
4303
+ // local registration
4304
+ // check instance[type] first which is resolved for options API
4305
+ resolve(instance[type] || Component[type], name) ||
4306
+ // global registration
4307
+ resolve(instance.appContext[type], name);
4308
+ if (!res && maybeSelfReference) {
4309
+ // fallback to implicit self-reference
4310
+ return Component;
4233
4311
  }
4234
- if (!isObject(data)) {
4235
- warn$1(`data() should return an object.`);
4312
+ if (warnMissing && !res) {
4313
+ const extra = type === COMPONENTS
4314
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
4315
+ `component resolution via compilerOptions.isCustomElement.`
4316
+ : ``;
4317
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4236
4318
  }
4237
- else {
4238
- instance.data = reactive(data);
4239
- {
4240
- for (const key in data) {
4241
- checkDuplicateProperties("Data" /* DATA */, key);
4242
- // expose data on ctx during dev
4243
- if (key[0] !== '$' && key[0] !== '_') {
4244
- Object.defineProperty(ctx, key, {
4245
- configurable: true,
4246
- enumerable: true,
4247
- get: () => data[key],
4248
- set: NOOP
4249
- });
4250
- }
4251
- }
4252
- }
4253
- }
4254
- }
4255
- // state initialization complete at this point - start caching access
4256
- shouldCacheAccess = true;
4257
- if (computedOptions) {
4258
- for (const key in computedOptions) {
4259
- const opt = computedOptions[key];
4260
- const get = isFunction(opt)
4261
- ? opt.bind(publicThis, publicThis)
4262
- : isFunction(opt.get)
4263
- ? opt.get.bind(publicThis, publicThis)
4264
- : NOOP;
4265
- if (get === NOOP) {
4266
- warn$1(`Computed property "${key}" has no getter.`);
4267
- }
4268
- const set = !isFunction(opt) && isFunction(opt.set)
4269
- ? opt.set.bind(publicThis)
4270
- : () => {
4271
- warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4272
- }
4273
- ;
4274
- const c = computed$1({
4275
- get,
4276
- set
4277
- });
4278
- Object.defineProperty(ctx, key, {
4279
- enumerable: true,
4280
- configurable: true,
4281
- get: () => c.value,
4282
- set: v => (c.value = v)
4283
- });
4284
- {
4285
- checkDuplicateProperties("Computed" /* COMPUTED */, key);
4286
- }
4287
- }
4288
- }
4289
- if (watchOptions) {
4290
- for (const key in watchOptions) {
4291
- createWatcher(watchOptions[key], ctx, publicThis, key);
4292
- }
4293
- }
4294
- if (provideOptions) {
4295
- const provides = isFunction(provideOptions)
4296
- ? provideOptions.call(publicThis)
4297
- : provideOptions;
4298
- Reflect.ownKeys(provides).forEach(key => {
4299
- provide(key, provides[key]);
4300
- });
4301
- }
4302
- if (created) {
4303
- callHook(created, instance, "c" /* CREATED */);
4304
- }
4305
- function registerLifecycleHook(register, hook) {
4306
- if (isArray(hook)) {
4307
- hook.forEach(_hook => register(_hook.bind(publicThis)));
4308
- }
4309
- else if (hook) {
4310
- register(hook.bind(publicThis));
4311
- }
4312
- }
4313
- registerLifecycleHook(onBeforeMount, beforeMount);
4314
- registerLifecycleHook(onMounted, mounted);
4315
- registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4316
- registerLifecycleHook(onUpdated, updated);
4317
- registerLifecycleHook(onActivated, activated);
4318
- registerLifecycleHook(onDeactivated, deactivated);
4319
- registerLifecycleHook(onErrorCaptured, errorCaptured);
4320
- registerLifecycleHook(onRenderTracked, renderTracked);
4321
- registerLifecycleHook(onRenderTriggered, renderTriggered);
4322
- registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4323
- registerLifecycleHook(onUnmounted, unmounted);
4324
- registerLifecycleHook(onServerPrefetch, serverPrefetch);
4325
- if (isArray(expose)) {
4326
- if (expose.length) {
4327
- const exposed = instance.exposed || (instance.exposed = {});
4328
- expose.forEach(key => {
4329
- Object.defineProperty(exposed, key, {
4330
- get: () => publicThis[key],
4331
- set: val => (publicThis[key] = val)
4332
- });
4333
- });
4334
- }
4335
- else if (!instance.exposed) {
4336
- instance.exposed = {};
4337
- }
4338
- }
4339
- // options that are handled when creating the instance but also need to be
4340
- // applied from mixins
4341
- if (render && instance.render === NOOP) {
4342
- instance.render = render;
4319
+ return res;
4343
4320
  }
4344
- if (inheritAttrs != null) {
4345
- instance.inheritAttrs = inheritAttrs;
4321
+ else {
4322
+ warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
4323
+ `can only be used in render() or setup().`);
4346
4324
  }
4347
- // asset options.
4348
- if (components)
4349
- instance.components = components;
4350
- if (directives)
4351
- instance.directives = directives;
4352
4325
  }
4353
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4354
- if (isArray(injectOptions)) {
4355
- injectOptions = normalizeInject(injectOptions);
4356
- }
4357
- for (const key in injectOptions) {
4358
- const opt = injectOptions[key];
4359
- let injected;
4360
- if (isObject(opt)) {
4361
- if ('default' in opt) {
4362
- injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4363
- }
4364
- else {
4365
- injected = inject(opt.from || key);
4366
- }
4367
- }
4368
- else {
4369
- injected = inject(opt);
4370
- }
4371
- if (isRef(injected)) {
4372
- // TODO remove the check in 3.3
4373
- if (unwrapRef) {
4374
- Object.defineProperty(ctx, key, {
4375
- enumerable: true,
4376
- configurable: true,
4377
- get: () => injected.value,
4378
- set: v => (injected.value = v)
4379
- });
4380
- }
4381
- else {
4382
- {
4383
- warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4384
- `and no longer needs \`.value\` in the next minor release. ` +
4385
- `To opt-in to the new behavior now, ` +
4386
- `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4387
- `temporary and will not be needed in the future.)`);
4388
- }
4389
- ctx[key] = injected;
4390
- }
4391
- }
4392
- else {
4393
- ctx[key] = injected;
4394
- }
4395
- {
4396
- checkDuplicateProperties("Inject" /* INJECT */, key);
4326
+ function resolve(registry, name) {
4327
+ return (registry &&
4328
+ (registry[name] ||
4329
+ registry[camelize(name)] ||
4330
+ registry[capitalize(camelize(name))]));
4331
+ }
4332
+
4333
+ /**
4334
+ * Actual implementation
4335
+ */
4336
+ function renderList(source, renderItem, cache, index) {
4337
+ let ret;
4338
+ const cached = (cache && cache[index]);
4339
+ if (isArray(source) || isString(source)) {
4340
+ ret = new Array(source.length);
4341
+ for (let i = 0, l = source.length; i < l; i++) {
4342
+ ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
4397
4343
  }
4398
4344
  }
4399
- }
4400
- function callHook(hook, instance, type) {
4401
- callWithAsyncErrorHandling(isArray(hook)
4402
- ? hook.map(h => h.bind(instance.proxy))
4403
- : hook.bind(instance.proxy), instance, type);
4404
- }
4405
- function createWatcher(raw, ctx, publicThis, key) {
4406
- const getter = key.includes('.')
4407
- ? createPathGetter(publicThis, key)
4408
- : () => publicThis[key];
4409
- if (isString(raw)) {
4410
- const handler = ctx[raw];
4411
- if (isFunction(handler)) {
4412
- watch(getter, handler);
4345
+ else if (typeof source === 'number') {
4346
+ if (!Number.isInteger(source)) {
4347
+ warn$1(`The v-for range expect an integer value but got ${source}.`);
4413
4348
  }
4414
- else {
4415
- warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4349
+ ret = new Array(source);
4350
+ for (let i = 0; i < source; i++) {
4351
+ ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
4416
4352
  }
4417
4353
  }
4418
- else if (isFunction(raw)) {
4419
- watch(getter, raw.bind(publicThis));
4420
- }
4421
- else if (isObject(raw)) {
4422
- if (isArray(raw)) {
4423
- raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4354
+ else if (isObject(source)) {
4355
+ if (source[Symbol.iterator]) {
4356
+ ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
4424
4357
  }
4425
4358
  else {
4426
- const handler = isFunction(raw.handler)
4427
- ? raw.handler.bind(publicThis)
4428
- : ctx[raw.handler];
4429
- if (isFunction(handler)) {
4430
- watch(getter, handler, raw);
4431
- }
4432
- else {
4433
- warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
4359
+ const keys = Object.keys(source);
4360
+ ret = new Array(keys.length);
4361
+ for (let i = 0, l = keys.length; i < l; i++) {
4362
+ const key = keys[i];
4363
+ ret[i] = renderItem(source[key], key, i, cached && cached[i]);
4434
4364
  }
4435
4365
  }
4436
4366
  }
4437
4367
  else {
4438
- warn$1(`Invalid watch option: "${key}"`, raw);
4368
+ ret = [];
4439
4369
  }
4440
- }
4370
+ if (cache) {
4371
+ cache[index] = ret;
4372
+ }
4373
+ return ret;
4374
+ }
4375
+
4441
4376
  /**
4442
- * Resolve merged options and cache it on the component.
4443
- * This is done only once per-component since the merging does not involve
4444
- * instances.
4377
+ * Compiler runtime helper for creating dynamic slots object
4378
+ * @private
4445
4379
  */
4446
- function resolveMergedOptions(instance) {
4447
- const base = instance.type;
4448
- const { mixins, extends: extendsOptions } = base;
4449
- const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4450
- const cached = cache.get(base);
4451
- let resolved;
4452
- if (cached) {
4453
- resolved = cached;
4454
- }
4455
- else if (!globalMixins.length && !mixins && !extendsOptions) {
4456
- {
4457
- resolved = base;
4380
+ function createSlots(slots, dynamicSlots) {
4381
+ for (let i = 0; i < dynamicSlots.length; i++) {
4382
+ const slot = dynamicSlots[i];
4383
+ // array of dynamic slot generated by <template v-for="..." #[...]>
4384
+ if (isArray(slot)) {
4385
+ for (let j = 0; j < slot.length; j++) {
4386
+ slots[slot[j].name] = slot[j].fn;
4387
+ }
4458
4388
  }
4459
- }
4460
- else {
4461
- resolved = {};
4462
- if (globalMixins.length) {
4463
- globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4389
+ else if (slot) {
4390
+ // conditional single slot generated by <template v-if="..." #foo>
4391
+ slots[slot.name] = slot.fn;
4464
4392
  }
4465
- mergeOptions(resolved, base, optionMergeStrategies);
4466
4393
  }
4467
- cache.set(base, resolved);
4468
- return resolved;
4469
- }
4470
- function mergeOptions(to, from, strats, asMixin = false) {
4471
- const { mixins, extends: extendsOptions } = from;
4472
- if (extendsOptions) {
4473
- mergeOptions(to, extendsOptions, strats, true);
4474
- }
4475
- if (mixins) {
4476
- mixins.forEach((m) => mergeOptions(to, m, strats, true));
4394
+ return slots;
4395
+ }
4396
+
4397
+ /**
4398
+ * Compiler runtime helper for rendering `<slot/>`
4399
+ * @private
4400
+ */
4401
+ function renderSlot(slots, name, props = {},
4402
+ // this is not a user-facing function, so the fallback is always generated by
4403
+ // the compiler and guaranteed to be a function returning an array
4404
+ fallback, noSlotted) {
4405
+ if (currentRenderingInstance.isCE ||
4406
+ (currentRenderingInstance.parent &&
4407
+ isAsyncWrapper(currentRenderingInstance.parent) &&
4408
+ currentRenderingInstance.parent.isCE)) {
4409
+ return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
4477
4410
  }
4478
- for (const key in from) {
4479
- if (asMixin && key === 'expose') {
4480
- warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4481
- `It should only be declared in the base component itself.`);
4482
- }
4483
- else {
4484
- const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4485
- to[key] = strat ? strat(to[key], from[key]) : from[key];
4486
- }
4411
+ let slot = slots[name];
4412
+ if (slot && slot.length > 1) {
4413
+ warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
4414
+ `function. You need to mark this component with $dynamic-slots in the ` +
4415
+ `parent template.`);
4416
+ slot = () => [];
4487
4417
  }
4488
- return to;
4489
- }
4490
- const internalOptionMergeStrats = {
4491
- data: mergeDataFn,
4492
- props: mergeObjectOptions,
4493
- emits: mergeObjectOptions,
4494
- // objects
4495
- methods: mergeObjectOptions,
4496
- computed: mergeObjectOptions,
4497
- // lifecycle
4498
- beforeCreate: mergeAsArray,
4499
- created: mergeAsArray,
4500
- beforeMount: mergeAsArray,
4501
- mounted: mergeAsArray,
4502
- beforeUpdate: mergeAsArray,
4503
- updated: mergeAsArray,
4504
- beforeDestroy: mergeAsArray,
4505
- beforeUnmount: mergeAsArray,
4506
- destroyed: mergeAsArray,
4507
- unmounted: mergeAsArray,
4508
- activated: mergeAsArray,
4509
- deactivated: mergeAsArray,
4510
- errorCaptured: mergeAsArray,
4511
- serverPrefetch: mergeAsArray,
4512
- // assets
4513
- components: mergeObjectOptions,
4514
- directives: mergeObjectOptions,
4515
- // watch
4516
- watch: mergeWatchOptions,
4517
- // provide / inject
4518
- provide: mergeDataFn,
4519
- inject: mergeInject
4520
- };
4521
- function mergeDataFn(to, from) {
4522
- if (!from) {
4523
- return to;
4418
+ // a compiled slot disables block tracking by default to avoid manual
4419
+ // invocation interfering with template-based block tracking, but in
4420
+ // `renderSlot` we can be sure that it's template-based so we can force
4421
+ // enable it.
4422
+ if (slot && slot._c) {
4423
+ slot._d = false;
4524
4424
  }
4525
- if (!to) {
4526
- return from;
4425
+ openBlock();
4426
+ const validSlotContent = slot && ensureValidVNode(slot(props));
4427
+ const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
4428
+ ? 64 /* STABLE_FRAGMENT */
4429
+ : -2 /* BAIL */);
4430
+ if (!noSlotted && rendered.scopeId) {
4431
+ rendered.slotScopeIds = [rendered.scopeId + '-s'];
4527
4432
  }
4528
- return function mergedDataFn() {
4529
- return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4530
- };
4531
- }
4532
- function mergeInject(to, from) {
4533
- return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4534
- }
4535
- function normalizeInject(raw) {
4536
- if (isArray(raw)) {
4537
- const res = {};
4538
- for (let i = 0; i < raw.length; i++) {
4539
- res[raw[i]] = raw[i];
4540
- }
4541
- return res;
4433
+ if (slot && slot._c) {
4434
+ slot._d = true;
4542
4435
  }
4543
- return raw;
4544
- }
4545
- function mergeAsArray(to, from) {
4546
- return to ? [...new Set([].concat(to, from))] : from;
4547
- }
4548
- function mergeObjectOptions(to, from) {
4549
- return to ? extend(extend(Object.create(null), to), from) : from;
4436
+ return rendered;
4550
4437
  }
4551
- function mergeWatchOptions(to, from) {
4552
- if (!to)
4553
- return from;
4554
- if (!from)
4555
- return to;
4556
- const merged = extend(Object.create(null), to);
4557
- for (const key in from) {
4558
- merged[key] = mergeAsArray(to[key], from[key]);
4559
- }
4560
- return merged;
4438
+ function ensureValidVNode(vnodes) {
4439
+ return vnodes.some(child => {
4440
+ if (!isVNode(child))
4441
+ return true;
4442
+ if (child.type === Comment)
4443
+ return false;
4444
+ if (child.type === Fragment &&
4445
+ !ensureValidVNode(child.children))
4446
+ return false;
4447
+ return true;
4448
+ })
4449
+ ? vnodes
4450
+ : null;
4561
4451
  }
4562
4452
 
4563
- function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4564
- isSSR = false) {
4565
- const props = {};
4566
- const attrs = {};
4567
- def(attrs, InternalObjectKey, 1);
4568
- instance.propsDefaults = Object.create(null);
4569
- setFullProps(instance, rawProps, props, attrs);
4570
- // ensure all declared prop keys are present
4571
- for (const key in instance.propsOptions[0]) {
4572
- if (!(key in props)) {
4573
- props[key] = undefined;
4574
- }
4575
- }
4576
- // validation
4577
- {
4578
- validateProps(rawProps || {}, props, instance);
4453
+ /**
4454
+ * For prefixing keys in v-on="obj" with "on"
4455
+ * @private
4456
+ */
4457
+ function toHandlers(obj) {
4458
+ const ret = {};
4459
+ if (!isObject(obj)) {
4460
+ warn$1(`v-on with no argument expects an object value.`);
4461
+ return ret;
4579
4462
  }
4580
- if (isStateful) {
4581
- // stateful
4582
- instance.props = isSSR ? props : shallowReactive(props);
4463
+ for (const key in obj) {
4464
+ ret[toHandlerKey(key)] = obj[key];
4583
4465
  }
4584
- else {
4585
- if (!instance.type.props) {
4586
- // functional w/ optional props, props === attrs
4587
- instance.props = attrs;
4466
+ return ret;
4467
+ }
4468
+
4469
+ /**
4470
+ * #2437 In Vue 3, functional components do not have a public instance proxy but
4471
+ * they exist in the internal parent chain. For code that relies on traversing
4472
+ * public $parent chains, skip functional ones and go to the parent instead.
4473
+ */
4474
+ const getPublicInstance = (i) => {
4475
+ if (!i)
4476
+ return null;
4477
+ if (isStatefulComponent(i))
4478
+ return getExposeProxy(i) || i.proxy;
4479
+ return getPublicInstance(i.parent);
4480
+ };
4481
+ const publicPropertiesMap =
4482
+ // Move PURE marker to new line to workaround compiler discarding it
4483
+ // due to type annotation
4484
+ /*#__PURE__*/ extend(Object.create(null), {
4485
+ $: i => i,
4486
+ $el: i => i.vnode.el,
4487
+ $data: i => i.data,
4488
+ $props: i => (shallowReadonly(i.props) ),
4489
+ $attrs: i => (shallowReadonly(i.attrs) ),
4490
+ $slots: i => (shallowReadonly(i.slots) ),
4491
+ $refs: i => (shallowReadonly(i.refs) ),
4492
+ $parent: i => getPublicInstance(i.parent),
4493
+ $root: i => getPublicInstance(i.root),
4494
+ $emit: i => i.emit,
4495
+ $options: i => (resolveMergedOptions(i) ),
4496
+ $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
4497
+ $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
4498
+ $watch: i => (instanceWatch.bind(i) )
4499
+ });
4500
+ const isReservedPrefix = (key) => key === '_' || key === '$';
4501
+ const PublicInstanceProxyHandlers = {
4502
+ get({ _: instance }, key) {
4503
+ const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
4504
+ // for internal formatters to know that this is a Vue instance
4505
+ if (key === '__isVue') {
4506
+ return true;
4588
4507
  }
4589
- else {
4590
- // functional w/ declared props
4591
- instance.props = props;
4508
+ // prioritize <script setup> bindings during dev.
4509
+ // this allows even properties that start with _ or $ to be used - so that
4510
+ // it aligns with the production behavior where the render fn is inlined and
4511
+ // indeed has access to all declared variables.
4512
+ if (setupState !== EMPTY_OBJ &&
4513
+ setupState.__isScriptSetup &&
4514
+ hasOwn(setupState, key)) {
4515
+ return setupState[key];
4592
4516
  }
4593
- }
4594
- instance.attrs = attrs;
4595
- }
4596
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
4597
- const { props, attrs, vnode: { patchFlag } } = instance;
4598
- const rawCurrentProps = toRaw(props);
4599
- const [options] = instance.propsOptions;
4600
- let hasAttrsChanged = false;
4601
- if (
4602
- // always force full diff in dev
4603
- // - #1942 if hmr is enabled with sfc component
4604
- // - vite#872 non-sfc component used by sfc component
4605
- !((instance.type.__hmrId ||
4606
- (instance.parent && instance.parent.type.__hmrId))) &&
4607
- (optimized || patchFlag > 0) &&
4608
- !(patchFlag & 16 /* FULL_PROPS */)) {
4609
- if (patchFlag & 8 /* PROPS */) {
4610
- // Compiler-generated props & no keys change, just set the updated
4611
- // the props.
4612
- const propsToUpdate = instance.vnode.dynamicProps;
4613
- for (let i = 0; i < propsToUpdate.length; i++) {
4614
- let key = propsToUpdate[i];
4615
- // skip if the prop key is a declared emit event listener
4616
- if (isEmitListener(instance.emitsOptions, key)) {
4617
- continue;
4618
- }
4619
- // PROPS flag guarantees rawProps to be non-null
4620
- const value = rawProps[key];
4621
- if (options) {
4622
- // attr / props separation was done on init and will be consistent
4623
- // in this code path, so just check if attrs have it.
4624
- if (hasOwn(attrs, key)) {
4625
- if (value !== attrs[key]) {
4626
- attrs[key] = value;
4627
- hasAttrsChanged = true;
4628
- }
4629
- }
4630
- else {
4631
- const camelizedKey = camelize(key);
4632
- props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4633
- }
4634
- }
4635
- else {
4636
- if (value !== attrs[key]) {
4637
- attrs[key] = value;
4638
- hasAttrsChanged = true;
4639
- }
4517
+ // data / props / ctx
4518
+ // This getter gets called for every property access on the render context
4519
+ // during render and is a major hotspot. The most expensive part of this
4520
+ // is the multiple hasOwn() calls. It's much faster to do a simple property
4521
+ // access on a plain object, so we use an accessCache object (with null
4522
+ // prototype) to memoize what access type a key corresponds to.
4523
+ let normalizedProps;
4524
+ if (key[0] !== '$') {
4525
+ const n = accessCache[key];
4526
+ if (n !== undefined) {
4527
+ switch (n) {
4528
+ case 1 /* SETUP */:
4529
+ return setupState[key];
4530
+ case 2 /* DATA */:
4531
+ return data[key];
4532
+ case 4 /* CONTEXT */:
4533
+ return ctx[key];
4534
+ case 3 /* PROPS */:
4535
+ return props[key];
4536
+ // default: just fallthrough
4640
4537
  }
4641
4538
  }
4642
- }
4643
- }
4644
- else {
4645
- // full props update.
4646
- if (setFullProps(instance, rawProps, props, attrs)) {
4647
- hasAttrsChanged = true;
4648
- }
4649
- // in case of dynamic props, check if we need to delete keys from
4650
- // the props object
4651
- let kebabKey;
4652
- for (const key in rawCurrentProps) {
4653
- if (!rawProps ||
4654
- // for camelCase
4655
- (!hasOwn(rawProps, key) &&
4656
- // it's possible the original props was passed in as kebab-case
4657
- // and converted to camelCase (#955)
4658
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4659
- if (options) {
4660
- if (rawPrevProps &&
4661
- // for camelCase
4662
- (rawPrevProps[key] !== undefined ||
4663
- // for kebab-case
4664
- rawPrevProps[kebabKey] !== undefined)) {
4665
- props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4666
- }
4667
- }
4668
- else {
4669
- delete props[key];
4670
- }
4539
+ else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4540
+ accessCache[key] = 1 /* SETUP */;
4541
+ return setupState[key];
4671
4542
  }
4672
- }
4673
- // in the case of functional component w/o props declaration, props and
4674
- // attrs point to the same object so it should already have been updated.
4675
- if (attrs !== rawCurrentProps) {
4676
- for (const key in attrs) {
4677
- if (!rawProps ||
4678
- (!hasOwn(rawProps, key) &&
4679
- (!false ))) {
4680
- delete attrs[key];
4681
- hasAttrsChanged = true;
4682
- }
4543
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4544
+ accessCache[key] = 2 /* DATA */;
4545
+ return data[key];
4683
4546
  }
4684
- }
4685
- }
4686
- // trigger updates for $attrs in case it's used in component slots
4687
- if (hasAttrsChanged) {
4688
- trigger(instance, "set" /* SET */, '$attrs');
4689
- }
4690
- {
4691
- validateProps(rawProps || {}, props, instance);
4692
- }
4693
- }
4694
- function setFullProps(instance, rawProps, props, attrs) {
4695
- const [options, needCastKeys] = instance.propsOptions;
4696
- let hasAttrsChanged = false;
4697
- let rawCastValues;
4698
- if (rawProps) {
4699
- for (let key in rawProps) {
4700
- // key, ref are reserved and never passed down
4701
- if (isReservedProp(key)) {
4702
- continue;
4547
+ else if (
4548
+ // only cache other properties when instance has declared (thus stable)
4549
+ // props
4550
+ (normalizedProps = instance.propsOptions[0]) &&
4551
+ hasOwn(normalizedProps, key)) {
4552
+ accessCache[key] = 3 /* PROPS */;
4553
+ return props[key];
4703
4554
  }
4704
- const value = rawProps[key];
4705
- // prop option names are camelized during normalization, so to support
4706
- // kebab -> camel conversion here we need to camelize the key.
4707
- let camelKey;
4708
- if (options && hasOwn(options, (camelKey = camelize(key)))) {
4709
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4710
- props[camelKey] = value;
4711
- }
4712
- else {
4713
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4714
- }
4555
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4556
+ accessCache[key] = 4 /* CONTEXT */;
4557
+ return ctx[key];
4715
4558
  }
4716
- else if (!isEmitListener(instance.emitsOptions, key)) {
4717
- if (!(key in attrs) || value !== attrs[key]) {
4718
- attrs[key] = value;
4719
- hasAttrsChanged = true;
4720
- }
4559
+ else if (shouldCacheAccess) {
4560
+ accessCache[key] = 0 /* OTHER */;
4721
4561
  }
4722
4562
  }
4723
- }
4724
- if (needCastKeys) {
4725
- const rawCurrentProps = toRaw(props);
4726
- const castValues = rawCastValues || EMPTY_OBJ;
4727
- for (let i = 0; i < needCastKeys.length; i++) {
4728
- const key = needCastKeys[i];
4729
- props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4730
- }
4731
- }
4732
- return hasAttrsChanged;
4733
- }
4734
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
4735
- const opt = options[key];
4736
- if (opt != null) {
4737
- const hasDefault = hasOwn(opt, 'default');
4738
- // default values
4739
- if (hasDefault && value === undefined) {
4740
- const defaultValue = opt.default;
4741
- if (opt.type !== Function && isFunction(defaultValue)) {
4742
- const { propsDefaults } = instance;
4743
- if (key in propsDefaults) {
4744
- value = propsDefaults[key];
4745
- }
4746
- else {
4747
- setCurrentInstance(instance);
4748
- value = propsDefaults[key] = defaultValue.call(null, props);
4749
- unsetCurrentInstance();
4750
- }
4563
+ const publicGetter = publicPropertiesMap[key];
4564
+ let cssModule, globalProperties;
4565
+ // public $xxx properties
4566
+ if (publicGetter) {
4567
+ if (key === '$attrs') {
4568
+ track(instance, "get" /* GET */, key);
4569
+ markAttrsAccessed();
4751
4570
  }
4752
- else {
4753
- value = defaultValue;
4571
+ return publicGetter(instance);
4572
+ }
4573
+ else if (
4574
+ // css module (injected by vue-loader)
4575
+ (cssModule = type.__cssModules) &&
4576
+ (cssModule = cssModule[key])) {
4577
+ return cssModule;
4578
+ }
4579
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4580
+ // user may set custom properties to `this` that start with `$`
4581
+ accessCache[key] = 4 /* CONTEXT */;
4582
+ return ctx[key];
4583
+ }
4584
+ else if (
4585
+ // global properties
4586
+ ((globalProperties = appContext.config.globalProperties),
4587
+ hasOwn(globalProperties, key))) {
4588
+ {
4589
+ return globalProperties[key];
4754
4590
  }
4755
4591
  }
4756
- // boolean casting
4757
- if (opt[0 /* shouldCast */]) {
4758
- if (isAbsent && !hasDefault) {
4759
- value = false;
4592
+ else if (currentRenderingInstance &&
4593
+ (!isString(key) ||
4594
+ // #1091 avoid internal isRef/isVNode checks on component instance leading
4595
+ // to infinite warning loop
4596
+ key.indexOf('__v') !== 0)) {
4597
+ if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
4598
+ warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
4599
+ `character ("$" or "_") and is not proxied on the render context.`);
4760
4600
  }
4761
- else if (opt[1 /* shouldCastTrue */] &&
4762
- (value === '' || value === hyphenate(key))) {
4763
- value = true;
4601
+ else if (instance === currentRenderingInstance) {
4602
+ warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
4603
+ `but is not defined on instance.`);
4764
4604
  }
4765
4605
  }
4766
- }
4767
- return value;
4768
- }
4769
- function normalizePropsOptions(comp, appContext, asMixin = false) {
4770
- const cache = appContext.propsCache;
4771
- const cached = cache.get(comp);
4772
- if (cached) {
4773
- return cached;
4774
- }
4775
- const raw = comp.props;
4776
- const normalized = {};
4777
- const needCastKeys = [];
4778
- // apply mixin/extends props
4779
- let hasExtends = false;
4780
- if (!isFunction(comp)) {
4781
- const extendProps = (raw) => {
4782
- hasExtends = true;
4783
- const [props, keys] = normalizePropsOptions(raw, appContext, true);
4784
- extend(normalized, props);
4785
- if (keys)
4786
- needCastKeys.push(...keys);
4787
- };
4788
- if (!asMixin && appContext.mixins.length) {
4789
- appContext.mixins.forEach(extendProps);
4606
+ },
4607
+ set({ _: instance }, key, value) {
4608
+ const { data, setupState, ctx } = instance;
4609
+ if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4610
+ setupState[key] = value;
4611
+ return true;
4790
4612
  }
4791
- if (comp.extends) {
4792
- extendProps(comp.extends);
4613
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4614
+ data[key] = value;
4615
+ return true;
4793
4616
  }
4794
- if (comp.mixins) {
4795
- comp.mixins.forEach(extendProps);
4617
+ else if (hasOwn(instance.props, key)) {
4618
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
4619
+ return false;
4796
4620
  }
4797
- }
4798
- if (!raw && !hasExtends) {
4799
- cache.set(comp, EMPTY_ARR);
4800
- return EMPTY_ARR;
4801
- }
4802
- if (isArray(raw)) {
4803
- for (let i = 0; i < raw.length; i++) {
4804
- if (!isString(raw[i])) {
4805
- warn$1(`props must be strings when using array syntax.`, raw[i]);
4621
+ if (key[0] === '$' && key.slice(1) in instance) {
4622
+ warn$1(`Attempting to mutate public property "${key}". ` +
4623
+ `Properties starting with $ are reserved and readonly.`, instance);
4624
+ return false;
4625
+ }
4626
+ else {
4627
+ if (key in instance.appContext.config.globalProperties) {
4628
+ Object.defineProperty(ctx, key, {
4629
+ enumerable: true,
4630
+ configurable: true,
4631
+ value
4632
+ });
4806
4633
  }
4807
- const normalizedKey = camelize(raw[i]);
4808
- if (validatePropName(normalizedKey)) {
4809
- normalized[normalizedKey] = EMPTY_OBJ;
4634
+ else {
4635
+ ctx[key] = value;
4810
4636
  }
4811
4637
  }
4812
- }
4813
- else if (raw) {
4814
- if (!isObject(raw)) {
4815
- warn$1(`invalid props options`, raw);
4816
- }
4817
- for (const key in raw) {
4818
- const normalizedKey = camelize(key);
4819
- if (validatePropName(normalizedKey)) {
4820
- const opt = raw[key];
4821
- const prop = (normalized[normalizedKey] =
4822
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4823
- if (prop) {
4824
- const booleanIndex = getTypeIndex(Boolean, prop.type);
4825
- const stringIndex = getTypeIndex(String, prop.type);
4826
- prop[0 /* shouldCast */] = booleanIndex > -1;
4827
- prop[1 /* shouldCastTrue */] =
4828
- stringIndex < 0 || booleanIndex < stringIndex;
4829
- // if the prop needs boolean casting or default value
4830
- if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4831
- needCastKeys.push(normalizedKey);
4832
- }
4833
- }
4834
- }
4835
- }
4836
- }
4837
- const res = [normalized, needCastKeys];
4838
- cache.set(comp, res);
4839
- return res;
4840
- }
4841
- function validatePropName(key) {
4842
- if (key[0] !== '$') {
4843
4638
  return true;
4639
+ },
4640
+ has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
4641
+ let normalizedProps;
4642
+ return (!!accessCache[key] ||
4643
+ (data !== EMPTY_OBJ && hasOwn(data, key)) ||
4644
+ (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
4645
+ ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
4646
+ hasOwn(ctx, key) ||
4647
+ hasOwn(publicPropertiesMap, key) ||
4648
+ hasOwn(appContext.config.globalProperties, key));
4649
+ },
4650
+ defineProperty(target, key, descriptor) {
4651
+ if (descriptor.get != null) {
4652
+ // invalidate key cache of a getter based property #5417
4653
+ target._.accessCache[key] = 0;
4654
+ }
4655
+ else if (hasOwn(descriptor, 'value')) {
4656
+ this.set(target, key, descriptor.value, null);
4657
+ }
4658
+ return Reflect.defineProperty(target, key, descriptor);
4844
4659
  }
4845
- else {
4846
- warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4847
- }
4848
- return false;
4849
- }
4850
- // use function string name to check type constructors
4851
- // so that it works across vms / iframes.
4852
- function getType(ctor) {
4853
- const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4854
- return match ? match[1] : ctor === null ? 'null' : '';
4855
- }
4856
- function isSameType(a, b) {
4857
- return getType(a) === getType(b);
4660
+ };
4661
+ {
4662
+ PublicInstanceProxyHandlers.ownKeys = (target) => {
4663
+ warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
4664
+ `The keys will be empty in production mode to avoid performance overhead.`);
4665
+ return Reflect.ownKeys(target);
4666
+ };
4858
4667
  }
4859
- function getTypeIndex(type, expectedTypes) {
4860
- if (isArray(expectedTypes)) {
4861
- return expectedTypes.findIndex(t => isSameType(t, type));
4862
- }
4863
- else if (isFunction(expectedTypes)) {
4864
- return isSameType(expectedTypes, type) ? 0 : -1;
4668
+ const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
4669
+ get(target, key) {
4670
+ // fast path for unscopables when using `with` block
4671
+ if (key === Symbol.unscopables) {
4672
+ return;
4673
+ }
4674
+ return PublicInstanceProxyHandlers.get(target, key, target);
4675
+ },
4676
+ has(_, key) {
4677
+ const has = key[0] !== '_' && !isGloballyWhitelisted(key);
4678
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
4679
+ warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
4680
+ }
4681
+ return has;
4865
4682
  }
4866
- return -1;
4683
+ });
4684
+ // dev only
4685
+ // In dev mode, the proxy target exposes the same properties as seen on `this`
4686
+ // for easier console inspection. In prod mode it will be an empty object so
4687
+ // these properties definitions can be skipped.
4688
+ function createDevRenderContext(instance) {
4689
+ const target = {};
4690
+ // expose internal instance for proxy handlers
4691
+ Object.defineProperty(target, `_`, {
4692
+ configurable: true,
4693
+ enumerable: false,
4694
+ get: () => instance
4695
+ });
4696
+ // expose public properties
4697
+ Object.keys(publicPropertiesMap).forEach(key => {
4698
+ Object.defineProperty(target, key, {
4699
+ configurable: true,
4700
+ enumerable: false,
4701
+ get: () => publicPropertiesMap[key](instance),
4702
+ // intercepted by the proxy so no need for implementation,
4703
+ // but needed to prevent set errors
4704
+ set: NOOP
4705
+ });
4706
+ });
4707
+ return target;
4867
4708
  }
4868
- /**
4869
- * dev only
4870
- */
4871
- function validateProps(rawProps, props, instance) {
4872
- const resolvedValues = toRaw(props);
4873
- const options = instance.propsOptions[0];
4874
- for (const key in options) {
4875
- let opt = options[key];
4876
- if (opt == null)
4877
- continue;
4878
- validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
4709
+ // dev only
4710
+ function exposePropsOnRenderContext(instance) {
4711
+ const { ctx, propsOptions: [propsOptions] } = instance;
4712
+ if (propsOptions) {
4713
+ Object.keys(propsOptions).forEach(key => {
4714
+ Object.defineProperty(ctx, key, {
4715
+ enumerable: true,
4716
+ configurable: true,
4717
+ get: () => instance.props[key],
4718
+ set: NOOP
4719
+ });
4720
+ });
4879
4721
  }
4880
4722
  }
4881
- /**
4882
- * dev only
4883
- */
4884
- function validateProp(name, value, prop, isAbsent) {
4885
- const { type, required, validator } = prop;
4886
- // required!
4887
- if (required && isAbsent) {
4888
- warn$1('Missing required prop: "' + name + '"');
4889
- return;
4890
- }
4891
- // missing but optional
4892
- if (value == null && !prop.required) {
4893
- return;
4894
- }
4895
- // type check
4896
- if (type != null && type !== true) {
4897
- let isValid = false;
4898
- const types = isArray(type) ? type : [type];
4899
- const expectedTypes = [];
4900
- // value is valid as long as one of the specified types match
4901
- for (let i = 0; i < types.length && !isValid; i++) {
4902
- const { valid, expectedType } = assertType(value, types[i]);
4903
- expectedTypes.push(expectedType || '');
4904
- isValid = valid;
4723
+ // dev only
4724
+ function exposeSetupStateOnRenderContext(instance) {
4725
+ const { ctx, setupState } = instance;
4726
+ Object.keys(toRaw(setupState)).forEach(key => {
4727
+ if (!setupState.__isScriptSetup) {
4728
+ if (isReservedPrefix(key[0])) {
4729
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
4730
+ `which are reserved prefixes for Vue internals.`);
4731
+ return;
4732
+ }
4733
+ Object.defineProperty(ctx, key, {
4734
+ enumerable: true,
4735
+ configurable: true,
4736
+ get: () => setupState[key],
4737
+ set: NOOP
4738
+ });
4905
4739
  }
4906
- if (!isValid) {
4907
- warn$1(getInvalidTypeMessage(name, value, expectedTypes));
4908
- return;
4740
+ });
4741
+ }
4742
+
4743
+ function createDuplicateChecker() {
4744
+ const cache = Object.create(null);
4745
+ return (type, key) => {
4746
+ if (cache[key]) {
4747
+ warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
4909
4748
  }
4910
- }
4911
- // custom validator
4912
- if (validator && !validator(value)) {
4913
- warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
4914
- }
4915
- }
4916
- const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
4917
- /**
4918
- * dev only
4919
- */
4920
- function assertType(value, type) {
4921
- let valid;
4922
- const expectedType = getType(type);
4923
- if (isSimpleType(expectedType)) {
4924
- const t = typeof value;
4925
- valid = t === expectedType.toLowerCase();
4926
- // for primitive wrapper objects
4927
- if (!valid && t === 'object') {
4928
- valid = value instanceof type;
4749
+ else {
4750
+ cache[key] = type;
4929
4751
  }
4930
- }
4931
- else if (expectedType === 'Object') {
4932
- valid = isObject(value);
4933
- }
4934
- else if (expectedType === 'Array') {
4935
- valid = isArray(value);
4936
- }
4937
- else if (expectedType === 'null') {
4938
- valid = value === null;
4939
- }
4940
- else {
4941
- valid = value instanceof type;
4942
- }
4943
- return {
4944
- valid,
4945
- expectedType
4946
4752
  };
4947
4753
  }
4948
- /**
4949
- * dev only
4950
- */
4951
- function getInvalidTypeMessage(name, value, expectedTypes) {
4952
- let message = `Invalid prop: type check failed for prop "${name}".` +
4953
- ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
4954
- const expectedType = expectedTypes[0];
4955
- const receivedType = toRawType(value);
4956
- const expectedValue = styleValue(value, expectedType);
4957
- const receivedValue = styleValue(value, receivedType);
4958
- // check if we need to specify expected value
4959
- if (expectedTypes.length === 1 &&
4960
- isExplicable(expectedType) &&
4961
- !isBoolean(expectedType, receivedType)) {
4962
- message += ` with value ${expectedValue}`;
4963
- }
4964
- message += `, got ${receivedType} `;
4965
- // check if we need to specify received value
4966
- if (isExplicable(receivedType)) {
4967
- message += `with value ${receivedValue}.`;
4754
+ let shouldCacheAccess = true;
4755
+ function applyOptions(instance) {
4756
+ const options = resolveMergedOptions(instance);
4757
+ const publicThis = instance.proxy;
4758
+ const ctx = instance.ctx;
4759
+ // do not cache property access on public proxy during state initialization
4760
+ shouldCacheAccess = false;
4761
+ // call beforeCreate first before accessing other options since
4762
+ // the hook may mutate resolved options (#2791)
4763
+ if (options.beforeCreate) {
4764
+ callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4968
4765
  }
4969
- return message;
4970
- }
4971
- /**
4972
- * dev only
4973
- */
4974
- function styleValue(value, type) {
4975
- if (type === 'String') {
4976
- return `"${value}"`;
4977
- }
4978
- else if (type === 'Number') {
4979
- return `${Number(value)}`;
4766
+ const {
4767
+ // state
4768
+ data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4769
+ // lifecycle
4770
+ created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4771
+ // public API
4772
+ expose, inheritAttrs,
4773
+ // assets
4774
+ components, directives, filters } = options;
4775
+ const checkDuplicateProperties = createDuplicateChecker() ;
4776
+ {
4777
+ const [propsOptions] = instance.propsOptions;
4778
+ if (propsOptions) {
4779
+ for (const key in propsOptions) {
4780
+ checkDuplicateProperties("Props" /* PROPS */, key);
4781
+ }
4782
+ }
4980
4783
  }
4981
- else {
4982
- return `${value}`;
4784
+ // options initialization order (to be consistent with Vue 2):
4785
+ // - props (already done outside of this function)
4786
+ // - inject
4787
+ // - methods
4788
+ // - data (deferred since it relies on `this` access)
4789
+ // - computed
4790
+ // - watch (deferred since it relies on `this` access)
4791
+ if (injectOptions) {
4792
+ resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
4983
4793
  }
4984
- }
4985
- /**
4986
- * dev only
4987
- */
4988
- function isExplicable(type) {
4989
- const explicitTypes = ['string', 'number', 'boolean'];
4990
- return explicitTypes.some(elem => type.toLowerCase() === elem);
4991
- }
4992
- /**
4993
- * dev only
4994
- */
4995
- function isBoolean(...args) {
4996
- return args.some(elem => elem.toLowerCase() === 'boolean');
4997
- }
4998
-
4999
- const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5000
- const normalizeSlotValue = (value) => isArray(value)
5001
- ? value.map(normalizeVNode)
5002
- : [normalizeVNode(value)];
5003
- const normalizeSlot = (key, rawSlot, ctx) => {
5004
- const normalized = withCtx((...args) => {
5005
- if (currentInstance) {
5006
- warn$1(`Slot "${key}" invoked outside of the render function: ` +
5007
- `this will not track dependencies used in the slot. ` +
5008
- `Invoke the slot function inside the render function instead.`);
5009
- }
5010
- return normalizeSlotValue(rawSlot(...args));
5011
- }, ctx);
5012
- normalized._c = false;
5013
- return normalized;
5014
- };
5015
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
5016
- const ctx = rawSlots._ctx;
5017
- for (const key in rawSlots) {
5018
- if (isInternalKey(key))
5019
- continue;
5020
- const value = rawSlots[key];
5021
- if (isFunction(value)) {
5022
- slots[key] = normalizeSlot(key, value, ctx);
5023
- }
5024
- else if (value != null) {
5025
- {
5026
- warn$1(`Non-function value encountered for slot "${key}". ` +
5027
- `Prefer function slots for better performance.`);
4794
+ if (methods) {
4795
+ for (const key in methods) {
4796
+ const methodHandler = methods[key];
4797
+ if (isFunction(methodHandler)) {
4798
+ // In dev mode, we use the `createRenderContext` function to define
4799
+ // methods to the proxy target, and those are read-only but
4800
+ // reconfigurable, so it needs to be redefined here
4801
+ {
4802
+ Object.defineProperty(ctx, key, {
4803
+ value: methodHandler.bind(publicThis),
4804
+ configurable: true,
4805
+ enumerable: true,
4806
+ writable: true
4807
+ });
4808
+ }
4809
+ {
4810
+ checkDuplicateProperties("Methods" /* METHODS */, key);
4811
+ }
4812
+ }
4813
+ else {
4814
+ warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4815
+ `Did you reference the function correctly?`);
5028
4816
  }
5029
- const normalized = normalizeSlotValue(value);
5030
- slots[key] = () => normalized;
5031
4817
  }
5032
4818
  }
5033
- };
5034
- const normalizeVNodeSlots = (instance, children) => {
5035
- if (!isKeepAlive(instance.vnode) &&
5036
- !(false )) {
5037
- warn$1(`Non-function value encountered for default slot. ` +
5038
- `Prefer function slots for better performance.`);
5039
- }
5040
- const normalized = normalizeSlotValue(children);
5041
- instance.slots.default = () => normalized;
5042
- };
5043
- const initSlots = (instance, children) => {
5044
- if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5045
- const type = children._;
5046
- if (type) {
5047
- // users can get the shallow readonly version of the slots object through `this.$slots`,
5048
- // we should avoid the proxy object polluting the slots of the internal instance
5049
- instance.slots = toRaw(children);
5050
- // make compiler marker non-enumerable
5051
- def(children, '_', type);
4819
+ if (dataOptions) {
4820
+ if (!isFunction(dataOptions)) {
4821
+ warn$1(`The data option must be a function. ` +
4822
+ `Plain object usage is no longer supported.`);
5052
4823
  }
5053
- else {
5054
- normalizeObjectSlots(children, (instance.slots = {}));
4824
+ const data = dataOptions.call(publicThis, publicThis);
4825
+ if (isPromise(data)) {
4826
+ warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4827
+ `intend to perform data fetching before component renders, use ` +
4828
+ `async setup() + <Suspense>.`);
5055
4829
  }
5056
- }
5057
- else {
5058
- instance.slots = {};
5059
- if (children) {
5060
- normalizeVNodeSlots(instance, children);
4830
+ if (!isObject(data)) {
4831
+ warn$1(`data() should return an object.`);
5061
4832
  }
5062
- }
5063
- def(instance.slots, InternalObjectKey, 1);
5064
- };
5065
- const updateSlots = (instance, children, optimized) => {
5066
- const { vnode, slots } = instance;
5067
- let needDeletionCheck = true;
5068
- let deletionComparisonTarget = EMPTY_OBJ;
5069
- if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5070
- const type = children._;
5071
- if (type) {
5072
- // compiled slots.
5073
- if (isHmrUpdating) {
5074
- // Parent was HMR updated so slot content may have changed.
5075
- // force update slots and mark instance for hmr as well
5076
- extend(slots, children);
4833
+ else {
4834
+ instance.data = reactive(data);
4835
+ {
4836
+ for (const key in data) {
4837
+ checkDuplicateProperties("Data" /* DATA */, key);
4838
+ // expose data on ctx during dev
4839
+ if (!isReservedPrefix(key[0])) {
4840
+ Object.defineProperty(ctx, key, {
4841
+ configurable: true,
4842
+ enumerable: true,
4843
+ get: () => data[key],
4844
+ set: NOOP
4845
+ });
4846
+ }
4847
+ }
5077
4848
  }
5078
- else if (optimized && type === 1 /* STABLE */) {
5079
- // compiled AND stable.
5080
- // no need to update, and skip stale slots removal.
5081
- needDeletionCheck = false;
4849
+ }
4850
+ }
4851
+ // state initialization complete at this point - start caching access
4852
+ shouldCacheAccess = true;
4853
+ if (computedOptions) {
4854
+ for (const key in computedOptions) {
4855
+ const opt = computedOptions[key];
4856
+ const get = isFunction(opt)
4857
+ ? opt.bind(publicThis, publicThis)
4858
+ : isFunction(opt.get)
4859
+ ? opt.get.bind(publicThis, publicThis)
4860
+ : NOOP;
4861
+ if (get === NOOP) {
4862
+ warn$1(`Computed property "${key}" has no getter.`);
5082
4863
  }
5083
- else {
5084
- // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5085
- // normalization.
5086
- extend(slots, children);
5087
- // #2893
5088
- // when rendering the optimized slots by manually written render function,
5089
- // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5090
- // i.e. let the `renderSlot` create the bailed Fragment
5091
- if (!optimized && type === 1 /* STABLE */) {
5092
- delete slots._;
5093
- }
4864
+ const set = !isFunction(opt) && isFunction(opt.set)
4865
+ ? opt.set.bind(publicThis)
4866
+ : () => {
4867
+ warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4868
+ }
4869
+ ;
4870
+ const c = computed$1({
4871
+ get,
4872
+ set
4873
+ });
4874
+ Object.defineProperty(ctx, key, {
4875
+ enumerable: true,
4876
+ configurable: true,
4877
+ get: () => c.value,
4878
+ set: v => (c.value = v)
4879
+ });
4880
+ {
4881
+ checkDuplicateProperties("Computed" /* COMPUTED */, key);
5094
4882
  }
5095
4883
  }
5096
- else {
5097
- needDeletionCheck = !children.$stable;
5098
- normalizeObjectSlots(children, slots);
4884
+ }
4885
+ if (watchOptions) {
4886
+ for (const key in watchOptions) {
4887
+ createWatcher(watchOptions[key], ctx, publicThis, key);
5099
4888
  }
5100
- deletionComparisonTarget = children;
5101
4889
  }
5102
- else if (children) {
5103
- // non slot object children (direct value) passed to a component
5104
- normalizeVNodeSlots(instance, children);
5105
- deletionComparisonTarget = { default: 1 };
4890
+ if (provideOptions) {
4891
+ const provides = isFunction(provideOptions)
4892
+ ? provideOptions.call(publicThis)
4893
+ : provideOptions;
4894
+ Reflect.ownKeys(provides).forEach(key => {
4895
+ provide(key, provides[key]);
4896
+ });
5106
4897
  }
5107
- // delete stale slots
5108
- if (needDeletionCheck) {
5109
- for (const key in slots) {
5110
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5111
- delete slots[key];
5112
- }
4898
+ if (created) {
4899
+ callHook(created, instance, "c" /* CREATED */);
4900
+ }
4901
+ function registerLifecycleHook(register, hook) {
4902
+ if (isArray(hook)) {
4903
+ hook.forEach(_hook => register(_hook.bind(publicThis)));
4904
+ }
4905
+ else if (hook) {
4906
+ register(hook.bind(publicThis));
5113
4907
  }
5114
4908
  }
5115
- };
5116
-
5117
- /**
5118
- Runtime helper for applying directives to a vnode. Example usage:
5119
-
5120
- const comp = resolveComponent('comp')
5121
- const foo = resolveDirective('foo')
5122
- const bar = resolveDirective('bar')
5123
-
5124
- return withDirectives(h(comp), [
5125
- [foo, this.x],
5126
- [bar, this.y]
5127
- ])
5128
- */
5129
- function validateDirectiveName(name) {
5130
- if (isBuiltInDirective(name)) {
5131
- warn$1('Do not use built-in directive ids as custom directive id: ' + name);
4909
+ registerLifecycleHook(onBeforeMount, beforeMount);
4910
+ registerLifecycleHook(onMounted, mounted);
4911
+ registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4912
+ registerLifecycleHook(onUpdated, updated);
4913
+ registerLifecycleHook(onActivated, activated);
4914
+ registerLifecycleHook(onDeactivated, deactivated);
4915
+ registerLifecycleHook(onErrorCaptured, errorCaptured);
4916
+ registerLifecycleHook(onRenderTracked, renderTracked);
4917
+ registerLifecycleHook(onRenderTriggered, renderTriggered);
4918
+ registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4919
+ registerLifecycleHook(onUnmounted, unmounted);
4920
+ registerLifecycleHook(onServerPrefetch, serverPrefetch);
4921
+ if (isArray(expose)) {
4922
+ if (expose.length) {
4923
+ const exposed = instance.exposed || (instance.exposed = {});
4924
+ expose.forEach(key => {
4925
+ Object.defineProperty(exposed, key, {
4926
+ get: () => publicThis[key],
4927
+ set: val => (publicThis[key] = val)
4928
+ });
4929
+ });
4930
+ }
4931
+ else if (!instance.exposed) {
4932
+ instance.exposed = {};
4933
+ }
4934
+ }
4935
+ // options that are handled when creating the instance but also need to be
4936
+ // applied from mixins
4937
+ if (render && instance.render === NOOP) {
4938
+ instance.render = render;
5132
4939
  }
4940
+ if (inheritAttrs != null) {
4941
+ instance.inheritAttrs = inheritAttrs;
4942
+ }
4943
+ // asset options.
4944
+ if (components)
4945
+ instance.components = components;
4946
+ if (directives)
4947
+ instance.directives = directives;
5133
4948
  }
5134
- /**
5135
- * Adds directives to a VNode.
5136
- */
5137
- function withDirectives(vnode, directives) {
5138
- const internalInstance = currentRenderingInstance;
5139
- if (internalInstance === null) {
5140
- warn$1(`withDirectives can only be used inside render functions.`);
5141
- return vnode;
4949
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4950
+ if (isArray(injectOptions)) {
4951
+ injectOptions = normalizeInject(injectOptions);
5142
4952
  }
5143
- const instance = getExposeProxy(internalInstance) ||
5144
- internalInstance.proxy;
5145
- const bindings = vnode.dirs || (vnode.dirs = []);
5146
- for (let i = 0; i < directives.length; i++) {
5147
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5148
- if (isFunction(dir)) {
5149
- dir = {
5150
- mounted: dir,
5151
- updated: dir
5152
- };
4953
+ for (const key in injectOptions) {
4954
+ const opt = injectOptions[key];
4955
+ let injected;
4956
+ if (isObject(opt)) {
4957
+ if ('default' in opt) {
4958
+ injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4959
+ }
4960
+ else {
4961
+ injected = inject(opt.from || key);
4962
+ }
5153
4963
  }
5154
- if (dir.deep) {
5155
- traverse(value);
4964
+ else {
4965
+ injected = inject(opt);
4966
+ }
4967
+ if (isRef(injected)) {
4968
+ // TODO remove the check in 3.3
4969
+ if (unwrapRef) {
4970
+ Object.defineProperty(ctx, key, {
4971
+ enumerable: true,
4972
+ configurable: true,
4973
+ get: () => injected.value,
4974
+ set: v => (injected.value = v)
4975
+ });
4976
+ }
4977
+ else {
4978
+ {
4979
+ warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4980
+ `and no longer needs \`.value\` in the next minor release. ` +
4981
+ `To opt-in to the new behavior now, ` +
4982
+ `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4983
+ `temporary and will not be needed in the future.)`);
4984
+ }
4985
+ ctx[key] = injected;
4986
+ }
4987
+ }
4988
+ else {
4989
+ ctx[key] = injected;
4990
+ }
4991
+ {
4992
+ checkDuplicateProperties("Inject" /* INJECT */, key);
5156
4993
  }
5157
- bindings.push({
5158
- dir,
5159
- instance,
5160
- value,
5161
- oldValue: void 0,
5162
- arg,
5163
- modifiers
5164
- });
5165
4994
  }
5166
- return vnode;
5167
4995
  }
5168
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5169
- const bindings = vnode.dirs;
5170
- const oldBindings = prevVNode && prevVNode.dirs;
5171
- for (let i = 0; i < bindings.length; i++) {
5172
- const binding = bindings[i];
5173
- if (oldBindings) {
5174
- binding.oldValue = oldBindings[i].value;
4996
+ function callHook(hook, instance, type) {
4997
+ callWithAsyncErrorHandling(isArray(hook)
4998
+ ? hook.map(h => h.bind(instance.proxy))
4999
+ : hook.bind(instance.proxy), instance, type);
5000
+ }
5001
+ function createWatcher(raw, ctx, publicThis, key) {
5002
+ const getter = key.includes('.')
5003
+ ? createPathGetter(publicThis, key)
5004
+ : () => publicThis[key];
5005
+ if (isString(raw)) {
5006
+ const handler = ctx[raw];
5007
+ if (isFunction(handler)) {
5008
+ watch(getter, handler);
5175
5009
  }
5176
- let hook = binding.dir[name];
5177
- if (hook) {
5178
- // disable tracking inside all lifecycle hooks
5179
- // since they can potentially be called inside effects.
5180
- pauseTracking();
5181
- callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5182
- vnode.el,
5183
- binding,
5184
- vnode,
5185
- prevVNode
5186
- ]);
5187
- resetTracking();
5010
+ else {
5011
+ warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5188
5012
  }
5189
5013
  }
5190
- }
5191
-
5192
- function createAppContext() {
5193
- return {
5194
- app: null,
5195
- config: {
5196
- isNativeTag: NO,
5197
- performance: false,
5198
- globalProperties: {},
5199
- optionMergeStrategies: {},
5200
- errorHandler: undefined,
5201
- warnHandler: undefined,
5202
- compilerOptions: {}
5203
- },
5204
- mixins: [],
5205
- components: {},
5206
- directives: {},
5207
- provides: Object.create(null),
5208
- optionsCache: new WeakMap(),
5209
- propsCache: new WeakMap(),
5210
- emitsCache: new WeakMap()
5211
- };
5014
+ else if (isFunction(raw)) {
5015
+ watch(getter, raw.bind(publicThis));
5016
+ }
5017
+ else if (isObject(raw)) {
5018
+ if (isArray(raw)) {
5019
+ raw.forEach(r => createWatcher(r, ctx, publicThis, key));
5020
+ }
5021
+ else {
5022
+ const handler = isFunction(raw.handler)
5023
+ ? raw.handler.bind(publicThis)
5024
+ : ctx[raw.handler];
5025
+ if (isFunction(handler)) {
5026
+ watch(getter, handler, raw);
5027
+ }
5028
+ else {
5029
+ warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
5030
+ }
5031
+ }
5032
+ }
5033
+ else {
5034
+ warn$1(`Invalid watch option: "${key}"`, raw);
5035
+ }
5212
5036
  }
5213
- let uid = 0;
5214
- function createAppAPI(render, hydrate) {
5215
- return function createApp(rootComponent, rootProps = null) {
5216
- if (!isFunction(rootComponent)) {
5217
- rootComponent = Object.assign({}, rootComponent);
5037
+ /**
5038
+ * Resolve merged options and cache it on the component.
5039
+ * This is done only once per-component since the merging does not involve
5040
+ * instances.
5041
+ */
5042
+ function resolveMergedOptions(instance) {
5043
+ const base = instance.type;
5044
+ const { mixins, extends: extendsOptions } = base;
5045
+ const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
5046
+ const cached = cache.get(base);
5047
+ let resolved;
5048
+ if (cached) {
5049
+ resolved = cached;
5050
+ }
5051
+ else if (!globalMixins.length && !mixins && !extendsOptions) {
5052
+ {
5053
+ resolved = base;
5218
5054
  }
5219
- if (rootProps != null && !isObject(rootProps)) {
5220
- warn$1(`root props passed to app.mount() must be an object.`);
5221
- rootProps = null;
5055
+ }
5056
+ else {
5057
+ resolved = {};
5058
+ if (globalMixins.length) {
5059
+ globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
5222
5060
  }
5223
- const context = createAppContext();
5224
- const installedPlugins = new Set();
5225
- let isMounted = false;
5226
- const app = (context.app = {
5227
- _uid: uid++,
5228
- _component: rootComponent,
5229
- _props: rootProps,
5230
- _container: null,
5231
- _context: context,
5232
- _instance: null,
5233
- version,
5234
- get config() {
5235
- return context.config;
5236
- },
5237
- set config(v) {
5238
- {
5239
- warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5240
- }
5241
- },
5242
- use(plugin, ...options) {
5243
- if (installedPlugins.has(plugin)) {
5244
- warn$1(`Plugin has already been applied to target app.`);
5245
- }
5246
- else if (plugin && isFunction(plugin.install)) {
5247
- installedPlugins.add(plugin);
5248
- plugin.install(app, ...options);
5249
- }
5250
- else if (isFunction(plugin)) {
5251
- installedPlugins.add(plugin);
5061
+ mergeOptions(resolved, base, optionMergeStrategies);
5062
+ }
5063
+ cache.set(base, resolved);
5064
+ return resolved;
5065
+ }
5066
+ function mergeOptions(to, from, strats, asMixin = false) {
5067
+ const { mixins, extends: extendsOptions } = from;
5068
+ if (extendsOptions) {
5069
+ mergeOptions(to, extendsOptions, strats, true);
5070
+ }
5071
+ if (mixins) {
5072
+ mixins.forEach((m) => mergeOptions(to, m, strats, true));
5073
+ }
5074
+ for (const key in from) {
5075
+ if (asMixin && key === 'expose') {
5076
+ warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
5077
+ `It should only be declared in the base component itself.`);
5078
+ }
5079
+ else {
5080
+ const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
5081
+ to[key] = strat ? strat(to[key], from[key]) : from[key];
5082
+ }
5083
+ }
5084
+ return to;
5085
+ }
5086
+ const internalOptionMergeStrats = {
5087
+ data: mergeDataFn,
5088
+ props: mergeObjectOptions,
5089
+ emits: mergeObjectOptions,
5090
+ // objects
5091
+ methods: mergeObjectOptions,
5092
+ computed: mergeObjectOptions,
5093
+ // lifecycle
5094
+ beforeCreate: mergeAsArray,
5095
+ created: mergeAsArray,
5096
+ beforeMount: mergeAsArray,
5097
+ mounted: mergeAsArray,
5098
+ beforeUpdate: mergeAsArray,
5099
+ updated: mergeAsArray,
5100
+ beforeDestroy: mergeAsArray,
5101
+ beforeUnmount: mergeAsArray,
5102
+ destroyed: mergeAsArray,
5103
+ unmounted: mergeAsArray,
5104
+ activated: mergeAsArray,
5105
+ deactivated: mergeAsArray,
5106
+ errorCaptured: mergeAsArray,
5107
+ serverPrefetch: mergeAsArray,
5108
+ // assets
5109
+ components: mergeObjectOptions,
5110
+ directives: mergeObjectOptions,
5111
+ // watch
5112
+ watch: mergeWatchOptions,
5113
+ // provide / inject
5114
+ provide: mergeDataFn,
5115
+ inject: mergeInject
5116
+ };
5117
+ function mergeDataFn(to, from) {
5118
+ if (!from) {
5119
+ return to;
5120
+ }
5121
+ if (!to) {
5122
+ return from;
5123
+ }
5124
+ return function mergedDataFn() {
5125
+ return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
5126
+ };
5127
+ }
5128
+ function mergeInject(to, from) {
5129
+ return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
5130
+ }
5131
+ function normalizeInject(raw) {
5132
+ if (isArray(raw)) {
5133
+ const res = {};
5134
+ for (let i = 0; i < raw.length; i++) {
5135
+ res[raw[i]] = raw[i];
5136
+ }
5137
+ return res;
5138
+ }
5139
+ return raw;
5140
+ }
5141
+ function mergeAsArray(to, from) {
5142
+ return to ? [...new Set([].concat(to, from))] : from;
5143
+ }
5144
+ function mergeObjectOptions(to, from) {
5145
+ return to ? extend(extend(Object.create(null), to), from) : from;
5146
+ }
5147
+ function mergeWatchOptions(to, from) {
5148
+ if (!to)
5149
+ return from;
5150
+ if (!from)
5151
+ return to;
5152
+ const merged = extend(Object.create(null), to);
5153
+ for (const key in from) {
5154
+ merged[key] = mergeAsArray(to[key], from[key]);
5155
+ }
5156
+ return merged;
5157
+ }
5158
+
5159
+ function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
5160
+ isSSR = false) {
5161
+ const props = {};
5162
+ const attrs = {};
5163
+ def(attrs, InternalObjectKey, 1);
5164
+ instance.propsDefaults = Object.create(null);
5165
+ setFullProps(instance, rawProps, props, attrs);
5166
+ // ensure all declared prop keys are present
5167
+ for (const key in instance.propsOptions[0]) {
5168
+ if (!(key in props)) {
5169
+ props[key] = undefined;
5170
+ }
5171
+ }
5172
+ // validation
5173
+ {
5174
+ validateProps(rawProps || {}, props, instance);
5175
+ }
5176
+ if (isStateful) {
5177
+ // stateful
5178
+ instance.props = isSSR ? props : shallowReactive(props);
5179
+ }
5180
+ else {
5181
+ if (!instance.type.props) {
5182
+ // functional w/ optional props, props === attrs
5183
+ instance.props = attrs;
5184
+ }
5185
+ else {
5186
+ // functional w/ declared props
5187
+ instance.props = props;
5188
+ }
5189
+ }
5190
+ instance.attrs = attrs;
5191
+ }
5192
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
5193
+ const { props, attrs, vnode: { patchFlag } } = instance;
5194
+ const rawCurrentProps = toRaw(props);
5195
+ const [options] = instance.propsOptions;
5196
+ let hasAttrsChanged = false;
5197
+ if (
5198
+ // always force full diff in dev
5199
+ // - #1942 if hmr is enabled with sfc component
5200
+ // - vite#872 non-sfc component used by sfc component
5201
+ !((instance.type.__hmrId ||
5202
+ (instance.parent && instance.parent.type.__hmrId))) &&
5203
+ (optimized || patchFlag > 0) &&
5204
+ !(patchFlag & 16 /* FULL_PROPS */)) {
5205
+ if (patchFlag & 8 /* PROPS */) {
5206
+ // Compiler-generated props & no keys change, just set the updated
5207
+ // the props.
5208
+ const propsToUpdate = instance.vnode.dynamicProps;
5209
+ for (let i = 0; i < propsToUpdate.length; i++) {
5210
+ let key = propsToUpdate[i];
5211
+ // skip if the prop key is a declared emit event listener
5212
+ if (isEmitListener(instance.emitsOptions, key)) {
5213
+ continue;
5214
+ }
5215
+ // PROPS flag guarantees rawProps to be non-null
5216
+ const value = rawProps[key];
5217
+ if (options) {
5218
+ // attr / props separation was done on init and will be consistent
5219
+ // in this code path, so just check if attrs have it.
5220
+ if (hasOwn(attrs, key)) {
5221
+ if (value !== attrs[key]) {
5222
+ attrs[key] = value;
5223
+ hasAttrsChanged = true;
5224
+ }
5225
+ }
5226
+ else {
5227
+ const camelizedKey = camelize(key);
5228
+ props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
5229
+ }
5230
+ }
5231
+ else {
5232
+ if (value !== attrs[key]) {
5233
+ attrs[key] = value;
5234
+ hasAttrsChanged = true;
5235
+ }
5236
+ }
5237
+ }
5238
+ }
5239
+ }
5240
+ else {
5241
+ // full props update.
5242
+ if (setFullProps(instance, rawProps, props, attrs)) {
5243
+ hasAttrsChanged = true;
5244
+ }
5245
+ // in case of dynamic props, check if we need to delete keys from
5246
+ // the props object
5247
+ let kebabKey;
5248
+ for (const key in rawCurrentProps) {
5249
+ if (!rawProps ||
5250
+ // for camelCase
5251
+ (!hasOwn(rawProps, key) &&
5252
+ // it's possible the original props was passed in as kebab-case
5253
+ // and converted to camelCase (#955)
5254
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
5255
+ if (options) {
5256
+ if (rawPrevProps &&
5257
+ // for camelCase
5258
+ (rawPrevProps[key] !== undefined ||
5259
+ // for kebab-case
5260
+ rawPrevProps[kebabKey] !== undefined)) {
5261
+ props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
5262
+ }
5263
+ }
5264
+ else {
5265
+ delete props[key];
5266
+ }
5267
+ }
5268
+ }
5269
+ // in the case of functional component w/o props declaration, props and
5270
+ // attrs point to the same object so it should already have been updated.
5271
+ if (attrs !== rawCurrentProps) {
5272
+ for (const key in attrs) {
5273
+ if (!rawProps ||
5274
+ (!hasOwn(rawProps, key) &&
5275
+ (!false ))) {
5276
+ delete attrs[key];
5277
+ hasAttrsChanged = true;
5278
+ }
5279
+ }
5280
+ }
5281
+ }
5282
+ // trigger updates for $attrs in case it's used in component slots
5283
+ if (hasAttrsChanged) {
5284
+ trigger(instance, "set" /* SET */, '$attrs');
5285
+ }
5286
+ {
5287
+ validateProps(rawProps || {}, props, instance);
5288
+ }
5289
+ }
5290
+ function setFullProps(instance, rawProps, props, attrs) {
5291
+ const [options, needCastKeys] = instance.propsOptions;
5292
+ let hasAttrsChanged = false;
5293
+ let rawCastValues;
5294
+ if (rawProps) {
5295
+ for (let key in rawProps) {
5296
+ // key, ref are reserved and never passed down
5297
+ if (isReservedProp(key)) {
5298
+ continue;
5299
+ }
5300
+ const value = rawProps[key];
5301
+ // prop option names are camelized during normalization, so to support
5302
+ // kebab -> camel conversion here we need to camelize the key.
5303
+ let camelKey;
5304
+ if (options && hasOwn(options, (camelKey = camelize(key)))) {
5305
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
5306
+ props[camelKey] = value;
5307
+ }
5308
+ else {
5309
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
5310
+ }
5311
+ }
5312
+ else if (!isEmitListener(instance.emitsOptions, key)) {
5313
+ if (!(key in attrs) || value !== attrs[key]) {
5314
+ attrs[key] = value;
5315
+ hasAttrsChanged = true;
5316
+ }
5317
+ }
5318
+ }
5319
+ }
5320
+ if (needCastKeys) {
5321
+ const rawCurrentProps = toRaw(props);
5322
+ const castValues = rawCastValues || EMPTY_OBJ;
5323
+ for (let i = 0; i < needCastKeys.length; i++) {
5324
+ const key = needCastKeys[i];
5325
+ props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
5326
+ }
5327
+ }
5328
+ return hasAttrsChanged;
5329
+ }
5330
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5331
+ const opt = options[key];
5332
+ if (opt != null) {
5333
+ const hasDefault = hasOwn(opt, 'default');
5334
+ // default values
5335
+ if (hasDefault && value === undefined) {
5336
+ const defaultValue = opt.default;
5337
+ if (opt.type !== Function && isFunction(defaultValue)) {
5338
+ const { propsDefaults } = instance;
5339
+ if (key in propsDefaults) {
5340
+ value = propsDefaults[key];
5341
+ }
5342
+ else {
5343
+ setCurrentInstance(instance);
5344
+ value = propsDefaults[key] = defaultValue.call(null, props);
5345
+ unsetCurrentInstance();
5346
+ }
5347
+ }
5348
+ else {
5349
+ value = defaultValue;
5350
+ }
5351
+ }
5352
+ // boolean casting
5353
+ if (opt[0 /* shouldCast */]) {
5354
+ if (isAbsent && !hasDefault) {
5355
+ value = false;
5356
+ }
5357
+ else if (opt[1 /* shouldCastTrue */] &&
5358
+ (value === '' || value === hyphenate(key))) {
5359
+ value = true;
5360
+ }
5361
+ }
5362
+ }
5363
+ return value;
5364
+ }
5365
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
5366
+ const cache = appContext.propsCache;
5367
+ const cached = cache.get(comp);
5368
+ if (cached) {
5369
+ return cached;
5370
+ }
5371
+ const raw = comp.props;
5372
+ const normalized = {};
5373
+ const needCastKeys = [];
5374
+ // apply mixin/extends props
5375
+ let hasExtends = false;
5376
+ if (!isFunction(comp)) {
5377
+ const extendProps = (raw) => {
5378
+ hasExtends = true;
5379
+ const [props, keys] = normalizePropsOptions(raw, appContext, true);
5380
+ extend(normalized, props);
5381
+ if (keys)
5382
+ needCastKeys.push(...keys);
5383
+ };
5384
+ if (!asMixin && appContext.mixins.length) {
5385
+ appContext.mixins.forEach(extendProps);
5386
+ }
5387
+ if (comp.extends) {
5388
+ extendProps(comp.extends);
5389
+ }
5390
+ if (comp.mixins) {
5391
+ comp.mixins.forEach(extendProps);
5392
+ }
5393
+ }
5394
+ if (!raw && !hasExtends) {
5395
+ cache.set(comp, EMPTY_ARR);
5396
+ return EMPTY_ARR;
5397
+ }
5398
+ if (isArray(raw)) {
5399
+ for (let i = 0; i < raw.length; i++) {
5400
+ if (!isString(raw[i])) {
5401
+ warn$1(`props must be strings when using array syntax.`, raw[i]);
5402
+ }
5403
+ const normalizedKey = camelize(raw[i]);
5404
+ if (validatePropName(normalizedKey)) {
5405
+ normalized[normalizedKey] = EMPTY_OBJ;
5406
+ }
5407
+ }
5408
+ }
5409
+ else if (raw) {
5410
+ if (!isObject(raw)) {
5411
+ warn$1(`invalid props options`, raw);
5412
+ }
5413
+ for (const key in raw) {
5414
+ const normalizedKey = camelize(key);
5415
+ if (validatePropName(normalizedKey)) {
5416
+ const opt = raw[key];
5417
+ const prop = (normalized[normalizedKey] =
5418
+ isArray(opt) || isFunction(opt) ? { type: opt } : opt);
5419
+ if (prop) {
5420
+ const booleanIndex = getTypeIndex(Boolean, prop.type);
5421
+ const stringIndex = getTypeIndex(String, prop.type);
5422
+ prop[0 /* shouldCast */] = booleanIndex > -1;
5423
+ prop[1 /* shouldCastTrue */] =
5424
+ stringIndex < 0 || booleanIndex < stringIndex;
5425
+ // if the prop needs boolean casting or default value
5426
+ if (booleanIndex > -1 || hasOwn(prop, 'default')) {
5427
+ needCastKeys.push(normalizedKey);
5428
+ }
5429
+ }
5430
+ }
5431
+ }
5432
+ }
5433
+ const res = [normalized, needCastKeys];
5434
+ cache.set(comp, res);
5435
+ return res;
5436
+ }
5437
+ function validatePropName(key) {
5438
+ if (key[0] !== '$') {
5439
+ return true;
5440
+ }
5441
+ else {
5442
+ warn$1(`Invalid prop name: "${key}" is a reserved property.`);
5443
+ }
5444
+ return false;
5445
+ }
5446
+ // use function string name to check type constructors
5447
+ // so that it works across vms / iframes.
5448
+ function getType(ctor) {
5449
+ const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
5450
+ return match ? match[1] : ctor === null ? 'null' : '';
5451
+ }
5452
+ function isSameType(a, b) {
5453
+ return getType(a) === getType(b);
5454
+ }
5455
+ function getTypeIndex(type, expectedTypes) {
5456
+ if (isArray(expectedTypes)) {
5457
+ return expectedTypes.findIndex(t => isSameType(t, type));
5458
+ }
5459
+ else if (isFunction(expectedTypes)) {
5460
+ return isSameType(expectedTypes, type) ? 0 : -1;
5461
+ }
5462
+ return -1;
5463
+ }
5464
+ /**
5465
+ * dev only
5466
+ */
5467
+ function validateProps(rawProps, props, instance) {
5468
+ const resolvedValues = toRaw(props);
5469
+ const options = instance.propsOptions[0];
5470
+ for (const key in options) {
5471
+ let opt = options[key];
5472
+ if (opt == null)
5473
+ continue;
5474
+ validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
5475
+ }
5476
+ }
5477
+ /**
5478
+ * dev only
5479
+ */
5480
+ function validateProp(name, value, prop, isAbsent) {
5481
+ const { type, required, validator } = prop;
5482
+ // required!
5483
+ if (required && isAbsent) {
5484
+ warn$1('Missing required prop: "' + name + '"');
5485
+ return;
5486
+ }
5487
+ // missing but optional
5488
+ if (value == null && !prop.required) {
5489
+ return;
5490
+ }
5491
+ // type check
5492
+ if (type != null && type !== true) {
5493
+ let isValid = false;
5494
+ const types = isArray(type) ? type : [type];
5495
+ const expectedTypes = [];
5496
+ // value is valid as long as one of the specified types match
5497
+ for (let i = 0; i < types.length && !isValid; i++) {
5498
+ const { valid, expectedType } = assertType(value, types[i]);
5499
+ expectedTypes.push(expectedType || '');
5500
+ isValid = valid;
5501
+ }
5502
+ if (!isValid) {
5503
+ warn$1(getInvalidTypeMessage(name, value, expectedTypes));
5504
+ return;
5505
+ }
5506
+ }
5507
+ // custom validator
5508
+ if (validator && !validator(value)) {
5509
+ warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
5510
+ }
5511
+ }
5512
+ const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
5513
+ /**
5514
+ * dev only
5515
+ */
5516
+ function assertType(value, type) {
5517
+ let valid;
5518
+ const expectedType = getType(type);
5519
+ if (isSimpleType(expectedType)) {
5520
+ const t = typeof value;
5521
+ valid = t === expectedType.toLowerCase();
5522
+ // for primitive wrapper objects
5523
+ if (!valid && t === 'object') {
5524
+ valid = value instanceof type;
5525
+ }
5526
+ }
5527
+ else if (expectedType === 'Object') {
5528
+ valid = isObject(value);
5529
+ }
5530
+ else if (expectedType === 'Array') {
5531
+ valid = isArray(value);
5532
+ }
5533
+ else if (expectedType === 'null') {
5534
+ valid = value === null;
5535
+ }
5536
+ else {
5537
+ valid = value instanceof type;
5538
+ }
5539
+ return {
5540
+ valid,
5541
+ expectedType
5542
+ };
5543
+ }
5544
+ /**
5545
+ * dev only
5546
+ */
5547
+ function getInvalidTypeMessage(name, value, expectedTypes) {
5548
+ let message = `Invalid prop: type check failed for prop "${name}".` +
5549
+ ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
5550
+ const expectedType = expectedTypes[0];
5551
+ const receivedType = toRawType(value);
5552
+ const expectedValue = styleValue(value, expectedType);
5553
+ const receivedValue = styleValue(value, receivedType);
5554
+ // check if we need to specify expected value
5555
+ if (expectedTypes.length === 1 &&
5556
+ isExplicable(expectedType) &&
5557
+ !isBoolean(expectedType, receivedType)) {
5558
+ message += ` with value ${expectedValue}`;
5559
+ }
5560
+ message += `, got ${receivedType} `;
5561
+ // check if we need to specify received value
5562
+ if (isExplicable(receivedType)) {
5563
+ message += `with value ${receivedValue}.`;
5564
+ }
5565
+ return message;
5566
+ }
5567
+ /**
5568
+ * dev only
5569
+ */
5570
+ function styleValue(value, type) {
5571
+ if (type === 'String') {
5572
+ return `"${value}"`;
5573
+ }
5574
+ else if (type === 'Number') {
5575
+ return `${Number(value)}`;
5576
+ }
5577
+ else {
5578
+ return `${value}`;
5579
+ }
5580
+ }
5581
+ /**
5582
+ * dev only
5583
+ */
5584
+ function isExplicable(type) {
5585
+ const explicitTypes = ['string', 'number', 'boolean'];
5586
+ return explicitTypes.some(elem => type.toLowerCase() === elem);
5587
+ }
5588
+ /**
5589
+ * dev only
5590
+ */
5591
+ function isBoolean(...args) {
5592
+ return args.some(elem => elem.toLowerCase() === 'boolean');
5593
+ }
5594
+
5595
+ const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5596
+ const normalizeSlotValue = (value) => isArray(value)
5597
+ ? value.map(normalizeVNode)
5598
+ : [normalizeVNode(value)];
5599
+ const normalizeSlot = (key, rawSlot, ctx) => {
5600
+ if (rawSlot._n) {
5601
+ // already normalized - #5353
5602
+ return rawSlot;
5603
+ }
5604
+ const normalized = withCtx((...args) => {
5605
+ if (currentInstance) {
5606
+ warn$1(`Slot "${key}" invoked outside of the render function: ` +
5607
+ `this will not track dependencies used in the slot. ` +
5608
+ `Invoke the slot function inside the render function instead.`);
5609
+ }
5610
+ return normalizeSlotValue(rawSlot(...args));
5611
+ }, ctx);
5612
+ normalized._c = false;
5613
+ return normalized;
5614
+ };
5615
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
5616
+ const ctx = rawSlots._ctx;
5617
+ for (const key in rawSlots) {
5618
+ if (isInternalKey(key))
5619
+ continue;
5620
+ const value = rawSlots[key];
5621
+ if (isFunction(value)) {
5622
+ slots[key] = normalizeSlot(key, value, ctx);
5623
+ }
5624
+ else if (value != null) {
5625
+ {
5626
+ warn$1(`Non-function value encountered for slot "${key}". ` +
5627
+ `Prefer function slots for better performance.`);
5628
+ }
5629
+ const normalized = normalizeSlotValue(value);
5630
+ slots[key] = () => normalized;
5631
+ }
5632
+ }
5633
+ };
5634
+ const normalizeVNodeSlots = (instance, children) => {
5635
+ if (!isKeepAlive(instance.vnode) &&
5636
+ !(false )) {
5637
+ warn$1(`Non-function value encountered for default slot. ` +
5638
+ `Prefer function slots for better performance.`);
5639
+ }
5640
+ const normalized = normalizeSlotValue(children);
5641
+ instance.slots.default = () => normalized;
5642
+ };
5643
+ const initSlots = (instance, children) => {
5644
+ if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5645
+ const type = children._;
5646
+ if (type) {
5647
+ // users can get the shallow readonly version of the slots object through `this.$slots`,
5648
+ // we should avoid the proxy object polluting the slots of the internal instance
5649
+ instance.slots = toRaw(children);
5650
+ // make compiler marker non-enumerable
5651
+ def(children, '_', type);
5652
+ }
5653
+ else {
5654
+ normalizeObjectSlots(children, (instance.slots = {}));
5655
+ }
5656
+ }
5657
+ else {
5658
+ instance.slots = {};
5659
+ if (children) {
5660
+ normalizeVNodeSlots(instance, children);
5661
+ }
5662
+ }
5663
+ def(instance.slots, InternalObjectKey, 1);
5664
+ };
5665
+ const updateSlots = (instance, children, optimized) => {
5666
+ const { vnode, slots } = instance;
5667
+ let needDeletionCheck = true;
5668
+ let deletionComparisonTarget = EMPTY_OBJ;
5669
+ if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5670
+ const type = children._;
5671
+ if (type) {
5672
+ // compiled slots.
5673
+ if (isHmrUpdating) {
5674
+ // Parent was HMR updated so slot content may have changed.
5675
+ // force update slots and mark instance for hmr as well
5676
+ extend(slots, children);
5677
+ }
5678
+ else if (optimized && type === 1 /* STABLE */) {
5679
+ // compiled AND stable.
5680
+ // no need to update, and skip stale slots removal.
5681
+ needDeletionCheck = false;
5682
+ }
5683
+ else {
5684
+ // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5685
+ // normalization.
5686
+ extend(slots, children);
5687
+ // #2893
5688
+ // when rendering the optimized slots by manually written render function,
5689
+ // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5690
+ // i.e. let the `renderSlot` create the bailed Fragment
5691
+ if (!optimized && type === 1 /* STABLE */) {
5692
+ delete slots._;
5693
+ }
5694
+ }
5695
+ }
5696
+ else {
5697
+ needDeletionCheck = !children.$stable;
5698
+ normalizeObjectSlots(children, slots);
5699
+ }
5700
+ deletionComparisonTarget = children;
5701
+ }
5702
+ else if (children) {
5703
+ // non slot object children (direct value) passed to a component
5704
+ normalizeVNodeSlots(instance, children);
5705
+ deletionComparisonTarget = { default: 1 };
5706
+ }
5707
+ // delete stale slots
5708
+ if (needDeletionCheck) {
5709
+ for (const key in slots) {
5710
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5711
+ delete slots[key];
5712
+ }
5713
+ }
5714
+ }
5715
+ };
5716
+
5717
+ function createAppContext() {
5718
+ return {
5719
+ app: null,
5720
+ config: {
5721
+ isNativeTag: NO,
5722
+ performance: false,
5723
+ globalProperties: {},
5724
+ optionMergeStrategies: {},
5725
+ errorHandler: undefined,
5726
+ warnHandler: undefined,
5727
+ compilerOptions: {}
5728
+ },
5729
+ mixins: [],
5730
+ components: {},
5731
+ directives: {},
5732
+ provides: Object.create(null),
5733
+ optionsCache: new WeakMap(),
5734
+ propsCache: new WeakMap(),
5735
+ emitsCache: new WeakMap()
5736
+ };
5737
+ }
5738
+ let uid = 0;
5739
+ function createAppAPI(render, hydrate) {
5740
+ return function createApp(rootComponent, rootProps = null) {
5741
+ if (!isFunction(rootComponent)) {
5742
+ rootComponent = Object.assign({}, rootComponent);
5743
+ }
5744
+ if (rootProps != null && !isObject(rootProps)) {
5745
+ warn$1(`root props passed to app.mount() must be an object.`);
5746
+ rootProps = null;
5747
+ }
5748
+ const context = createAppContext();
5749
+ const installedPlugins = new Set();
5750
+ let isMounted = false;
5751
+ const app = (context.app = {
5752
+ _uid: uid++,
5753
+ _component: rootComponent,
5754
+ _props: rootProps,
5755
+ _container: null,
5756
+ _context: context,
5757
+ _instance: null,
5758
+ version,
5759
+ get config() {
5760
+ return context.config;
5761
+ },
5762
+ set config(v) {
5763
+ {
5764
+ warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5765
+ }
5766
+ },
5767
+ use(plugin, ...options) {
5768
+ if (installedPlugins.has(plugin)) {
5769
+ warn$1(`Plugin has already been applied to target app.`);
5770
+ }
5771
+ else if (plugin && isFunction(plugin.install)) {
5772
+ installedPlugins.add(plugin);
5773
+ plugin.install(app, ...options);
5774
+ }
5775
+ else if (isFunction(plugin)) {
5776
+ installedPlugins.add(plugin);
5252
5777
  plugin(app, ...options);
5253
5778
  }
5254
5779
  else {
@@ -5297,6 +5822,12 @@ function createAppAPI(render, hydrate) {
5297
5822
  },
5298
5823
  mount(rootContainer, isHydrate, isSVG) {
5299
5824
  if (!isMounted) {
5825
+ // #5571
5826
+ if (rootContainer.__vue_app__) {
5827
+ warn$1(`There is already an app instance mounted on the host container.\n` +
5828
+ ` If you want to mount another app on the same host container,` +
5829
+ ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
5830
+ }
5300
5831
  const vnode = createVNode(rootComponent, rootProps);
5301
5832
  // store app context on the root VNode.
5302
5833
  // this will be set on the root instance on initial mount.
@@ -5347,8 +5878,6 @@ function createAppAPI(render, hydrate) {
5347
5878
  warn$1(`App already provides property with key "${String(key)}". ` +
5348
5879
  `It will be overwritten with the new value.`);
5349
5880
  }
5350
- // TypeScript doesn't allow symbols as index type
5351
- // https://github.com/Microsoft/TypeScript/issues/24587
5352
5881
  context.provides[key] = value;
5353
5882
  return app;
5354
5883
  }
@@ -5465,7 +5994,7 @@ const isComment = (node) => node.nodeType === 8 /* COMMENT */;
5465
5994
  // Hydration also depends on some renderer internal logic which needs to be
5466
5995
  // passed in via arguments.
5467
5996
  function createHydrationFunctions(rendererInternals) {
5468
- const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
5997
+ const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
5469
5998
  const hydrate = (vnode, container) => {
5470
5999
  if (!container.hasChildNodes()) {
5471
6000
  warn$1(`Attempting to hydrate existing markup but container is empty. ` +
@@ -5485,14 +6014,26 @@ function createHydrationFunctions(rendererInternals) {
5485
6014
  const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
5486
6015
  const isFragmentStart = isComment(node) && node.data === '[';
5487
6016
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
5488
- const { type, ref, shapeFlag } = vnode;
6017
+ const { type, ref, shapeFlag, patchFlag } = vnode;
5489
6018
  const domType = node.nodeType;
5490
6019
  vnode.el = node;
6020
+ if (patchFlag === -2 /* BAIL */) {
6021
+ optimized = false;
6022
+ vnode.dynamicChildren = null;
6023
+ }
5491
6024
  let nextNode = null;
5492
6025
  switch (type) {
5493
6026
  case Text:
5494
6027
  if (domType !== 3 /* TEXT */) {
5495
- nextNode = onMismatch();
6028
+ // #5728 empty text node inside a slot can cause hydration failure
6029
+ // because the server rendered HTML won't contain a text node
6030
+ if (vnode.children === '') {
6031
+ insert((vnode.el = createText('')), node.parentElement, node);
6032
+ nextNode = node;
6033
+ }
6034
+ else {
6035
+ nextNode = onMismatch();
6036
+ }
5496
6037
  }
5497
6038
  else {
5498
6039
  if (node.data !== vnode.children) {
@@ -5566,6 +6107,12 @@ function createHydrationFunctions(rendererInternals) {
5566
6107
  nextNode = isFragmentStart
5567
6108
  ? locateClosingAsyncAnchor(node)
5568
6109
  : nextSibling(node);
6110
+ // #4293 teleport as component root
6111
+ if (nextNode &&
6112
+ isComment(nextNode) &&
6113
+ nextNode.data === 'teleport end') {
6114
+ nextNode = nextSibling(nextNode);
6115
+ }
5569
6116
  // #3787
5570
6117
  // if component is async, it may get moved / unmounted before its
5571
6118
  // inner component is loaded, so we need to give it a placeholder
@@ -6229,8 +6776,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6229
6776
  const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
6230
6777
  const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
6231
6778
  let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
6232
- if (isHmrUpdating) {
6233
- // HMR updated, force full diff
6779
+ if (// #5523 dev root fragment may inherit directives
6780
+ (isHmrUpdating || patchFlag & 2048 /* DEV_ROOT_FRAGMENT */)) {
6781
+ // HMR updated / Dev root fragment (w/ comments), force full diff
6234
6782
  patchFlag = 0;
6235
6783
  optimized = false;
6236
6784
  dynamicChildren = null;
@@ -6364,7 +6912,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6364
6912
  }
6365
6913
  else {
6366
6914
  // no update needed. just copy over properties
6367
- n2.component = n1.component;
6368
6915
  n2.el = n1.el;
6369
6916
  instance.vnode = n2;
6370
6917
  }
@@ -6447,7 +6994,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6447
6994
  // activated hook for keep-alive roots.
6448
6995
  // #1742 activated hook must be accessed after first render
6449
6996
  // since the hook may be injected by a child keep-alive
6450
- if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
6997
+ if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */ ||
6998
+ (parent &&
6999
+ isAsyncWrapper(parent.vnode) &&
7000
+ parent.vnode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */)) {
6451
7001
  instance.a && queuePostRenderEffect(instance.a, parentSuspense);
6452
7002
  }
6453
7003
  instance.isMounted = true;
@@ -6530,9 +7080,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6530
7080
  }
6531
7081
  };
6532
7082
  // create reactive effect for rendering
6533
- const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7083
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
6534
7084
  ));
6535
- const update = (instance.update = effect.run.bind(effect));
7085
+ const update = (instance.update = () => effect.run());
6536
7086
  update.id = instance.uid;
6537
7087
  // allowRecurse
6538
7088
  // #1801, #2043 component render effects should allow recursive updates
@@ -6544,7 +7094,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6544
7094
  effect.onTrigger = instance.rtg
6545
7095
  ? e => invokeArrayFns(instance.rtg, e)
6546
7096
  : void 0;
6547
- // @ts-ignore (for scheduler)
6548
7097
  update.ownerInstance = instance;
6549
7098
  }
6550
7099
  update();
@@ -6928,7 +7477,22 @@ function baseCreateRenderer(options, createHydrationFns) {
6928
7477
  const remove = vnode => {
6929
7478
  const { type, el, anchor, transition } = vnode;
6930
7479
  if (type === Fragment) {
6931
- removeFragment(el, anchor);
7480
+ if (vnode.patchFlag > 0 &&
7481
+ vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
7482
+ transition &&
7483
+ !transition.persisted) {
7484
+ vnode.children.forEach(child => {
7485
+ if (child.type === Comment) {
7486
+ hostRemove(child.el);
7487
+ }
7488
+ else {
7489
+ remove(child);
7490
+ }
7491
+ });
7492
+ }
7493
+ else {
7494
+ removeFragment(el, anchor);
7495
+ }
6932
7496
  return;
6933
7497
  }
6934
7498
  if (type === Static) {
@@ -7321,89 +7885,29 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
7321
7885
  }
7322
7886
  else {
7323
7887
  vnode.anchor = nextSibling(node);
7324
- vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7325
- }
7326
- target._lpa =
7327
- vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7328
- }
7329
- }
7330
- return vnode.anchor && nextSibling(vnode.anchor);
7331
- }
7332
- // Force-casted public typing for h and TSX props inference
7333
- const Teleport = TeleportImpl;
7334
-
7335
- const COMPONENTS = 'components';
7336
- const DIRECTIVES = 'directives';
7337
- /**
7338
- * @private
7339
- */
7340
- function resolveComponent(name, maybeSelfReference) {
7341
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7342
- }
7343
- const NULL_DYNAMIC_COMPONENT = Symbol();
7344
- /**
7345
- * @private
7346
- */
7347
- function resolveDynamicComponent(component) {
7348
- if (isString(component)) {
7349
- return resolveAsset(COMPONENTS, component, false) || component;
7350
- }
7351
- else {
7352
- // invalid types will fallthrough to createVNode and raise warning
7353
- return (component || NULL_DYNAMIC_COMPONENT);
7354
- }
7355
- }
7356
- /**
7357
- * @private
7358
- */
7359
- function resolveDirective(name) {
7360
- return resolveAsset(DIRECTIVES, name);
7361
- }
7362
- // implementation
7363
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7364
- const instance = currentRenderingInstance || currentInstance;
7365
- if (instance) {
7366
- const Component = instance.type;
7367
- // explicit self name has highest priority
7368
- if (type === COMPONENTS) {
7369
- const selfName = getComponentName(Component);
7370
- if (selfName &&
7371
- (selfName === name ||
7372
- selfName === camelize(name) ||
7373
- selfName === capitalize(camelize(name)))) {
7374
- return Component;
7375
- }
7376
- }
7377
- const res =
7378
- // local registration
7379
- // check instance[type] first which is resolved for options API
7380
- resolve(instance[type] || Component[type], name) ||
7381
- // global registration
7382
- resolve(instance.appContext[type], name);
7383
- if (!res && maybeSelfReference) {
7384
- // fallback to implicit self-reference
7385
- return Component;
7386
- }
7387
- if (warnMissing && !res) {
7388
- const extra = type === COMPONENTS
7389
- ? `\nIf this is a native custom element, make sure to exclude it from ` +
7390
- `component resolution via compilerOptions.isCustomElement.`
7391
- : ``;
7392
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7888
+ // lookahead until we find the target anchor
7889
+ // we cannot rely on return value of hydrateChildren() because there
7890
+ // could be nested teleports
7891
+ let targetAnchor = targetNode;
7892
+ while (targetAnchor) {
7893
+ targetAnchor = nextSibling(targetAnchor);
7894
+ if (targetAnchor &&
7895
+ targetAnchor.nodeType === 8 &&
7896
+ targetAnchor.data === 'teleport anchor') {
7897
+ vnode.targetAnchor = targetAnchor;
7898
+ target._lpa =
7899
+ vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7900
+ break;
7901
+ }
7902
+ }
7903
+ hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7904
+ }
7393
7905
  }
7394
- return res;
7395
- }
7396
- else {
7397
- warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
7398
- `can only be used in render() or setup().`);
7399
7906
  }
7907
+ return vnode.anchor && nextSibling(vnode.anchor);
7400
7908
  }
7401
- function resolve(registry, name) {
7402
- return (registry &&
7403
- (registry[name] ||
7404
- registry[camelize(name)] ||
7405
- registry[capitalize(camelize(name))]));
7406
- }
7909
+ // Force-casted public typing for h and TSX props inference
7910
+ const Teleport = TeleportImpl;
7407
7911
 
7408
7912
  const Fragment = Symbol('Fragment' );
7409
7913
  const Text = Symbol('Text' );
@@ -7607,6 +8111,15 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
7607
8111
  if (children) {
7608
8112
  normalizeChildren(cloned, children);
7609
8113
  }
8114
+ if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
8115
+ if (cloned.shapeFlag & 6 /* COMPONENT */) {
8116
+ currentBlock[currentBlock.indexOf(type)] = cloned;
8117
+ }
8118
+ else {
8119
+ currentBlock.push(cloned);
8120
+ }
8121
+ }
8122
+ cloned.patchFlag |= -2 /* BAIL */;
7610
8123
  return cloned;
7611
8124
  }
7612
8125
  // class component normalization.
@@ -7682,602 +8195,196 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
7682
8195
  scopeId: vnode.scopeId,
7683
8196
  slotScopeIds: vnode.slotScopeIds,
7684
8197
  children: patchFlag === -1 /* HOISTED */ && isArray(children)
7685
- ? children.map(deepCloneVNode)
7686
- : children,
7687
- target: vnode.target,
7688
- targetAnchor: vnode.targetAnchor,
7689
- staticCount: vnode.staticCount,
7690
- shapeFlag: vnode.shapeFlag,
7691
- // if the vnode is cloned with extra props, we can no longer assume its
7692
- // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7693
- // note: preserve flag for fragments since they use the flag for children
7694
- // fast paths only.
7695
- patchFlag: extraProps && vnode.type !== Fragment
7696
- ? patchFlag === -1 // hoisted node
7697
- ? 16 /* FULL_PROPS */
7698
- : patchFlag | 16 /* FULL_PROPS */
7699
- : patchFlag,
7700
- dynamicProps: vnode.dynamicProps,
7701
- dynamicChildren: vnode.dynamicChildren,
7702
- appContext: vnode.appContext,
7703
- dirs: vnode.dirs,
7704
- transition: vnode.transition,
7705
- // These should technically only be non-null on mounted VNodes. However,
7706
- // they *should* be copied for kept-alive vnodes. So we just always copy
7707
- // them since them being non-null during a mount doesn't affect the logic as
7708
- // they will simply be overwritten.
7709
- component: vnode.component,
7710
- suspense: vnode.suspense,
7711
- ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7712
- ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7713
- el: vnode.el,
7714
- anchor: vnode.anchor
7715
- };
7716
- return cloned;
7717
- }
7718
- /**
7719
- * Dev only, for HMR of hoisted vnodes reused in v-for
7720
- * https://github.com/vitejs/vite/issues/2022
7721
- */
7722
- function deepCloneVNode(vnode) {
7723
- const cloned = cloneVNode(vnode);
7724
- if (isArray(vnode.children)) {
7725
- cloned.children = vnode.children.map(deepCloneVNode);
7726
- }
7727
- return cloned;
7728
- }
7729
- /**
7730
- * @private
7731
- */
7732
- function createTextVNode(text = ' ', flag = 0) {
7733
- return createVNode(Text, null, text, flag);
7734
- }
7735
- /**
7736
- * @private
7737
- */
7738
- function createStaticVNode(content, numberOfNodes) {
7739
- // A static vnode can contain multiple stringified elements, and the number
7740
- // of elements is necessary for hydration.
7741
- const vnode = createVNode(Static, null, content);
7742
- vnode.staticCount = numberOfNodes;
7743
- return vnode;
7744
- }
7745
- /**
7746
- * @private
7747
- */
7748
- function createCommentVNode(text = '',
7749
- // when used as the v-else branch, the comment node must be created as a
7750
- // block to ensure correct updates.
7751
- asBlock = false) {
7752
- return asBlock
7753
- ? (openBlock(), createBlock(Comment, null, text))
7754
- : createVNode(Comment, null, text);
7755
- }
7756
- function normalizeVNode(child) {
7757
- if (child == null || typeof child === 'boolean') {
7758
- // empty placeholder
7759
- return createVNode(Comment);
7760
- }
7761
- else if (isArray(child)) {
7762
- // fragment
7763
- return createVNode(Fragment, null,
7764
- // #3666, avoid reference pollution when reusing vnode
7765
- child.slice());
7766
- }
7767
- else if (typeof child === 'object') {
7768
- // already vnode, this should be the most common since compiled templates
7769
- // always produce all-vnode children arrays
7770
- return cloneIfMounted(child);
7771
- }
7772
- else {
7773
- // strings and numbers
7774
- return createVNode(Text, null, String(child));
7775
- }
7776
- }
7777
- // optimized normalization for template-compiled render fns
7778
- function cloneIfMounted(child) {
7779
- return child.el === null || child.memo ? child : cloneVNode(child);
7780
- }
7781
- function normalizeChildren(vnode, children) {
7782
- let type = 0;
7783
- const { shapeFlag } = vnode;
7784
- if (children == null) {
7785
- children = null;
7786
- }
7787
- else if (isArray(children)) {
7788
- type = 16 /* ARRAY_CHILDREN */;
7789
- }
7790
- else if (typeof children === 'object') {
7791
- if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7792
- // Normalize slot to plain children for plain element and Teleport
7793
- const slot = children.default;
7794
- if (slot) {
7795
- // _c marker is added by withCtx() indicating this is a compiled slot
7796
- slot._c && (slot._d = false);
7797
- normalizeChildren(vnode, slot());
7798
- slot._c && (slot._d = true);
7799
- }
7800
- return;
7801
- }
7802
- else {
7803
- type = 32 /* SLOTS_CHILDREN */;
7804
- const slotFlag = children._;
7805
- if (!slotFlag && !(InternalObjectKey in children)) {
7806
- children._ctx = currentRenderingInstance;
7807
- }
7808
- else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7809
- // a child component receives forwarded slots from the parent.
7810
- // its slot type is determined by its parent's slot type.
7811
- if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7812
- children._ = 1 /* STABLE */;
7813
- }
7814
- else {
7815
- children._ = 2 /* DYNAMIC */;
7816
- vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7817
- }
7818
- }
7819
- }
7820
- }
7821
- else if (isFunction(children)) {
7822
- children = { default: children, _ctx: currentRenderingInstance };
7823
- type = 32 /* SLOTS_CHILDREN */;
7824
- }
7825
- else {
7826
- children = String(children);
7827
- // force teleport children to array so it can be moved around
7828
- if (shapeFlag & 64 /* TELEPORT */) {
7829
- type = 16 /* ARRAY_CHILDREN */;
7830
- children = [createTextVNode(children)];
7831
- }
7832
- else {
7833
- type = 8 /* TEXT_CHILDREN */;
7834
- }
7835
- }
7836
- vnode.children = children;
7837
- vnode.shapeFlag |= type;
7838
- }
7839
- function mergeProps(...args) {
7840
- const ret = {};
7841
- for (let i = 0; i < args.length; i++) {
7842
- const toMerge = args[i];
7843
- for (const key in toMerge) {
7844
- if (key === 'class') {
7845
- if (ret.class !== toMerge.class) {
7846
- ret.class = normalizeClass([ret.class, toMerge.class]);
7847
- }
7848
- }
7849
- else if (key === 'style') {
7850
- ret.style = normalizeStyle([ret.style, toMerge.style]);
7851
- }
7852
- else if (isOn(key)) {
7853
- const existing = ret[key];
7854
- const incoming = toMerge[key];
7855
- if (incoming &&
7856
- existing !== incoming &&
7857
- !(isArray(existing) && existing.includes(incoming))) {
7858
- ret[key] = existing
7859
- ? [].concat(existing, incoming)
7860
- : incoming;
7861
- }
7862
- }
7863
- else if (key !== '') {
7864
- ret[key] = toMerge[key];
7865
- }
7866
- }
7867
- }
7868
- return ret;
7869
- }
7870
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7871
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7872
- vnode,
7873
- prevVNode
7874
- ]);
7875
- }
7876
-
7877
- /**
7878
- * Actual implementation
7879
- */
7880
- function renderList(source, renderItem, cache, index) {
7881
- let ret;
7882
- const cached = (cache && cache[index]);
7883
- if (isArray(source) || isString(source)) {
7884
- ret = new Array(source.length);
7885
- for (let i = 0, l = source.length; i < l; i++) {
7886
- ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
7887
- }
7888
- }
7889
- else if (typeof source === 'number') {
7890
- if (!Number.isInteger(source)) {
7891
- warn$1(`The v-for range expect an integer value but got ${source}.`);
7892
- return [];
7893
- }
7894
- ret = new Array(source);
7895
- for (let i = 0; i < source; i++) {
7896
- ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
7897
- }
7898
- }
7899
- else if (isObject(source)) {
7900
- if (source[Symbol.iterator]) {
7901
- ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
7902
- }
7903
- else {
7904
- const keys = Object.keys(source);
7905
- ret = new Array(keys.length);
7906
- for (let i = 0, l = keys.length; i < l; i++) {
7907
- const key = keys[i];
7908
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
7909
- }
7910
- }
7911
- }
7912
- else {
7913
- ret = [];
7914
- }
7915
- if (cache) {
7916
- cache[index] = ret;
7917
- }
7918
- return ret;
7919
- }
7920
-
8198
+ ? children.map(deepCloneVNode)
8199
+ : children,
8200
+ target: vnode.target,
8201
+ targetAnchor: vnode.targetAnchor,
8202
+ staticCount: vnode.staticCount,
8203
+ shapeFlag: vnode.shapeFlag,
8204
+ // if the vnode is cloned with extra props, we can no longer assume its
8205
+ // existing patch flag to be reliable and need to add the FULL_PROPS flag.
8206
+ // note: preserve flag for fragments since they use the flag for children
8207
+ // fast paths only.
8208
+ patchFlag: extraProps && vnode.type !== Fragment
8209
+ ? patchFlag === -1 // hoisted node
8210
+ ? 16 /* FULL_PROPS */
8211
+ : patchFlag | 16 /* FULL_PROPS */
8212
+ : patchFlag,
8213
+ dynamicProps: vnode.dynamicProps,
8214
+ dynamicChildren: vnode.dynamicChildren,
8215
+ appContext: vnode.appContext,
8216
+ dirs: vnode.dirs,
8217
+ transition: vnode.transition,
8218
+ // These should technically only be non-null on mounted VNodes. However,
8219
+ // they *should* be copied for kept-alive vnodes. So we just always copy
8220
+ // them since them being non-null during a mount doesn't affect the logic as
8221
+ // they will simply be overwritten.
8222
+ component: vnode.component,
8223
+ suspense: vnode.suspense,
8224
+ ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
8225
+ ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
8226
+ el: vnode.el,
8227
+ anchor: vnode.anchor
8228
+ };
8229
+ return cloned;
8230
+ }
7921
8231
  /**
7922
- * Compiler runtime helper for creating dynamic slots object
7923
- * @private
8232
+ * Dev only, for HMR of hoisted vnodes reused in v-for
8233
+ * https://github.com/vitejs/vite/issues/2022
7924
8234
  */
7925
- function createSlots(slots, dynamicSlots) {
7926
- for (let i = 0; i < dynamicSlots.length; i++) {
7927
- const slot = dynamicSlots[i];
7928
- // array of dynamic slot generated by <template v-for="..." #[...]>
7929
- if (isArray(slot)) {
7930
- for (let j = 0; j < slot.length; j++) {
7931
- slots[slot[j].name] = slot[j].fn;
7932
- }
7933
- }
7934
- else if (slot) {
7935
- // conditional single slot generated by <template v-if="..." #foo>
7936
- slots[slot.name] = slot.fn;
7937
- }
8235
+ function deepCloneVNode(vnode) {
8236
+ const cloned = cloneVNode(vnode);
8237
+ if (isArray(vnode.children)) {
8238
+ cloned.children = vnode.children.map(deepCloneVNode);
7938
8239
  }
7939
- return slots;
7940
- }
7941
-
8240
+ return cloned;
8241
+ }
7942
8242
  /**
7943
- * Compiler runtime helper for rendering `<slot/>`
7944
8243
  * @private
7945
8244
  */
7946
- function renderSlot(slots, name, props = {},
7947
- // this is not a user-facing function, so the fallback is always generated by
7948
- // the compiler and guaranteed to be a function returning an array
7949
- fallback, noSlotted) {
7950
- if (currentRenderingInstance.isCE) {
7951
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
7952
- }
7953
- let slot = slots[name];
7954
- if (slot && slot.length > 1) {
7955
- warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
7956
- `function. You need to mark this component with $dynamic-slots in the ` +
7957
- `parent template.`);
7958
- slot = () => [];
7959
- }
7960
- // a compiled slot disables block tracking by default to avoid manual
7961
- // invocation interfering with template-based block tracking, but in
7962
- // `renderSlot` we can be sure that it's template-based so we can force
7963
- // enable it.
7964
- if (slot && slot._c) {
7965
- slot._d = false;
7966
- }
7967
- openBlock();
7968
- const validSlotContent = slot && ensureValidVNode(slot(props));
7969
- const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
7970
- ? 64 /* STABLE_FRAGMENT */
7971
- : -2 /* BAIL */);
7972
- if (!noSlotted && rendered.scopeId) {
7973
- rendered.slotScopeIds = [rendered.scopeId + '-s'];
7974
- }
7975
- if (slot && slot._c) {
7976
- slot._d = true;
7977
- }
7978
- return rendered;
8245
+ function createTextVNode(text = ' ', flag = 0) {
8246
+ return createVNode(Text, null, text, flag);
7979
8247
  }
7980
- function ensureValidVNode(vnodes) {
7981
- return vnodes.some(child => {
7982
- if (!isVNode(child))
7983
- return true;
7984
- if (child.type === Comment)
7985
- return false;
7986
- if (child.type === Fragment &&
7987
- !ensureValidVNode(child.children))
7988
- return false;
7989
- return true;
7990
- })
7991
- ? vnodes
7992
- : null;
7993
- }
7994
-
7995
8248
  /**
7996
- * For prefixing keys in v-on="obj" with "on"
7997
8249
  * @private
7998
8250
  */
7999
- function toHandlers(obj) {
8000
- const ret = {};
8001
- if (!isObject(obj)) {
8002
- warn$1(`v-on with no argument expects an object value.`);
8003
- return ret;
8004
- }
8005
- for (const key in obj) {
8006
- ret[toHandlerKey(key)] = obj[key];
8007
- }
8008
- return ret;
8009
- }
8010
-
8011
- /**
8012
- * #2437 In Vue 3, functional components do not have a public instance proxy but
8013
- * they exist in the internal parent chain. For code that relies on traversing
8014
- * public $parent chains, skip functional ones and go to the parent instead.
8015
- */
8016
- const getPublicInstance = (i) => {
8017
- if (!i)
8018
- return null;
8019
- if (isStatefulComponent(i))
8020
- return getExposeProxy(i) || i.proxy;
8021
- return getPublicInstance(i.parent);
8022
- };
8023
- const publicPropertiesMap = extend(Object.create(null), {
8024
- $: i => i,
8025
- $el: i => i.vnode.el,
8026
- $data: i => i.data,
8027
- $props: i => (shallowReadonly(i.props) ),
8028
- $attrs: i => (shallowReadonly(i.attrs) ),
8029
- $slots: i => (shallowReadonly(i.slots) ),
8030
- $refs: i => (shallowReadonly(i.refs) ),
8031
- $parent: i => getPublicInstance(i.parent),
8032
- $root: i => getPublicInstance(i.root),
8033
- $emit: i => i.emit,
8034
- $options: i => (resolveMergedOptions(i) ),
8035
- $forceUpdate: i => () => queueJob(i.update),
8036
- $nextTick: i => nextTick.bind(i.proxy),
8037
- $watch: i => (instanceWatch.bind(i) )
8038
- });
8039
- const PublicInstanceProxyHandlers = {
8040
- get({ _: instance }, key) {
8041
- const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
8042
- // for internal formatters to know that this is a Vue instance
8043
- if (key === '__isVue') {
8044
- return true;
8045
- }
8046
- // prioritize <script setup> bindings during dev.
8047
- // this allows even properties that start with _ or $ to be used - so that
8048
- // it aligns with the production behavior where the render fn is inlined and
8049
- // indeed has access to all declared variables.
8050
- if (setupState !== EMPTY_OBJ &&
8051
- setupState.__isScriptSetup &&
8052
- hasOwn(setupState, key)) {
8053
- return setupState[key];
8054
- }
8055
- // data / props / ctx
8056
- // This getter gets called for every property access on the render context
8057
- // during render and is a major hotspot. The most expensive part of this
8058
- // is the multiple hasOwn() calls. It's much faster to do a simple property
8059
- // access on a plain object, so we use an accessCache object (with null
8060
- // prototype) to memoize what access type a key corresponds to.
8061
- let normalizedProps;
8062
- if (key[0] !== '$') {
8063
- const n = accessCache[key];
8064
- if (n !== undefined) {
8065
- switch (n) {
8066
- case 1 /* SETUP */:
8067
- return setupState[key];
8068
- case 2 /* DATA */:
8069
- return data[key];
8070
- case 4 /* CONTEXT */:
8071
- return ctx[key];
8072
- case 3 /* PROPS */:
8073
- return props[key];
8074
- // default: just fallthrough
8075
- }
8076
- }
8077
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8078
- accessCache[key] = 1 /* SETUP */;
8079
- return setupState[key];
8080
- }
8081
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8082
- accessCache[key] = 2 /* DATA */;
8083
- return data[key];
8084
- }
8085
- else if (
8086
- // only cache other properties when instance has declared (thus stable)
8087
- // props
8088
- (normalizedProps = instance.propsOptions[0]) &&
8089
- hasOwn(normalizedProps, key)) {
8090
- accessCache[key] = 3 /* PROPS */;
8091
- return props[key];
8092
- }
8093
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8094
- accessCache[key] = 4 /* CONTEXT */;
8095
- return ctx[key];
8096
- }
8097
- else if (shouldCacheAccess) {
8098
- accessCache[key] = 0 /* OTHER */;
8099
- }
8100
- }
8101
- const publicGetter = publicPropertiesMap[key];
8102
- let cssModule, globalProperties;
8103
- // public $xxx properties
8104
- if (publicGetter) {
8105
- if (key === '$attrs') {
8106
- track(instance, "get" /* GET */, key);
8107
- markAttrsAccessed();
8108
- }
8109
- return publicGetter(instance);
8110
- }
8111
- else if (
8112
- // css module (injected by vue-loader)
8113
- (cssModule = type.__cssModules) &&
8114
- (cssModule = cssModule[key])) {
8115
- return cssModule;
8116
- }
8117
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8118
- // user may set custom properties to `this` that start with `$`
8119
- accessCache[key] = 4 /* CONTEXT */;
8120
- return ctx[key];
8121
- }
8122
- else if (
8123
- // global properties
8124
- ((globalProperties = appContext.config.globalProperties),
8125
- hasOwn(globalProperties, key))) {
8126
- {
8127
- return globalProperties[key];
8128
- }
8129
- }
8130
- else if (currentRenderingInstance &&
8131
- (!isString(key) ||
8132
- // #1091 avoid internal isRef/isVNode checks on component instance leading
8133
- // to infinite warning loop
8134
- key.indexOf('__v') !== 0)) {
8135
- if (data !== EMPTY_OBJ &&
8136
- (key[0] === '$' || key[0] === '_') &&
8137
- hasOwn(data, key)) {
8138
- warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
8139
- `character ("$" or "_") and is not proxied on the render context.`);
8140
- }
8141
- else if (instance === currentRenderingInstance) {
8142
- warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
8143
- `but is not defined on instance.`);
8251
+ function createStaticVNode(content, numberOfNodes) {
8252
+ // A static vnode can contain multiple stringified elements, and the number
8253
+ // of elements is necessary for hydration.
8254
+ const vnode = createVNode(Static, null, content);
8255
+ vnode.staticCount = numberOfNodes;
8256
+ return vnode;
8257
+ }
8258
+ /**
8259
+ * @private
8260
+ */
8261
+ function createCommentVNode(text = '',
8262
+ // when used as the v-else branch, the comment node must be created as a
8263
+ // block to ensure correct updates.
8264
+ asBlock = false) {
8265
+ return asBlock
8266
+ ? (openBlock(), createBlock(Comment, null, text))
8267
+ : createVNode(Comment, null, text);
8268
+ }
8269
+ function normalizeVNode(child) {
8270
+ if (child == null || typeof child === 'boolean') {
8271
+ // empty placeholder
8272
+ return createVNode(Comment);
8273
+ }
8274
+ else if (isArray(child)) {
8275
+ // fragment
8276
+ return createVNode(Fragment, null,
8277
+ // #3666, avoid reference pollution when reusing vnode
8278
+ child.slice());
8279
+ }
8280
+ else if (typeof child === 'object') {
8281
+ // already vnode, this should be the most common since compiled templates
8282
+ // always produce all-vnode children arrays
8283
+ return cloneIfMounted(child);
8284
+ }
8285
+ else {
8286
+ // strings and numbers
8287
+ return createVNode(Text, null, String(child));
8288
+ }
8289
+ }
8290
+ // optimized normalization for template-compiled render fns
8291
+ function cloneIfMounted(child) {
8292
+ return child.el === null || child.memo ? child : cloneVNode(child);
8293
+ }
8294
+ function normalizeChildren(vnode, children) {
8295
+ let type = 0;
8296
+ const { shapeFlag } = vnode;
8297
+ if (children == null) {
8298
+ children = null;
8299
+ }
8300
+ else if (isArray(children)) {
8301
+ type = 16 /* ARRAY_CHILDREN */;
8302
+ }
8303
+ else if (typeof children === 'object') {
8304
+ if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
8305
+ // Normalize slot to plain children for plain element and Teleport
8306
+ const slot = children.default;
8307
+ if (slot) {
8308
+ // _c marker is added by withCtx() indicating this is a compiled slot
8309
+ slot._c && (slot._d = false);
8310
+ normalizeChildren(vnode, slot());
8311
+ slot._c && (slot._d = true);
8144
8312
  }
8145
- }
8146
- },
8147
- set({ _: instance }, key, value) {
8148
- const { data, setupState, ctx } = instance;
8149
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8150
- setupState[key] = value;
8151
- return true;
8152
- }
8153
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8154
- data[key] = value;
8155
- return true;
8156
- }
8157
- else if (hasOwn(instance.props, key)) {
8158
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
8159
- return false;
8160
- }
8161
- if (key[0] === '$' && key.slice(1) in instance) {
8162
- warn$1(`Attempting to mutate public property "${key}". ` +
8163
- `Properties starting with $ are reserved and readonly.`, instance);
8164
- return false;
8313
+ return;
8165
8314
  }
8166
8315
  else {
8167
- if (key in instance.appContext.config.globalProperties) {
8168
- Object.defineProperty(ctx, key, {
8169
- enumerable: true,
8170
- configurable: true,
8171
- value
8172
- });
8316
+ type = 32 /* SLOTS_CHILDREN */;
8317
+ const slotFlag = children._;
8318
+ if (!slotFlag && !(InternalObjectKey in children)) {
8319
+ children._ctx = currentRenderingInstance;
8173
8320
  }
8174
- else {
8175
- ctx[key] = value;
8321
+ else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
8322
+ // a child component receives forwarded slots from the parent.
8323
+ // its slot type is determined by its parent's slot type.
8324
+ if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
8325
+ children._ = 1 /* STABLE */;
8326
+ }
8327
+ else {
8328
+ children._ = 2 /* DYNAMIC */;
8329
+ vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
8330
+ }
8176
8331
  }
8177
8332
  }
8178
- return true;
8179
- },
8180
- has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
8181
- let normalizedProps;
8182
- return (!!accessCache[key] ||
8183
- (data !== EMPTY_OBJ && hasOwn(data, key)) ||
8184
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
8185
- ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
8186
- hasOwn(ctx, key) ||
8187
- hasOwn(publicPropertiesMap, key) ||
8188
- hasOwn(appContext.config.globalProperties, key));
8189
- },
8190
- defineProperty(target, key, descriptor) {
8191
- if (descriptor.get != null) {
8192
- // invalidate key cache of a getter based property #5417
8193
- target.$.accessCache[key] = 0;
8194
- }
8195
- else if (hasOwn(descriptor, 'value')) {
8196
- this.set(target, key, descriptor.value, null);
8197
- }
8198
- return Reflect.defineProperty(target, key, descriptor);
8199
8333
  }
8200
- };
8201
- {
8202
- PublicInstanceProxyHandlers.ownKeys = (target) => {
8203
- warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
8204
- `The keys will be empty in production mode to avoid performance overhead.`);
8205
- return Reflect.ownKeys(target);
8206
- };
8207
- }
8208
- const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
8209
- get(target, key) {
8210
- // fast path for unscopables when using `with` block
8211
- if (key === Symbol.unscopables) {
8212
- return;
8334
+ else if (isFunction(children)) {
8335
+ children = { default: children, _ctx: currentRenderingInstance };
8336
+ type = 32 /* SLOTS_CHILDREN */;
8337
+ }
8338
+ else {
8339
+ children = String(children);
8340
+ // force teleport children to array so it can be moved around
8341
+ if (shapeFlag & 64 /* TELEPORT */) {
8342
+ type = 16 /* ARRAY_CHILDREN */;
8343
+ children = [createTextVNode(children)];
8213
8344
  }
8214
- return PublicInstanceProxyHandlers.get(target, key, target);
8215
- },
8216
- has(_, key) {
8217
- const has = key[0] !== '_' && !isGloballyWhitelisted(key);
8218
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
8219
- warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
8345
+ else {
8346
+ type = 8 /* TEXT_CHILDREN */;
8220
8347
  }
8221
- return has;
8222
- }
8223
- });
8224
- // dev only
8225
- // In dev mode, the proxy target exposes the same properties as seen on `this`
8226
- // for easier console inspection. In prod mode it will be an empty object so
8227
- // these properties definitions can be skipped.
8228
- function createDevRenderContext(instance) {
8229
- const target = {};
8230
- // expose internal instance for proxy handlers
8231
- Object.defineProperty(target, `_`, {
8232
- configurable: true,
8233
- enumerable: false,
8234
- get: () => instance
8235
- });
8236
- // expose public properties
8237
- Object.keys(publicPropertiesMap).forEach(key => {
8238
- Object.defineProperty(target, key, {
8239
- configurable: true,
8240
- enumerable: false,
8241
- get: () => publicPropertiesMap[key](instance),
8242
- // intercepted by the proxy so no need for implementation,
8243
- // but needed to prevent set errors
8244
- set: NOOP
8245
- });
8246
- });
8247
- return target;
8248
- }
8249
- // dev only
8250
- function exposePropsOnRenderContext(instance) {
8251
- const { ctx, propsOptions: [propsOptions] } = instance;
8252
- if (propsOptions) {
8253
- Object.keys(propsOptions).forEach(key => {
8254
- Object.defineProperty(ctx, key, {
8255
- enumerable: true,
8256
- configurable: true,
8257
- get: () => instance.props[key],
8258
- set: NOOP
8259
- });
8260
- });
8261
8348
  }
8349
+ vnode.children = children;
8350
+ vnode.shapeFlag |= type;
8262
8351
  }
8263
- // dev only
8264
- function exposeSetupStateOnRenderContext(instance) {
8265
- const { ctx, setupState } = instance;
8266
- Object.keys(toRaw(setupState)).forEach(key => {
8267
- if (!setupState.__isScriptSetup) {
8268
- if (key[0] === '$' || key[0] === '_') {
8269
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8270
- `which are reserved prefixes for Vue internals.`);
8271
- return;
8352
+ function mergeProps(...args) {
8353
+ const ret = {};
8354
+ for (let i = 0; i < args.length; i++) {
8355
+ const toMerge = args[i];
8356
+ for (const key in toMerge) {
8357
+ if (key === 'class') {
8358
+ if (ret.class !== toMerge.class) {
8359
+ ret.class = normalizeClass([ret.class, toMerge.class]);
8360
+ }
8361
+ }
8362
+ else if (key === 'style') {
8363
+ ret.style = normalizeStyle([ret.style, toMerge.style]);
8364
+ }
8365
+ else if (isOn(key)) {
8366
+ const existing = ret[key];
8367
+ const incoming = toMerge[key];
8368
+ if (incoming &&
8369
+ existing !== incoming &&
8370
+ !(isArray(existing) && existing.includes(incoming))) {
8371
+ ret[key] = existing
8372
+ ? [].concat(existing, incoming)
8373
+ : incoming;
8374
+ }
8375
+ }
8376
+ else if (key !== '') {
8377
+ ret[key] = toMerge[key];
8272
8378
  }
8273
- Object.defineProperty(ctx, key, {
8274
- enumerable: true,
8275
- configurable: true,
8276
- get: () => setupState[key],
8277
- set: NOOP
8278
- });
8279
8379
  }
8280
- });
8380
+ }
8381
+ return ret;
8382
+ }
8383
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8384
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8385
+ vnode,
8386
+ prevVNode
8387
+ ]);
8281
8388
  }
8282
8389
 
8283
8390
  const emptyAppContext = createAppContext();
@@ -8306,7 +8413,7 @@ function createComponentInstance(vnode, parent, suspense) {
8306
8413
  provides: parent ? parent.provides : Object.create(appContext.provides),
8307
8414
  accessCache: null,
8308
8415
  renderCache: [],
8309
- // local resovled assets
8416
+ // local resolved assets
8310
8417
  components: null,
8311
8418
  directives: null,
8312
8419
  // resolved props and emits options
@@ -8398,6 +8505,7 @@ function setupComponent(instance, isSSR = false) {
8398
8505
  return setupResult;
8399
8506
  }
8400
8507
  function setupStatefulComponent(instance, isSSR) {
8508
+ var _a;
8401
8509
  const Component = instance.type;
8402
8510
  {
8403
8511
  if (Component.name) {
@@ -8455,6 +8563,13 @@ function setupStatefulComponent(instance, isSSR) {
8455
8563
  // async setup returned Promise.
8456
8564
  // bail here and wait for re-entry.
8457
8565
  instance.asyncDep = setupResult;
8566
+ if (!instance.suspense) {
8567
+ const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
8568
+ warn$1(`Component <${name}>: setup function returned a promise, but no ` +
8569
+ `<Suspense> boundary was found in the parent component tree. ` +
8570
+ `A component with async setup() must be nested in a <Suspense> ` +
8571
+ `in order to be rendered.`);
8572
+ }
8458
8573
  }
8459
8574
  }
8460
8575
  else {
@@ -9059,7 +9174,7 @@ function isMemoSame(cached, memo) {
9059
9174
  return false;
9060
9175
  }
9061
9176
  for (let i = 0; i < prev.length; i++) {
9062
- if (prev[i] !== memo[i]) {
9177
+ if (hasChanged(prev[i], memo[i])) {
9063
9178
  return false;
9064
9179
  }
9065
9180
  }
@@ -9071,7 +9186,7 @@ function isMemoSame(cached, memo) {
9071
9186
  }
9072
9187
 
9073
9188
  // Core API ------------------------------------------------------------------
9074
- const version = "3.2.32";
9189
+ const version = "3.2.34";
9075
9190
  /**
9076
9191
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9077
9192
  * @internal
@@ -9088,7 +9203,7 @@ const compatUtils = (null);
9088
9203
 
9089
9204
  const svgNS = 'http://www.w3.org/2000/svg';
9090
9205
  const doc = (typeof document !== 'undefined' ? document : null);
9091
- const templateContainer = doc && doc.createElement('template');
9206
+ const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
9092
9207
  const nodeOps = {
9093
9208
  insert: (child, parent, anchor) => {
9094
9209
  parent.insertBefore(child, anchor || null);
@@ -9239,6 +9354,8 @@ function setStyle(style, name, val) {
9239
9354
  val.forEach(v => setStyle(style, name, v));
9240
9355
  }
9241
9356
  else {
9357
+ if (val == null)
9358
+ val = '';
9242
9359
  if (name.startsWith('--')) {
9243
9360
  // custom property definition
9244
9361
  style.setProperty(name, val);
@@ -9333,31 +9450,28 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9333
9450
  }
9334
9451
  return;
9335
9452
  }
9453
+ let needRemove = false;
9336
9454
  if (value === '' || value == null) {
9337
9455
  const type = typeof el[key];
9338
9456
  if (type === 'boolean') {
9339
9457
  // e.g. <select multiple> compiles to { multiple: '' }
9340
- el[key] = includeBooleanAttr(value);
9341
- return;
9458
+ value = includeBooleanAttr(value);
9342
9459
  }
9343
9460
  else if (value == null && type === 'string') {
9344
9461
  // e.g. <div :id="null">
9345
- el[key] = '';
9346
- el.removeAttribute(key);
9347
- return;
9462
+ value = '';
9463
+ needRemove = true;
9348
9464
  }
9349
9465
  else if (type === 'number') {
9350
9466
  // e.g. <img :width="null">
9351
9467
  // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9352
- try {
9353
- el[key] = 0;
9354
- }
9355
- catch (_a) { }
9356
- el.removeAttribute(key);
9357
- return;
9468
+ value = 0;
9469
+ needRemove = true;
9358
9470
  }
9359
9471
  }
9360
- // some properties perform value validation and throw
9472
+ // some properties perform value validation and throw,
9473
+ // some properties has getter, no setter, will error in 'use strict'
9474
+ // eg. <select :type="null"></select> <select :willValidate="null"></select>
9361
9475
  try {
9362
9476
  el[key] = value;
9363
9477
  }
@@ -9367,31 +9481,35 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9367
9481
  `value ${value} is invalid.`, e);
9368
9482
  }
9369
9483
  }
9484
+ needRemove && el.removeAttribute(key);
9370
9485
  }
9371
9486
 
9372
9487
  // Async edge case fix requires storing an event listener's attach timestamp.
9373
- let _getNow = Date.now;
9374
- let skipTimestampCheck = false;
9375
- if (typeof window !== 'undefined') {
9376
- // Determine what event timestamp the browser is using. Annoyingly, the
9377
- // timestamp can either be hi-res (relative to page load) or low-res
9378
- // (relative to UNIX epoch), so in order to compare time we have to use the
9379
- // same timestamp type when saving the flush timestamp.
9380
- if (_getNow() > document.createEvent('Event').timeStamp) {
9381
- // if the low-res timestamp which is bigger than the event timestamp
9382
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9383
- // and we need to use the hi-res version for event listeners as well.
9384
- _getNow = () => performance.now();
9385
- }
9386
- // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9387
- // and does not fire microtasks in between event propagation, so safe to exclude.
9388
- const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9389
- skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9390
- }
9488
+ const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
9489
+ let _getNow = Date.now;
9490
+ let skipTimestampCheck = false;
9491
+ if (typeof window !== 'undefined') {
9492
+ // Determine what event timestamp the browser is using. Annoyingly, the
9493
+ // timestamp can either be hi-res (relative to page load) or low-res
9494
+ // (relative to UNIX epoch), so in order to compare time we have to use the
9495
+ // same timestamp type when saving the flush timestamp.
9496
+ if (Date.now() > document.createEvent('Event').timeStamp) {
9497
+ // if the low-res timestamp which is bigger than the event timestamp
9498
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9499
+ // and we need to use the hi-res version for event listeners as well.
9500
+ _getNow = () => performance.now();
9501
+ }
9502
+ // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9503
+ // and does not fire microtasks in between event propagation, so safe to exclude.
9504
+ const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9505
+ skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9506
+ }
9507
+ return [_getNow, skipTimestampCheck];
9508
+ })();
9391
9509
  // To avoid the overhead of repeatedly calling performance.now(), we cache
9392
9510
  // and use the same timestamp for all event listeners attached in the same tick.
9393
9511
  let cachedNow = 0;
9394
- const p = Promise.resolve();
9512
+ const p = /*#__PURE__*/ Promise.resolve();
9395
9513
  const reset = () => {
9396
9514
  cachedNow = 0;
9397
9515
  };
@@ -9516,13 +9634,13 @@ function shouldSetAsProp(el, key, value, isSVG) {
9516
9634
  }
9517
9635
  return false;
9518
9636
  }
9519
- // spellcheck and draggable are numerated attrs, however their
9520
- // corresponding DOM properties are actually booleans - this leads to
9521
- // setting it with a string "false" value leading it to be coerced to
9522
- // `true`, so we need to always treat them as attributes.
9637
+ // these are enumerated attrs, however their corresponding DOM properties
9638
+ // are actually booleans - this leads to setting it with a string "false"
9639
+ // value leading it to be coerced to `true`, so we need to always treat
9640
+ // them as attributes.
9523
9641
  // Note that `contentEditable` doesn't have this problem: its DOM
9524
9642
  // property is also enumerated string values.
9525
- if (key === 'spellcheck' || key === 'draggable') {
9643
+ if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
9526
9644
  return false;
9527
9645
  }
9528
9646
  // #1787, #2840 form property on form elements is readonly and must be set as
@@ -9545,11 +9663,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
9545
9663
  return key in el;
9546
9664
  }
9547
9665
 
9548
- function defineCustomElement(options, hydate) {
9666
+ function defineCustomElement(options, hydrate) {
9549
9667
  const Comp = defineComponent(options);
9550
9668
  class VueCustomElement extends VueElement {
9551
9669
  constructor(initialProps) {
9552
- super(Comp, initialProps, hydate);
9670
+ super(Comp, initialProps, hydrate);
9553
9671
  }
9554
9672
  }
9555
9673
  VueCustomElement.def = Comp;
@@ -9909,7 +10027,10 @@ function resolveTransitionProps(rawProps) {
9909
10027
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
9910
10028
  done && done();
9911
10029
  };
10030
+ let isLeaving = false;
9912
10031
  const finishLeave = (el, done) => {
10032
+ isLeaving = false;
10033
+ removeTransitionClass(el, leaveFromClass);
9913
10034
  removeTransitionClass(el, leaveToClass);
9914
10035
  removeTransitionClass(el, leaveActiveClass);
9915
10036
  done && done();
@@ -9942,12 +10063,17 @@ function resolveTransitionProps(rawProps) {
9942
10063
  onEnter: makeEnterHook(false),
9943
10064
  onAppear: makeEnterHook(true),
9944
10065
  onLeave(el, done) {
10066
+ isLeaving = true;
9945
10067
  const resolve = () => finishLeave(el, done);
9946
10068
  addTransitionClass(el, leaveFromClass);
9947
10069
  // force reflow so *-leave-from classes immediately take effect (#2593)
9948
10070
  forceReflow();
9949
10071
  addTransitionClass(el, leaveActiveClass);
9950
10072
  nextFrame(() => {
10073
+ if (!isLeaving) {
10074
+ // cancelled
10075
+ return;
10076
+ }
9951
10077
  removeTransitionClass(el, leaveFromClass);
9952
10078
  addTransitionClass(el, leaveToClass);
9953
10079
  if (!hasExplicitCallback(onLeave)) {
@@ -10239,7 +10365,8 @@ function hasCSSTransform(el, root, moveClass) {
10239
10365
  }
10240
10366
 
10241
10367
  const getModelAssigner = (vnode) => {
10242
- const fn = vnode.props['onUpdate:modelValue'];
10368
+ const fn = vnode.props['onUpdate:modelValue'] ||
10369
+ (false );
10243
10370
  return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10244
10371
  };
10245
10372
  function onCompositionStart(e) {
@@ -10249,14 +10376,9 @@ function onCompositionEnd(e) {
10249
10376
  const target = e.target;
10250
10377
  if (target.composing) {
10251
10378
  target.composing = false;
10252
- trigger$1(target, 'input');
10379
+ target.dispatchEvent(new Event('input'));
10253
10380
  }
10254
10381
  }
10255
- function trigger$1(el, type) {
10256
- const e = document.createEvent('HTMLEvents');
10257
- e.initEvent(type, true, true);
10258
- el.dispatchEvent(e);
10259
- }
10260
10382
  // We are exporting the v-model runtime directly as vnode hooks so that it can
10261
10383
  // be tree-shaken in case v-model is never used.
10262
10384
  const vModelText = {
@@ -10270,7 +10392,7 @@ const vModelText = {
10270
10392
  if (trim) {
10271
10393
  domValue = domValue.trim();
10272
10394
  }
10273
- else if (castToNumber) {
10395
+ if (castToNumber) {
10274
10396
  domValue = toNumber(domValue);
10275
10397
  }
10276
10398
  el._assign(domValue);
@@ -10299,7 +10421,7 @@ const vModelText = {
10299
10421
  // avoid clearing unresolved text. #2302
10300
10422
  if (el.composing)
10301
10423
  return;
10302
- if (document.activeElement === el) {
10424
+ if (document.activeElement === el && el.type !== 'range') {
10303
10425
  if (lazy) {
10304
10426
  return;
10305
10427
  }
@@ -10469,27 +10591,25 @@ const vModelDynamic = {
10469
10591
  callModelHook(el, binding, vnode, prevVNode, 'updated');
10470
10592
  }
10471
10593
  };
10472
- function callModelHook(el, binding, vnode, prevVNode, hook) {
10473
- let modelToUse;
10474
- switch (el.tagName) {
10594
+ function resolveDynamicModel(tagName, type) {
10595
+ switch (tagName) {
10475
10596
  case 'SELECT':
10476
- modelToUse = vModelSelect;
10477
- break;
10597
+ return vModelSelect;
10478
10598
  case 'TEXTAREA':
10479
- modelToUse = vModelText;
10480
- break;
10599
+ return vModelText;
10481
10600
  default:
10482
- switch (vnode.props && vnode.props.type) {
10601
+ switch (type) {
10483
10602
  case 'checkbox':
10484
- modelToUse = vModelCheckbox;
10485
- break;
10603
+ return vModelCheckbox;
10486
10604
  case 'radio':
10487
- modelToUse = vModelRadio;
10488
- break;
10605
+ return vModelRadio;
10489
10606
  default:
10490
- modelToUse = vModelText;
10607
+ return vModelText;
10491
10608
  }
10492
10609
  }
10610
+ }
10611
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
10612
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
10493
10613
  const fn = modelToUse[hook];
10494
10614
  fn && fn(el, binding, vnode, prevVNode);
10495
10615
  }
@@ -10589,7 +10709,7 @@ function setDisplay(el, value) {
10589
10709
  el.style.display = value ? el._vod : 'none';
10590
10710
  }
10591
10711
 
10592
- const rendererOptions = extend({ patchProp }, nodeOps);
10712
+ const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
10593
10713
  // lazy create the renderer - this makes core renderer logic tree-shakable
10594
10714
  // in case the user only imports reactivity utilities from Vue.
10595
10715
  let renderer;