@vue/runtime-dom 3.2.33 → 3.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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';
@@ -702,17 +707,28 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
702
707
  }
703
708
  function triggerEffects(dep, debuggerEventExtraInfo) {
704
709
  // spread into array for stabilization
705
- for (const effect of isArray(dep) ? dep : [...dep]) {
706
- if (effect !== activeEffect || effect.allowRecurse) {
707
- if (effect.onTrigger) {
708
- effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
709
- }
710
- if (effect.scheduler) {
711
- effect.scheduler();
712
- }
713
- else {
714
- effect.run();
715
- }
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();
716
732
  }
717
733
  }
718
734
  }
@@ -721,6 +737,10 @@ const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
721
737
  const builtInSymbols = new Set(
722
738
  /*#__PURE__*/
723
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')
724
744
  .map(key => Symbol[key])
725
745
  .filter(isSymbol));
726
746
  const get = /*#__PURE__*/ createGetter();
@@ -794,9 +814,8 @@ function createGetter(isReadonly = false, shallow = false) {
794
814
  return res;
795
815
  }
796
816
  if (isRef(res)) {
797
- // ref unwrapping - does not apply for Array + integer key.
798
- const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
799
- return shouldUnwrap ? res.value : res;
817
+ // ref unwrapping - skip unwrap for Array + integer key.
818
+ return targetIsArray && isIntegerKey(key) ? res : res.value;
800
819
  }
801
820
  if (isObject(res)) {
802
821
  // Convert returned value into a proxy as well. we do the isObject check
@@ -902,10 +921,12 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
902
921
  target = target["__v_raw" /* RAW */];
903
922
  const rawTarget = toRaw(target);
904
923
  const rawKey = toRaw(key);
905
- if (key !== rawKey) {
906
- !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);
907
929
  }
908
- !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
909
930
  const { has } = getProto(rawTarget);
910
931
  const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
911
932
  if (has.call(rawTarget, key)) {
@@ -924,10 +945,12 @@ function has$1(key, isReadonly = false) {
924
945
  const target = this["__v_raw" /* RAW */];
925
946
  const rawTarget = toRaw(target);
926
947
  const rawKey = toRaw(key);
927
- if (key !== rawKey) {
928
- !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);
929
953
  }
930
- !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
931
954
  return key === rawKey
932
955
  ? target.has(key)
933
956
  : target.has(key) || target.has(rawKey);
@@ -1253,7 +1276,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1253
1276
  if (existingProxy) {
1254
1277
  return existingProxy;
1255
1278
  }
1256
- // only a whitelist of value types can be observed.
1279
+ // only specific value types can be observed.
1257
1280
  const targetType = getTargetType(target);
1258
1281
  if (targetType === 0 /* INVALID */) {
1259
1282
  return target;
@@ -1803,6 +1826,8 @@ function flushPreFlushCbs(seen, parentJob = null) {
1803
1826
  }
1804
1827
  }
1805
1828
  function flushPostFlushCbs(seen) {
1829
+ // flush any pre cbs queued during the flush (e.g. pre watchers)
1830
+ flushPreFlushCbs();
1806
1831
  if (pendingPostFlushCbs.length) {
1807
1832
  const deduped = [...new Set(pendingPostFlushCbs)];
1808
1833
  pendingPostFlushCbs.length = 0;
@@ -2062,7 +2087,6 @@ function setDevtoolsHook(hook, target) {
2062
2087
  // handle late devtools injection - only do this if we are in an actual
2063
2088
  // browser environment to avoid the timer handle stalling test runner exit
2064
2089
  // (#4815)
2065
- // eslint-disable-next-line no-restricted-globals
2066
2090
  typeof window !== 'undefined' &&
2067
2091
  // some envs mock window but not fully
2068
2092
  window.HTMLElement &&
@@ -2156,7 +2180,7 @@ function emit$1(instance, event, ...rawArgs) {
2156
2180
  if (trim) {
2157
2181
  args = rawArgs.map(a => a.trim());
2158
2182
  }
2159
- else if (number) {
2183
+ if (number) {
2160
2184
  args = rawArgs.map(toNumber);
2161
2185
  }
2162
2186
  }
@@ -2454,6 +2478,8 @@ function renderComponentRoot(instance) {
2454
2478
  warn$1(`Runtime directive used on component with non-element root node. ` +
2455
2479
  `The directives will not function as intended.`);
2456
2480
  }
2481
+ // clone before mutating since the root may be a hoisted vnode
2482
+ root = cloneVNode(root);
2457
2483
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2458
2484
  }
2459
2485
  // inherit transition data
@@ -3156,7 +3182,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3156
3182
  }
3157
3183
  else if (isArray(source)) {
3158
3184
  isMultiSource = true;
3159
- forceTrigger = source.some(isReactive);
3185
+ forceTrigger = source.some(s => isReactive(s) || isShallow(s));
3160
3186
  getter = () => source.map(s => {
3161
3187
  if (isRef(s)) {
3162
3188
  return s.value;
@@ -3248,16 +3274,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3248
3274
  }
3249
3275
  else {
3250
3276
  // default: 'pre'
3251
- scheduler = () => {
3252
- if (!instance || instance.isMounted) {
3253
- queuePreFlushCb(job);
3254
- }
3255
- else {
3256
- // with 'pre' option, the first call must happen before
3257
- // the component is mounted so it is called synchronously.
3258
- job();
3259
- }
3260
- };
3277
+ scheduler = () => queuePreFlushCb(job);
3261
3278
  }
3262
3279
  const effect = new ReactiveEffect(getter, scheduler);
3263
3280
  {
@@ -3510,6 +3527,17 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3510
3527
  hook &&
3511
3528
  callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3512
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
+ };
3513
3541
  const hooks = {
3514
3542
  mode,
3515
3543
  persisted,
@@ -3568,10 +3596,7 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3568
3596
  el._enterCb = undefined;
3569
3597
  });
3570
3598
  if (hook) {
3571
- hook(el, done);
3572
- if (hook.length <= 1) {
3573
- done();
3574
- }
3599
+ callAsyncHook(hook, [el, done]);
3575
3600
  }
3576
3601
  else {
3577
3602
  done();
@@ -3605,10 +3630,7 @@ function resolveTransitionHooks(vnode, props, state, instance) {
3605
3630
  });
3606
3631
  leavingVNodesCache[key] = vnode;
3607
3632
  if (onLeave) {
3608
- onLeave(el, done);
3609
- if (onLeave.length <= 1) {
3610
- done();
3611
- }
3633
+ callAsyncHook(onLeave, [el, done]);
3612
3634
  }
3613
3635
  else {
3614
3636
  done();
@@ -3818,7 +3840,7 @@ function defineAsyncComponent(source) {
3818
3840
  }
3819
3841
  });
3820
3842
  }
3821
- function createInnerComp(comp, { vnode: { ref, props, children } }) {
3843
+ function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3822
3844
  const vnode = createVNode(comp, props, children);
3823
3845
  // ensure inner component inherits the async wrapper's ref owner
3824
3846
  vnode.ref = ref;
@@ -3845,11 +3867,6 @@ const KeepAliveImpl = {
3845
3867
  // The whole point of this is to avoid importing KeepAlive directly in the
3846
3868
  // renderer to facilitate tree-shaking.
3847
3869
  const sharedContext = instance.ctx;
3848
- // if the internal renderer is not registered, it indicates that this is server-side rendering,
3849
- // for KeepAlive, we just need to render its children
3850
- if (!sharedContext.renderer) {
3851
- return slots.default;
3852
- }
3853
3870
  const cache = new Map();
3854
3871
  const keys = new Set();
3855
3872
  let current = null;
@@ -4027,7 +4044,7 @@ const KeepAliveImpl = {
4027
4044
  // avoid vnode being unmounted
4028
4045
  vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
4029
4046
  current = vnode;
4030
- return rawVNode;
4047
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
4031
4048
  };
4032
4049
  }
4033
4050
  };
@@ -4165,1110 +4182,1597 @@ function onErrorCaptured(hook, target = currentInstance) {
4165
4182
  injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4166
4183
  }
4167
4184
 
4168
- function createDuplicateChecker() {
4169
- const cache = Object.create(null);
4170
- return (type, key) => {
4171
- if (cache[key]) {
4172
- 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
+ };
4173
4221
  }
4174
- else {
4175
- cache[key] = type;
4222
+ if (dir.deep) {
4223
+ traverse(value);
4176
4224
  }
4177
- };
4178
- }
4179
- let shouldCacheAccess = true;
4180
- function applyOptions(instance) {
4181
- const options = resolveMergedOptions(instance);
4182
- const publicThis = instance.proxy;
4183
- const ctx = instance.ctx;
4184
- // do not cache property access on public proxy during state initialization
4185
- shouldCacheAccess = false;
4186
- // call beforeCreate first before accessing other options since
4187
- // the hook may mutate resolved options (#2791)
4188
- if (options.beforeCreate) {
4189
- 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
+ });
4190
4233
  }
4191
- const {
4192
- // state
4193
- data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4194
- // lifecycle
4195
- created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4196
- // public API
4197
- expose, inheritAttrs,
4198
- // assets
4199
- components, directives, filters } = options;
4200
- const checkDuplicateProperties = createDuplicateChecker() ;
4201
- {
4202
- const [propsOptions] = instance.propsOptions;
4203
- if (propsOptions) {
4204
- for (const key in propsOptions) {
4205
- checkDuplicateProperties("Props" /* PROPS */, key);
4206
- }
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();
4207
4256
  }
4208
4257
  }
4209
- // options initialization order (to be consistent with Vue 2):
4210
- // - props (already done outside of this function)
4211
- // - inject
4212
- // - methods
4213
- // - data (deferred since it relies on `this` access)
4214
- // - computed
4215
- // - watch (deferred since it relies on `this` access)
4216
- if (injectOptions) {
4217
- 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;
4218
4275
  }
4219
- if (methods) {
4220
- for (const key in methods) {
4221
- const methodHandler = methods[key];
4222
- if (isFunction(methodHandler)) {
4223
- // In dev mode, we use the `createRenderContext` function to define
4224
- // methods to the proxy target, and those are read-only but
4225
- // reconfigurable, so it needs to be redefined here
4226
- {
4227
- Object.defineProperty(ctx, key, {
4228
- value: methodHandler.bind(publicThis),
4229
- configurable: true,
4230
- enumerable: true,
4231
- writable: true
4232
- });
4233
- }
4234
- {
4235
- checkDuplicateProperties("Methods" /* METHODS */, key);
4236
- }
4237
- }
4238
- else {
4239
- warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4240
- `Did you reference the function correctly?`);
4241
- }
4242
- }
4276
+ else {
4277
+ // invalid types will fallthrough to createVNode and raise warning
4278
+ return (component || NULL_DYNAMIC_COMPONENT);
4243
4279
  }
4244
- if (dataOptions) {
4245
- if (!isFunction(dataOptions)) {
4246
- warn$1(`The data option must be a function. ` +
4247
- `Plain object usage is no longer supported.`);
4248
- }
4249
- const data = dataOptions.call(publicThis, publicThis);
4250
- if (isPromise(data)) {
4251
- warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4252
- `intend to perform data fetching before component renders, use ` +
4253
- `async setup() + <Suspense>.`);
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
+ }
4254
4301
  }
4255
- if (!isObject(data)) {
4256
- warn$1(`data() should return an object.`);
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;
4257
4311
  }
4258
- else {
4259
- instance.data = reactive(data);
4260
- {
4261
- for (const key in data) {
4262
- checkDuplicateProperties("Data" /* DATA */, key);
4263
- // expose data on ctx during dev
4264
- if (key[0] !== '$' && key[0] !== '_') {
4265
- Object.defineProperty(ctx, key, {
4266
- configurable: true,
4267
- enumerable: true,
4268
- get: () => data[key],
4269
- set: NOOP
4270
- });
4271
- }
4272
- }
4273
- }
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}`);
4274
4318
  }
4319
+ return res;
4275
4320
  }
4276
- // state initialization complete at this point - start caching access
4277
- shouldCacheAccess = true;
4278
- if (computedOptions) {
4279
- for (const key in computedOptions) {
4280
- const opt = computedOptions[key];
4281
- const get = isFunction(opt)
4282
- ? opt.bind(publicThis, publicThis)
4283
- : isFunction(opt.get)
4284
- ? opt.get.bind(publicThis, publicThis)
4285
- : NOOP;
4286
- if (get === NOOP) {
4287
- warn$1(`Computed property "${key}" has no getter.`);
4288
- }
4289
- const set = !isFunction(opt) && isFunction(opt.set)
4290
- ? opt.set.bind(publicThis)
4291
- : () => {
4292
- warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4293
- }
4294
- ;
4295
- const c = computed$1({
4296
- get,
4297
- set
4298
- });
4299
- Object.defineProperty(ctx, key, {
4300
- enumerable: true,
4301
- configurable: true,
4302
- get: () => c.value,
4303
- set: v => (c.value = v)
4304
- });
4305
- {
4306
- checkDuplicateProperties("Computed" /* COMPUTED */, key);
4307
- }
4308
- }
4309
- }
4310
- if (watchOptions) {
4311
- for (const key in watchOptions) {
4312
- createWatcher(watchOptions[key], ctx, publicThis, key);
4313
- }
4314
- }
4315
- if (provideOptions) {
4316
- const provides = isFunction(provideOptions)
4317
- ? provideOptions.call(publicThis)
4318
- : provideOptions;
4319
- Reflect.ownKeys(provides).forEach(key => {
4320
- provide(key, provides[key]);
4321
- });
4322
- }
4323
- if (created) {
4324
- callHook(created, instance, "c" /* CREATED */);
4321
+ else {
4322
+ warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
4323
+ `can only be used in render() or setup().`);
4325
4324
  }
4326
- function registerLifecycleHook(register, hook) {
4327
- if (isArray(hook)) {
4328
- hook.forEach(_hook => register(_hook.bind(publicThis)));
4329
- }
4330
- else if (hook) {
4331
- register(hook.bind(publicThis));
4325
+ }
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]);
4332
4343
  }
4333
4344
  }
4334
- registerLifecycleHook(onBeforeMount, beforeMount);
4335
- registerLifecycleHook(onMounted, mounted);
4336
- registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4337
- registerLifecycleHook(onUpdated, updated);
4338
- registerLifecycleHook(onActivated, activated);
4339
- registerLifecycleHook(onDeactivated, deactivated);
4340
- registerLifecycleHook(onErrorCaptured, errorCaptured);
4341
- registerLifecycleHook(onRenderTracked, renderTracked);
4342
- registerLifecycleHook(onRenderTriggered, renderTriggered);
4343
- registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4344
- registerLifecycleHook(onUnmounted, unmounted);
4345
- registerLifecycleHook(onServerPrefetch, serverPrefetch);
4346
- if (isArray(expose)) {
4347
- if (expose.length) {
4348
- const exposed = instance.exposed || (instance.exposed = {});
4349
- expose.forEach(key => {
4350
- Object.defineProperty(exposed, key, {
4351
- get: () => publicThis[key],
4352
- set: val => (publicThis[key] = val)
4353
- });
4354
- });
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}.`);
4355
4348
  }
4356
- else if (!instance.exposed) {
4357
- instance.exposed = {};
4349
+ ret = new Array(source);
4350
+ for (let i = 0; i < source; i++) {
4351
+ ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
4358
4352
  }
4359
4353
  }
4360
- // options that are handled when creating the instance but also need to be
4361
- // applied from mixins
4362
- if (render && instance.render === NOOP) {
4363
- instance.render = render;
4364
- }
4365
- if (inheritAttrs != null) {
4366
- instance.inheritAttrs = inheritAttrs;
4367
- }
4368
- // asset options.
4369
- if (components)
4370
- instance.components = components;
4371
- if (directives)
4372
- instance.directives = directives;
4373
- }
4374
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4375
- if (isArray(injectOptions)) {
4376
- injectOptions = normalizeInject(injectOptions);
4377
- }
4378
- for (const key in injectOptions) {
4379
- const opt = injectOptions[key];
4380
- let injected;
4381
- if (isObject(opt)) {
4382
- if ('default' in opt) {
4383
- injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4384
- }
4385
- else {
4386
- injected = inject(opt.from || key);
4387
- }
4354
+ else if (isObject(source)) {
4355
+ if (source[Symbol.iterator]) {
4356
+ ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
4388
4357
  }
4389
4358
  else {
4390
- injected = inject(opt);
4391
- }
4392
- if (isRef(injected)) {
4393
- // TODO remove the check in 3.3
4394
- if (unwrapRef) {
4395
- Object.defineProperty(ctx, key, {
4396
- enumerable: true,
4397
- configurable: true,
4398
- get: () => injected.value,
4399
- set: v => (injected.value = v)
4400
- });
4401
- }
4402
- else {
4403
- {
4404
- warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4405
- `and no longer needs \`.value\` in the next minor release. ` +
4406
- `To opt-in to the new behavior now, ` +
4407
- `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4408
- `temporary and will not be needed in the future.)`);
4409
- }
4410
- ctx[key] = injected;
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]);
4411
4364
  }
4412
4365
  }
4413
- else {
4414
- ctx[key] = injected;
4415
- }
4416
- {
4417
- checkDuplicateProperties("Inject" /* INJECT */, key);
4418
- }
4419
4366
  }
4420
- }
4421
- function callHook(hook, instance, type) {
4422
- callWithAsyncErrorHandling(isArray(hook)
4423
- ? hook.map(h => h.bind(instance.proxy))
4424
- : hook.bind(instance.proxy), instance, type);
4425
- }
4426
- function createWatcher(raw, ctx, publicThis, key) {
4427
- const getter = key.includes('.')
4428
- ? createPathGetter(publicThis, key)
4429
- : () => publicThis[key];
4430
- if (isString(raw)) {
4431
- const handler = ctx[raw];
4432
- if (isFunction(handler)) {
4433
- watch(getter, handler);
4434
- }
4435
- else {
4436
- warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4437
- }
4367
+ else {
4368
+ ret = [];
4438
4369
  }
4439
- else if (isFunction(raw)) {
4440
- watch(getter, raw.bind(publicThis));
4370
+ if (cache) {
4371
+ cache[index] = ret;
4441
4372
  }
4442
- else if (isObject(raw)) {
4443
- if (isArray(raw)) {
4444
- raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4445
- }
4446
- else {
4447
- const handler = isFunction(raw.handler)
4448
- ? raw.handler.bind(publicThis)
4449
- : ctx[raw.handler];
4450
- if (isFunction(handler)) {
4451
- watch(getter, handler, raw);
4452
- }
4453
- else {
4454
- warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
4373
+ return ret;
4374
+ }
4375
+
4376
+ /**
4377
+ * Compiler runtime helper for creating dynamic slots object
4378
+ * @private
4379
+ */
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;
4455
4387
  }
4456
4388
  }
4389
+ else if (slot) {
4390
+ // conditional single slot generated by <template v-if="..." #foo>
4391
+ slots[slot.name] = slot.fn;
4392
+ }
4457
4393
  }
4458
- else {
4459
- warn$1(`Invalid watch option: "${key}"`, raw);
4460
- }
4461
- }
4394
+ return slots;
4395
+ }
4396
+
4462
4397
  /**
4463
- * Resolve merged options and cache it on the component.
4464
- * This is done only once per-component since the merging does not involve
4465
- * instances.
4398
+ * Compiler runtime helper for rendering `<slot/>`
4399
+ * @private
4466
4400
  */
4467
- function resolveMergedOptions(instance) {
4468
- const base = instance.type;
4469
- const { mixins, extends: extendsOptions } = base;
4470
- const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4471
- const cached = cache.get(base);
4472
- let resolved;
4473
- if (cached) {
4474
- resolved = cached;
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());
4475
4410
  }
4476
- else if (!globalMixins.length && !mixins && !extendsOptions) {
4477
- {
4478
- resolved = base;
4479
- }
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 = () => [];
4480
4417
  }
4481
- else {
4482
- resolved = {};
4483
- if (globalMixins.length) {
4484
- globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4485
- }
4486
- mergeOptions(resolved, base, optionMergeStrategies);
4487
- }
4488
- cache.set(base, resolved);
4489
- return resolved;
4490
- }
4491
- function mergeOptions(to, from, strats, asMixin = false) {
4492
- const { mixins, extends: extendsOptions } = from;
4493
- if (extendsOptions) {
4494
- mergeOptions(to, extendsOptions, strats, true);
4495
- }
4496
- if (mixins) {
4497
- mixins.forEach((m) => mergeOptions(to, m, strats, true));
4498
- }
4499
- for (const key in from) {
4500
- if (asMixin && key === 'expose') {
4501
- warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4502
- `It should only be declared in the base component itself.`);
4503
- }
4504
- else {
4505
- const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4506
- to[key] = strat ? strat(to[key], from[key]) : from[key];
4507
- }
4508
- }
4509
- return to;
4510
- }
4511
- const internalOptionMergeStrats = {
4512
- data: mergeDataFn,
4513
- props: mergeObjectOptions,
4514
- emits: mergeObjectOptions,
4515
- // objects
4516
- methods: mergeObjectOptions,
4517
- computed: mergeObjectOptions,
4518
- // lifecycle
4519
- beforeCreate: mergeAsArray,
4520
- created: mergeAsArray,
4521
- beforeMount: mergeAsArray,
4522
- mounted: mergeAsArray,
4523
- beforeUpdate: mergeAsArray,
4524
- updated: mergeAsArray,
4525
- beforeDestroy: mergeAsArray,
4526
- beforeUnmount: mergeAsArray,
4527
- destroyed: mergeAsArray,
4528
- unmounted: mergeAsArray,
4529
- activated: mergeAsArray,
4530
- deactivated: mergeAsArray,
4531
- errorCaptured: mergeAsArray,
4532
- serverPrefetch: mergeAsArray,
4533
- // assets
4534
- components: mergeObjectOptions,
4535
- directives: mergeObjectOptions,
4536
- // watch
4537
- watch: mergeWatchOptions,
4538
- // provide / inject
4539
- provide: mergeDataFn,
4540
- inject: mergeInject
4541
- };
4542
- function mergeDataFn(to, from) {
4543
- if (!from) {
4544
- 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;
4545
4424
  }
4546
- if (!to) {
4547
- 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'];
4548
4432
  }
4549
- return function mergedDataFn() {
4550
- return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4551
- };
4552
- }
4553
- function mergeInject(to, from) {
4554
- return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4555
- }
4556
- function normalizeInject(raw) {
4557
- if (isArray(raw)) {
4558
- const res = {};
4559
- for (let i = 0; i < raw.length; i++) {
4560
- res[raw[i]] = raw[i];
4561
- }
4562
- return res;
4433
+ if (slot && slot._c) {
4434
+ slot._d = true;
4563
4435
  }
4564
- return raw;
4565
- }
4566
- function mergeAsArray(to, from) {
4567
- return to ? [...new Set([].concat(to, from))] : from;
4568
- }
4569
- function mergeObjectOptions(to, from) {
4570
- return to ? extend(extend(Object.create(null), to), from) : from;
4436
+ return rendered;
4571
4437
  }
4572
- function mergeWatchOptions(to, from) {
4573
- if (!to)
4574
- return from;
4575
- if (!from)
4576
- return to;
4577
- const merged = extend(Object.create(null), to);
4578
- for (const key in from) {
4579
- merged[key] = mergeAsArray(to[key], from[key]);
4580
- }
4581
- 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;
4582
4451
  }
4583
4452
 
4584
- function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4585
- isSSR = false) {
4586
- const props = {};
4587
- const attrs = {};
4588
- def(attrs, InternalObjectKey, 1);
4589
- instance.propsDefaults = Object.create(null);
4590
- setFullProps(instance, rawProps, props, attrs);
4591
- // ensure all declared prop keys are present
4592
- for (const key in instance.propsOptions[0]) {
4593
- if (!(key in props)) {
4594
- props[key] = undefined;
4595
- }
4596
- }
4597
- // validation
4598
- {
4599
- 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;
4600
4462
  }
4601
- if (isStateful) {
4602
- // stateful
4603
- instance.props = isSSR ? props : shallowReactive(props);
4463
+ for (const key in obj) {
4464
+ ret[toHandlerKey(key)] = obj[key];
4604
4465
  }
4605
- else {
4606
- if (!instance.type.props) {
4607
- // functional w/ optional props, props === attrs
4608
- 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;
4609
4507
  }
4610
- else {
4611
- // functional w/ declared props
4612
- 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];
4613
4516
  }
4614
- }
4615
- instance.attrs = attrs;
4616
- }
4617
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
4618
- const { props, attrs, vnode: { patchFlag } } = instance;
4619
- const rawCurrentProps = toRaw(props);
4620
- const [options] = instance.propsOptions;
4621
- let hasAttrsChanged = false;
4622
- if (
4623
- // always force full diff in dev
4624
- // - #1942 if hmr is enabled with sfc component
4625
- // - vite#872 non-sfc component used by sfc component
4626
- !((instance.type.__hmrId ||
4627
- (instance.parent && instance.parent.type.__hmrId))) &&
4628
- (optimized || patchFlag > 0) &&
4629
- !(patchFlag & 16 /* FULL_PROPS */)) {
4630
- if (patchFlag & 8 /* PROPS */) {
4631
- // Compiler-generated props & no keys change, just set the updated
4632
- // the props.
4633
- const propsToUpdate = instance.vnode.dynamicProps;
4634
- for (let i = 0; i < propsToUpdate.length; i++) {
4635
- let key = propsToUpdate[i];
4636
- // skip if the prop key is a declared emit event listener
4637
- if (isEmitListener(instance.emitsOptions, key)) {
4638
- continue;
4639
- }
4640
- // PROPS flag guarantees rawProps to be non-null
4641
- const value = rawProps[key];
4642
- if (options) {
4643
- // attr / props separation was done on init and will be consistent
4644
- // in this code path, so just check if attrs have it.
4645
- if (hasOwn(attrs, key)) {
4646
- if (value !== attrs[key]) {
4647
- attrs[key] = value;
4648
- hasAttrsChanged = true;
4649
- }
4650
- }
4651
- else {
4652
- const camelizedKey = camelize(key);
4653
- props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4654
- }
4655
- }
4656
- else {
4657
- if (value !== attrs[key]) {
4658
- attrs[key] = value;
4659
- hasAttrsChanged = true;
4660
- }
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
4661
4537
  }
4662
4538
  }
4663
- }
4664
- }
4665
- else {
4666
- // full props update.
4667
- if (setFullProps(instance, rawProps, props, attrs)) {
4668
- hasAttrsChanged = true;
4669
- }
4670
- // in case of dynamic props, check if we need to delete keys from
4671
- // the props object
4672
- let kebabKey;
4673
- for (const key in rawCurrentProps) {
4674
- if (!rawProps ||
4675
- // for camelCase
4676
- (!hasOwn(rawProps, key) &&
4677
- // it's possible the original props was passed in as kebab-case
4678
- // and converted to camelCase (#955)
4679
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4680
- if (options) {
4681
- if (rawPrevProps &&
4682
- // for camelCase
4683
- (rawPrevProps[key] !== undefined ||
4684
- // for kebab-case
4685
- rawPrevProps[kebabKey] !== undefined)) {
4686
- props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4687
- }
4688
- }
4689
- else {
4690
- delete props[key];
4691
- }
4539
+ else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4540
+ accessCache[key] = 1 /* SETUP */;
4541
+ return setupState[key];
4692
4542
  }
4693
- }
4694
- // in the case of functional component w/o props declaration, props and
4695
- // attrs point to the same object so it should already have been updated.
4696
- if (attrs !== rawCurrentProps) {
4697
- for (const key in attrs) {
4698
- if (!rawProps ||
4699
- (!hasOwn(rawProps, key) &&
4700
- (!false ))) {
4701
- delete attrs[key];
4702
- hasAttrsChanged = true;
4703
- }
4543
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4544
+ accessCache[key] = 2 /* DATA */;
4545
+ return data[key];
4704
4546
  }
4705
- }
4706
- }
4707
- // trigger updates for $attrs in case it's used in component slots
4708
- if (hasAttrsChanged) {
4709
- trigger(instance, "set" /* SET */, '$attrs');
4710
- }
4711
- {
4712
- validateProps(rawProps || {}, props, instance);
4713
- }
4714
- }
4715
- function setFullProps(instance, rawProps, props, attrs) {
4716
- const [options, needCastKeys] = instance.propsOptions;
4717
- let hasAttrsChanged = false;
4718
- let rawCastValues;
4719
- if (rawProps) {
4720
- for (let key in rawProps) {
4721
- // key, ref are reserved and never passed down
4722
- if (isReservedProp(key)) {
4723
- 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];
4724
4554
  }
4725
- const value = rawProps[key];
4726
- // prop option names are camelized during normalization, so to support
4727
- // kebab -> camel conversion here we need to camelize the key.
4728
- let camelKey;
4729
- if (options && hasOwn(options, (camelKey = camelize(key)))) {
4730
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4731
- props[camelKey] = value;
4732
- }
4733
- else {
4734
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4735
- }
4555
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4556
+ accessCache[key] = 4 /* CONTEXT */;
4557
+ return ctx[key];
4736
4558
  }
4737
- else if (!isEmitListener(instance.emitsOptions, key)) {
4738
- if (!(key in attrs) || value !== attrs[key]) {
4739
- attrs[key] = value;
4740
- hasAttrsChanged = true;
4741
- }
4559
+ else if (shouldCacheAccess) {
4560
+ accessCache[key] = 0 /* OTHER */;
4742
4561
  }
4743
4562
  }
4744
- }
4745
- if (needCastKeys) {
4746
- const rawCurrentProps = toRaw(props);
4747
- const castValues = rawCastValues || EMPTY_OBJ;
4748
- for (let i = 0; i < needCastKeys.length; i++) {
4749
- const key = needCastKeys[i];
4750
- props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4751
- }
4752
- }
4753
- return hasAttrsChanged;
4754
- }
4755
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
4756
- const opt = options[key];
4757
- if (opt != null) {
4758
- const hasDefault = hasOwn(opt, 'default');
4759
- // default values
4760
- if (hasDefault && value === undefined) {
4761
- const defaultValue = opt.default;
4762
- if (opt.type !== Function && isFunction(defaultValue)) {
4763
- const { propsDefaults } = instance;
4764
- if (key in propsDefaults) {
4765
- value = propsDefaults[key];
4766
- }
4767
- else {
4768
- setCurrentInstance(instance);
4769
- value = propsDefaults[key] = defaultValue.call(null, props);
4770
- unsetCurrentInstance();
4771
- }
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();
4772
4570
  }
4773
- else {
4774
- 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];
4775
4590
  }
4776
4591
  }
4777
- // boolean casting
4778
- if (opt[0 /* shouldCast */]) {
4779
- if (isAbsent && !hasDefault) {
4780
- 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.`);
4781
4600
  }
4782
- else if (opt[1 /* shouldCastTrue */] &&
4783
- (value === '' || value === hyphenate(key))) {
4784
- 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.`);
4785
4604
  }
4786
4605
  }
4787
- }
4788
- return value;
4789
- }
4790
- function normalizePropsOptions(comp, appContext, asMixin = false) {
4791
- const cache = appContext.propsCache;
4792
- const cached = cache.get(comp);
4793
- if (cached) {
4794
- return cached;
4795
- }
4796
- const raw = comp.props;
4797
- const normalized = {};
4798
- const needCastKeys = [];
4799
- // apply mixin/extends props
4800
- let hasExtends = false;
4801
- if (!isFunction(comp)) {
4802
- const extendProps = (raw) => {
4803
- hasExtends = true;
4804
- const [props, keys] = normalizePropsOptions(raw, appContext, true);
4805
- extend(normalized, props);
4806
- if (keys)
4807
- needCastKeys.push(...keys);
4808
- };
4809
- if (!asMixin && appContext.mixins.length) {
4810
- 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;
4811
4612
  }
4812
- if (comp.extends) {
4813
- extendProps(comp.extends);
4613
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4614
+ data[key] = value;
4615
+ return true;
4814
4616
  }
4815
- if (comp.mixins) {
4816
- 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;
4817
4620
  }
4818
- }
4819
- if (!raw && !hasExtends) {
4820
- cache.set(comp, EMPTY_ARR);
4821
- return EMPTY_ARR;
4822
- }
4823
- if (isArray(raw)) {
4824
- for (let i = 0; i < raw.length; i++) {
4825
- if (!isString(raw[i])) {
4826
- 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
+ });
4827
4633
  }
4828
- const normalizedKey = camelize(raw[i]);
4829
- if (validatePropName(normalizedKey)) {
4830
- normalized[normalizedKey] = EMPTY_OBJ;
4634
+ else {
4635
+ ctx[key] = value;
4831
4636
  }
4832
4637
  }
4833
- }
4834
- else if (raw) {
4835
- if (!isObject(raw)) {
4836
- warn$1(`invalid props options`, raw);
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;
4837
4654
  }
4838
- for (const key in raw) {
4839
- const normalizedKey = camelize(key);
4840
- if (validatePropName(normalizedKey)) {
4841
- const opt = raw[key];
4842
- const prop = (normalized[normalizedKey] =
4843
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4844
- if (prop) {
4845
- const booleanIndex = getTypeIndex(Boolean, prop.type);
4846
- const stringIndex = getTypeIndex(String, prop.type);
4847
- prop[0 /* shouldCast */] = booleanIndex > -1;
4848
- prop[1 /* shouldCastTrue */] =
4849
- stringIndex < 0 || booleanIndex < stringIndex;
4850
- // if the prop needs boolean casting or default value
4851
- if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4852
- needCastKeys.push(normalizedKey);
4853
- }
4854
- }
4855
- }
4655
+ else if (hasOwn(descriptor, 'value')) {
4656
+ this.set(target, key, descriptor.value, null);
4856
4657
  }
4658
+ return Reflect.defineProperty(target, key, descriptor);
4857
4659
  }
4858
- const res = [normalized, needCastKeys];
4859
- cache.set(comp, res);
4860
- return res;
4861
- }
4862
- function validatePropName(key) {
4863
- if (key[0] !== '$') {
4864
- return true;
4865
- }
4866
- else {
4867
- warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4868
- }
4869
- return false;
4870
- }
4871
- // use function string name to check type constructors
4872
- // so that it works across vms / iframes.
4873
- function getType(ctor) {
4874
- const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4875
- return match ? match[1] : ctor === null ? 'null' : '';
4876
- }
4877
- function isSameType(a, b) {
4878
- 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
+ };
4879
4667
  }
4880
- function getTypeIndex(type, expectedTypes) {
4881
- if (isArray(expectedTypes)) {
4882
- return expectedTypes.findIndex(t => isSameType(t, type));
4883
- }
4884
- else if (isFunction(expectedTypes)) {
4885
- 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;
4886
4682
  }
4887
- 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;
4888
4708
  }
4889
- /**
4890
- * dev only
4891
- */
4892
- function validateProps(rawProps, props, instance) {
4893
- const resolvedValues = toRaw(props);
4894
- const options = instance.propsOptions[0];
4895
- for (const key in options) {
4896
- let opt = options[key];
4897
- if (opt == null)
4898
- continue;
4899
- 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
+ });
4900
4721
  }
4901
4722
  }
4902
- /**
4903
- * dev only
4904
- */
4905
- function validateProp(name, value, prop, isAbsent) {
4906
- const { type, required, validator } = prop;
4907
- // required!
4908
- if (required && isAbsent) {
4909
- warn$1('Missing required prop: "' + name + '"');
4910
- return;
4911
- }
4912
- // missing but optional
4913
- if (value == null && !prop.required) {
4914
- return;
4915
- }
4916
- // type check
4917
- if (type != null && type !== true) {
4918
- let isValid = false;
4919
- const types = isArray(type) ? type : [type];
4920
- const expectedTypes = [];
4921
- // value is valid as long as one of the specified types match
4922
- for (let i = 0; i < types.length && !isValid; i++) {
4923
- const { valid, expectedType } = assertType(value, types[i]);
4924
- expectedTypes.push(expectedType || '');
4925
- 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
+ });
4926
4739
  }
4927
- if (!isValid) {
4928
- warn$1(getInvalidTypeMessage(name, value, expectedTypes));
4929
- 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]}.`);
4930
4748
  }
4931
- }
4932
- // custom validator
4933
- if (validator && !validator(value)) {
4934
- warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
4935
- }
4936
- }
4937
- const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
4938
- /**
4939
- * dev only
4940
- */
4941
- function assertType(value, type) {
4942
- let valid;
4943
- const expectedType = getType(type);
4944
- if (isSimpleType(expectedType)) {
4945
- const t = typeof value;
4946
- valid = t === expectedType.toLowerCase();
4947
- // for primitive wrapper objects
4948
- if (!valid && t === 'object') {
4949
- valid = value instanceof type;
4749
+ else {
4750
+ cache[key] = type;
4950
4751
  }
4951
- }
4952
- else if (expectedType === 'Object') {
4953
- valid = isObject(value);
4954
- }
4955
- else if (expectedType === 'Array') {
4956
- valid = isArray(value);
4957
- }
4958
- else if (expectedType === 'null') {
4959
- valid = value === null;
4960
- }
4961
- else {
4962
- valid = value instanceof type;
4963
- }
4964
- return {
4965
- valid,
4966
- expectedType
4967
4752
  };
4968
4753
  }
4969
- /**
4970
- * dev only
4971
- */
4972
- function getInvalidTypeMessage(name, value, expectedTypes) {
4973
- let message = `Invalid prop: type check failed for prop "${name}".` +
4974
- ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
4975
- const expectedType = expectedTypes[0];
4976
- const receivedType = toRawType(value);
4977
- const expectedValue = styleValue(value, expectedType);
4978
- const receivedValue = styleValue(value, receivedType);
4979
- // check if we need to specify expected value
4980
- if (expectedTypes.length === 1 &&
4981
- isExplicable(expectedType) &&
4982
- !isBoolean(expectedType, receivedType)) {
4983
- message += ` with value ${expectedValue}`;
4984
- }
4985
- message += `, got ${receivedType} `;
4986
- // check if we need to specify received value
4987
- if (isExplicable(receivedType)) {
4988
- 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 */);
4989
4765
  }
4990
- return message;
4991
- }
4992
- /**
4993
- * dev only
4994
- */
4995
- function styleValue(value, type) {
4996
- if (type === 'String') {
4997
- return `"${value}"`;
4998
- }
4999
- else if (type === 'Number') {
5000
- 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
+ }
5001
4783
  }
5002
- else {
5003
- 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);
5004
4793
  }
5005
- }
5006
- /**
5007
- * dev only
5008
- */
5009
- function isExplicable(type) {
5010
- const explicitTypes = ['string', 'number', 'boolean'];
5011
- return explicitTypes.some(elem => type.toLowerCase() === elem);
5012
- }
5013
- /**
5014
- * dev only
5015
- */
5016
- function isBoolean(...args) {
5017
- return args.some(elem => elem.toLowerCase() === 'boolean');
5018
- }
5019
-
5020
- const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5021
- const normalizeSlotValue = (value) => isArray(value)
5022
- ? value.map(normalizeVNode)
5023
- : [normalizeVNode(value)];
5024
- const normalizeSlot = (key, rawSlot, ctx) => {
5025
- const normalized = withCtx((...args) => {
5026
- if (currentInstance) {
5027
- warn$1(`Slot "${key}" invoked outside of the render function: ` +
5028
- `this will not track dependencies used in the slot. ` +
5029
- `Invoke the slot function inside the render function instead.`);
5030
- }
5031
- return normalizeSlotValue(rawSlot(...args));
5032
- }, ctx);
5033
- normalized._c = false;
5034
- return normalized;
5035
- };
5036
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
5037
- const ctx = rawSlots._ctx;
5038
- for (const key in rawSlots) {
5039
- if (isInternalKey(key))
5040
- continue;
5041
- const value = rawSlots[key];
5042
- if (isFunction(value)) {
5043
- slots[key] = normalizeSlot(key, value, ctx);
5044
- }
5045
- else if (value != null) {
5046
- {
5047
- warn$1(`Non-function value encountered for slot "${key}". ` +
5048
- `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?`);
5049
4816
  }
5050
- const normalized = normalizeSlotValue(value);
5051
- slots[key] = () => normalized;
5052
4817
  }
5053
4818
  }
5054
- };
5055
- const normalizeVNodeSlots = (instance, children) => {
5056
- if (!isKeepAlive(instance.vnode) &&
5057
- !(false )) {
5058
- warn$1(`Non-function value encountered for default slot. ` +
5059
- `Prefer function slots for better performance.`);
5060
- }
5061
- const normalized = normalizeSlotValue(children);
5062
- instance.slots.default = () => normalized;
5063
- };
5064
- const initSlots = (instance, children) => {
5065
- if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5066
- const type = children._;
5067
- if (type) {
5068
- // users can get the shallow readonly version of the slots object through `this.$slots`,
5069
- // we should avoid the proxy object polluting the slots of the internal instance
5070
- instance.slots = toRaw(children);
5071
- // make compiler marker non-enumerable
5072
- 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.`);
5073
4823
  }
5074
- else {
5075
- 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>.`);
5076
4829
  }
5077
- }
5078
- else {
5079
- instance.slots = {};
5080
- if (children) {
5081
- normalizeVNodeSlots(instance, children);
4830
+ if (!isObject(data)) {
4831
+ warn$1(`data() should return an object.`);
5082
4832
  }
5083
- }
5084
- def(instance.slots, InternalObjectKey, 1);
5085
- };
5086
- const updateSlots = (instance, children, optimized) => {
5087
- const { vnode, slots } = instance;
5088
- let needDeletionCheck = true;
5089
- let deletionComparisonTarget = EMPTY_OBJ;
5090
- if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5091
- const type = children._;
5092
- if (type) {
5093
- // compiled slots.
5094
- if (isHmrUpdating) {
5095
- // Parent was HMR updated so slot content may have changed.
5096
- // force update slots and mark instance for hmr as well
5097
- 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
+ }
5098
4848
  }
5099
- else if (optimized && type === 1 /* STABLE */) {
5100
- // compiled AND stable.
5101
- // no need to update, and skip stale slots removal.
5102
- 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.`);
5103
4863
  }
5104
- else {
5105
- // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5106
- // normalization.
5107
- extend(slots, children);
5108
- // #2893
5109
- // when rendering the optimized slots by manually written render function,
5110
- // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5111
- // i.e. let the `renderSlot` create the bailed Fragment
5112
- if (!optimized && type === 1 /* STABLE */) {
5113
- delete slots._;
5114
- }
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);
5115
4882
  }
5116
4883
  }
5117
- else {
5118
- needDeletionCheck = !children.$stable;
5119
- normalizeObjectSlots(children, slots);
4884
+ }
4885
+ if (watchOptions) {
4886
+ for (const key in watchOptions) {
4887
+ createWatcher(watchOptions[key], ctx, publicThis, key);
5120
4888
  }
5121
- deletionComparisonTarget = children;
5122
4889
  }
5123
- else if (children) {
5124
- // non slot object children (direct value) passed to a component
5125
- normalizeVNodeSlots(instance, children);
5126
- 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
+ });
5127
4897
  }
5128
- // delete stale slots
5129
- if (needDeletionCheck) {
5130
- for (const key in slots) {
5131
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5132
- delete slots[key];
5133
- }
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));
5134
4907
  }
5135
4908
  }
5136
- };
5137
-
5138
- /**
5139
- Runtime helper for applying directives to a vnode. Example usage:
5140
-
5141
- const comp = resolveComponent('comp')
5142
- const foo = resolveDirective('foo')
5143
- const bar = resolveDirective('bar')
5144
-
5145
- return withDirectives(h(comp), [
5146
- [foo, this.x],
5147
- [bar, this.y]
5148
- ])
5149
- */
5150
- function validateDirectiveName(name) {
5151
- if (isBuiltInDirective(name)) {
5152
- 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;
4939
+ }
4940
+ if (inheritAttrs != null) {
4941
+ instance.inheritAttrs = inheritAttrs;
5153
4942
  }
4943
+ // asset options.
4944
+ if (components)
4945
+ instance.components = components;
4946
+ if (directives)
4947
+ instance.directives = directives;
5154
4948
  }
5155
- /**
5156
- * Adds directives to a VNode.
5157
- */
5158
- function withDirectives(vnode, directives) {
5159
- const internalInstance = currentRenderingInstance;
5160
- if (internalInstance === null) {
5161
- warn$1(`withDirectives can only be used inside render functions.`);
5162
- return vnode;
4949
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4950
+ if (isArray(injectOptions)) {
4951
+ injectOptions = normalizeInject(injectOptions);
5163
4952
  }
5164
- const instance = getExposeProxy(internalInstance) ||
5165
- internalInstance.proxy;
5166
- const bindings = vnode.dirs || (vnode.dirs = []);
5167
- for (let i = 0; i < directives.length; i++) {
5168
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5169
- if (isFunction(dir)) {
5170
- dir = {
5171
- mounted: dir,
5172
- updated: dir
5173
- };
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
+ }
5174
4963
  }
5175
- if (dir.deep) {
5176
- 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);
5177
4993
  }
5178
- bindings.push({
5179
- dir,
5180
- instance,
5181
- value,
5182
- oldValue: void 0,
5183
- arg,
5184
- modifiers
5185
- });
5186
4994
  }
5187
- return vnode;
5188
4995
  }
5189
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5190
- const bindings = vnode.dirs;
5191
- const oldBindings = prevVNode && prevVNode.dirs;
5192
- for (let i = 0; i < bindings.length; i++) {
5193
- const binding = bindings[i];
5194
- if (oldBindings) {
5195
- 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);
5196
5009
  }
5197
- let hook = binding.dir[name];
5198
- if (hook) {
5199
- // disable tracking inside all lifecycle hooks
5200
- // since they can potentially be called inside effects.
5201
- pauseTracking();
5202
- callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5203
- vnode.el,
5204
- binding,
5205
- vnode,
5206
- prevVNode
5207
- ]);
5208
- resetTracking();
5010
+ else {
5011
+ warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5209
5012
  }
5210
5013
  }
5211
- }
5212
-
5213
- function createAppContext() {
5214
- return {
5215
- app: null,
5216
- config: {
5217
- isNativeTag: NO,
5218
- performance: false,
5219
- globalProperties: {},
5220
- optionMergeStrategies: {},
5221
- errorHandler: undefined,
5222
- warnHandler: undefined,
5223
- compilerOptions: {}
5224
- },
5225
- mixins: [],
5226
- components: {},
5227
- directives: {},
5228
- provides: Object.create(null),
5229
- optionsCache: new WeakMap(),
5230
- propsCache: new WeakMap(),
5231
- emitsCache: new WeakMap()
5232
- };
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
+ }
5233
5036
  }
5234
- let uid = 0;
5235
- function createAppAPI(render, hydrate) {
5236
- return function createApp(rootComponent, rootProps = null) {
5237
- if (!isFunction(rootComponent)) {
5238
- 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;
5239
5054
  }
5240
- if (rootProps != null && !isObject(rootProps)) {
5241
- warn$1(`root props passed to app.mount() must be an object.`);
5242
- rootProps = null;
5055
+ }
5056
+ else {
5057
+ resolved = {};
5058
+ if (globalMixins.length) {
5059
+ globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
5243
5060
  }
5244
- const context = createAppContext();
5245
- const installedPlugins = new Set();
5246
- let isMounted = false;
5247
- const app = (context.app = {
5248
- _uid: uid++,
5249
- _component: rootComponent,
5250
- _props: rootProps,
5251
- _container: null,
5252
- _context: context,
5253
- _instance: null,
5254
- version,
5255
- get config() {
5256
- return context.config;
5257
- },
5258
- set config(v) {
5259
- {
5260
- warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5261
- }
5262
- },
5263
- use(plugin, ...options) {
5264
- if (installedPlugins.has(plugin)) {
5265
- warn$1(`Plugin has already been applied to target app.`);
5266
- }
5267
- else if (plugin && isFunction(plugin.install)) {
5268
- installedPlugins.add(plugin);
5269
- plugin.install(app, ...options);
5270
- }
5271
- else if (isFunction(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)) {
5272
5776
  installedPlugins.add(plugin);
5273
5777
  plugin(app, ...options);
5274
5778
  }
@@ -5318,6 +5822,12 @@ function createAppAPI(render, hydrate) {
5318
5822
  },
5319
5823
  mount(rootContainer, isHydrate, isSVG) {
5320
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
+ }
5321
5831
  const vnode = createVNode(rootComponent, rootProps);
5322
5832
  // store app context on the root VNode.
5323
5833
  // this will be set on the root instance on initial mount.
@@ -5368,8 +5878,6 @@ function createAppAPI(render, hydrate) {
5368
5878
  warn$1(`App already provides property with key "${String(key)}". ` +
5369
5879
  `It will be overwritten with the new value.`);
5370
5880
  }
5371
- // TypeScript doesn't allow symbols as index type
5372
- // https://github.com/Microsoft/TypeScript/issues/24587
5373
5881
  context.provides[key] = value;
5374
5882
  return app;
5375
5883
  }
@@ -5486,7 +5994,7 @@ const isComment = (node) => node.nodeType === 8 /* COMMENT */;
5486
5994
  // Hydration also depends on some renderer internal logic which needs to be
5487
5995
  // passed in via arguments.
5488
5996
  function createHydrationFunctions(rendererInternals) {
5489
- 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;
5490
5998
  const hydrate = (vnode, container) => {
5491
5999
  if (!container.hasChildNodes()) {
5492
6000
  warn$1(`Attempting to hydrate existing markup but container is empty. ` +
@@ -5506,14 +6014,26 @@ function createHydrationFunctions(rendererInternals) {
5506
6014
  const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
5507
6015
  const isFragmentStart = isComment(node) && node.data === '[';
5508
6016
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
5509
- const { type, ref, shapeFlag } = vnode;
6017
+ const { type, ref, shapeFlag, patchFlag } = vnode;
5510
6018
  const domType = node.nodeType;
5511
6019
  vnode.el = node;
6020
+ if (patchFlag === -2 /* BAIL */) {
6021
+ optimized = false;
6022
+ vnode.dynamicChildren = null;
6023
+ }
5512
6024
  let nextNode = null;
5513
6025
  switch (type) {
5514
6026
  case Text:
5515
6027
  if (domType !== 3 /* TEXT */) {
5516
- 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('')), parentNode(node), node);
6032
+ nextNode = node;
6033
+ }
6034
+ else {
6035
+ nextNode = onMismatch();
6036
+ }
5517
6037
  }
5518
6038
  else {
5519
6039
  if (node.data !== vnode.children) {
@@ -5587,6 +6107,12 @@ function createHydrationFunctions(rendererInternals) {
5587
6107
  nextNode = isFragmentStart
5588
6108
  ? locateClosingAsyncAnchor(node)
5589
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
+ }
5590
6116
  // #3787
5591
6117
  // if component is async, it may get moved / unmounted before its
5592
6118
  // inner component is loaded, so we need to give it a placeholder
@@ -6250,8 +6776,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6250
6776
  const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
6251
6777
  const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
6252
6778
  let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
6253
- if (isHmrUpdating) {
6254
- // 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
6255
6782
  patchFlag = 0;
6256
6783
  optimized = false;
6257
6784
  dynamicChildren = null;
@@ -6385,7 +6912,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6385
6912
  }
6386
6913
  else {
6387
6914
  // no update needed. just copy over properties
6388
- n2.component = n1.component;
6389
6915
  n2.el = n1.el;
6390
6916
  instance.vnode = n2;
6391
6917
  }
@@ -6468,7 +6994,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6468
6994
  // activated hook for keep-alive roots.
6469
6995
  // #1742 activated hook must be accessed after first render
6470
6996
  // since the hook may be injected by a child keep-alive
6471
- 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 */)) {
6472
7001
  instance.a && queuePostRenderEffect(instance.a, parentSuspense);
6473
7002
  }
6474
7003
  instance.isMounted = true;
@@ -6551,9 +7080,9 @@ function baseCreateRenderer(options, createHydrationFns) {
6551
7080
  }
6552
7081
  };
6553
7082
  // create reactive effect for rendering
6554
- 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
6555
7084
  ));
6556
- const update = (instance.update = effect.run.bind(effect));
7085
+ const update = (instance.update = () => effect.run());
6557
7086
  update.id = instance.uid;
6558
7087
  // allowRecurse
6559
7088
  // #1801, #2043 component render effects should allow recursive updates
@@ -6565,7 +7094,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6565
7094
  effect.onTrigger = instance.rtg
6566
7095
  ? e => invokeArrayFns(instance.rtg, e)
6567
7096
  : void 0;
6568
- // @ts-ignore (for scheduler)
6569
7097
  update.ownerInstance = instance;
6570
7098
  }
6571
7099
  update();
@@ -7356,90 +7884,30 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
7356
7884
  vnode.targetAnchor = targetNode;
7357
7885
  }
7358
7886
  else {
7359
- vnode.anchor = nextSibling(node);
7360
- vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7361
- }
7362
- target._lpa =
7363
- vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7364
- }
7365
- }
7366
- return vnode.anchor && nextSibling(vnode.anchor);
7367
- }
7368
- // Force-casted public typing for h and TSX props inference
7369
- const Teleport = TeleportImpl;
7370
-
7371
- const COMPONENTS = 'components';
7372
- const DIRECTIVES = 'directives';
7373
- /**
7374
- * @private
7375
- */
7376
- function resolveComponent(name, maybeSelfReference) {
7377
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7378
- }
7379
- const NULL_DYNAMIC_COMPONENT = Symbol();
7380
- /**
7381
- * @private
7382
- */
7383
- function resolveDynamicComponent(component) {
7384
- if (isString(component)) {
7385
- return resolveAsset(COMPONENTS, component, false) || component;
7386
- }
7387
- else {
7388
- // invalid types will fallthrough to createVNode and raise warning
7389
- return (component || NULL_DYNAMIC_COMPONENT);
7390
- }
7391
- }
7392
- /**
7393
- * @private
7394
- */
7395
- function resolveDirective(name) {
7396
- return resolveAsset(DIRECTIVES, name);
7397
- }
7398
- // implementation
7399
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7400
- const instance = currentRenderingInstance || currentInstance;
7401
- if (instance) {
7402
- const Component = instance.type;
7403
- // explicit self name has highest priority
7404
- if (type === COMPONENTS) {
7405
- const selfName = getComponentName(Component);
7406
- if (selfName &&
7407
- (selfName === name ||
7408
- selfName === camelize(name) ||
7409
- selfName === capitalize(camelize(name)))) {
7410
- return Component;
7411
- }
7412
- }
7413
- const res =
7414
- // local registration
7415
- // check instance[type] first which is resolved for options API
7416
- resolve(instance[type] || Component[type], name) ||
7417
- // global registration
7418
- resolve(instance.appContext[type], name);
7419
- if (!res && maybeSelfReference) {
7420
- // fallback to implicit self-reference
7421
- return Component;
7422
- }
7423
- if (warnMissing && !res) {
7424
- const extra = type === COMPONENTS
7425
- ? `\nIf this is a native custom element, make sure to exclude it from ` +
7426
- `component resolution via compilerOptions.isCustomElement.`
7427
- : ``;
7428
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7887
+ vnode.anchor = nextSibling(node);
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
+ }
7429
7905
  }
7430
- return res;
7431
- }
7432
- else {
7433
- warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
7434
- `can only be used in render() or setup().`);
7435
7906
  }
7907
+ return vnode.anchor && nextSibling(vnode.anchor);
7436
7908
  }
7437
- function resolve(registry, name) {
7438
- return (registry &&
7439
- (registry[name] ||
7440
- registry[camelize(name)] ||
7441
- registry[capitalize(camelize(name))]));
7442
- }
7909
+ // Force-casted public typing for h and TSX props inference
7910
+ const Teleport = TeleportImpl;
7443
7911
 
7444
7912
  const Fragment = Symbol('Fragment' );
7445
7913
  const Text = Symbol('Text' );
@@ -7643,6 +8111,15 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
7643
8111
  if (children) {
7644
8112
  normalizeChildren(cloned, children);
7645
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 */;
7646
8123
  return cloned;
7647
8124
  }
7648
8125
  // class component normalization.
@@ -7720,606 +8197,194 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
7720
8197
  children: patchFlag === -1 /* HOISTED */ && isArray(children)
7721
8198
  ? children.map(deepCloneVNode)
7722
8199
  : children,
7723
- target: vnode.target,
7724
- targetAnchor: vnode.targetAnchor,
7725
- staticCount: vnode.staticCount,
7726
- shapeFlag: vnode.shapeFlag,
7727
- // if the vnode is cloned with extra props, we can no longer assume its
7728
- // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7729
- // note: preserve flag for fragments since they use the flag for children
7730
- // fast paths only.
7731
- patchFlag: extraProps && vnode.type !== Fragment
7732
- ? patchFlag === -1 // hoisted node
7733
- ? 16 /* FULL_PROPS */
7734
- : patchFlag | 16 /* FULL_PROPS */
7735
- : patchFlag,
7736
- dynamicProps: vnode.dynamicProps,
7737
- dynamicChildren: vnode.dynamicChildren,
7738
- appContext: vnode.appContext,
7739
- dirs: vnode.dirs,
7740
- transition: vnode.transition,
7741
- // These should technically only be non-null on mounted VNodes. However,
7742
- // they *should* be copied for kept-alive vnodes. So we just always copy
7743
- // them since them being non-null during a mount doesn't affect the logic as
7744
- // they will simply be overwritten.
7745
- component: vnode.component,
7746
- suspense: vnode.suspense,
7747
- ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7748
- ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7749
- el: vnode.el,
7750
- anchor: vnode.anchor
7751
- };
7752
- return cloned;
7753
- }
7754
- /**
7755
- * Dev only, for HMR of hoisted vnodes reused in v-for
7756
- * https://github.com/vitejs/vite/issues/2022
7757
- */
7758
- function deepCloneVNode(vnode) {
7759
- const cloned = cloneVNode(vnode);
7760
- if (isArray(vnode.children)) {
7761
- cloned.children = vnode.children.map(deepCloneVNode);
7762
- }
7763
- return cloned;
7764
- }
7765
- /**
7766
- * @private
7767
- */
7768
- function createTextVNode(text = ' ', flag = 0) {
7769
- return createVNode(Text, null, text, flag);
7770
- }
7771
- /**
7772
- * @private
7773
- */
7774
- function createStaticVNode(content, numberOfNodes) {
7775
- // A static vnode can contain multiple stringified elements, and the number
7776
- // of elements is necessary for hydration.
7777
- const vnode = createVNode(Static, null, content);
7778
- vnode.staticCount = numberOfNodes;
7779
- return vnode;
7780
- }
7781
- /**
7782
- * @private
7783
- */
7784
- function createCommentVNode(text = '',
7785
- // when used as the v-else branch, the comment node must be created as a
7786
- // block to ensure correct updates.
7787
- asBlock = false) {
7788
- return asBlock
7789
- ? (openBlock(), createBlock(Comment, null, text))
7790
- : createVNode(Comment, null, text);
7791
- }
7792
- function normalizeVNode(child) {
7793
- if (child == null || typeof child === 'boolean') {
7794
- // empty placeholder
7795
- return createVNode(Comment);
7796
- }
7797
- else if (isArray(child)) {
7798
- // fragment
7799
- return createVNode(Fragment, null,
7800
- // #3666, avoid reference pollution when reusing vnode
7801
- child.slice());
7802
- }
7803
- else if (typeof child === 'object') {
7804
- // already vnode, this should be the most common since compiled templates
7805
- // always produce all-vnode children arrays
7806
- return cloneIfMounted(child);
7807
- }
7808
- else {
7809
- // strings and numbers
7810
- return createVNode(Text, null, String(child));
7811
- }
7812
- }
7813
- // optimized normalization for template-compiled render fns
7814
- function cloneIfMounted(child) {
7815
- return child.el === null || child.memo ? child : cloneVNode(child);
7816
- }
7817
- function normalizeChildren(vnode, children) {
7818
- let type = 0;
7819
- const { shapeFlag } = vnode;
7820
- if (children == null) {
7821
- children = null;
7822
- }
7823
- else if (isArray(children)) {
7824
- type = 16 /* ARRAY_CHILDREN */;
7825
- }
7826
- else if (typeof children === 'object') {
7827
- if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7828
- // Normalize slot to plain children for plain element and Teleport
7829
- const slot = children.default;
7830
- if (slot) {
7831
- // _c marker is added by withCtx() indicating this is a compiled slot
7832
- slot._c && (slot._d = false);
7833
- normalizeChildren(vnode, slot());
7834
- slot._c && (slot._d = true);
7835
- }
7836
- return;
7837
- }
7838
- else {
7839
- type = 32 /* SLOTS_CHILDREN */;
7840
- const slotFlag = children._;
7841
- if (!slotFlag && !(InternalObjectKey in children)) {
7842
- children._ctx = currentRenderingInstance;
7843
- }
7844
- else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7845
- // a child component receives forwarded slots from the parent.
7846
- // its slot type is determined by its parent's slot type.
7847
- if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7848
- children._ = 1 /* STABLE */;
7849
- }
7850
- else {
7851
- children._ = 2 /* DYNAMIC */;
7852
- vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7853
- }
7854
- }
7855
- }
7856
- }
7857
- else if (isFunction(children)) {
7858
- children = { default: children, _ctx: currentRenderingInstance };
7859
- type = 32 /* SLOTS_CHILDREN */;
7860
- }
7861
- else {
7862
- children = String(children);
7863
- // force teleport children to array so it can be moved around
7864
- if (shapeFlag & 64 /* TELEPORT */) {
7865
- type = 16 /* ARRAY_CHILDREN */;
7866
- children = [createTextVNode(children)];
7867
- }
7868
- else {
7869
- type = 8 /* TEXT_CHILDREN */;
7870
- }
7871
- }
7872
- vnode.children = children;
7873
- vnode.shapeFlag |= type;
7874
- }
7875
- function mergeProps(...args) {
7876
- const ret = {};
7877
- for (let i = 0; i < args.length; i++) {
7878
- const toMerge = args[i];
7879
- for (const key in toMerge) {
7880
- if (key === 'class') {
7881
- if (ret.class !== toMerge.class) {
7882
- ret.class = normalizeClass([ret.class, toMerge.class]);
7883
- }
7884
- }
7885
- else if (key === 'style') {
7886
- ret.style = normalizeStyle([ret.style, toMerge.style]);
7887
- }
7888
- else if (isOn(key)) {
7889
- const existing = ret[key];
7890
- const incoming = toMerge[key];
7891
- if (incoming &&
7892
- existing !== incoming &&
7893
- !(isArray(existing) && existing.includes(incoming))) {
7894
- ret[key] = existing
7895
- ? [].concat(existing, incoming)
7896
- : incoming;
7897
- }
7898
- }
7899
- else if (key !== '') {
7900
- ret[key] = toMerge[key];
7901
- }
7902
- }
7903
- }
7904
- return ret;
7905
- }
7906
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7907
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7908
- vnode,
7909
- prevVNode
7910
- ]);
7911
- }
7912
-
7913
- /**
7914
- * Actual implementation
7915
- */
7916
- function renderList(source, renderItem, cache, index) {
7917
- let ret;
7918
- const cached = (cache && cache[index]);
7919
- if (isArray(source) || isString(source)) {
7920
- ret = new Array(source.length);
7921
- for (let i = 0, l = source.length; i < l; i++) {
7922
- ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
7923
- }
7924
- }
7925
- else if (typeof source === 'number') {
7926
- if (!Number.isInteger(source)) {
7927
- warn$1(`The v-for range expect an integer value but got ${source}.`);
7928
- return [];
7929
- }
7930
- ret = new Array(source);
7931
- for (let i = 0; i < source; i++) {
7932
- ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
7933
- }
7934
- }
7935
- else if (isObject(source)) {
7936
- if (source[Symbol.iterator]) {
7937
- ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
7938
- }
7939
- else {
7940
- const keys = Object.keys(source);
7941
- ret = new Array(keys.length);
7942
- for (let i = 0, l = keys.length; i < l; i++) {
7943
- const key = keys[i];
7944
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
7945
- }
7946
- }
7947
- }
7948
- else {
7949
- ret = [];
7950
- }
7951
- if (cache) {
7952
- cache[index] = ret;
7953
- }
7954
- return ret;
7955
- }
7956
-
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
+ }
7957
8231
  /**
7958
- * Compiler runtime helper for creating dynamic slots object
7959
- * @private
8232
+ * Dev only, for HMR of hoisted vnodes reused in v-for
8233
+ * https://github.com/vitejs/vite/issues/2022
7960
8234
  */
7961
- function createSlots(slots, dynamicSlots) {
7962
- for (let i = 0; i < dynamicSlots.length; i++) {
7963
- const slot = dynamicSlots[i];
7964
- // array of dynamic slot generated by <template v-for="..." #[...]>
7965
- if (isArray(slot)) {
7966
- for (let j = 0; j < slot.length; j++) {
7967
- slots[slot[j].name] = slot[j].fn;
7968
- }
7969
- }
7970
- else if (slot) {
7971
- // conditional single slot generated by <template v-if="..." #foo>
7972
- slots[slot.name] = slot.fn;
7973
- }
8235
+ function deepCloneVNode(vnode) {
8236
+ const cloned = cloneVNode(vnode);
8237
+ if (isArray(vnode.children)) {
8238
+ cloned.children = vnode.children.map(deepCloneVNode);
7974
8239
  }
7975
- return slots;
7976
- }
7977
-
8240
+ return cloned;
8241
+ }
7978
8242
  /**
7979
- * Compiler runtime helper for rendering `<slot/>`
7980
8243
  * @private
7981
8244
  */
7982
- function renderSlot(slots, name, props = {},
7983
- // this is not a user-facing function, so the fallback is always generated by
7984
- // the compiler and guaranteed to be a function returning an array
7985
- fallback, noSlotted) {
7986
- if (currentRenderingInstance.isCE ||
7987
- (currentRenderingInstance.parent &&
7988
- isAsyncWrapper(currentRenderingInstance.parent) &&
7989
- currentRenderingInstance.parent.isCE)) {
7990
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
7991
- }
7992
- let slot = slots[name];
7993
- if (slot && slot.length > 1) {
7994
- warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
7995
- `function. You need to mark this component with $dynamic-slots in the ` +
7996
- `parent template.`);
7997
- slot = () => [];
7998
- }
7999
- // a compiled slot disables block tracking by default to avoid manual
8000
- // invocation interfering with template-based block tracking, but in
8001
- // `renderSlot` we can be sure that it's template-based so we can force
8002
- // enable it.
8003
- if (slot && slot._c) {
8004
- slot._d = false;
8005
- }
8006
- openBlock();
8007
- const validSlotContent = slot && ensureValidVNode(slot(props));
8008
- const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
8009
- ? 64 /* STABLE_FRAGMENT */
8010
- : -2 /* BAIL */);
8011
- if (!noSlotted && rendered.scopeId) {
8012
- rendered.slotScopeIds = [rendered.scopeId + '-s'];
8013
- }
8014
- if (slot && slot._c) {
8015
- slot._d = true;
8016
- }
8017
- return rendered;
8245
+ function createTextVNode(text = ' ', flag = 0) {
8246
+ return createVNode(Text, null, text, flag);
8018
8247
  }
8019
- function ensureValidVNode(vnodes) {
8020
- return vnodes.some(child => {
8021
- if (!isVNode(child))
8022
- return true;
8023
- if (child.type === Comment)
8024
- return false;
8025
- if (child.type === Fragment &&
8026
- !ensureValidVNode(child.children))
8027
- return false;
8028
- return true;
8029
- })
8030
- ? vnodes
8031
- : null;
8032
- }
8033
-
8034
8248
  /**
8035
- * For prefixing keys in v-on="obj" with "on"
8036
8249
  * @private
8037
- */
8038
- function toHandlers(obj) {
8039
- const ret = {};
8040
- if (!isObject(obj)) {
8041
- warn$1(`v-on with no argument expects an object value.`);
8042
- return ret;
8043
- }
8044
- for (const key in obj) {
8045
- ret[toHandlerKey(key)] = obj[key];
8046
- }
8047
- return ret;
8048
- }
8049
-
8050
- /**
8051
- * #2437 In Vue 3, functional components do not have a public instance proxy but
8052
- * they exist in the internal parent chain. For code that relies on traversing
8053
- * public $parent chains, skip functional ones and go to the parent instead.
8054
- */
8055
- const getPublicInstance = (i) => {
8056
- if (!i)
8057
- return null;
8058
- if (isStatefulComponent(i))
8059
- return getExposeProxy(i) || i.proxy;
8060
- return getPublicInstance(i.parent);
8061
- };
8062
- const publicPropertiesMap =
8063
- // Move PURE marker to new line to workaround compiler discarding it
8064
- // due to type annotation
8065
- /*#__PURE__*/ extend(Object.create(null), {
8066
- $: i => i,
8067
- $el: i => i.vnode.el,
8068
- $data: i => i.data,
8069
- $props: i => (shallowReadonly(i.props) ),
8070
- $attrs: i => (shallowReadonly(i.attrs) ),
8071
- $slots: i => (shallowReadonly(i.slots) ),
8072
- $refs: i => (shallowReadonly(i.refs) ),
8073
- $parent: i => getPublicInstance(i.parent),
8074
- $root: i => getPublicInstance(i.root),
8075
- $emit: i => i.emit,
8076
- $options: i => (resolveMergedOptions(i) ),
8077
- $forceUpdate: i => () => queueJob(i.update),
8078
- $nextTick: i => nextTick.bind(i.proxy),
8079
- $watch: i => (instanceWatch.bind(i) )
8080
- });
8081
- const PublicInstanceProxyHandlers = {
8082
- get({ _: instance }, key) {
8083
- const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
8084
- // for internal formatters to know that this is a Vue instance
8085
- if (key === '__isVue') {
8086
- return true;
8087
- }
8088
- // prioritize <script setup> bindings during dev.
8089
- // this allows even properties that start with _ or $ to be used - so that
8090
- // it aligns with the production behavior where the render fn is inlined and
8091
- // indeed has access to all declared variables.
8092
- if (setupState !== EMPTY_OBJ &&
8093
- setupState.__isScriptSetup &&
8094
- hasOwn(setupState, key)) {
8095
- return setupState[key];
8096
- }
8097
- // data / props / ctx
8098
- // This getter gets called for every property access on the render context
8099
- // during render and is a major hotspot. The most expensive part of this
8100
- // is the multiple hasOwn() calls. It's much faster to do a simple property
8101
- // access on a plain object, so we use an accessCache object (with null
8102
- // prototype) to memoize what access type a key corresponds to.
8103
- let normalizedProps;
8104
- if (key[0] !== '$') {
8105
- const n = accessCache[key];
8106
- if (n !== undefined) {
8107
- switch (n) {
8108
- case 1 /* SETUP */:
8109
- return setupState[key];
8110
- case 2 /* DATA */:
8111
- return data[key];
8112
- case 4 /* CONTEXT */:
8113
- return ctx[key];
8114
- case 3 /* PROPS */:
8115
- return props[key];
8116
- // default: just fallthrough
8117
- }
8118
- }
8119
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8120
- accessCache[key] = 1 /* SETUP */;
8121
- return setupState[key];
8122
- }
8123
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8124
- accessCache[key] = 2 /* DATA */;
8125
- return data[key];
8126
- }
8127
- else if (
8128
- // only cache other properties when instance has declared (thus stable)
8129
- // props
8130
- (normalizedProps = instance.propsOptions[0]) &&
8131
- hasOwn(normalizedProps, key)) {
8132
- accessCache[key] = 3 /* PROPS */;
8133
- return props[key];
8134
- }
8135
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8136
- accessCache[key] = 4 /* CONTEXT */;
8137
- return ctx[key];
8138
- }
8139
- else if (shouldCacheAccess) {
8140
- accessCache[key] = 0 /* OTHER */;
8141
- }
8142
- }
8143
- const publicGetter = publicPropertiesMap[key];
8144
- let cssModule, globalProperties;
8145
- // public $xxx properties
8146
- if (publicGetter) {
8147
- if (key === '$attrs') {
8148
- track(instance, "get" /* GET */, key);
8149
- markAttrsAccessed();
8150
- }
8151
- return publicGetter(instance);
8152
- }
8153
- else if (
8154
- // css module (injected by vue-loader)
8155
- (cssModule = type.__cssModules) &&
8156
- (cssModule = cssModule[key])) {
8157
- return cssModule;
8158
- }
8159
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8160
- // user may set custom properties to `this` that start with `$`
8161
- accessCache[key] = 4 /* CONTEXT */;
8162
- return ctx[key];
8163
- }
8164
- else if (
8165
- // global properties
8166
- ((globalProperties = appContext.config.globalProperties),
8167
- hasOwn(globalProperties, key))) {
8168
- {
8169
- return globalProperties[key];
8170
- }
8171
- }
8172
- else if (currentRenderingInstance &&
8173
- (!isString(key) ||
8174
- // #1091 avoid internal isRef/isVNode checks on component instance leading
8175
- // to infinite warning loop
8176
- key.indexOf('__v') !== 0)) {
8177
- if (data !== EMPTY_OBJ &&
8178
- (key[0] === '$' || key[0] === '_') &&
8179
- hasOwn(data, key)) {
8180
- warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
8181
- `character ("$" or "_") and is not proxied on the render context.`);
8182
- }
8183
- else if (instance === currentRenderingInstance) {
8184
- warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
8185
- `but is not defined on instance.`);
8250
+ */
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);
8186
8312
  }
8187
- }
8188
- },
8189
- set({ _: instance }, key, value) {
8190
- const { data, setupState, ctx } = instance;
8191
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8192
- setupState[key] = value;
8193
- return true;
8194
- }
8195
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8196
- data[key] = value;
8197
- return true;
8198
- }
8199
- else if (hasOwn(instance.props, key)) {
8200
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
8201
- return false;
8202
- }
8203
- if (key[0] === '$' && key.slice(1) in instance) {
8204
- warn$1(`Attempting to mutate public property "${key}". ` +
8205
- `Properties starting with $ are reserved and readonly.`, instance);
8206
- return false;
8313
+ return;
8207
8314
  }
8208
8315
  else {
8209
- if (key in instance.appContext.config.globalProperties) {
8210
- Object.defineProperty(ctx, key, {
8211
- enumerable: true,
8212
- configurable: true,
8213
- value
8214
- });
8316
+ type = 32 /* SLOTS_CHILDREN */;
8317
+ const slotFlag = children._;
8318
+ if (!slotFlag && !(InternalObjectKey in children)) {
8319
+ children._ctx = currentRenderingInstance;
8215
8320
  }
8216
- else {
8217
- 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
+ }
8218
8331
  }
8219
8332
  }
8220
- return true;
8221
- },
8222
- has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
8223
- let normalizedProps;
8224
- return (!!accessCache[key] ||
8225
- (data !== EMPTY_OBJ && hasOwn(data, key)) ||
8226
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
8227
- ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
8228
- hasOwn(ctx, key) ||
8229
- hasOwn(publicPropertiesMap, key) ||
8230
- hasOwn(appContext.config.globalProperties, key));
8231
- },
8232
- defineProperty(target, key, descriptor) {
8233
- if (descriptor.get != null) {
8234
- // invalidate key cache of a getter based property #5417
8235
- target._.accessCache[key] = 0;
8236
- }
8237
- else if (hasOwn(descriptor, 'value')) {
8238
- this.set(target, key, descriptor.value, null);
8239
- }
8240
- return Reflect.defineProperty(target, key, descriptor);
8241
8333
  }
8242
- };
8243
- {
8244
- PublicInstanceProxyHandlers.ownKeys = (target) => {
8245
- warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
8246
- `The keys will be empty in production mode to avoid performance overhead.`);
8247
- return Reflect.ownKeys(target);
8248
- };
8249
- }
8250
- const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
8251
- get(target, key) {
8252
- // fast path for unscopables when using `with` block
8253
- if (key === Symbol.unscopables) {
8254
- 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)];
8255
8344
  }
8256
- return PublicInstanceProxyHandlers.get(target, key, target);
8257
- },
8258
- has(_, key) {
8259
- const has = key[0] !== '_' && !isGloballyWhitelisted(key);
8260
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
8261
- 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 */;
8262
8347
  }
8263
- return has;
8264
- }
8265
- });
8266
- // dev only
8267
- // In dev mode, the proxy target exposes the same properties as seen on `this`
8268
- // for easier console inspection. In prod mode it will be an empty object so
8269
- // these properties definitions can be skipped.
8270
- function createDevRenderContext(instance) {
8271
- const target = {};
8272
- // expose internal instance for proxy handlers
8273
- Object.defineProperty(target, `_`, {
8274
- configurable: true,
8275
- enumerable: false,
8276
- get: () => instance
8277
- });
8278
- // expose public properties
8279
- Object.keys(publicPropertiesMap).forEach(key => {
8280
- Object.defineProperty(target, key, {
8281
- configurable: true,
8282
- enumerable: false,
8283
- get: () => publicPropertiesMap[key](instance),
8284
- // intercepted by the proxy so no need for implementation,
8285
- // but needed to prevent set errors
8286
- set: NOOP
8287
- });
8288
- });
8289
- return target;
8290
- }
8291
- // dev only
8292
- function exposePropsOnRenderContext(instance) {
8293
- const { ctx, propsOptions: [propsOptions] } = instance;
8294
- if (propsOptions) {
8295
- Object.keys(propsOptions).forEach(key => {
8296
- Object.defineProperty(ctx, key, {
8297
- enumerable: true,
8298
- configurable: true,
8299
- get: () => instance.props[key],
8300
- set: NOOP
8301
- });
8302
- });
8303
8348
  }
8349
+ vnode.children = children;
8350
+ vnode.shapeFlag |= type;
8304
8351
  }
8305
- // dev only
8306
- function exposeSetupStateOnRenderContext(instance) {
8307
- const { ctx, setupState } = instance;
8308
- Object.keys(toRaw(setupState)).forEach(key => {
8309
- if (!setupState.__isScriptSetup) {
8310
- if (key[0] === '$' || key[0] === '_') {
8311
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8312
- `which are reserved prefixes for Vue internals.`);
8313
- 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];
8314
8378
  }
8315
- Object.defineProperty(ctx, key, {
8316
- enumerable: true,
8317
- configurable: true,
8318
- get: () => setupState[key],
8319
- set: NOOP
8320
- });
8321
8379
  }
8322
- });
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
+ ]);
8323
8388
  }
8324
8389
 
8325
8390
  const emptyAppContext = createAppContext();
@@ -8348,7 +8413,7 @@ function createComponentInstance(vnode, parent, suspense) {
8348
8413
  provides: parent ? parent.provides : Object.create(appContext.provides),
8349
8414
  accessCache: null,
8350
8415
  renderCache: [],
8351
- // local resovled assets
8416
+ // local resolved assets
8352
8417
  components: null,
8353
8418
  directives: null,
8354
8419
  // resolved props and emits options
@@ -9109,7 +9174,7 @@ function isMemoSame(cached, memo) {
9109
9174
  return false;
9110
9175
  }
9111
9176
  for (let i = 0; i < prev.length; i++) {
9112
- if (prev[i] !== memo[i]) {
9177
+ if (hasChanged(prev[i], memo[i])) {
9113
9178
  return false;
9114
9179
  }
9115
9180
  }
@@ -9121,7 +9186,7 @@ function isMemoSame(cached, memo) {
9121
9186
  }
9122
9187
 
9123
9188
  // Core API ------------------------------------------------------------------
9124
- const version = "3.2.33";
9189
+ const version = "3.2.35";
9125
9190
  /**
9126
9191
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9127
9192
  * @internal
@@ -9598,11 +9663,11 @@ function shouldSetAsProp(el, key, value, isSVG) {
9598
9663
  return key in el;
9599
9664
  }
9600
9665
 
9601
- function defineCustomElement(options, hydate) {
9666
+ function defineCustomElement(options, hydrate) {
9602
9667
  const Comp = defineComponent(options);
9603
9668
  class VueCustomElement extends VueElement {
9604
9669
  constructor(initialProps) {
9605
- super(Comp, initialProps, hydate);
9670
+ super(Comp, initialProps, hydrate);
9606
9671
  }
9607
9672
  }
9608
9673
  VueCustomElement.def = Comp;
@@ -9962,7 +10027,10 @@ function resolveTransitionProps(rawProps) {
9962
10027
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
9963
10028
  done && done();
9964
10029
  };
10030
+ let isLeaving = false;
9965
10031
  const finishLeave = (el, done) => {
10032
+ isLeaving = false;
10033
+ removeTransitionClass(el, leaveFromClass);
9966
10034
  removeTransitionClass(el, leaveToClass);
9967
10035
  removeTransitionClass(el, leaveActiveClass);
9968
10036
  done && done();
@@ -9995,12 +10063,17 @@ function resolveTransitionProps(rawProps) {
9995
10063
  onEnter: makeEnterHook(false),
9996
10064
  onAppear: makeEnterHook(true),
9997
10065
  onLeave(el, done) {
10066
+ isLeaving = true;
9998
10067
  const resolve = () => finishLeave(el, done);
9999
10068
  addTransitionClass(el, leaveFromClass);
10000
10069
  // force reflow so *-leave-from classes immediately take effect (#2593)
10001
10070
  forceReflow();
10002
10071
  addTransitionClass(el, leaveActiveClass);
10003
10072
  nextFrame(() => {
10073
+ if (!isLeaving) {
10074
+ // cancelled
10075
+ return;
10076
+ }
10004
10077
  removeTransitionClass(el, leaveFromClass);
10005
10078
  addTransitionClass(el, leaveToClass);
10006
10079
  if (!hasExplicitCallback(onLeave)) {
@@ -10292,7 +10365,8 @@ function hasCSSTransform(el, root, moveClass) {
10292
10365
  }
10293
10366
 
10294
10367
  const getModelAssigner = (vnode) => {
10295
- const fn = vnode.props['onUpdate:modelValue'];
10368
+ const fn = vnode.props['onUpdate:modelValue'] ||
10369
+ (false );
10296
10370
  return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10297
10371
  };
10298
10372
  function onCompositionStart(e) {
@@ -10302,14 +10376,9 @@ function onCompositionEnd(e) {
10302
10376
  const target = e.target;
10303
10377
  if (target.composing) {
10304
10378
  target.composing = false;
10305
- trigger$1(target, 'input');
10379
+ target.dispatchEvent(new Event('input'));
10306
10380
  }
10307
10381
  }
10308
- function trigger$1(el, type) {
10309
- const e = document.createEvent('HTMLEvents');
10310
- e.initEvent(type, true, true);
10311
- el.dispatchEvent(e);
10312
- }
10313
10382
  // We are exporting the v-model runtime directly as vnode hooks so that it can
10314
10383
  // be tree-shaken in case v-model is never used.
10315
10384
  const vModelText = {
@@ -10323,7 +10392,7 @@ const vModelText = {
10323
10392
  if (trim) {
10324
10393
  domValue = domValue.trim();
10325
10394
  }
10326
- else if (castToNumber) {
10395
+ if (castToNumber) {
10327
10396
  domValue = toNumber(domValue);
10328
10397
  }
10329
10398
  el._assign(domValue);
@@ -10352,7 +10421,7 @@ const vModelText = {
10352
10421
  // avoid clearing unresolved text. #2302
10353
10422
  if (el.composing)
10354
10423
  return;
10355
- if (document.activeElement === el) {
10424
+ if (document.activeElement === el && el.type !== 'range') {
10356
10425
  if (lazy) {
10357
10426
  return;
10358
10427
  }
@@ -10522,27 +10591,25 @@ const vModelDynamic = {
10522
10591
  callModelHook(el, binding, vnode, prevVNode, 'updated');
10523
10592
  }
10524
10593
  };
10525
- function callModelHook(el, binding, vnode, prevVNode, hook) {
10526
- let modelToUse;
10527
- switch (el.tagName) {
10594
+ function resolveDynamicModel(tagName, type) {
10595
+ switch (tagName) {
10528
10596
  case 'SELECT':
10529
- modelToUse = vModelSelect;
10530
- break;
10597
+ return vModelSelect;
10531
10598
  case 'TEXTAREA':
10532
- modelToUse = vModelText;
10533
- break;
10599
+ return vModelText;
10534
10600
  default:
10535
- switch (vnode.props && vnode.props.type) {
10601
+ switch (type) {
10536
10602
  case 'checkbox':
10537
- modelToUse = vModelCheckbox;
10538
- break;
10603
+ return vModelCheckbox;
10539
10604
  case 'radio':
10540
- modelToUse = vModelRadio;
10541
- break;
10605
+ return vModelRadio;
10542
10606
  default:
10543
- modelToUse = vModelText;
10607
+ return vModelText;
10544
10608
  }
10545
10609
  }
10610
+ }
10611
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
10612
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
10546
10613
  const fn = modelToUse[hook];
10547
10614
  fn && fn(el, binding, vnode, prevVNode);
10548
10615
  }