@vue/runtime-dom 3.2.31 → 3.2.34-beta.1

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.
@@ -163,6 +163,11 @@ var VueRuntimeDOM = (function (exports) {
163
163
  if (aValidType || bValidType) {
164
164
  return aValidType && bValidType ? a.getTime() === b.getTime() : false;
165
165
  }
166
+ aValidType = isSymbol(a);
167
+ bValidType = isSymbol(b);
168
+ if (aValidType || bValidType) {
169
+ return a === b;
170
+ }
166
171
  aValidType = isArray(a);
167
172
  bValidType = isArray(b);
168
173
  if (aValidType || bValidType) {
@@ -258,7 +263,7 @@ var VueRuntimeDOM = (function (exports) {
258
263
  const isArray = Array.isArray;
259
264
  const isMap = (val) => toTypeString(val) === '[object Map]';
260
265
  const isSet = (val) => toTypeString(val) === '[object Set]';
261
- const isDate = (val) => val instanceof Date;
266
+ const isDate = (val) => toTypeString(val) === '[object Date]';
262
267
  const isFunction = (val) => typeof val === 'function';
263
268
  const isString = (val) => typeof val === 'string';
264
269
  const isSymbol = (val) => typeof val === 'symbol';
@@ -351,8 +356,17 @@ var VueRuntimeDOM = (function (exports) {
351
356
  let activeEffectScope;
352
357
  class EffectScope {
353
358
  constructor(detached = false) {
359
+ /**
360
+ * @internal
361
+ */
354
362
  this.active = true;
363
+ /**
364
+ * @internal
365
+ */
355
366
  this.effects = [];
367
+ /**
368
+ * @internal
369
+ */
356
370
  this.cleanups = [];
357
371
  if (!detached && activeEffectScope) {
358
372
  this.parent = activeEffectScope;
@@ -362,21 +376,30 @@ var VueRuntimeDOM = (function (exports) {
362
376
  }
363
377
  run(fn) {
364
378
  if (this.active) {
379
+ const currentEffectScope = activeEffectScope;
365
380
  try {
366
381
  activeEffectScope = this;
367
382
  return fn();
368
383
  }
369
384
  finally {
370
- activeEffectScope = this.parent;
385
+ activeEffectScope = currentEffectScope;
371
386
  }
372
387
  }
373
388
  else {
374
389
  warn(`cannot run an inactive effect scope.`);
375
390
  }
376
391
  }
392
+ /**
393
+ * This should only be called on non-detached scopes
394
+ * @internal
395
+ */
377
396
  on() {
378
397
  activeEffectScope = this;
379
398
  }
399
+ /**
400
+ * This should only be called on non-detached scopes
401
+ * @internal
402
+ */
380
403
  off() {
381
404
  activeEffectScope = this.parent;
382
405
  }
@@ -518,10 +541,17 @@ var VueRuntimeDOM = (function (exports) {
518
541
  activeEffect = this.parent;
519
542
  shouldTrack = lastShouldTrack;
520
543
  this.parent = undefined;
544
+ if (this.deferStop) {
545
+ this.stop();
546
+ }
521
547
  }
522
548
  }
523
549
  stop() {
524
- if (this.active) {
550
+ // stopped while running itself - defer the cleanup
551
+ if (activeEffect === this) {
552
+ this.deferStop = true;
553
+ }
554
+ else if (this.active) {
525
555
  cleanupEffect(this);
526
556
  if (this.onStop) {
527
557
  this.onStop();
@@ -600,9 +630,7 @@ var VueRuntimeDOM = (function (exports) {
600
630
  dep.add(activeEffect);
601
631
  activeEffect.deps.push(dep);
602
632
  if (activeEffect.onTrack) {
603
- activeEffect.onTrack(Object.assign({
604
- effect: activeEffect
605
- }, debuggerEventExtraInfo));
633
+ activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
606
634
  }
607
635
  }
608
636
  }
@@ -682,23 +710,40 @@ var VueRuntimeDOM = (function (exports) {
682
710
  }
683
711
  function triggerEffects(dep, debuggerEventExtraInfo) {
684
712
  // spread into array for stabilization
685
- for (const effect of isArray(dep) ? dep : [...dep]) {
686
- if (effect !== activeEffect || effect.allowRecurse) {
687
- if (effect.onTrigger) {
688
- effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
689
- }
690
- if (effect.scheduler) {
691
- effect.scheduler();
692
- }
693
- else {
694
- effect.run();
695
- }
713
+ const effects = isArray(dep) ? dep : [...dep];
714
+ for (const effect of effects) {
715
+ if (effect.computed) {
716
+ triggerEffect(effect, debuggerEventExtraInfo);
717
+ }
718
+ }
719
+ for (const effect of effects) {
720
+ if (!effect.computed) {
721
+ triggerEffect(effect, debuggerEventExtraInfo);
722
+ }
723
+ }
724
+ }
725
+ function triggerEffect(effect, debuggerEventExtraInfo) {
726
+ if (effect !== activeEffect || effect.allowRecurse) {
727
+ if (effect.onTrigger) {
728
+ effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
729
+ }
730
+ if (effect.scheduler) {
731
+ effect.scheduler();
732
+ }
733
+ else {
734
+ effect.run();
696
735
  }
697
736
  }
698
737
  }
699
738
 
700
739
  const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
701
- const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
740
+ const builtInSymbols = new Set(
741
+ /*#__PURE__*/
742
+ Object.getOwnPropertyNames(Symbol)
743
+ // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
744
+ // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
745
+ // function
746
+ .filter(key => key !== 'arguments' && key !== 'caller')
702
747
  .map(key => Symbol[key])
703
748
  .filter(isSymbol));
704
749
  const get = /*#__PURE__*/ createGetter();
@@ -772,9 +817,8 @@ var VueRuntimeDOM = (function (exports) {
772
817
  return res;
773
818
  }
774
819
  if (isRef(res)) {
775
- // ref unwrapping - does not apply for Array + integer key.
776
- const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
777
- return shouldUnwrap ? res.value : res;
820
+ // ref unwrapping - skip unwrap for Array + integer key.
821
+ return targetIsArray && isIntegerKey(key) ? res : res.value;
778
822
  }
779
823
  if (isObject(res)) {
780
824
  // Convert returned value into a proxy as well. we do the isObject check
@@ -850,13 +894,13 @@ var VueRuntimeDOM = (function (exports) {
850
894
  get: readonlyGet,
851
895
  set(target, key) {
852
896
  {
853
- console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
897
+ warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
854
898
  }
855
899
  return true;
856
900
  },
857
901
  deleteProperty(target, key) {
858
902
  {
859
- console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
903
+ warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
860
904
  }
861
905
  return true;
862
906
  }
@@ -880,10 +924,12 @@ var VueRuntimeDOM = (function (exports) {
880
924
  target = target["__v_raw" /* RAW */];
881
925
  const rawTarget = toRaw(target);
882
926
  const rawKey = toRaw(key);
883
- if (key !== rawKey) {
884
- !isReadonly && track(rawTarget, "get" /* GET */, key);
927
+ if (!isReadonly) {
928
+ if (key !== rawKey) {
929
+ track(rawTarget, "get" /* GET */, key);
930
+ }
931
+ track(rawTarget, "get" /* GET */, rawKey);
885
932
  }
886
- !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
887
933
  const { has } = getProto(rawTarget);
888
934
  const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
889
935
  if (has.call(rawTarget, key)) {
@@ -902,10 +948,12 @@ var VueRuntimeDOM = (function (exports) {
902
948
  const target = this["__v_raw" /* RAW */];
903
949
  const rawTarget = toRaw(target);
904
950
  const rawKey = toRaw(key);
905
- if (key !== rawKey) {
906
- !isReadonly && track(rawTarget, "has" /* HAS */, key);
951
+ if (!isReadonly) {
952
+ if (key !== rawKey) {
953
+ track(rawTarget, "has" /* HAS */, key);
954
+ }
955
+ track(rawTarget, "has" /* HAS */, rawKey);
907
956
  }
908
- !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
909
957
  return key === rawKey
910
958
  ? target.has(key)
911
959
  : target.has(key) || target.has(rawKey);
@@ -1231,7 +1279,7 @@ var VueRuntimeDOM = (function (exports) {
1231
1279
  if (existingProxy) {
1232
1280
  return existingProxy;
1233
1281
  }
1234
- // only a whitelist of value types can be observed.
1282
+ // only specific value types can be observed.
1235
1283
  const targetType = getTargetType(target);
1236
1284
  if (targetType === 0 /* INVALID */) {
1237
1285
  return target;
@@ -1684,7 +1732,7 @@ var VueRuntimeDOM = (function (exports) {
1684
1732
  const pendingPostFlushCbs = [];
1685
1733
  let activePostFlushCbs = null;
1686
1734
  let postFlushIndex = 0;
1687
- const resolvedPromise = Promise.resolve();
1735
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
1688
1736
  let currentFlushPromise = null;
1689
1737
  let currentPreFlushParentJob = null;
1690
1738
  const RECURSION_LIMIT = 100;
@@ -1781,6 +1829,8 @@ var VueRuntimeDOM = (function (exports) {
1781
1829
  }
1782
1830
  }
1783
1831
  function flushPostFlushCbs(seen) {
1832
+ // flush any pre cbs queued during the flush (e.g. pre watchers)
1833
+ flushPreFlushCbs();
1784
1834
  if (pendingPostFlushCbs.length) {
1785
1835
  const deduped = [...new Set(pendingPostFlushCbs)];
1786
1836
  pendingPostFlushCbs.length = 0;
@@ -2039,7 +2089,6 @@ var VueRuntimeDOM = (function (exports) {
2039
2089
  // handle late devtools injection - only do this if we are in an actual
2040
2090
  // browser environment to avoid the timer handle stalling test runner exit
2041
2091
  // (#4815)
2042
- // eslint-disable-next-line no-restricted-globals
2043
2092
  typeof window !== 'undefined' &&
2044
2093
  // some envs mock window but not fully
2045
2094
  window.HTMLElement &&
@@ -2099,6 +2148,8 @@ var VueRuntimeDOM = (function (exports) {
2099
2148
  }
2100
2149
 
2101
2150
  function emit$1(instance, event, ...rawArgs) {
2151
+ if (instance.isUnmounted)
2152
+ return;
2102
2153
  const props = instance.vnode.props || EMPTY_OBJ;
2103
2154
  {
2104
2155
  const { emitsOptions, propsOptions: [propsOptions] } = instance;
@@ -2131,7 +2182,7 @@ var VueRuntimeDOM = (function (exports) {
2131
2182
  if (trim) {
2132
2183
  args = rawArgs.map(a => a.trim());
2133
2184
  }
2134
- else if (number) {
2185
+ if (number) {
2135
2186
  args = rawArgs.map(toNumber);
2136
2187
  }
2137
2188
  }
@@ -2429,6 +2480,8 @@ var VueRuntimeDOM = (function (exports) {
2429
2480
  warn$1(`Runtime directive used on component with non-element root node. ` +
2430
2481
  `The directives will not function as intended.`);
2431
2482
  }
2483
+ // clone before mutating since the root may be a hoisted vnode
2484
+ root = cloneVNode(root);
2432
2485
  root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2433
2486
  }
2434
2487
  // inherit transition data
@@ -3086,12 +3139,10 @@ var VueRuntimeDOM = (function (exports) {
3086
3139
  return doWatch(effect, null, options);
3087
3140
  }
3088
3141
  function watchPostEffect(effect, options) {
3089
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
3090
- ));
3142
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
3091
3143
  }
3092
3144
  function watchSyncEffect(effect, options) {
3093
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
3094
- ));
3145
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
3095
3146
  }
3096
3147
  // initial value for watchers to trigger on undefined initial values
3097
3148
  const INITIAL_WATCHER_VALUE = {};
@@ -3133,7 +3184,7 @@ var VueRuntimeDOM = (function (exports) {
3133
3184
  }
3134
3185
  else if (isArray(source)) {
3135
3186
  isMultiSource = true;
3136
- forceTrigger = source.some(isReactive);
3187
+ forceTrigger = source.some(s => isReactive(s) || isShallow(s));
3137
3188
  getter = () => source.map(s => {
3138
3189
  if (isRef(s)) {
3139
3190
  return s.value;
@@ -3225,16 +3276,7 @@ var VueRuntimeDOM = (function (exports) {
3225
3276
  }
3226
3277
  else {
3227
3278
  // default: 'pre'
3228
- scheduler = () => {
3229
- if (!instance || instance.isMounted) {
3230
- queuePreFlushCb(job);
3231
- }
3232
- else {
3233
- // with 'pre' option, the first call must happen before
3234
- // the component is mounted so it is called synchronously.
3235
- job();
3236
- }
3237
- };
3279
+ scheduler = () => queuePreFlushCb(job);
3238
3280
  }
3239
3281
  const effect = new ReactiveEffect(getter, scheduler);
3240
3282
  {
@@ -3377,10 +3419,22 @@ var VueRuntimeDOM = (function (exports) {
3377
3419
  if (!children || !children.length) {
3378
3420
  return;
3379
3421
  }
3380
- // warn multiple elements
3422
+ let child = children[0];
3381
3423
  if (children.length > 1) {
3382
- warn$1('<transition> can only be used on a single element or component. Use ' +
3383
- '<transition-group> for lists.');
3424
+ let hasFound = false;
3425
+ // locate first non-comment child
3426
+ for (const c of children) {
3427
+ if (c.type !== Comment) {
3428
+ if (hasFound) {
3429
+ // warn more than one non-comment child
3430
+ warn$1('<transition> can only be used on a single element or component. ' +
3431
+ 'Use <transition-group> for lists.');
3432
+ break;
3433
+ }
3434
+ child = c;
3435
+ hasFound = true;
3436
+ }
3437
+ }
3384
3438
  }
3385
3439
  // there's no need to track reactivity for these props so use the raw
3386
3440
  // props for a bit better perf
@@ -3388,11 +3442,11 @@ var VueRuntimeDOM = (function (exports) {
3388
3442
  const { mode } = rawProps;
3389
3443
  // check mode
3390
3444
  if (mode &&
3391
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3445
+ mode !== 'in-out' &&
3446
+ mode !== 'out-in' &&
3447
+ mode !== 'default') {
3392
3448
  warn$1(`invalid <transition> mode: ${mode}`);
3393
3449
  }
3394
- // at this point children has a guaranteed length of 1.
3395
- const child = children[0];
3396
3450
  if (state.isLeaving) {
3397
3451
  return emptyPlaceholder(child);
3398
3452
  }
@@ -3475,6 +3529,17 @@ var VueRuntimeDOM = (function (exports) {
3475
3529
  hook &&
3476
3530
  callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3477
3531
  };
3532
+ const callAsyncHook = (hook, args) => {
3533
+ const done = args[1];
3534
+ callHook(hook, args);
3535
+ if (isArray(hook)) {
3536
+ if (hook.every(hook => hook.length <= 1))
3537
+ done();
3538
+ }
3539
+ else if (hook.length <= 1) {
3540
+ done();
3541
+ }
3542
+ };
3478
3543
  const hooks = {
3479
3544
  mode,
3480
3545
  persisted,
@@ -3533,10 +3598,7 @@ var VueRuntimeDOM = (function (exports) {
3533
3598
  el._enterCb = undefined;
3534
3599
  });
3535
3600
  if (hook) {
3536
- hook(el, done);
3537
- if (hook.length <= 1) {
3538
- done();
3539
- }
3601
+ callAsyncHook(hook, [el, done]);
3540
3602
  }
3541
3603
  else {
3542
3604
  done();
@@ -3570,10 +3632,7 @@ var VueRuntimeDOM = (function (exports) {
3570
3632
  });
3571
3633
  leavingVNodesCache[key] = vnode;
3572
3634
  if (onLeave) {
3573
- onLeave(el, done);
3574
- if (onLeave.length <= 1) {
3575
- done();
3576
- }
3635
+ callAsyncHook(onLeave, [el, done]);
3577
3636
  }
3578
3637
  else {
3579
3638
  done();
@@ -3615,20 +3674,24 @@ var VueRuntimeDOM = (function (exports) {
3615
3674
  vnode.transition = hooks;
3616
3675
  }
3617
3676
  }
3618
- function getTransitionRawChildren(children, keepComment = false) {
3677
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3619
3678
  let ret = [];
3620
3679
  let keyedFragmentCount = 0;
3621
3680
  for (let i = 0; i < children.length; i++) {
3622
- const child = children[i];
3681
+ let child = children[i];
3682
+ // #5360 inherit parent key in case of <template v-for>
3683
+ const key = parentKey == null
3684
+ ? child.key
3685
+ : String(parentKey) + String(child.key != null ? child.key : i);
3623
3686
  // handle fragment children case, e.g. v-for
3624
3687
  if (child.type === Fragment) {
3625
3688
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3626
3689
  keyedFragmentCount++;
3627
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3690
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3628
3691
  }
3629
3692
  // comment placeholders should be skipped, e.g. v-if
3630
3693
  else if (keepComment || child.type !== Comment) {
3631
- ret.push(child);
3694
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3632
3695
  }
3633
3696
  }
3634
3697
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -3779,7 +3842,7 @@ var VueRuntimeDOM = (function (exports) {
3779
3842
  }
3780
3843
  });
3781
3844
  }
3782
- function createInnerComp(comp, { vnode: { ref, props, children } }) {
3845
+ function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3783
3846
  const vnode = createVNode(comp, props, children);
3784
3847
  // ensure inner component inherits the async wrapper's ref owner
3785
3848
  vnode.ref = ref;
@@ -3988,7 +4051,7 @@ var VueRuntimeDOM = (function (exports) {
3988
4051
  // avoid vnode being unmounted
3989
4052
  vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
3990
4053
  current = vnode;
3991
- return rawVNode;
4054
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
3992
4055
  };
3993
4056
  }
3994
4057
  };
@@ -4126,1074 +4189,1569 @@ var VueRuntimeDOM = (function (exports) {
4126
4189
  injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4127
4190
  }
4128
4191
 
4129
- function createDuplicateChecker() {
4130
- const cache = Object.create(null);
4131
- return (type, key) => {
4132
- if (cache[key]) {
4133
- warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
4192
+ /**
4193
+ Runtime helper for applying directives to a vnode. Example usage:
4194
+
4195
+ const comp = resolveComponent('comp')
4196
+ const foo = resolveDirective('foo')
4197
+ const bar = resolveDirective('bar')
4198
+
4199
+ return withDirectives(h(comp), [
4200
+ [foo, this.x],
4201
+ [bar, this.y]
4202
+ ])
4203
+ */
4204
+ function validateDirectiveName(name) {
4205
+ if (isBuiltInDirective(name)) {
4206
+ warn$1('Do not use built-in directive ids as custom directive id: ' + name);
4207
+ }
4208
+ }
4209
+ /**
4210
+ * Adds directives to a VNode.
4211
+ */
4212
+ function withDirectives(vnode, directives) {
4213
+ const internalInstance = currentRenderingInstance;
4214
+ if (internalInstance === null) {
4215
+ warn$1(`withDirectives can only be used inside render functions.`);
4216
+ return vnode;
4217
+ }
4218
+ const instance = getExposeProxy(internalInstance) ||
4219
+ internalInstance.proxy;
4220
+ const bindings = vnode.dirs || (vnode.dirs = []);
4221
+ for (let i = 0; i < directives.length; i++) {
4222
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4223
+ if (isFunction(dir)) {
4224
+ dir = {
4225
+ mounted: dir,
4226
+ updated: dir
4227
+ };
4134
4228
  }
4135
- else {
4136
- cache[key] = type;
4229
+ if (dir.deep) {
4230
+ traverse(value);
4137
4231
  }
4138
- };
4139
- }
4140
- let shouldCacheAccess = true;
4141
- function applyOptions(instance) {
4142
- const options = resolveMergedOptions(instance);
4143
- const publicThis = instance.proxy;
4144
- const ctx = instance.ctx;
4145
- // do not cache property access on public proxy during state initialization
4146
- shouldCacheAccess = false;
4147
- // call beforeCreate first before accessing other options since
4148
- // the hook may mutate resolved options (#2791)
4149
- if (options.beforeCreate) {
4150
- callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4232
+ bindings.push({
4233
+ dir,
4234
+ instance,
4235
+ value,
4236
+ oldValue: void 0,
4237
+ arg,
4238
+ modifiers
4239
+ });
4151
4240
  }
4152
- const {
4153
- // state
4154
- data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4155
- // lifecycle
4156
- created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4157
- // public API
4158
- expose, inheritAttrs,
4159
- // assets
4160
- components, directives, filters } = options;
4161
- const checkDuplicateProperties = createDuplicateChecker() ;
4162
- {
4163
- const [propsOptions] = instance.propsOptions;
4164
- if (propsOptions) {
4165
- for (const key in propsOptions) {
4166
- checkDuplicateProperties("Props" /* PROPS */, key);
4167
- }
4241
+ return vnode;
4242
+ }
4243
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4244
+ const bindings = vnode.dirs;
4245
+ const oldBindings = prevVNode && prevVNode.dirs;
4246
+ for (let i = 0; i < bindings.length; i++) {
4247
+ const binding = bindings[i];
4248
+ if (oldBindings) {
4249
+ binding.oldValue = oldBindings[i].value;
4250
+ }
4251
+ let hook = binding.dir[name];
4252
+ if (hook) {
4253
+ // disable tracking inside all lifecycle hooks
4254
+ // since they can potentially be called inside effects.
4255
+ pauseTracking();
4256
+ callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
4257
+ vnode.el,
4258
+ binding,
4259
+ vnode,
4260
+ prevVNode
4261
+ ]);
4262
+ resetTracking();
4168
4263
  }
4169
4264
  }
4170
- // options initialization order (to be consistent with Vue 2):
4171
- // - props (already done outside of this function)
4172
- // - inject
4173
- // - methods
4174
- // - data (deferred since it relies on `this` access)
4175
- // - computed
4176
- // - watch (deferred since it relies on `this` access)
4177
- if (injectOptions) {
4178
- resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
4265
+ }
4266
+
4267
+ const COMPONENTS = 'components';
4268
+ const DIRECTIVES = 'directives';
4269
+ /**
4270
+ * @private
4271
+ */
4272
+ function resolveComponent(name, maybeSelfReference) {
4273
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4274
+ }
4275
+ const NULL_DYNAMIC_COMPONENT = Symbol();
4276
+ /**
4277
+ * @private
4278
+ */
4279
+ function resolveDynamicComponent(component) {
4280
+ if (isString(component)) {
4281
+ return resolveAsset(COMPONENTS, component, false) || component;
4179
4282
  }
4180
- if (methods) {
4181
- for (const key in methods) {
4182
- const methodHandler = methods[key];
4183
- if (isFunction(methodHandler)) {
4184
- // In dev mode, we use the `createRenderContext` function to define
4185
- // methods to the proxy target, and those are read-only but
4186
- // reconfigurable, so it needs to be redefined here
4187
- {
4188
- Object.defineProperty(ctx, key, {
4189
- value: methodHandler.bind(publicThis),
4190
- configurable: true,
4191
- enumerable: true,
4192
- writable: true
4193
- });
4194
- }
4195
- {
4196
- checkDuplicateProperties("Methods" /* METHODS */, key);
4197
- }
4198
- }
4199
- else {
4200
- warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4201
- `Did you reference the function correctly?`);
4202
- }
4203
- }
4283
+ else {
4284
+ // invalid types will fallthrough to createVNode and raise warning
4285
+ return (component || NULL_DYNAMIC_COMPONENT);
4204
4286
  }
4205
- if (dataOptions) {
4206
- if (!isFunction(dataOptions)) {
4207
- warn$1(`The data option must be a function. ` +
4208
- `Plain object usage is no longer supported.`);
4287
+ }
4288
+ /**
4289
+ * @private
4290
+ */
4291
+ function resolveDirective(name) {
4292
+ return resolveAsset(DIRECTIVES, name);
4293
+ }
4294
+ // implementation
4295
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4296
+ const instance = currentRenderingInstance || currentInstance;
4297
+ if (instance) {
4298
+ const Component = instance.type;
4299
+ // explicit self name has highest priority
4300
+ if (type === COMPONENTS) {
4301
+ const selfName = getComponentName(Component);
4302
+ if (selfName &&
4303
+ (selfName === name ||
4304
+ selfName === camelize(name) ||
4305
+ selfName === capitalize(camelize(name)))) {
4306
+ return Component;
4307
+ }
4209
4308
  }
4210
- const data = dataOptions.call(publicThis, publicThis);
4211
- if (isPromise(data)) {
4212
- warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4213
- `intend to perform data fetching before component renders, use ` +
4214
- `async setup() + <Suspense>.`);
4309
+ const res =
4310
+ // local registration
4311
+ // check instance[type] first which is resolved for options API
4312
+ resolve(instance[type] || Component[type], name) ||
4313
+ // global registration
4314
+ resolve(instance.appContext[type], name);
4315
+ if (!res && maybeSelfReference) {
4316
+ // fallback to implicit self-reference
4317
+ return Component;
4215
4318
  }
4216
- if (!isObject(data)) {
4217
- warn$1(`data() should return an object.`);
4319
+ if (warnMissing && !res) {
4320
+ const extra = type === COMPONENTS
4321
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
4322
+ `component resolution via compilerOptions.isCustomElement.`
4323
+ : ``;
4324
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4218
4325
  }
4219
- else {
4220
- instance.data = reactive(data);
4221
- {
4222
- for (const key in data) {
4223
- checkDuplicateProperties("Data" /* DATA */, key);
4224
- // expose data on ctx during dev
4225
- if (key[0] !== '$' && key[0] !== '_') {
4226
- Object.defineProperty(ctx, key, {
4227
- configurable: true,
4228
- enumerable: true,
4229
- get: () => data[key],
4230
- set: NOOP
4231
- });
4232
- }
4233
- }
4234
- }
4235
- }
4236
- }
4237
- // state initialization complete at this point - start caching access
4238
- shouldCacheAccess = true;
4239
- if (computedOptions) {
4240
- for (const key in computedOptions) {
4241
- const opt = computedOptions[key];
4242
- const get = isFunction(opt)
4243
- ? opt.bind(publicThis, publicThis)
4244
- : isFunction(opt.get)
4245
- ? opt.get.bind(publicThis, publicThis)
4246
- : NOOP;
4247
- if (get === NOOP) {
4248
- warn$1(`Computed property "${key}" has no getter.`);
4249
- }
4250
- const set = !isFunction(opt) && isFunction(opt.set)
4251
- ? opt.set.bind(publicThis)
4252
- : () => {
4253
- warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4254
- }
4255
- ;
4256
- const c = computed$1({
4257
- get,
4258
- set
4259
- });
4260
- Object.defineProperty(ctx, key, {
4261
- enumerable: true,
4262
- configurable: true,
4263
- get: () => c.value,
4264
- set: v => (c.value = v)
4265
- });
4266
- {
4267
- checkDuplicateProperties("Computed" /* COMPUTED */, key);
4268
- }
4269
- }
4270
- }
4271
- if (watchOptions) {
4272
- for (const key in watchOptions) {
4273
- createWatcher(watchOptions[key], ctx, publicThis, key);
4274
- }
4275
- }
4276
- if (provideOptions) {
4277
- const provides = isFunction(provideOptions)
4278
- ? provideOptions.call(publicThis)
4279
- : provideOptions;
4280
- Reflect.ownKeys(provides).forEach(key => {
4281
- provide(key, provides[key]);
4282
- });
4326
+ return res;
4283
4327
  }
4284
- if (created) {
4285
- callHook(created, instance, "c" /* CREATED */);
4328
+ else {
4329
+ warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
4330
+ `can only be used in render() or setup().`);
4286
4331
  }
4287
- function registerLifecycleHook(register, hook) {
4288
- if (isArray(hook)) {
4289
- hook.forEach(_hook => register(_hook.bind(publicThis)));
4290
- }
4291
- else if (hook) {
4292
- register(hook.bind(publicThis));
4332
+ }
4333
+ function resolve(registry, name) {
4334
+ return (registry &&
4335
+ (registry[name] ||
4336
+ registry[camelize(name)] ||
4337
+ registry[capitalize(camelize(name))]));
4338
+ }
4339
+
4340
+ /**
4341
+ * Actual implementation
4342
+ */
4343
+ function renderList(source, renderItem, cache, index) {
4344
+ let ret;
4345
+ const cached = (cache && cache[index]);
4346
+ if (isArray(source) || isString(source)) {
4347
+ ret = new Array(source.length);
4348
+ for (let i = 0, l = source.length; i < l; i++) {
4349
+ ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
4293
4350
  }
4294
4351
  }
4295
- registerLifecycleHook(onBeforeMount, beforeMount);
4296
- registerLifecycleHook(onMounted, mounted);
4297
- registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4298
- registerLifecycleHook(onUpdated, updated);
4299
- registerLifecycleHook(onActivated, activated);
4300
- registerLifecycleHook(onDeactivated, deactivated);
4301
- registerLifecycleHook(onErrorCaptured, errorCaptured);
4302
- registerLifecycleHook(onRenderTracked, renderTracked);
4303
- registerLifecycleHook(onRenderTriggered, renderTriggered);
4304
- registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4305
- registerLifecycleHook(onUnmounted, unmounted);
4306
- registerLifecycleHook(onServerPrefetch, serverPrefetch);
4307
- if (isArray(expose)) {
4308
- if (expose.length) {
4309
- const exposed = instance.exposed || (instance.exposed = {});
4310
- expose.forEach(key => {
4311
- Object.defineProperty(exposed, key, {
4312
- get: () => publicThis[key],
4313
- set: val => (publicThis[key] = val)
4314
- });
4315
- });
4352
+ else if (typeof source === 'number') {
4353
+ if (!Number.isInteger(source)) {
4354
+ warn$1(`The v-for range expect an integer value but got ${source}.`);
4316
4355
  }
4317
- else if (!instance.exposed) {
4318
- instance.exposed = {};
4356
+ ret = new Array(source);
4357
+ for (let i = 0; i < source; i++) {
4358
+ ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
4319
4359
  }
4320
4360
  }
4321
- // options that are handled when creating the instance but also need to be
4322
- // applied from mixins
4323
- if (render && instance.render === NOOP) {
4324
- instance.render = render;
4325
- }
4326
- if (inheritAttrs != null) {
4327
- instance.inheritAttrs = inheritAttrs;
4328
- }
4329
- // asset options.
4330
- if (components)
4331
- instance.components = components;
4332
- if (directives)
4333
- instance.directives = directives;
4334
- }
4335
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4336
- if (isArray(injectOptions)) {
4337
- injectOptions = normalizeInject(injectOptions);
4338
- }
4339
- for (const key in injectOptions) {
4340
- const opt = injectOptions[key];
4341
- let injected;
4342
- if (isObject(opt)) {
4343
- if ('default' in opt) {
4344
- injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4345
- }
4346
- else {
4347
- injected = inject(opt.from || key);
4348
- }
4361
+ else if (isObject(source)) {
4362
+ if (source[Symbol.iterator]) {
4363
+ ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
4349
4364
  }
4350
4365
  else {
4351
- injected = inject(opt);
4352
- }
4353
- if (isRef(injected)) {
4354
- // TODO remove the check in 3.3
4355
- if (unwrapRef) {
4356
- Object.defineProperty(ctx, key, {
4357
- enumerable: true,
4358
- configurable: true,
4359
- get: () => injected.value,
4360
- set: v => (injected.value = v)
4361
- });
4362
- }
4363
- else {
4364
- {
4365
- warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4366
- `and no longer needs \`.value\` in the next minor release. ` +
4367
- `To opt-in to the new behavior now, ` +
4368
- `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4369
- `temporary and will not be needed in the future.)`);
4370
- }
4371
- ctx[key] = injected;
4366
+ const keys = Object.keys(source);
4367
+ ret = new Array(keys.length);
4368
+ for (let i = 0, l = keys.length; i < l; i++) {
4369
+ const key = keys[i];
4370
+ ret[i] = renderItem(source[key], key, i, cached && cached[i]);
4372
4371
  }
4373
4372
  }
4374
- else {
4375
- ctx[key] = injected;
4376
- }
4377
- {
4378
- checkDuplicateProperties("Inject" /* INJECT */, key);
4379
- }
4380
4373
  }
4381
- }
4382
- function callHook(hook, instance, type) {
4383
- callWithAsyncErrorHandling(isArray(hook)
4384
- ? hook.map(h => h.bind(instance.proxy))
4385
- : hook.bind(instance.proxy), instance, type);
4386
- }
4387
- function createWatcher(raw, ctx, publicThis, key) {
4388
- const getter = key.includes('.')
4389
- ? createPathGetter(publicThis, key)
4390
- : () => publicThis[key];
4391
- if (isString(raw)) {
4392
- const handler = ctx[raw];
4393
- if (isFunction(handler)) {
4394
- watch(getter, handler);
4395
- }
4396
- else {
4397
- warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4398
- }
4374
+ else {
4375
+ ret = [];
4399
4376
  }
4400
- else if (isFunction(raw)) {
4401
- watch(getter, raw.bind(publicThis));
4377
+ if (cache) {
4378
+ cache[index] = ret;
4402
4379
  }
4403
- else if (isObject(raw)) {
4404
- if (isArray(raw)) {
4405
- raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4406
- }
4407
- else {
4408
- const handler = isFunction(raw.handler)
4409
- ? raw.handler.bind(publicThis)
4410
- : ctx[raw.handler];
4411
- if (isFunction(handler)) {
4412
- watch(getter, handler, raw);
4413
- }
4414
- else {
4415
- warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
4380
+ return ret;
4381
+ }
4382
+
4383
+ /**
4384
+ * Compiler runtime helper for creating dynamic slots object
4385
+ * @private
4386
+ */
4387
+ function createSlots(slots, dynamicSlots) {
4388
+ for (let i = 0; i < dynamicSlots.length; i++) {
4389
+ const slot = dynamicSlots[i];
4390
+ // array of dynamic slot generated by <template v-for="..." #[...]>
4391
+ if (isArray(slot)) {
4392
+ for (let j = 0; j < slot.length; j++) {
4393
+ slots[slot[j].name] = slot[j].fn;
4416
4394
  }
4417
4395
  }
4396
+ else if (slot) {
4397
+ // conditional single slot generated by <template v-if="..." #foo>
4398
+ slots[slot.name] = slot.fn;
4399
+ }
4418
4400
  }
4419
- else {
4420
- warn$1(`Invalid watch option: "${key}"`, raw);
4421
- }
4422
- }
4401
+ return slots;
4402
+ }
4403
+
4423
4404
  /**
4424
- * Resolve merged options and cache it on the component.
4425
- * This is done only once per-component since the merging does not involve
4426
- * instances.
4405
+ * Compiler runtime helper for rendering `<slot/>`
4406
+ * @private
4427
4407
  */
4428
- function resolveMergedOptions(instance) {
4429
- const base = instance.type;
4430
- const { mixins, extends: extendsOptions } = base;
4431
- const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4432
- const cached = cache.get(base);
4433
- let resolved;
4434
- if (cached) {
4435
- resolved = cached;
4436
- }
4437
- else if (!globalMixins.length && !mixins && !extendsOptions) {
4438
- {
4439
- resolved = base;
4440
- }
4441
- }
4442
- else {
4443
- resolved = {};
4444
- if (globalMixins.length) {
4445
- globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4446
- }
4447
- mergeOptions(resolved, base, optionMergeStrategies);
4448
- }
4449
- cache.set(base, resolved);
4450
- return resolved;
4451
- }
4452
- function mergeOptions(to, from, strats, asMixin = false) {
4453
- const { mixins, extends: extendsOptions } = from;
4454
- if (extendsOptions) {
4455
- mergeOptions(to, extendsOptions, strats, true);
4456
- }
4457
- if (mixins) {
4458
- mixins.forEach((m) => mergeOptions(to, m, strats, true));
4408
+ function renderSlot(slots, name, props = {},
4409
+ // this is not a user-facing function, so the fallback is always generated by
4410
+ // the compiler and guaranteed to be a function returning an array
4411
+ fallback, noSlotted) {
4412
+ if (currentRenderingInstance.isCE ||
4413
+ (currentRenderingInstance.parent &&
4414
+ isAsyncWrapper(currentRenderingInstance.parent) &&
4415
+ currentRenderingInstance.parent.isCE)) {
4416
+ return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
4459
4417
  }
4460
- for (const key in from) {
4461
- if (asMixin && key === 'expose') {
4462
- warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4463
- `It should only be declared in the base component itself.`);
4464
- }
4465
- else {
4466
- const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4467
- to[key] = strat ? strat(to[key], from[key]) : from[key];
4468
- }
4418
+ let slot = slots[name];
4419
+ if (slot && slot.length > 1) {
4420
+ warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
4421
+ `function. You need to mark this component with $dynamic-slots in the ` +
4422
+ `parent template.`);
4423
+ slot = () => [];
4469
4424
  }
4470
- return to;
4471
- }
4472
- const internalOptionMergeStrats = {
4473
- data: mergeDataFn,
4474
- props: mergeObjectOptions,
4475
- emits: mergeObjectOptions,
4476
- // objects
4477
- methods: mergeObjectOptions,
4478
- computed: mergeObjectOptions,
4479
- // lifecycle
4480
- beforeCreate: mergeAsArray,
4481
- created: mergeAsArray,
4482
- beforeMount: mergeAsArray,
4483
- mounted: mergeAsArray,
4484
- beforeUpdate: mergeAsArray,
4485
- updated: mergeAsArray,
4486
- beforeDestroy: mergeAsArray,
4487
- beforeUnmount: mergeAsArray,
4488
- destroyed: mergeAsArray,
4489
- unmounted: mergeAsArray,
4490
- activated: mergeAsArray,
4491
- deactivated: mergeAsArray,
4492
- errorCaptured: mergeAsArray,
4493
- serverPrefetch: mergeAsArray,
4494
- // assets
4495
- components: mergeObjectOptions,
4496
- directives: mergeObjectOptions,
4497
- // watch
4498
- watch: mergeWatchOptions,
4499
- // provide / inject
4500
- provide: mergeDataFn,
4501
- inject: mergeInject
4502
- };
4503
- function mergeDataFn(to, from) {
4504
- if (!from) {
4505
- return to;
4425
+ // a compiled slot disables block tracking by default to avoid manual
4426
+ // invocation interfering with template-based block tracking, but in
4427
+ // `renderSlot` we can be sure that it's template-based so we can force
4428
+ // enable it.
4429
+ if (slot && slot._c) {
4430
+ slot._d = false;
4506
4431
  }
4507
- if (!to) {
4508
- return from;
4432
+ openBlock();
4433
+ const validSlotContent = slot && ensureValidVNode(slot(props));
4434
+ const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
4435
+ ? 64 /* STABLE_FRAGMENT */
4436
+ : -2 /* BAIL */);
4437
+ if (!noSlotted && rendered.scopeId) {
4438
+ rendered.slotScopeIds = [rendered.scopeId + '-s'];
4509
4439
  }
4510
- return function mergedDataFn() {
4511
- return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4512
- };
4513
- }
4514
- function mergeInject(to, from) {
4515
- return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4516
- }
4517
- function normalizeInject(raw) {
4518
- if (isArray(raw)) {
4519
- const res = {};
4520
- for (let i = 0; i < raw.length; i++) {
4521
- res[raw[i]] = raw[i];
4522
- }
4523
- return res;
4440
+ if (slot && slot._c) {
4441
+ slot._d = true;
4524
4442
  }
4525
- return raw;
4526
- }
4527
- function mergeAsArray(to, from) {
4528
- return to ? [...new Set([].concat(to, from))] : from;
4529
- }
4530
- function mergeObjectOptions(to, from) {
4531
- return to ? extend(extend(Object.create(null), to), from) : from;
4443
+ return rendered;
4532
4444
  }
4533
- function mergeWatchOptions(to, from) {
4534
- if (!to)
4535
- return from;
4536
- if (!from)
4537
- return to;
4538
- const merged = extend(Object.create(null), to);
4539
- for (const key in from) {
4540
- merged[key] = mergeAsArray(to[key], from[key]);
4541
- }
4542
- return merged;
4445
+ function ensureValidVNode(vnodes) {
4446
+ return vnodes.some(child => {
4447
+ if (!isVNode(child))
4448
+ return true;
4449
+ if (child.type === Comment)
4450
+ return false;
4451
+ if (child.type === Fragment &&
4452
+ !ensureValidVNode(child.children))
4453
+ return false;
4454
+ return true;
4455
+ })
4456
+ ? vnodes
4457
+ : null;
4543
4458
  }
4544
4459
 
4545
- function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4546
- isSSR = false) {
4547
- const props = {};
4548
- const attrs = {};
4549
- def(attrs, InternalObjectKey, 1);
4550
- instance.propsDefaults = Object.create(null);
4551
- setFullProps(instance, rawProps, props, attrs);
4552
- // ensure all declared prop keys are present
4553
- for (const key in instance.propsOptions[0]) {
4554
- if (!(key in props)) {
4555
- props[key] = undefined;
4556
- }
4557
- }
4558
- // validation
4559
- {
4560
- validateProps(rawProps || {}, props, instance);
4460
+ /**
4461
+ * For prefixing keys in v-on="obj" with "on"
4462
+ * @private
4463
+ */
4464
+ function toHandlers(obj) {
4465
+ const ret = {};
4466
+ if (!isObject(obj)) {
4467
+ warn$1(`v-on with no argument expects an object value.`);
4468
+ return ret;
4561
4469
  }
4562
- if (isStateful) {
4563
- // stateful
4564
- instance.props = isSSR ? props : shallowReactive(props);
4470
+ for (const key in obj) {
4471
+ ret[toHandlerKey(key)] = obj[key];
4565
4472
  }
4566
- else {
4567
- if (!instance.type.props) {
4568
- // functional w/ optional props, props === attrs
4569
- instance.props = attrs;
4473
+ return ret;
4474
+ }
4475
+
4476
+ /**
4477
+ * #2437 In Vue 3, functional components do not have a public instance proxy but
4478
+ * they exist in the internal parent chain. For code that relies on traversing
4479
+ * public $parent chains, skip functional ones and go to the parent instead.
4480
+ */
4481
+ const getPublicInstance = (i) => {
4482
+ if (!i)
4483
+ return null;
4484
+ if (isStatefulComponent(i))
4485
+ return getExposeProxy(i) || i.proxy;
4486
+ return getPublicInstance(i.parent);
4487
+ };
4488
+ const publicPropertiesMap =
4489
+ // Move PURE marker to new line to workaround compiler discarding it
4490
+ // due to type annotation
4491
+ /*#__PURE__*/ extend(Object.create(null), {
4492
+ $: i => i,
4493
+ $el: i => i.vnode.el,
4494
+ $data: i => i.data,
4495
+ $props: i => (shallowReadonly(i.props) ),
4496
+ $attrs: i => (shallowReadonly(i.attrs) ),
4497
+ $slots: i => (shallowReadonly(i.slots) ),
4498
+ $refs: i => (shallowReadonly(i.refs) ),
4499
+ $parent: i => getPublicInstance(i.parent),
4500
+ $root: i => getPublicInstance(i.root),
4501
+ $emit: i => i.emit,
4502
+ $options: i => (resolveMergedOptions(i) ),
4503
+ $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
4504
+ $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
4505
+ $watch: i => (instanceWatch.bind(i) )
4506
+ });
4507
+ const isReservedPrefix = (key) => key === '_' || key === '$';
4508
+ const PublicInstanceProxyHandlers = {
4509
+ get({ _: instance }, key) {
4510
+ const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
4511
+ // for internal formatters to know that this is a Vue instance
4512
+ if (key === '__isVue') {
4513
+ return true;
4570
4514
  }
4571
- else {
4572
- // functional w/ declared props
4573
- instance.props = props;
4515
+ // prioritize <script setup> bindings during dev.
4516
+ // this allows even properties that start with _ or $ to be used - so that
4517
+ // it aligns with the production behavior where the render fn is inlined and
4518
+ // indeed has access to all declared variables.
4519
+ if (setupState !== EMPTY_OBJ &&
4520
+ setupState.__isScriptSetup &&
4521
+ hasOwn(setupState, key)) {
4522
+ return setupState[key];
4574
4523
  }
4575
- }
4576
- instance.attrs = attrs;
4577
- }
4578
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
4579
- const { props, attrs, vnode: { patchFlag } } = instance;
4580
- const rawCurrentProps = toRaw(props);
4581
- const [options] = instance.propsOptions;
4582
- let hasAttrsChanged = false;
4583
- if (
4584
- // always force full diff in dev
4585
- // - #1942 if hmr is enabled with sfc component
4586
- // - vite#872 non-sfc component used by sfc component
4587
- !((instance.type.__hmrId ||
4588
- (instance.parent && instance.parent.type.__hmrId))) &&
4589
- (optimized || patchFlag > 0) &&
4590
- !(patchFlag & 16 /* FULL_PROPS */)) {
4591
- if (patchFlag & 8 /* PROPS */) {
4592
- // Compiler-generated props & no keys change, just set the updated
4593
- // the props.
4594
- const propsToUpdate = instance.vnode.dynamicProps;
4595
- for (let i = 0; i < propsToUpdate.length; i++) {
4596
- let key = propsToUpdate[i];
4597
- // PROPS flag guarantees rawProps to be non-null
4598
- const value = rawProps[key];
4599
- if (options) {
4600
- // attr / props separation was done on init and will be consistent
4601
- // in this code path, so just check if attrs have it.
4602
- if (hasOwn(attrs, key)) {
4603
- if (value !== attrs[key]) {
4604
- attrs[key] = value;
4605
- hasAttrsChanged = true;
4606
- }
4607
- }
4608
- else {
4609
- const camelizedKey = camelize(key);
4610
- props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4611
- }
4612
- }
4613
- else {
4614
- if (value !== attrs[key]) {
4615
- attrs[key] = value;
4616
- hasAttrsChanged = true;
4617
- }
4524
+ // data / props / ctx
4525
+ // This getter gets called for every property access on the render context
4526
+ // during render and is a major hotspot. The most expensive part of this
4527
+ // is the multiple hasOwn() calls. It's much faster to do a simple property
4528
+ // access on a plain object, so we use an accessCache object (with null
4529
+ // prototype) to memoize what access type a key corresponds to.
4530
+ let normalizedProps;
4531
+ if (key[0] !== '$') {
4532
+ const n = accessCache[key];
4533
+ if (n !== undefined) {
4534
+ switch (n) {
4535
+ case 1 /* SETUP */:
4536
+ return setupState[key];
4537
+ case 2 /* DATA */:
4538
+ return data[key];
4539
+ case 4 /* CONTEXT */:
4540
+ return ctx[key];
4541
+ case 3 /* PROPS */:
4542
+ return props[key];
4543
+ // default: just fallthrough
4618
4544
  }
4619
4545
  }
4620
- }
4621
- }
4622
- else {
4623
- // full props update.
4624
- if (setFullProps(instance, rawProps, props, attrs)) {
4625
- hasAttrsChanged = true;
4626
- }
4627
- // in case of dynamic props, check if we need to delete keys from
4628
- // the props object
4629
- let kebabKey;
4630
- for (const key in rawCurrentProps) {
4631
- if (!rawProps ||
4632
- // for camelCase
4633
- (!hasOwn(rawProps, key) &&
4634
- // it's possible the original props was passed in as kebab-case
4635
- // and converted to camelCase (#955)
4636
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4637
- if (options) {
4638
- if (rawPrevProps &&
4639
- // for camelCase
4640
- (rawPrevProps[key] !== undefined ||
4641
- // for kebab-case
4642
- rawPrevProps[kebabKey] !== undefined)) {
4643
- props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4644
- }
4645
- }
4646
- else {
4647
- delete props[key];
4648
- }
4546
+ else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4547
+ accessCache[key] = 1 /* SETUP */;
4548
+ return setupState[key];
4649
4549
  }
4650
- }
4651
- // in the case of functional component w/o props declaration, props and
4652
- // attrs point to the same object so it should already have been updated.
4653
- if (attrs !== rawCurrentProps) {
4654
- for (const key in attrs) {
4655
- if (!rawProps ||
4656
- (!hasOwn(rawProps, key) &&
4657
- (!false ))) {
4658
- delete attrs[key];
4659
- hasAttrsChanged = true;
4660
- }
4550
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4551
+ accessCache[key] = 2 /* DATA */;
4552
+ return data[key];
4661
4553
  }
4662
- }
4663
- }
4664
- // trigger updates for $attrs in case it's used in component slots
4665
- if (hasAttrsChanged) {
4666
- trigger(instance, "set" /* SET */, '$attrs');
4667
- }
4668
- {
4669
- validateProps(rawProps || {}, props, instance);
4670
- }
4671
- }
4672
- function setFullProps(instance, rawProps, props, attrs) {
4673
- const [options, needCastKeys] = instance.propsOptions;
4674
- let hasAttrsChanged = false;
4675
- let rawCastValues;
4676
- if (rawProps) {
4677
- for (let key in rawProps) {
4678
- // key, ref are reserved and never passed down
4679
- if (isReservedProp(key)) {
4680
- continue;
4554
+ else if (
4555
+ // only cache other properties when instance has declared (thus stable)
4556
+ // props
4557
+ (normalizedProps = instance.propsOptions[0]) &&
4558
+ hasOwn(normalizedProps, key)) {
4559
+ accessCache[key] = 3 /* PROPS */;
4560
+ return props[key];
4681
4561
  }
4682
- const value = rawProps[key];
4683
- // prop option names are camelized during normalization, so to support
4684
- // kebab -> camel conversion here we need to camelize the key.
4685
- let camelKey;
4686
- if (options && hasOwn(options, (camelKey = camelize(key)))) {
4687
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4688
- props[camelKey] = value;
4689
- }
4690
- else {
4691
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4692
- }
4562
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4563
+ accessCache[key] = 4 /* CONTEXT */;
4564
+ return ctx[key];
4693
4565
  }
4694
- else if (!isEmitListener(instance.emitsOptions, key)) {
4695
- if (!(key in attrs) || value !== attrs[key]) {
4696
- attrs[key] = value;
4697
- hasAttrsChanged = true;
4698
- }
4566
+ else if (shouldCacheAccess) {
4567
+ accessCache[key] = 0 /* OTHER */;
4699
4568
  }
4700
4569
  }
4701
- }
4702
- if (needCastKeys) {
4703
- const rawCurrentProps = toRaw(props);
4704
- const castValues = rawCastValues || EMPTY_OBJ;
4705
- for (let i = 0; i < needCastKeys.length; i++) {
4706
- const key = needCastKeys[i];
4707
- props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4708
- }
4709
- }
4710
- return hasAttrsChanged;
4711
- }
4712
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
4713
- const opt = options[key];
4714
- if (opt != null) {
4715
- const hasDefault = hasOwn(opt, 'default');
4716
- // default values
4717
- if (hasDefault && value === undefined) {
4718
- const defaultValue = opt.default;
4719
- if (opt.type !== Function && isFunction(defaultValue)) {
4720
- const { propsDefaults } = instance;
4721
- if (key in propsDefaults) {
4722
- value = propsDefaults[key];
4723
- }
4724
- else {
4725
- setCurrentInstance(instance);
4726
- value = propsDefaults[key] = defaultValue.call(null, props);
4727
- unsetCurrentInstance();
4728
- }
4570
+ const publicGetter = publicPropertiesMap[key];
4571
+ let cssModule, globalProperties;
4572
+ // public $xxx properties
4573
+ if (publicGetter) {
4574
+ if (key === '$attrs') {
4575
+ track(instance, "get" /* GET */, key);
4576
+ markAttrsAccessed();
4729
4577
  }
4730
- else {
4731
- value = defaultValue;
4578
+ return publicGetter(instance);
4579
+ }
4580
+ else if (
4581
+ // css module (injected by vue-loader)
4582
+ (cssModule = type.__cssModules) &&
4583
+ (cssModule = cssModule[key])) {
4584
+ return cssModule;
4585
+ }
4586
+ else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
4587
+ // user may set custom properties to `this` that start with `$`
4588
+ accessCache[key] = 4 /* CONTEXT */;
4589
+ return ctx[key];
4590
+ }
4591
+ else if (
4592
+ // global properties
4593
+ ((globalProperties = appContext.config.globalProperties),
4594
+ hasOwn(globalProperties, key))) {
4595
+ {
4596
+ return globalProperties[key];
4732
4597
  }
4733
4598
  }
4734
- // boolean casting
4735
- if (opt[0 /* shouldCast */]) {
4736
- if (isAbsent && !hasDefault) {
4737
- value = false;
4599
+ else if (currentRenderingInstance &&
4600
+ (!isString(key) ||
4601
+ // #1091 avoid internal isRef/isVNode checks on component instance leading
4602
+ // to infinite warning loop
4603
+ key.indexOf('__v') !== 0)) {
4604
+ if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
4605
+ warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
4606
+ `character ("$" or "_") and is not proxied on the render context.`);
4738
4607
  }
4739
- else if (opt[1 /* shouldCastTrue */] &&
4740
- (value === '' || value === hyphenate(key))) {
4741
- value = true;
4608
+ else if (instance === currentRenderingInstance) {
4609
+ warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
4610
+ `but is not defined on instance.`);
4742
4611
  }
4743
4612
  }
4744
- }
4745
- return value;
4746
- }
4747
- function normalizePropsOptions(comp, appContext, asMixin = false) {
4748
- const cache = appContext.propsCache;
4749
- const cached = cache.get(comp);
4750
- if (cached) {
4751
- return cached;
4752
- }
4753
- const raw = comp.props;
4754
- const normalized = {};
4755
- const needCastKeys = [];
4756
- // apply mixin/extends props
4757
- let hasExtends = false;
4758
- if (!isFunction(comp)) {
4759
- const extendProps = (raw) => {
4760
- hasExtends = true;
4761
- const [props, keys] = normalizePropsOptions(raw, appContext, true);
4762
- extend(normalized, props);
4763
- if (keys)
4764
- needCastKeys.push(...keys);
4765
- };
4766
- if (!asMixin && appContext.mixins.length) {
4767
- appContext.mixins.forEach(extendProps);
4613
+ },
4614
+ set({ _: instance }, key, value) {
4615
+ const { data, setupState, ctx } = instance;
4616
+ if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4617
+ setupState[key] = value;
4618
+ return true;
4768
4619
  }
4769
- if (comp.extends) {
4770
- extendProps(comp.extends);
4620
+ else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4621
+ data[key] = value;
4622
+ return true;
4771
4623
  }
4772
- if (comp.mixins) {
4773
- comp.mixins.forEach(extendProps);
4624
+ else if (hasOwn(instance.props, key)) {
4625
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
4626
+ return false;
4774
4627
  }
4775
- }
4776
- if (!raw && !hasExtends) {
4777
- cache.set(comp, EMPTY_ARR);
4778
- return EMPTY_ARR;
4779
- }
4780
- if (isArray(raw)) {
4781
- for (let i = 0; i < raw.length; i++) {
4782
- if (!isString(raw[i])) {
4783
- warn$1(`props must be strings when using array syntax.`, raw[i]);
4784
- }
4785
- const normalizedKey = camelize(raw[i]);
4786
- if (validatePropName(normalizedKey)) {
4787
- normalized[normalizedKey] = EMPTY_OBJ;
4788
- }
4628
+ if (key[0] === '$' && key.slice(1) in instance) {
4629
+ warn$1(`Attempting to mutate public property "${key}". ` +
4630
+ `Properties starting with $ are reserved and readonly.`, instance);
4631
+ return false;
4789
4632
  }
4790
- }
4791
- else if (raw) {
4792
- if (!isObject(raw)) {
4793
- warn$1(`invalid props options`, raw);
4794
- }
4795
- for (const key in raw) {
4796
- const normalizedKey = camelize(key);
4797
- if (validatePropName(normalizedKey)) {
4798
- const opt = raw[key];
4799
- const prop = (normalized[normalizedKey] =
4800
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4801
- if (prop) {
4802
- const booleanIndex = getTypeIndex(Boolean, prop.type);
4803
- const stringIndex = getTypeIndex(String, prop.type);
4804
- prop[0 /* shouldCast */] = booleanIndex > -1;
4805
- prop[1 /* shouldCastTrue */] =
4806
- stringIndex < 0 || booleanIndex < stringIndex;
4807
- // if the prop needs boolean casting or default value
4808
- if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4809
- needCastKeys.push(normalizedKey);
4810
- }
4811
- }
4633
+ else {
4634
+ if (key in instance.appContext.config.globalProperties) {
4635
+ Object.defineProperty(ctx, key, {
4636
+ enumerable: true,
4637
+ configurable: true,
4638
+ value
4639
+ });
4640
+ }
4641
+ else {
4642
+ ctx[key] = value;
4812
4643
  }
4813
4644
  }
4814
- }
4815
- const res = [normalized, needCastKeys];
4816
- cache.set(comp, res);
4817
- return res;
4818
- }
4819
- function validatePropName(key) {
4820
- if (key[0] !== '$') {
4821
4645
  return true;
4646
+ },
4647
+ has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
4648
+ let normalizedProps;
4649
+ return (!!accessCache[key] ||
4650
+ (data !== EMPTY_OBJ && hasOwn(data, key)) ||
4651
+ (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
4652
+ ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
4653
+ hasOwn(ctx, key) ||
4654
+ hasOwn(publicPropertiesMap, key) ||
4655
+ hasOwn(appContext.config.globalProperties, key));
4656
+ },
4657
+ defineProperty(target, key, descriptor) {
4658
+ if (descriptor.get != null) {
4659
+ // invalidate key cache of a getter based property #5417
4660
+ target._.accessCache[key] = 0;
4661
+ }
4662
+ else if (hasOwn(descriptor, 'value')) {
4663
+ this.set(target, key, descriptor.value, null);
4664
+ }
4665
+ return Reflect.defineProperty(target, key, descriptor);
4822
4666
  }
4823
- else {
4824
- warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4825
- }
4826
- return false;
4827
- }
4828
- // use function string name to check type constructors
4829
- // so that it works across vms / iframes.
4830
- function getType(ctor) {
4831
- const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4832
- return match ? match[1] : ctor === null ? 'null' : '';
4833
- }
4834
- function isSameType(a, b) {
4835
- return getType(a) === getType(b);
4667
+ };
4668
+ {
4669
+ PublicInstanceProxyHandlers.ownKeys = (target) => {
4670
+ warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
4671
+ `The keys will be empty in production mode to avoid performance overhead.`);
4672
+ return Reflect.ownKeys(target);
4673
+ };
4836
4674
  }
4837
- function getTypeIndex(type, expectedTypes) {
4838
- if (isArray(expectedTypes)) {
4839
- return expectedTypes.findIndex(t => isSameType(t, type));
4840
- }
4841
- else if (isFunction(expectedTypes)) {
4842
- return isSameType(expectedTypes, type) ? 0 : -1;
4675
+ const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
4676
+ get(target, key) {
4677
+ // fast path for unscopables when using `with` block
4678
+ if (key === Symbol.unscopables) {
4679
+ return;
4680
+ }
4681
+ return PublicInstanceProxyHandlers.get(target, key, target);
4682
+ },
4683
+ has(_, key) {
4684
+ const has = key[0] !== '_' && !isGloballyWhitelisted(key);
4685
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
4686
+ warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
4687
+ }
4688
+ return has;
4843
4689
  }
4844
- return -1;
4690
+ });
4691
+ // dev only
4692
+ // In dev mode, the proxy target exposes the same properties as seen on `this`
4693
+ // for easier console inspection. In prod mode it will be an empty object so
4694
+ // these properties definitions can be skipped.
4695
+ function createDevRenderContext(instance) {
4696
+ const target = {};
4697
+ // expose internal instance for proxy handlers
4698
+ Object.defineProperty(target, `_`, {
4699
+ configurable: true,
4700
+ enumerable: false,
4701
+ get: () => instance
4702
+ });
4703
+ // expose public properties
4704
+ Object.keys(publicPropertiesMap).forEach(key => {
4705
+ Object.defineProperty(target, key, {
4706
+ configurable: true,
4707
+ enumerable: false,
4708
+ get: () => publicPropertiesMap[key](instance),
4709
+ // intercepted by the proxy so no need for implementation,
4710
+ // but needed to prevent set errors
4711
+ set: NOOP
4712
+ });
4713
+ });
4714
+ return target;
4845
4715
  }
4846
- /**
4847
- * dev only
4848
- */
4849
- function validateProps(rawProps, props, instance) {
4850
- const resolvedValues = toRaw(props);
4851
- const options = instance.propsOptions[0];
4852
- for (const key in options) {
4853
- let opt = options[key];
4854
- if (opt == null)
4855
- continue;
4856
- validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
4716
+ // dev only
4717
+ function exposePropsOnRenderContext(instance) {
4718
+ const { ctx, propsOptions: [propsOptions] } = instance;
4719
+ if (propsOptions) {
4720
+ Object.keys(propsOptions).forEach(key => {
4721
+ Object.defineProperty(ctx, key, {
4722
+ enumerable: true,
4723
+ configurable: true,
4724
+ get: () => instance.props[key],
4725
+ set: NOOP
4726
+ });
4727
+ });
4857
4728
  }
4858
4729
  }
4859
- /**
4860
- * dev only
4861
- */
4862
- function validateProp(name, value, prop, isAbsent) {
4863
- const { type, required, validator } = prop;
4864
- // required!
4865
- if (required && isAbsent) {
4866
- warn$1('Missing required prop: "' + name + '"');
4867
- return;
4868
- }
4869
- // missing but optional
4870
- if (value == null && !prop.required) {
4871
- return;
4872
- }
4873
- // type check
4874
- if (type != null && type !== true) {
4875
- let isValid = false;
4876
- const types = isArray(type) ? type : [type];
4877
- const expectedTypes = [];
4878
- // value is valid as long as one of the specified types match
4879
- for (let i = 0; i < types.length && !isValid; i++) {
4880
- const { valid, expectedType } = assertType(value, types[i]);
4881
- expectedTypes.push(expectedType || '');
4882
- isValid = valid;
4730
+ // dev only
4731
+ function exposeSetupStateOnRenderContext(instance) {
4732
+ const { ctx, setupState } = instance;
4733
+ Object.keys(toRaw(setupState)).forEach(key => {
4734
+ if (!setupState.__isScriptSetup) {
4735
+ if (isReservedPrefix(key[0])) {
4736
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
4737
+ `which are reserved prefixes for Vue internals.`);
4738
+ return;
4739
+ }
4740
+ Object.defineProperty(ctx, key, {
4741
+ enumerable: true,
4742
+ configurable: true,
4743
+ get: () => setupState[key],
4744
+ set: NOOP
4745
+ });
4883
4746
  }
4884
- if (!isValid) {
4885
- warn$1(getInvalidTypeMessage(name, value, expectedTypes));
4886
- return;
4747
+ });
4748
+ }
4749
+
4750
+ function createDuplicateChecker() {
4751
+ const cache = Object.create(null);
4752
+ return (type, key) => {
4753
+ if (cache[key]) {
4754
+ warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
4887
4755
  }
4888
- }
4889
- // custom validator
4890
- if (validator && !validator(value)) {
4891
- warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
4892
- }
4756
+ else {
4757
+ cache[key] = type;
4758
+ }
4759
+ };
4893
4760
  }
4894
- const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
4895
- /**
4896
- * dev only
4897
- */
4898
- function assertType(value, type) {
4899
- let valid;
4900
- const expectedType = getType(type);
4901
- if (isSimpleType(expectedType)) {
4902
- const t = typeof value;
4903
- valid = t === expectedType.toLowerCase();
4904
- // for primitive wrapper objects
4905
- if (!valid && t === 'object') {
4906
- valid = value instanceof type;
4761
+ let shouldCacheAccess = true;
4762
+ function applyOptions(instance) {
4763
+ const options = resolveMergedOptions(instance);
4764
+ const publicThis = instance.proxy;
4765
+ const ctx = instance.ctx;
4766
+ // do not cache property access on public proxy during state initialization
4767
+ shouldCacheAccess = false;
4768
+ // call beforeCreate first before accessing other options since
4769
+ // the hook may mutate resolved options (#2791)
4770
+ if (options.beforeCreate) {
4771
+ callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4772
+ }
4773
+ const {
4774
+ // state
4775
+ data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4776
+ // lifecycle
4777
+ created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4778
+ // public API
4779
+ expose, inheritAttrs,
4780
+ // assets
4781
+ components, directives, filters } = options;
4782
+ const checkDuplicateProperties = createDuplicateChecker() ;
4783
+ {
4784
+ const [propsOptions] = instance.propsOptions;
4785
+ if (propsOptions) {
4786
+ for (const key in propsOptions) {
4787
+ checkDuplicateProperties("Props" /* PROPS */, key);
4788
+ }
4907
4789
  }
4908
4790
  }
4909
- else if (expectedType === 'Object') {
4910
- valid = isObject(value);
4791
+ // options initialization order (to be consistent with Vue 2):
4792
+ // - props (already done outside of this function)
4793
+ // - inject
4794
+ // - methods
4795
+ // - data (deferred since it relies on `this` access)
4796
+ // - computed
4797
+ // - watch (deferred since it relies on `this` access)
4798
+ if (injectOptions) {
4799
+ resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
4911
4800
  }
4912
- else if (expectedType === 'Array') {
4913
- valid = isArray(value);
4914
- }
4915
- else if (expectedType === 'null') {
4916
- valid = value === null;
4917
- }
4918
- else {
4919
- valid = value instanceof type;
4920
- }
4921
- return {
4922
- valid,
4923
- expectedType
4924
- };
4925
- }
4926
- /**
4927
- * dev only
4928
- */
4929
- function getInvalidTypeMessage(name, value, expectedTypes) {
4930
- let message = `Invalid prop: type check failed for prop "${name}".` +
4931
- ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
4932
- const expectedType = expectedTypes[0];
4933
- const receivedType = toRawType(value);
4934
- const expectedValue = styleValue(value, expectedType);
4935
- const receivedValue = styleValue(value, receivedType);
4936
- // check if we need to specify expected value
4937
- if (expectedTypes.length === 1 &&
4938
- isExplicable(expectedType) &&
4939
- !isBoolean(expectedType, receivedType)) {
4940
- message += ` with value ${expectedValue}`;
4941
- }
4942
- message += `, got ${receivedType} `;
4943
- // check if we need to specify received value
4944
- if (isExplicable(receivedType)) {
4945
- message += `with value ${receivedValue}.`;
4946
- }
4947
- return message;
4948
- }
4949
- /**
4950
- * dev only
4951
- */
4952
- function styleValue(value, type) {
4953
- if (type === 'String') {
4954
- return `"${value}"`;
4955
- }
4956
- else if (type === 'Number') {
4957
- return `${Number(value)}`;
4958
- }
4959
- else {
4960
- return `${value}`;
4801
+ if (methods) {
4802
+ for (const key in methods) {
4803
+ const methodHandler = methods[key];
4804
+ if (isFunction(methodHandler)) {
4805
+ // In dev mode, we use the `createRenderContext` function to define
4806
+ // methods to the proxy target, and those are read-only but
4807
+ // reconfigurable, so it needs to be redefined here
4808
+ {
4809
+ Object.defineProperty(ctx, key, {
4810
+ value: methodHandler.bind(publicThis),
4811
+ configurable: true,
4812
+ enumerable: true,
4813
+ writable: true
4814
+ });
4815
+ }
4816
+ {
4817
+ checkDuplicateProperties("Methods" /* METHODS */, key);
4818
+ }
4819
+ }
4820
+ else {
4821
+ warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4822
+ `Did you reference the function correctly?`);
4823
+ }
4824
+ }
4961
4825
  }
4962
- }
4963
- /**
4964
- * dev only
4965
- */
4966
- function isExplicable(type) {
4967
- const explicitTypes = ['string', 'number', 'boolean'];
4968
- return explicitTypes.some(elem => type.toLowerCase() === elem);
4969
- }
4970
- /**
4971
- * dev only
4972
- */
4973
- function isBoolean(...args) {
4974
- return args.some(elem => elem.toLowerCase() === 'boolean');
4975
- }
4976
-
4977
- const isInternalKey = (key) => key[0] === '_' || key === '$stable';
4978
- const normalizeSlotValue = (value) => isArray(value)
4979
- ? value.map(normalizeVNode)
4980
- : [normalizeVNode(value)];
4981
- const normalizeSlot = (key, rawSlot, ctx) => {
4982
- const normalized = withCtx((...args) => {
4983
- if (currentInstance) {
4984
- warn$1(`Slot "${key}" invoked outside of the render function: ` +
4985
- `this will not track dependencies used in the slot. ` +
4986
- `Invoke the slot function inside the render function instead.`);
4826
+ if (dataOptions) {
4827
+ if (!isFunction(dataOptions)) {
4828
+ warn$1(`The data option must be a function. ` +
4829
+ `Plain object usage is no longer supported.`);
4987
4830
  }
4988
- return normalizeSlotValue(rawSlot(...args));
4989
- }, ctx);
4990
- normalized._c = false;
4991
- return normalized;
4992
- };
4993
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
4994
- const ctx = rawSlots._ctx;
4995
- for (const key in rawSlots) {
4996
- if (isInternalKey(key))
4997
- continue;
4998
- const value = rawSlots[key];
4999
- if (isFunction(value)) {
5000
- slots[key] = normalizeSlot(key, value, ctx);
4831
+ const data = dataOptions.call(publicThis, publicThis);
4832
+ if (isPromise(data)) {
4833
+ warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4834
+ `intend to perform data fetching before component renders, use ` +
4835
+ `async setup() + <Suspense>.`);
5001
4836
  }
5002
- else if (value != null) {
4837
+ if (!isObject(data)) {
4838
+ warn$1(`data() should return an object.`);
4839
+ }
4840
+ else {
4841
+ instance.data = reactive(data);
5003
4842
  {
5004
- warn$1(`Non-function value encountered for slot "${key}". ` +
5005
- `Prefer function slots for better performance.`);
4843
+ for (const key in data) {
4844
+ checkDuplicateProperties("Data" /* DATA */, key);
4845
+ // expose data on ctx during dev
4846
+ if (!isReservedPrefix(key[0])) {
4847
+ Object.defineProperty(ctx, key, {
4848
+ configurable: true,
4849
+ enumerable: true,
4850
+ get: () => data[key],
4851
+ set: NOOP
4852
+ });
4853
+ }
4854
+ }
5006
4855
  }
5007
- const normalized = normalizeSlotValue(value);
5008
- slots[key] = () => normalized;
5009
4856
  }
5010
4857
  }
5011
- };
5012
- const normalizeVNodeSlots = (instance, children) => {
5013
- if (!isKeepAlive(instance.vnode) &&
5014
- !(false )) {
5015
- warn$1(`Non-function value encountered for default slot. ` +
5016
- `Prefer function slots for better performance.`);
5017
- }
5018
- const normalized = normalizeSlotValue(children);
5019
- instance.slots.default = () => normalized;
5020
- };
5021
- const initSlots = (instance, children) => {
5022
- if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5023
- const type = children._;
5024
- if (type) {
5025
- // users can get the shallow readonly version of the slots object through `this.$slots`,
5026
- // we should avoid the proxy object polluting the slots of the internal instance
5027
- instance.slots = toRaw(children);
5028
- // make compiler marker non-enumerable
5029
- def(children, '_', type);
5030
- }
5031
- else {
5032
- normalizeObjectSlots(children, (instance.slots = {}));
4858
+ // state initialization complete at this point - start caching access
4859
+ shouldCacheAccess = true;
4860
+ if (computedOptions) {
4861
+ for (const key in computedOptions) {
4862
+ const opt = computedOptions[key];
4863
+ const get = isFunction(opt)
4864
+ ? opt.bind(publicThis, publicThis)
4865
+ : isFunction(opt.get)
4866
+ ? opt.get.bind(publicThis, publicThis)
4867
+ : NOOP;
4868
+ if (get === NOOP) {
4869
+ warn$1(`Computed property "${key}" has no getter.`);
4870
+ }
4871
+ const set = !isFunction(opt) && isFunction(opt.set)
4872
+ ? opt.set.bind(publicThis)
4873
+ : () => {
4874
+ warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4875
+ }
4876
+ ;
4877
+ const c = computed$1({
4878
+ get,
4879
+ set
4880
+ });
4881
+ Object.defineProperty(ctx, key, {
4882
+ enumerable: true,
4883
+ configurable: true,
4884
+ get: () => c.value,
4885
+ set: v => (c.value = v)
4886
+ });
4887
+ {
4888
+ checkDuplicateProperties("Computed" /* COMPUTED */, key);
4889
+ }
5033
4890
  }
5034
4891
  }
5035
- else {
5036
- instance.slots = {};
5037
- if (children) {
5038
- normalizeVNodeSlots(instance, children);
4892
+ if (watchOptions) {
4893
+ for (const key in watchOptions) {
4894
+ createWatcher(watchOptions[key], ctx, publicThis, key);
5039
4895
  }
5040
4896
  }
5041
- def(instance.slots, InternalObjectKey, 1);
5042
- };
5043
- const updateSlots = (instance, children, optimized) => {
5044
- const { vnode, slots } = instance;
5045
- let needDeletionCheck = true;
5046
- let deletionComparisonTarget = EMPTY_OBJ;
5047
- if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5048
- const type = children._;
5049
- if (type) {
5050
- // compiled slots.
5051
- if (isHmrUpdating) {
5052
- // Parent was HMR updated so slot content may have changed.
5053
- // force update slots and mark instance for hmr as well
5054
- extend(slots, children);
5055
- }
5056
- else if (optimized && type === 1 /* STABLE */) {
5057
- // compiled AND stable.
5058
- // no need to update, and skip stale slots removal.
5059
- needDeletionCheck = false;
5060
- }
5061
- else {
5062
- // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5063
- // normalization.
5064
- extend(slots, children);
5065
- // #2893
5066
- // when rendering the optimized slots by manually written render function,
5067
- // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5068
- // i.e. let the `renderSlot` create the bailed Fragment
5069
- if (!optimized && type === 1 /* STABLE */) {
5070
- delete slots._;
5071
- }
5072
- }
4897
+ if (provideOptions) {
4898
+ const provides = isFunction(provideOptions)
4899
+ ? provideOptions.call(publicThis)
4900
+ : provideOptions;
4901
+ Reflect.ownKeys(provides).forEach(key => {
4902
+ provide(key, provides[key]);
4903
+ });
4904
+ }
4905
+ if (created) {
4906
+ callHook(created, instance, "c" /* CREATED */);
4907
+ }
4908
+ function registerLifecycleHook(register, hook) {
4909
+ if (isArray(hook)) {
4910
+ hook.forEach(_hook => register(_hook.bind(publicThis)));
5073
4911
  }
5074
- else {
5075
- needDeletionCheck = !children.$stable;
5076
- normalizeObjectSlots(children, slots);
4912
+ else if (hook) {
4913
+ register(hook.bind(publicThis));
5077
4914
  }
5078
- deletionComparisonTarget = children;
5079
4915
  }
5080
- else if (children) {
5081
- // non slot object children (direct value) passed to a component
5082
- normalizeVNodeSlots(instance, children);
5083
- deletionComparisonTarget = { default: 1 };
4916
+ registerLifecycleHook(onBeforeMount, beforeMount);
4917
+ registerLifecycleHook(onMounted, mounted);
4918
+ registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4919
+ registerLifecycleHook(onUpdated, updated);
4920
+ registerLifecycleHook(onActivated, activated);
4921
+ registerLifecycleHook(onDeactivated, deactivated);
4922
+ registerLifecycleHook(onErrorCaptured, errorCaptured);
4923
+ registerLifecycleHook(onRenderTracked, renderTracked);
4924
+ registerLifecycleHook(onRenderTriggered, renderTriggered);
4925
+ registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4926
+ registerLifecycleHook(onUnmounted, unmounted);
4927
+ registerLifecycleHook(onServerPrefetch, serverPrefetch);
4928
+ if (isArray(expose)) {
4929
+ if (expose.length) {
4930
+ const exposed = instance.exposed || (instance.exposed = {});
4931
+ expose.forEach(key => {
4932
+ Object.defineProperty(exposed, key, {
4933
+ get: () => publicThis[key],
4934
+ set: val => (publicThis[key] = val)
4935
+ });
4936
+ });
4937
+ }
4938
+ else if (!instance.exposed) {
4939
+ instance.exposed = {};
4940
+ }
5084
4941
  }
5085
- // delete stale slots
5086
- if (needDeletionCheck) {
5087
- for (const key in slots) {
5088
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5089
- delete slots[key];
4942
+ // options that are handled when creating the instance but also need to be
4943
+ // applied from mixins
4944
+ if (render && instance.render === NOOP) {
4945
+ instance.render = render;
4946
+ }
4947
+ if (inheritAttrs != null) {
4948
+ instance.inheritAttrs = inheritAttrs;
4949
+ }
4950
+ // asset options.
4951
+ if (components)
4952
+ instance.components = components;
4953
+ if (directives)
4954
+ instance.directives = directives;
4955
+ }
4956
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4957
+ if (isArray(injectOptions)) {
4958
+ injectOptions = normalizeInject(injectOptions);
4959
+ }
4960
+ for (const key in injectOptions) {
4961
+ const opt = injectOptions[key];
4962
+ let injected;
4963
+ if (isObject(opt)) {
4964
+ if ('default' in opt) {
4965
+ injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4966
+ }
4967
+ else {
4968
+ injected = inject(opt.from || key);
4969
+ }
4970
+ }
4971
+ else {
4972
+ injected = inject(opt);
4973
+ }
4974
+ if (isRef(injected)) {
4975
+ // TODO remove the check in 3.3
4976
+ if (unwrapRef) {
4977
+ Object.defineProperty(ctx, key, {
4978
+ enumerable: true,
4979
+ configurable: true,
4980
+ get: () => injected.value,
4981
+ set: v => (injected.value = v)
4982
+ });
4983
+ }
4984
+ else {
4985
+ {
4986
+ warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4987
+ `and no longer needs \`.value\` in the next minor release. ` +
4988
+ `To opt-in to the new behavior now, ` +
4989
+ `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4990
+ `temporary and will not be needed in the future.)`);
4991
+ }
4992
+ ctx[key] = injected;
5090
4993
  }
5091
4994
  }
4995
+ else {
4996
+ ctx[key] = injected;
4997
+ }
4998
+ {
4999
+ checkDuplicateProperties("Inject" /* INJECT */, key);
5000
+ }
5092
5001
  }
5093
- };
5094
-
5095
- /**
5096
- Runtime helper for applying directives to a vnode. Example usage:
5097
-
5098
- const comp = resolveComponent('comp')
5099
- const foo = resolveDirective('foo')
5100
- const bar = resolveDirective('bar')
5101
-
5102
- return withDirectives(h(comp), [
5103
- [foo, this.x],
5104
- [bar, this.y]
5105
- ])
5106
- */
5107
- function validateDirectiveName(name) {
5108
- if (isBuiltInDirective(name)) {
5109
- warn$1('Do not use built-in directive ids as custom directive id: ' + name);
5002
+ }
5003
+ function callHook(hook, instance, type) {
5004
+ callWithAsyncErrorHandling(isArray(hook)
5005
+ ? hook.map(h => h.bind(instance.proxy))
5006
+ : hook.bind(instance.proxy), instance, type);
5007
+ }
5008
+ function createWatcher(raw, ctx, publicThis, key) {
5009
+ const getter = key.includes('.')
5010
+ ? createPathGetter(publicThis, key)
5011
+ : () => publicThis[key];
5012
+ if (isString(raw)) {
5013
+ const handler = ctx[raw];
5014
+ if (isFunction(handler)) {
5015
+ watch(getter, handler);
5016
+ }
5017
+ else {
5018
+ warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
5019
+ }
5020
+ }
5021
+ else if (isFunction(raw)) {
5022
+ watch(getter, raw.bind(publicThis));
5023
+ }
5024
+ else if (isObject(raw)) {
5025
+ if (isArray(raw)) {
5026
+ raw.forEach(r => createWatcher(r, ctx, publicThis, key));
5027
+ }
5028
+ else {
5029
+ const handler = isFunction(raw.handler)
5030
+ ? raw.handler.bind(publicThis)
5031
+ : ctx[raw.handler];
5032
+ if (isFunction(handler)) {
5033
+ watch(getter, handler, raw);
5034
+ }
5035
+ else {
5036
+ warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
5037
+ }
5038
+ }
5039
+ }
5040
+ else {
5041
+ warn$1(`Invalid watch option: "${key}"`, raw);
5110
5042
  }
5111
5043
  }
5112
5044
  /**
5113
- * Adds directives to a VNode.
5045
+ * Resolve merged options and cache it on the component.
5046
+ * This is done only once per-component since the merging does not involve
5047
+ * instances.
5114
5048
  */
5115
- function withDirectives(vnode, directives) {
5116
- const internalInstance = currentRenderingInstance;
5117
- if (internalInstance === null) {
5118
- warn$1(`withDirectives can only be used inside render functions.`);
5119
- return vnode;
5049
+ function resolveMergedOptions(instance) {
5050
+ const base = instance.type;
5051
+ const { mixins, extends: extendsOptions } = base;
5052
+ const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
5053
+ const cached = cache.get(base);
5054
+ let resolved;
5055
+ if (cached) {
5056
+ resolved = cached;
5120
5057
  }
5121
- const instance = internalInstance.proxy;
5122
- const bindings = vnode.dirs || (vnode.dirs = []);
5123
- for (let i = 0; i < directives.length; i++) {
5124
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5125
- if (isFunction(dir)) {
5126
- dir = {
5127
- mounted: dir,
5128
- updated: dir
5129
- };
5058
+ else if (!globalMixins.length && !mixins && !extendsOptions) {
5059
+ {
5060
+ resolved = base;
5130
5061
  }
5131
- if (dir.deep) {
5132
- traverse(value);
5062
+ }
5063
+ else {
5064
+ resolved = {};
5065
+ if (globalMixins.length) {
5066
+ globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
5133
5067
  }
5134
- bindings.push({
5135
- dir,
5136
- instance,
5137
- value,
5138
- oldValue: void 0,
5139
- arg,
5140
- modifiers
5141
- });
5068
+ mergeOptions(resolved, base, optionMergeStrategies);
5142
5069
  }
5143
- return vnode;
5070
+ cache.set(base, resolved);
5071
+ return resolved;
5144
5072
  }
5145
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5146
- const bindings = vnode.dirs;
5147
- const oldBindings = prevVNode && prevVNode.dirs;
5148
- for (let i = 0; i < bindings.length; i++) {
5149
- const binding = bindings[i];
5150
- if (oldBindings) {
5151
- binding.oldValue = oldBindings[i].value;
5073
+ function mergeOptions(to, from, strats, asMixin = false) {
5074
+ const { mixins, extends: extendsOptions } = from;
5075
+ if (extendsOptions) {
5076
+ mergeOptions(to, extendsOptions, strats, true);
5077
+ }
5078
+ if (mixins) {
5079
+ mixins.forEach((m) => mergeOptions(to, m, strats, true));
5080
+ }
5081
+ for (const key in from) {
5082
+ if (asMixin && key === 'expose') {
5083
+ warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
5084
+ `It should only be declared in the base component itself.`);
5152
5085
  }
5153
- let hook = binding.dir[name];
5154
- if (hook) {
5155
- // disable tracking inside all lifecycle hooks
5156
- // since they can potentially be called inside effects.
5157
- pauseTracking();
5158
- callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5159
- vnode.el,
5160
- binding,
5161
- vnode,
5162
- prevVNode
5163
- ]);
5164
- resetTracking();
5086
+ else {
5087
+ const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
5088
+ to[key] = strat ? strat(to[key], from[key]) : from[key];
5165
5089
  }
5166
5090
  }
5167
- }
5168
-
5169
- function createAppContext() {
5170
- return {
5171
- app: null,
5172
- config: {
5173
- isNativeTag: NO,
5174
- performance: false,
5175
- globalProperties: {},
5176
- optionMergeStrategies: {},
5177
- errorHandler: undefined,
5178
- warnHandler: undefined,
5179
- compilerOptions: {}
5180
- },
5181
- mixins: [],
5182
- components: {},
5183
- directives: {},
5184
- provides: Object.create(null),
5185
- optionsCache: new WeakMap(),
5186
- propsCache: new WeakMap(),
5187
- emitsCache: new WeakMap()
5188
- };
5091
+ return to;
5189
5092
  }
5190
- let uid = 0;
5191
- function createAppAPI(render, hydrate) {
5192
- return function createApp(rootComponent, rootProps = null) {
5193
- if (rootProps != null && !isObject(rootProps)) {
5194
- warn$1(`root props passed to app.mount() must be an object.`);
5195
- rootProps = null;
5196
- }
5093
+ const internalOptionMergeStrats = {
5094
+ data: mergeDataFn,
5095
+ props: mergeObjectOptions,
5096
+ emits: mergeObjectOptions,
5097
+ // objects
5098
+ methods: mergeObjectOptions,
5099
+ computed: mergeObjectOptions,
5100
+ // lifecycle
5101
+ beforeCreate: mergeAsArray,
5102
+ created: mergeAsArray,
5103
+ beforeMount: mergeAsArray,
5104
+ mounted: mergeAsArray,
5105
+ beforeUpdate: mergeAsArray,
5106
+ updated: mergeAsArray,
5107
+ beforeDestroy: mergeAsArray,
5108
+ beforeUnmount: mergeAsArray,
5109
+ destroyed: mergeAsArray,
5110
+ unmounted: mergeAsArray,
5111
+ activated: mergeAsArray,
5112
+ deactivated: mergeAsArray,
5113
+ errorCaptured: mergeAsArray,
5114
+ serverPrefetch: mergeAsArray,
5115
+ // assets
5116
+ components: mergeObjectOptions,
5117
+ directives: mergeObjectOptions,
5118
+ // watch
5119
+ watch: mergeWatchOptions,
5120
+ // provide / inject
5121
+ provide: mergeDataFn,
5122
+ inject: mergeInject
5123
+ };
5124
+ function mergeDataFn(to, from) {
5125
+ if (!from) {
5126
+ return to;
5127
+ }
5128
+ if (!to) {
5129
+ return from;
5130
+ }
5131
+ return function mergedDataFn() {
5132
+ return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
5133
+ };
5134
+ }
5135
+ function mergeInject(to, from) {
5136
+ return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
5137
+ }
5138
+ function normalizeInject(raw) {
5139
+ if (isArray(raw)) {
5140
+ const res = {};
5141
+ for (let i = 0; i < raw.length; i++) {
5142
+ res[raw[i]] = raw[i];
5143
+ }
5144
+ return res;
5145
+ }
5146
+ return raw;
5147
+ }
5148
+ function mergeAsArray(to, from) {
5149
+ return to ? [...new Set([].concat(to, from))] : from;
5150
+ }
5151
+ function mergeObjectOptions(to, from) {
5152
+ return to ? extend(extend(Object.create(null), to), from) : from;
5153
+ }
5154
+ function mergeWatchOptions(to, from) {
5155
+ if (!to)
5156
+ return from;
5157
+ if (!from)
5158
+ return to;
5159
+ const merged = extend(Object.create(null), to);
5160
+ for (const key in from) {
5161
+ merged[key] = mergeAsArray(to[key], from[key]);
5162
+ }
5163
+ return merged;
5164
+ }
5165
+
5166
+ function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
5167
+ isSSR = false) {
5168
+ const props = {};
5169
+ const attrs = {};
5170
+ def(attrs, InternalObjectKey, 1);
5171
+ instance.propsDefaults = Object.create(null);
5172
+ setFullProps(instance, rawProps, props, attrs);
5173
+ // ensure all declared prop keys are present
5174
+ for (const key in instance.propsOptions[0]) {
5175
+ if (!(key in props)) {
5176
+ props[key] = undefined;
5177
+ }
5178
+ }
5179
+ // validation
5180
+ {
5181
+ validateProps(rawProps || {}, props, instance);
5182
+ }
5183
+ if (isStateful) {
5184
+ // stateful
5185
+ instance.props = isSSR ? props : shallowReactive(props);
5186
+ }
5187
+ else {
5188
+ if (!instance.type.props) {
5189
+ // functional w/ optional props, props === attrs
5190
+ instance.props = attrs;
5191
+ }
5192
+ else {
5193
+ // functional w/ declared props
5194
+ instance.props = props;
5195
+ }
5196
+ }
5197
+ instance.attrs = attrs;
5198
+ }
5199
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
5200
+ const { props, attrs, vnode: { patchFlag } } = instance;
5201
+ const rawCurrentProps = toRaw(props);
5202
+ const [options] = instance.propsOptions;
5203
+ let hasAttrsChanged = false;
5204
+ if (
5205
+ // always force full diff in dev
5206
+ // - #1942 if hmr is enabled with sfc component
5207
+ // - vite#872 non-sfc component used by sfc component
5208
+ !((instance.type.__hmrId ||
5209
+ (instance.parent && instance.parent.type.__hmrId))) &&
5210
+ (optimized || patchFlag > 0) &&
5211
+ !(patchFlag & 16 /* FULL_PROPS */)) {
5212
+ if (patchFlag & 8 /* PROPS */) {
5213
+ // Compiler-generated props & no keys change, just set the updated
5214
+ // the props.
5215
+ const propsToUpdate = instance.vnode.dynamicProps;
5216
+ for (let i = 0; i < propsToUpdate.length; i++) {
5217
+ let key = propsToUpdate[i];
5218
+ // skip if the prop key is a declared emit event listener
5219
+ if (isEmitListener(instance.emitsOptions, key)) {
5220
+ continue;
5221
+ }
5222
+ // PROPS flag guarantees rawProps to be non-null
5223
+ const value = rawProps[key];
5224
+ if (options) {
5225
+ // attr / props separation was done on init and will be consistent
5226
+ // in this code path, so just check if attrs have it.
5227
+ if (hasOwn(attrs, key)) {
5228
+ if (value !== attrs[key]) {
5229
+ attrs[key] = value;
5230
+ hasAttrsChanged = true;
5231
+ }
5232
+ }
5233
+ else {
5234
+ const camelizedKey = camelize(key);
5235
+ props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
5236
+ }
5237
+ }
5238
+ else {
5239
+ if (value !== attrs[key]) {
5240
+ attrs[key] = value;
5241
+ hasAttrsChanged = true;
5242
+ }
5243
+ }
5244
+ }
5245
+ }
5246
+ }
5247
+ else {
5248
+ // full props update.
5249
+ if (setFullProps(instance, rawProps, props, attrs)) {
5250
+ hasAttrsChanged = true;
5251
+ }
5252
+ // in case of dynamic props, check if we need to delete keys from
5253
+ // the props object
5254
+ let kebabKey;
5255
+ for (const key in rawCurrentProps) {
5256
+ if (!rawProps ||
5257
+ // for camelCase
5258
+ (!hasOwn(rawProps, key) &&
5259
+ // it's possible the original props was passed in as kebab-case
5260
+ // and converted to camelCase (#955)
5261
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
5262
+ if (options) {
5263
+ if (rawPrevProps &&
5264
+ // for camelCase
5265
+ (rawPrevProps[key] !== undefined ||
5266
+ // for kebab-case
5267
+ rawPrevProps[kebabKey] !== undefined)) {
5268
+ props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
5269
+ }
5270
+ }
5271
+ else {
5272
+ delete props[key];
5273
+ }
5274
+ }
5275
+ }
5276
+ // in the case of functional component w/o props declaration, props and
5277
+ // attrs point to the same object so it should already have been updated.
5278
+ if (attrs !== rawCurrentProps) {
5279
+ for (const key in attrs) {
5280
+ if (!rawProps ||
5281
+ (!hasOwn(rawProps, key) &&
5282
+ (!false ))) {
5283
+ delete attrs[key];
5284
+ hasAttrsChanged = true;
5285
+ }
5286
+ }
5287
+ }
5288
+ }
5289
+ // trigger updates for $attrs in case it's used in component slots
5290
+ if (hasAttrsChanged) {
5291
+ trigger(instance, "set" /* SET */, '$attrs');
5292
+ }
5293
+ {
5294
+ validateProps(rawProps || {}, props, instance);
5295
+ }
5296
+ }
5297
+ function setFullProps(instance, rawProps, props, attrs) {
5298
+ const [options, needCastKeys] = instance.propsOptions;
5299
+ let hasAttrsChanged = false;
5300
+ let rawCastValues;
5301
+ if (rawProps) {
5302
+ for (let key in rawProps) {
5303
+ // key, ref are reserved and never passed down
5304
+ if (isReservedProp(key)) {
5305
+ continue;
5306
+ }
5307
+ const value = rawProps[key];
5308
+ // prop option names are camelized during normalization, so to support
5309
+ // kebab -> camel conversion here we need to camelize the key.
5310
+ let camelKey;
5311
+ if (options && hasOwn(options, (camelKey = camelize(key)))) {
5312
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
5313
+ props[camelKey] = value;
5314
+ }
5315
+ else {
5316
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
5317
+ }
5318
+ }
5319
+ else if (!isEmitListener(instance.emitsOptions, key)) {
5320
+ if (!(key in attrs) || value !== attrs[key]) {
5321
+ attrs[key] = value;
5322
+ hasAttrsChanged = true;
5323
+ }
5324
+ }
5325
+ }
5326
+ }
5327
+ if (needCastKeys) {
5328
+ const rawCurrentProps = toRaw(props);
5329
+ const castValues = rawCastValues || EMPTY_OBJ;
5330
+ for (let i = 0; i < needCastKeys.length; i++) {
5331
+ const key = needCastKeys[i];
5332
+ props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
5333
+ }
5334
+ }
5335
+ return hasAttrsChanged;
5336
+ }
5337
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5338
+ const opt = options[key];
5339
+ if (opt != null) {
5340
+ const hasDefault = hasOwn(opt, 'default');
5341
+ // default values
5342
+ if (hasDefault && value === undefined) {
5343
+ const defaultValue = opt.default;
5344
+ if (opt.type !== Function && isFunction(defaultValue)) {
5345
+ const { propsDefaults } = instance;
5346
+ if (key in propsDefaults) {
5347
+ value = propsDefaults[key];
5348
+ }
5349
+ else {
5350
+ setCurrentInstance(instance);
5351
+ value = propsDefaults[key] = defaultValue.call(null, props);
5352
+ unsetCurrentInstance();
5353
+ }
5354
+ }
5355
+ else {
5356
+ value = defaultValue;
5357
+ }
5358
+ }
5359
+ // boolean casting
5360
+ if (opt[0 /* shouldCast */]) {
5361
+ if (isAbsent && !hasDefault) {
5362
+ value = false;
5363
+ }
5364
+ else if (opt[1 /* shouldCastTrue */] &&
5365
+ (value === '' || value === hyphenate(key))) {
5366
+ value = true;
5367
+ }
5368
+ }
5369
+ }
5370
+ return value;
5371
+ }
5372
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
5373
+ const cache = appContext.propsCache;
5374
+ const cached = cache.get(comp);
5375
+ if (cached) {
5376
+ return cached;
5377
+ }
5378
+ const raw = comp.props;
5379
+ const normalized = {};
5380
+ const needCastKeys = [];
5381
+ // apply mixin/extends props
5382
+ let hasExtends = false;
5383
+ if (!isFunction(comp)) {
5384
+ const extendProps = (raw) => {
5385
+ hasExtends = true;
5386
+ const [props, keys] = normalizePropsOptions(raw, appContext, true);
5387
+ extend(normalized, props);
5388
+ if (keys)
5389
+ needCastKeys.push(...keys);
5390
+ };
5391
+ if (!asMixin && appContext.mixins.length) {
5392
+ appContext.mixins.forEach(extendProps);
5393
+ }
5394
+ if (comp.extends) {
5395
+ extendProps(comp.extends);
5396
+ }
5397
+ if (comp.mixins) {
5398
+ comp.mixins.forEach(extendProps);
5399
+ }
5400
+ }
5401
+ if (!raw && !hasExtends) {
5402
+ cache.set(comp, EMPTY_ARR);
5403
+ return EMPTY_ARR;
5404
+ }
5405
+ if (isArray(raw)) {
5406
+ for (let i = 0; i < raw.length; i++) {
5407
+ if (!isString(raw[i])) {
5408
+ warn$1(`props must be strings when using array syntax.`, raw[i]);
5409
+ }
5410
+ const normalizedKey = camelize(raw[i]);
5411
+ if (validatePropName(normalizedKey)) {
5412
+ normalized[normalizedKey] = EMPTY_OBJ;
5413
+ }
5414
+ }
5415
+ }
5416
+ else if (raw) {
5417
+ if (!isObject(raw)) {
5418
+ warn$1(`invalid props options`, raw);
5419
+ }
5420
+ for (const key in raw) {
5421
+ const normalizedKey = camelize(key);
5422
+ if (validatePropName(normalizedKey)) {
5423
+ const opt = raw[key];
5424
+ const prop = (normalized[normalizedKey] =
5425
+ isArray(opt) || isFunction(opt) ? { type: opt } : opt);
5426
+ if (prop) {
5427
+ const booleanIndex = getTypeIndex(Boolean, prop.type);
5428
+ const stringIndex = getTypeIndex(String, prop.type);
5429
+ prop[0 /* shouldCast */] = booleanIndex > -1;
5430
+ prop[1 /* shouldCastTrue */] =
5431
+ stringIndex < 0 || booleanIndex < stringIndex;
5432
+ // if the prop needs boolean casting or default value
5433
+ if (booleanIndex > -1 || hasOwn(prop, 'default')) {
5434
+ needCastKeys.push(normalizedKey);
5435
+ }
5436
+ }
5437
+ }
5438
+ }
5439
+ }
5440
+ const res = [normalized, needCastKeys];
5441
+ cache.set(comp, res);
5442
+ return res;
5443
+ }
5444
+ function validatePropName(key) {
5445
+ if (key[0] !== '$') {
5446
+ return true;
5447
+ }
5448
+ else {
5449
+ warn$1(`Invalid prop name: "${key}" is a reserved property.`);
5450
+ }
5451
+ return false;
5452
+ }
5453
+ // use function string name to check type constructors
5454
+ // so that it works across vms / iframes.
5455
+ function getType(ctor) {
5456
+ const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
5457
+ return match ? match[1] : ctor === null ? 'null' : '';
5458
+ }
5459
+ function isSameType(a, b) {
5460
+ return getType(a) === getType(b);
5461
+ }
5462
+ function getTypeIndex(type, expectedTypes) {
5463
+ if (isArray(expectedTypes)) {
5464
+ return expectedTypes.findIndex(t => isSameType(t, type));
5465
+ }
5466
+ else if (isFunction(expectedTypes)) {
5467
+ return isSameType(expectedTypes, type) ? 0 : -1;
5468
+ }
5469
+ return -1;
5470
+ }
5471
+ /**
5472
+ * dev only
5473
+ */
5474
+ function validateProps(rawProps, props, instance) {
5475
+ const resolvedValues = toRaw(props);
5476
+ const options = instance.propsOptions[0];
5477
+ for (const key in options) {
5478
+ let opt = options[key];
5479
+ if (opt == null)
5480
+ continue;
5481
+ validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
5482
+ }
5483
+ }
5484
+ /**
5485
+ * dev only
5486
+ */
5487
+ function validateProp(name, value, prop, isAbsent) {
5488
+ const { type, required, validator } = prop;
5489
+ // required!
5490
+ if (required && isAbsent) {
5491
+ warn$1('Missing required prop: "' + name + '"');
5492
+ return;
5493
+ }
5494
+ // missing but optional
5495
+ if (value == null && !prop.required) {
5496
+ return;
5497
+ }
5498
+ // type check
5499
+ if (type != null && type !== true) {
5500
+ let isValid = false;
5501
+ const types = isArray(type) ? type : [type];
5502
+ const expectedTypes = [];
5503
+ // value is valid as long as one of the specified types match
5504
+ for (let i = 0; i < types.length && !isValid; i++) {
5505
+ const { valid, expectedType } = assertType(value, types[i]);
5506
+ expectedTypes.push(expectedType || '');
5507
+ isValid = valid;
5508
+ }
5509
+ if (!isValid) {
5510
+ warn$1(getInvalidTypeMessage(name, value, expectedTypes));
5511
+ return;
5512
+ }
5513
+ }
5514
+ // custom validator
5515
+ if (validator && !validator(value)) {
5516
+ warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
5517
+ }
5518
+ }
5519
+ const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
5520
+ /**
5521
+ * dev only
5522
+ */
5523
+ function assertType(value, type) {
5524
+ let valid;
5525
+ const expectedType = getType(type);
5526
+ if (isSimpleType(expectedType)) {
5527
+ const t = typeof value;
5528
+ valid = t === expectedType.toLowerCase();
5529
+ // for primitive wrapper objects
5530
+ if (!valid && t === 'object') {
5531
+ valid = value instanceof type;
5532
+ }
5533
+ }
5534
+ else if (expectedType === 'Object') {
5535
+ valid = isObject(value);
5536
+ }
5537
+ else if (expectedType === 'Array') {
5538
+ valid = isArray(value);
5539
+ }
5540
+ else if (expectedType === 'null') {
5541
+ valid = value === null;
5542
+ }
5543
+ else {
5544
+ valid = value instanceof type;
5545
+ }
5546
+ return {
5547
+ valid,
5548
+ expectedType
5549
+ };
5550
+ }
5551
+ /**
5552
+ * dev only
5553
+ */
5554
+ function getInvalidTypeMessage(name, value, expectedTypes) {
5555
+ let message = `Invalid prop: type check failed for prop "${name}".` +
5556
+ ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
5557
+ const expectedType = expectedTypes[0];
5558
+ const receivedType = toRawType(value);
5559
+ const expectedValue = styleValue(value, expectedType);
5560
+ const receivedValue = styleValue(value, receivedType);
5561
+ // check if we need to specify expected value
5562
+ if (expectedTypes.length === 1 &&
5563
+ isExplicable(expectedType) &&
5564
+ !isBoolean(expectedType, receivedType)) {
5565
+ message += ` with value ${expectedValue}`;
5566
+ }
5567
+ message += `, got ${receivedType} `;
5568
+ // check if we need to specify received value
5569
+ if (isExplicable(receivedType)) {
5570
+ message += `with value ${receivedValue}.`;
5571
+ }
5572
+ return message;
5573
+ }
5574
+ /**
5575
+ * dev only
5576
+ */
5577
+ function styleValue(value, type) {
5578
+ if (type === 'String') {
5579
+ return `"${value}"`;
5580
+ }
5581
+ else if (type === 'Number') {
5582
+ return `${Number(value)}`;
5583
+ }
5584
+ else {
5585
+ return `${value}`;
5586
+ }
5587
+ }
5588
+ /**
5589
+ * dev only
5590
+ */
5591
+ function isExplicable(type) {
5592
+ const explicitTypes = ['string', 'number', 'boolean'];
5593
+ return explicitTypes.some(elem => type.toLowerCase() === elem);
5594
+ }
5595
+ /**
5596
+ * dev only
5597
+ */
5598
+ function isBoolean(...args) {
5599
+ return args.some(elem => elem.toLowerCase() === 'boolean');
5600
+ }
5601
+
5602
+ const isInternalKey = (key) => key[0] === '_' || key === '$stable';
5603
+ const normalizeSlotValue = (value) => isArray(value)
5604
+ ? value.map(normalizeVNode)
5605
+ : [normalizeVNode(value)];
5606
+ const normalizeSlot = (key, rawSlot, ctx) => {
5607
+ if (rawSlot._n) {
5608
+ // already normalized - #5353
5609
+ return rawSlot;
5610
+ }
5611
+ const normalized = withCtx((...args) => {
5612
+ if (currentInstance) {
5613
+ warn$1(`Slot "${key}" invoked outside of the render function: ` +
5614
+ `this will not track dependencies used in the slot. ` +
5615
+ `Invoke the slot function inside the render function instead.`);
5616
+ }
5617
+ return normalizeSlotValue(rawSlot(...args));
5618
+ }, ctx);
5619
+ normalized._c = false;
5620
+ return normalized;
5621
+ };
5622
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
5623
+ const ctx = rawSlots._ctx;
5624
+ for (const key in rawSlots) {
5625
+ if (isInternalKey(key))
5626
+ continue;
5627
+ const value = rawSlots[key];
5628
+ if (isFunction(value)) {
5629
+ slots[key] = normalizeSlot(key, value, ctx);
5630
+ }
5631
+ else if (value != null) {
5632
+ {
5633
+ warn$1(`Non-function value encountered for slot "${key}". ` +
5634
+ `Prefer function slots for better performance.`);
5635
+ }
5636
+ const normalized = normalizeSlotValue(value);
5637
+ slots[key] = () => normalized;
5638
+ }
5639
+ }
5640
+ };
5641
+ const normalizeVNodeSlots = (instance, children) => {
5642
+ if (!isKeepAlive(instance.vnode) &&
5643
+ !(false )) {
5644
+ warn$1(`Non-function value encountered for default slot. ` +
5645
+ `Prefer function slots for better performance.`);
5646
+ }
5647
+ const normalized = normalizeSlotValue(children);
5648
+ instance.slots.default = () => normalized;
5649
+ };
5650
+ const initSlots = (instance, children) => {
5651
+ if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5652
+ const type = children._;
5653
+ if (type) {
5654
+ // users can get the shallow readonly version of the slots object through `this.$slots`,
5655
+ // we should avoid the proxy object polluting the slots of the internal instance
5656
+ instance.slots = toRaw(children);
5657
+ // make compiler marker non-enumerable
5658
+ def(children, '_', type);
5659
+ }
5660
+ else {
5661
+ normalizeObjectSlots(children, (instance.slots = {}));
5662
+ }
5663
+ }
5664
+ else {
5665
+ instance.slots = {};
5666
+ if (children) {
5667
+ normalizeVNodeSlots(instance, children);
5668
+ }
5669
+ }
5670
+ def(instance.slots, InternalObjectKey, 1);
5671
+ };
5672
+ const updateSlots = (instance, children, optimized) => {
5673
+ const { vnode, slots } = instance;
5674
+ let needDeletionCheck = true;
5675
+ let deletionComparisonTarget = EMPTY_OBJ;
5676
+ if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5677
+ const type = children._;
5678
+ if (type) {
5679
+ // compiled slots.
5680
+ if (isHmrUpdating) {
5681
+ // Parent was HMR updated so slot content may have changed.
5682
+ // force update slots and mark instance for hmr as well
5683
+ extend(slots, children);
5684
+ }
5685
+ else if (optimized && type === 1 /* STABLE */) {
5686
+ // compiled AND stable.
5687
+ // no need to update, and skip stale slots removal.
5688
+ needDeletionCheck = false;
5689
+ }
5690
+ else {
5691
+ // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5692
+ // normalization.
5693
+ extend(slots, children);
5694
+ // #2893
5695
+ // when rendering the optimized slots by manually written render function,
5696
+ // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5697
+ // i.e. let the `renderSlot` create the bailed Fragment
5698
+ if (!optimized && type === 1 /* STABLE */) {
5699
+ delete slots._;
5700
+ }
5701
+ }
5702
+ }
5703
+ else {
5704
+ needDeletionCheck = !children.$stable;
5705
+ normalizeObjectSlots(children, slots);
5706
+ }
5707
+ deletionComparisonTarget = children;
5708
+ }
5709
+ else if (children) {
5710
+ // non slot object children (direct value) passed to a component
5711
+ normalizeVNodeSlots(instance, children);
5712
+ deletionComparisonTarget = { default: 1 };
5713
+ }
5714
+ // delete stale slots
5715
+ if (needDeletionCheck) {
5716
+ for (const key in slots) {
5717
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5718
+ delete slots[key];
5719
+ }
5720
+ }
5721
+ }
5722
+ };
5723
+
5724
+ function createAppContext() {
5725
+ return {
5726
+ app: null,
5727
+ config: {
5728
+ isNativeTag: NO,
5729
+ performance: false,
5730
+ globalProperties: {},
5731
+ optionMergeStrategies: {},
5732
+ errorHandler: undefined,
5733
+ warnHandler: undefined,
5734
+ compilerOptions: {}
5735
+ },
5736
+ mixins: [],
5737
+ components: {},
5738
+ directives: {},
5739
+ provides: Object.create(null),
5740
+ optionsCache: new WeakMap(),
5741
+ propsCache: new WeakMap(),
5742
+ emitsCache: new WeakMap()
5743
+ };
5744
+ }
5745
+ let uid = 0;
5746
+ function createAppAPI(render, hydrate) {
5747
+ return function createApp(rootComponent, rootProps = null) {
5748
+ if (!isFunction(rootComponent)) {
5749
+ rootComponent = Object.assign({}, rootComponent);
5750
+ }
5751
+ if (rootProps != null && !isObject(rootProps)) {
5752
+ warn$1(`root props passed to app.mount() must be an object.`);
5753
+ rootProps = null;
5754
+ }
5197
5755
  const context = createAppContext();
5198
5756
  const installedPlugins = new Set();
5199
5757
  let isMounted = false;
@@ -5271,6 +5829,12 @@ var VueRuntimeDOM = (function (exports) {
5271
5829
  },
5272
5830
  mount(rootContainer, isHydrate, isSVG) {
5273
5831
  if (!isMounted) {
5832
+ // #5571
5833
+ if (rootContainer.__vue_app__) {
5834
+ warn$1(`There is already an app instance mounted on the host container.\n` +
5835
+ ` If you want to mount another app on the same host container,` +
5836
+ ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
5837
+ }
5274
5838
  const vnode = createVNode(rootComponent, rootProps);
5275
5839
  // store app context on the root VNode.
5276
5840
  // this will be set on the root instance on initial mount.
@@ -5321,8 +5885,6 @@ var VueRuntimeDOM = (function (exports) {
5321
5885
  warn$1(`App already provides property with key "${String(key)}". ` +
5322
5886
  `It will be overwritten with the new value.`);
5323
5887
  }
5324
- // TypeScript doesn't allow symbols as index type
5325
- // https://github.com/Microsoft/TypeScript/issues/24587
5326
5888
  context.provides[key] = value;
5327
5889
  return app;
5328
5890
  }
@@ -5386,6 +5948,9 @@ var VueRuntimeDOM = (function (exports) {
5386
5948
  if (!isArray(existing)) {
5387
5949
  if (_isString) {
5388
5950
  refs[ref] = [refValue];
5951
+ if (hasOwn(setupState, ref)) {
5952
+ setupState[ref] = refs[ref];
5953
+ }
5389
5954
  }
5390
5955
  else {
5391
5956
  ref.value = [refValue];
@@ -5456,9 +6021,13 @@ var VueRuntimeDOM = (function (exports) {
5456
6021
  const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
5457
6022
  const isFragmentStart = isComment(node) && node.data === '[';
5458
6023
  const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
5459
- const { type, ref, shapeFlag } = vnode;
6024
+ const { type, ref, shapeFlag, patchFlag } = vnode;
5460
6025
  const domType = node.nodeType;
5461
6026
  vnode.el = node;
6027
+ if (patchFlag === -2 /* BAIL */) {
6028
+ optimized = false;
6029
+ vnode.dynamicChildren = null;
6030
+ }
5462
6031
  let nextNode = null;
5463
6032
  switch (type) {
5464
6033
  case Text:
@@ -5758,7 +6327,7 @@ var VueRuntimeDOM = (function (exports) {
5758
6327
  perf.mark(`vue-${type}-${instance.uid}`);
5759
6328
  }
5760
6329
  {
5761
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
6330
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
5762
6331
  }
5763
6332
  }
5764
6333
  function endMeasure(instance, type) {
@@ -5771,7 +6340,7 @@ var VueRuntimeDOM = (function (exports) {
5771
6340
  perf.clearMarks(endTag);
5772
6341
  }
5773
6342
  {
5774
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
6343
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
5775
6344
  }
5776
6345
  }
5777
6346
  function isSupported() {
@@ -6223,6 +6792,8 @@ var VueRuntimeDOM = (function (exports) {
6223
6792
  else {
6224
6793
  if (patchFlag > 0 &&
6225
6794
  patchFlag & 64 /* STABLE_FRAGMENT */ &&
6795
+ // #5523 dev root fragment may inherit directives so always force update
6796
+ !(patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) &&
6226
6797
  dynamicChildren &&
6227
6798
  // #2715 the previous fragment could've been a BAILed one as a result
6228
6799
  // of renderSlot() with no valid children
@@ -6335,7 +6906,6 @@ var VueRuntimeDOM = (function (exports) {
6335
6906
  }
6336
6907
  else {
6337
6908
  // no update needed. just copy over properties
6338
- n2.component = n1.component;
6339
6909
  n2.el = n1.el;
6340
6910
  instance.vnode = n2;
6341
6911
  }
@@ -6418,7 +6988,10 @@ var VueRuntimeDOM = (function (exports) {
6418
6988
  // activated hook for keep-alive roots.
6419
6989
  // #1742 activated hook must be accessed after first render
6420
6990
  // since the hook may be injected by a child keep-alive
6421
- if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
6991
+ if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */ ||
6992
+ (parent &&
6993
+ isAsyncWrapper(parent.vnode) &&
6994
+ parent.vnode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */)) {
6422
6995
  instance.a && queuePostRenderEffect(instance.a, parentSuspense);
6423
6996
  }
6424
6997
  instance.isMounted = true;
@@ -6501,9 +7074,9 @@ var VueRuntimeDOM = (function (exports) {
6501
7074
  }
6502
7075
  };
6503
7076
  // create reactive effect for rendering
6504
- const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7077
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
6505
7078
  ));
6506
- const update = (instance.update = effect.run.bind(effect));
7079
+ const update = (instance.update = () => effect.run());
6507
7080
  update.id = instance.uid;
6508
7081
  // allowRecurse
6509
7082
  // #1801, #2043 component render effects should allow recursive updates
@@ -6515,7 +7088,6 @@ var VueRuntimeDOM = (function (exports) {
6515
7088
  effect.onTrigger = instance.rtg
6516
7089
  ? e => invokeArrayFns(instance.rtg, e)
6517
7090
  : void 0;
6518
- // @ts-ignore (for scheduler)
6519
7091
  update.ownerInstance = instance;
6520
7092
  }
6521
7093
  update();
@@ -6899,7 +7471,22 @@ var VueRuntimeDOM = (function (exports) {
6899
7471
  const remove = vnode => {
6900
7472
  const { type, el, anchor, transition } = vnode;
6901
7473
  if (type === Fragment) {
6902
- removeFragment(el, anchor);
7474
+ if (vnode.patchFlag > 0 &&
7475
+ vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
7476
+ transition &&
7477
+ !transition.persisted) {
7478
+ vnode.children.forEach(child => {
7479
+ if (child.type === Comment) {
7480
+ hostRemove(child.el);
7481
+ }
7482
+ else {
7483
+ remove(child);
7484
+ }
7485
+ });
7486
+ }
7487
+ else {
7488
+ removeFragment(el, anchor);
7489
+ }
6903
7490
  return;
6904
7491
  }
6905
7492
  if (type === Static) {
@@ -7296,85 +7883,12 @@ var VueRuntimeDOM = (function (exports) {
7296
7883
  }
7297
7884
  target._lpa =
7298
7885
  vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7299
- }
7300
- }
7301
- return vnode.anchor && nextSibling(vnode.anchor);
7302
- }
7303
- // Force-casted public typing for h and TSX props inference
7304
- const Teleport = TeleportImpl;
7305
-
7306
- const COMPONENTS = 'components';
7307
- const DIRECTIVES = 'directives';
7308
- /**
7309
- * @private
7310
- */
7311
- function resolveComponent(name, maybeSelfReference) {
7312
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7313
- }
7314
- const NULL_DYNAMIC_COMPONENT = Symbol();
7315
- /**
7316
- * @private
7317
- */
7318
- function resolveDynamicComponent(component) {
7319
- if (isString(component)) {
7320
- return resolveAsset(COMPONENTS, component, false) || component;
7321
- }
7322
- else {
7323
- // invalid types will fallthrough to createVNode and raise warning
7324
- return (component || NULL_DYNAMIC_COMPONENT);
7325
- }
7326
- }
7327
- /**
7328
- * @private
7329
- */
7330
- function resolveDirective(name) {
7331
- return resolveAsset(DIRECTIVES, name);
7332
- }
7333
- // implementation
7334
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7335
- const instance = currentRenderingInstance || currentInstance;
7336
- if (instance) {
7337
- const Component = instance.type;
7338
- // explicit self name has highest priority
7339
- if (type === COMPONENTS) {
7340
- const selfName = getComponentName(Component);
7341
- if (selfName &&
7342
- (selfName === name ||
7343
- selfName === camelize(name) ||
7344
- selfName === capitalize(camelize(name)))) {
7345
- return Component;
7346
- }
7347
- }
7348
- const res =
7349
- // local registration
7350
- // check instance[type] first which is resolved for options API
7351
- resolve(instance[type] || Component[type], name) ||
7352
- // global registration
7353
- resolve(instance.appContext[type], name);
7354
- if (!res && maybeSelfReference) {
7355
- // fallback to implicit self-reference
7356
- return Component;
7357
- }
7358
- if (warnMissing && !res) {
7359
- const extra = type === COMPONENTS
7360
- ? `\nIf this is a native custom element, make sure to exclude it from ` +
7361
- `component resolution via compilerOptions.isCustomElement.`
7362
- : ``;
7363
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7364
- }
7365
- return res;
7366
- }
7367
- else {
7368
- warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
7369
- `can only be used in render() or setup().`);
7886
+ }
7370
7887
  }
7888
+ return vnode.anchor && nextSibling(vnode.anchor);
7371
7889
  }
7372
- function resolve(registry, name) {
7373
- return (registry &&
7374
- (registry[name] ||
7375
- registry[camelize(name)] ||
7376
- registry[capitalize(camelize(name))]));
7377
- }
7890
+ // Force-casted public typing for h and TSX props inference
7891
+ const Teleport = TeleportImpl;
7378
7892
 
7379
7893
  const Fragment = Symbol('Fragment' );
7380
7894
  const Text = Symbol('Text' );
@@ -7578,6 +8092,15 @@ var VueRuntimeDOM = (function (exports) {
7578
8092
  if (children) {
7579
8093
  normalizeChildren(cloned, children);
7580
8094
  }
8095
+ if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
8096
+ if (cloned.shapeFlag & 6 /* COMPONENT */) {
8097
+ currentBlock[currentBlock.indexOf(type)] = cloned;
8098
+ }
8099
+ else {
8100
+ currentBlock.push(cloned);
8101
+ }
8102
+ }
8103
+ cloned.patchFlag |= -2 /* BAIL */;
7581
8104
  return cloned;
7582
8105
  }
7583
8106
  // class component normalization.
@@ -7646,608 +8169,203 @@ var VueRuntimeDOM = (function (exports) {
7646
8169
  // the refs so the single vnode can be set on multiple refs
7647
8170
  mergeRef && ref
7648
8171
  ? isArray(ref)
7649
- ? ref.concat(normalizeRef(extraProps))
7650
- : [ref, normalizeRef(extraProps)]
7651
- : normalizeRef(extraProps)
7652
- : ref,
7653
- scopeId: vnode.scopeId,
7654
- slotScopeIds: vnode.slotScopeIds,
7655
- children: patchFlag === -1 /* HOISTED */ && isArray(children)
7656
- ? children.map(deepCloneVNode)
7657
- : children,
7658
- target: vnode.target,
7659
- targetAnchor: vnode.targetAnchor,
7660
- staticCount: vnode.staticCount,
7661
- shapeFlag: vnode.shapeFlag,
7662
- // if the vnode is cloned with extra props, we can no longer assume its
7663
- // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7664
- // note: preserve flag for fragments since they use the flag for children
7665
- // fast paths only.
7666
- patchFlag: extraProps && vnode.type !== Fragment
7667
- ? patchFlag === -1 // hoisted node
7668
- ? 16 /* FULL_PROPS */
7669
- : patchFlag | 16 /* FULL_PROPS */
7670
- : patchFlag,
7671
- dynamicProps: vnode.dynamicProps,
7672
- dynamicChildren: vnode.dynamicChildren,
7673
- appContext: vnode.appContext,
7674
- dirs: vnode.dirs,
7675
- transition: vnode.transition,
7676
- // These should technically only be non-null on mounted VNodes. However,
7677
- // they *should* be copied for kept-alive vnodes. So we just always copy
7678
- // them since them being non-null during a mount doesn't affect the logic as
7679
- // they will simply be overwritten.
7680
- component: vnode.component,
7681
- suspense: vnode.suspense,
7682
- ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7683
- ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7684
- el: vnode.el,
7685
- anchor: vnode.anchor
7686
- };
7687
- return cloned;
7688
- }
7689
- /**
7690
- * Dev only, for HMR of hoisted vnodes reused in v-for
7691
- * https://github.com/vitejs/vite/issues/2022
7692
- */
7693
- function deepCloneVNode(vnode) {
7694
- const cloned = cloneVNode(vnode);
7695
- if (isArray(vnode.children)) {
7696
- cloned.children = vnode.children.map(deepCloneVNode);
7697
- }
7698
- return cloned;
7699
- }
7700
- /**
7701
- * @private
7702
- */
7703
- function createTextVNode(text = ' ', flag = 0) {
7704
- return createVNode(Text, null, text, flag);
7705
- }
7706
- /**
7707
- * @private
7708
- */
7709
- function createStaticVNode(content, numberOfNodes) {
7710
- // A static vnode can contain multiple stringified elements, and the number
7711
- // of elements is necessary for hydration.
7712
- const vnode = createVNode(Static, null, content);
7713
- vnode.staticCount = numberOfNodes;
7714
- return vnode;
7715
- }
7716
- /**
7717
- * @private
7718
- */
7719
- function createCommentVNode(text = '',
7720
- // when used as the v-else branch, the comment node must be created as a
7721
- // block to ensure correct updates.
7722
- asBlock = false) {
7723
- return asBlock
7724
- ? (openBlock(), createBlock(Comment, null, text))
7725
- : createVNode(Comment, null, text);
7726
- }
7727
- function normalizeVNode(child) {
7728
- if (child == null || typeof child === 'boolean') {
7729
- // empty placeholder
7730
- return createVNode(Comment);
7731
- }
7732
- else if (isArray(child)) {
7733
- // fragment
7734
- return createVNode(Fragment, null,
7735
- // #3666, avoid reference pollution when reusing vnode
7736
- child.slice());
7737
- }
7738
- else if (typeof child === 'object') {
7739
- // already vnode, this should be the most common since compiled templates
7740
- // always produce all-vnode children arrays
7741
- return cloneIfMounted(child);
7742
- }
7743
- else {
7744
- // strings and numbers
7745
- return createVNode(Text, null, String(child));
7746
- }
7747
- }
7748
- // optimized normalization for template-compiled render fns
7749
- function cloneIfMounted(child) {
7750
- return child.el === null || child.memo ? child : cloneVNode(child);
7751
- }
7752
- function normalizeChildren(vnode, children) {
7753
- let type = 0;
7754
- const { shapeFlag } = vnode;
7755
- if (children == null) {
7756
- children = null;
7757
- }
7758
- else if (isArray(children)) {
7759
- type = 16 /* ARRAY_CHILDREN */;
7760
- }
7761
- else if (typeof children === 'object') {
7762
- if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7763
- // Normalize slot to plain children for plain element and Teleport
7764
- const slot = children.default;
7765
- if (slot) {
7766
- // _c marker is added by withCtx() indicating this is a compiled slot
7767
- slot._c && (slot._d = false);
7768
- normalizeChildren(vnode, slot());
7769
- slot._c && (slot._d = true);
7770
- }
7771
- return;
7772
- }
7773
- else {
7774
- type = 32 /* SLOTS_CHILDREN */;
7775
- const slotFlag = children._;
7776
- if (!slotFlag && !(InternalObjectKey in children)) {
7777
- children._ctx = currentRenderingInstance;
7778
- }
7779
- else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7780
- // a child component receives forwarded slots from the parent.
7781
- // its slot type is determined by its parent's slot type.
7782
- if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7783
- children._ = 1 /* STABLE */;
7784
- }
7785
- else {
7786
- children._ = 2 /* DYNAMIC */;
7787
- vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7788
- }
7789
- }
7790
- }
7791
- }
7792
- else if (isFunction(children)) {
7793
- children = { default: children, _ctx: currentRenderingInstance };
7794
- type = 32 /* SLOTS_CHILDREN */;
7795
- }
7796
- else {
7797
- children = String(children);
7798
- // force teleport children to array so it can be moved around
7799
- if (shapeFlag & 64 /* TELEPORT */) {
7800
- type = 16 /* ARRAY_CHILDREN */;
7801
- children = [createTextVNode(children)];
7802
- }
7803
- else {
7804
- type = 8 /* TEXT_CHILDREN */;
7805
- }
7806
- }
7807
- vnode.children = children;
7808
- vnode.shapeFlag |= type;
7809
- }
7810
- function mergeProps(...args) {
7811
- const ret = {};
7812
- for (let i = 0; i < args.length; i++) {
7813
- const toMerge = args[i];
7814
- for (const key in toMerge) {
7815
- if (key === 'class') {
7816
- if (ret.class !== toMerge.class) {
7817
- ret.class = normalizeClass([ret.class, toMerge.class]);
7818
- }
7819
- }
7820
- else if (key === 'style') {
7821
- ret.style = normalizeStyle([ret.style, toMerge.style]);
7822
- }
7823
- else if (isOn(key)) {
7824
- const existing = ret[key];
7825
- const incoming = toMerge[key];
7826
- if (incoming &&
7827
- existing !== incoming &&
7828
- !(isArray(existing) && existing.includes(incoming))) {
7829
- ret[key] = existing
7830
- ? [].concat(existing, incoming)
7831
- : incoming;
7832
- }
7833
- }
7834
- else if (key !== '') {
7835
- ret[key] = toMerge[key];
7836
- }
7837
- }
7838
- }
7839
- return ret;
7840
- }
7841
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7842
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7843
- vnode,
7844
- prevVNode
7845
- ]);
7846
- }
7847
-
7848
- /**
7849
- * Actual implementation
7850
- */
7851
- function renderList(source, renderItem, cache, index) {
7852
- let ret;
7853
- const cached = (cache && cache[index]);
7854
- if (isArray(source) || isString(source)) {
7855
- ret = new Array(source.length);
7856
- for (let i = 0, l = source.length; i < l; i++) {
7857
- ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
7858
- }
7859
- }
7860
- else if (typeof source === 'number') {
7861
- if (!Number.isInteger(source)) {
7862
- warn$1(`The v-for range expect an integer value but got ${source}.`);
7863
- return [];
7864
- }
7865
- ret = new Array(source);
7866
- for (let i = 0; i < source; i++) {
7867
- ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
7868
- }
7869
- }
7870
- else if (isObject(source)) {
7871
- if (source[Symbol.iterator]) {
7872
- ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
7873
- }
7874
- else {
7875
- const keys = Object.keys(source);
7876
- ret = new Array(keys.length);
7877
- for (let i = 0, l = keys.length; i < l; i++) {
7878
- const key = keys[i];
7879
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
7880
- }
7881
- }
7882
- }
7883
- else {
7884
- ret = [];
7885
- }
7886
- if (cache) {
7887
- cache[index] = ret;
7888
- }
7889
- return ret;
7890
- }
7891
-
8172
+ ? ref.concat(normalizeRef(extraProps))
8173
+ : [ref, normalizeRef(extraProps)]
8174
+ : normalizeRef(extraProps)
8175
+ : ref,
8176
+ scopeId: vnode.scopeId,
8177
+ slotScopeIds: vnode.slotScopeIds,
8178
+ children: patchFlag === -1 /* HOISTED */ && isArray(children)
8179
+ ? children.map(deepCloneVNode)
8180
+ : children,
8181
+ target: vnode.target,
8182
+ targetAnchor: vnode.targetAnchor,
8183
+ staticCount: vnode.staticCount,
8184
+ shapeFlag: vnode.shapeFlag,
8185
+ // if the vnode is cloned with extra props, we can no longer assume its
8186
+ // existing patch flag to be reliable and need to add the FULL_PROPS flag.
8187
+ // note: preserve flag for fragments since they use the flag for children
8188
+ // fast paths only.
8189
+ patchFlag: extraProps && vnode.type !== Fragment
8190
+ ? patchFlag === -1 // hoisted node
8191
+ ? 16 /* FULL_PROPS */
8192
+ : patchFlag | 16 /* FULL_PROPS */
8193
+ : patchFlag,
8194
+ dynamicProps: vnode.dynamicProps,
8195
+ dynamicChildren: vnode.dynamicChildren,
8196
+ appContext: vnode.appContext,
8197
+ dirs: vnode.dirs,
8198
+ transition: vnode.transition,
8199
+ // These should technically only be non-null on mounted VNodes. However,
8200
+ // they *should* be copied for kept-alive vnodes. So we just always copy
8201
+ // them since them being non-null during a mount doesn't affect the logic as
8202
+ // they will simply be overwritten.
8203
+ component: vnode.component,
8204
+ suspense: vnode.suspense,
8205
+ ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
8206
+ ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
8207
+ el: vnode.el,
8208
+ anchor: vnode.anchor
8209
+ };
8210
+ return cloned;
8211
+ }
7892
8212
  /**
7893
- * Compiler runtime helper for creating dynamic slots object
7894
- * @private
8213
+ * Dev only, for HMR of hoisted vnodes reused in v-for
8214
+ * https://github.com/vitejs/vite/issues/2022
7895
8215
  */
7896
- function createSlots(slots, dynamicSlots) {
7897
- for (let i = 0; i < dynamicSlots.length; i++) {
7898
- const slot = dynamicSlots[i];
7899
- // array of dynamic slot generated by <template v-for="..." #[...]>
7900
- if (isArray(slot)) {
7901
- for (let j = 0; j < slot.length; j++) {
7902
- slots[slot[j].name] = slot[j].fn;
7903
- }
7904
- }
7905
- else if (slot) {
7906
- // conditional single slot generated by <template v-if="..." #foo>
7907
- slots[slot.name] = slot.fn;
7908
- }
8216
+ function deepCloneVNode(vnode) {
8217
+ const cloned = cloneVNode(vnode);
8218
+ if (isArray(vnode.children)) {
8219
+ cloned.children = vnode.children.map(deepCloneVNode);
7909
8220
  }
7910
- return slots;
7911
- }
7912
-
8221
+ return cloned;
8222
+ }
7913
8223
  /**
7914
- * Compiler runtime helper for rendering `<slot/>`
7915
8224
  * @private
7916
8225
  */
7917
- function renderSlot(slots, name, props = {},
7918
- // this is not a user-facing function, so the fallback is always generated by
7919
- // the compiler and guaranteed to be a function returning an array
7920
- fallback, noSlotted) {
7921
- if (currentRenderingInstance.isCE) {
7922
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
7923
- }
7924
- let slot = slots[name];
7925
- if (slot && slot.length > 1) {
7926
- warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
7927
- `function. You need to mark this component with $dynamic-slots in the ` +
7928
- `parent template.`);
7929
- slot = () => [];
7930
- }
7931
- // a compiled slot disables block tracking by default to avoid manual
7932
- // invocation interfering with template-based block tracking, but in
7933
- // `renderSlot` we can be sure that it's template-based so we can force
7934
- // enable it.
7935
- if (slot && slot._c) {
7936
- slot._d = false;
7937
- }
7938
- openBlock();
7939
- const validSlotContent = slot && ensureValidVNode(slot(props));
7940
- const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
7941
- ? 64 /* STABLE_FRAGMENT */
7942
- : -2 /* BAIL */);
7943
- if (!noSlotted && rendered.scopeId) {
7944
- rendered.slotScopeIds = [rendered.scopeId + '-s'];
7945
- }
7946
- if (slot && slot._c) {
7947
- slot._d = true;
7948
- }
7949
- return rendered;
8226
+ function createTextVNode(text = ' ', flag = 0) {
8227
+ return createVNode(Text, null, text, flag);
7950
8228
  }
7951
- function ensureValidVNode(vnodes) {
7952
- return vnodes.some(child => {
7953
- if (!isVNode(child))
7954
- return true;
7955
- if (child.type === Comment)
7956
- return false;
7957
- if (child.type === Fragment &&
7958
- !ensureValidVNode(child.children))
7959
- return false;
7960
- return true;
7961
- })
7962
- ? vnodes
7963
- : null;
7964
- }
7965
-
7966
8229
  /**
7967
- * For prefixing keys in v-on="obj" with "on"
7968
8230
  * @private
7969
8231
  */
7970
- function toHandlers(obj) {
7971
- const ret = {};
7972
- if (!isObject(obj)) {
7973
- warn$1(`v-on with no argument expects an object value.`);
7974
- return ret;
7975
- }
7976
- for (const key in obj) {
7977
- ret[toHandlerKey(key)] = obj[key];
7978
- }
7979
- return ret;
7980
- }
7981
-
7982
- /**
7983
- * #2437 In Vue 3, functional components do not have a public instance proxy but
7984
- * they exist in the internal parent chain. For code that relies on traversing
7985
- * public $parent chains, skip functional ones and go to the parent instead.
7986
- */
7987
- const getPublicInstance = (i) => {
7988
- if (!i)
7989
- return null;
7990
- if (isStatefulComponent(i))
7991
- return getExposeProxy(i) || i.proxy;
7992
- return getPublicInstance(i.parent);
7993
- };
7994
- const publicPropertiesMap = extend(Object.create(null), {
7995
- $: i => i,
7996
- $el: i => i.vnode.el,
7997
- $data: i => i.data,
7998
- $props: i => (shallowReadonly(i.props) ),
7999
- $attrs: i => (shallowReadonly(i.attrs) ),
8000
- $slots: i => (shallowReadonly(i.slots) ),
8001
- $refs: i => (shallowReadonly(i.refs) ),
8002
- $parent: i => getPublicInstance(i.parent),
8003
- $root: i => getPublicInstance(i.root),
8004
- $emit: i => i.emit,
8005
- $options: i => (resolveMergedOptions(i) ),
8006
- $forceUpdate: i => () => queueJob(i.update),
8007
- $nextTick: i => nextTick.bind(i.proxy),
8008
- $watch: i => (instanceWatch.bind(i) )
8009
- });
8010
- const PublicInstanceProxyHandlers = {
8011
- get({ _: instance }, key) {
8012
- const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
8013
- // for internal formatters to know that this is a Vue instance
8014
- if (key === '__isVue') {
8015
- return true;
8016
- }
8017
- // prioritize <script setup> bindings during dev.
8018
- // this allows even properties that start with _ or $ to be used - so that
8019
- // it aligns with the production behavior where the render fn is inlined and
8020
- // indeed has access to all declared variables.
8021
- if (setupState !== EMPTY_OBJ &&
8022
- setupState.__isScriptSetup &&
8023
- hasOwn(setupState, key)) {
8024
- return setupState[key];
8025
- }
8026
- // data / props / ctx
8027
- // This getter gets called for every property access on the render context
8028
- // during render and is a major hotspot. The most expensive part of this
8029
- // is the multiple hasOwn() calls. It's much faster to do a simple property
8030
- // access on a plain object, so we use an accessCache object (with null
8031
- // prototype) to memoize what access type a key corresponds to.
8032
- let normalizedProps;
8033
- if (key[0] !== '$') {
8034
- const n = accessCache[key];
8035
- if (n !== undefined) {
8036
- switch (n) {
8037
- case 1 /* SETUP */:
8038
- return setupState[key];
8039
- case 2 /* DATA */:
8040
- return data[key];
8041
- case 4 /* CONTEXT */:
8042
- return ctx[key];
8043
- case 3 /* PROPS */:
8044
- return props[key];
8045
- // default: just fallthrough
8046
- }
8047
- }
8048
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8049
- accessCache[key] = 1 /* SETUP */;
8050
- return setupState[key];
8051
- }
8052
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8053
- accessCache[key] = 2 /* DATA */;
8054
- return data[key];
8055
- }
8056
- else if (
8057
- // only cache other properties when instance has declared (thus stable)
8058
- // props
8059
- (normalizedProps = instance.propsOptions[0]) &&
8060
- hasOwn(normalizedProps, key)) {
8061
- accessCache[key] = 3 /* PROPS */;
8062
- return props[key];
8063
- }
8064
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8065
- accessCache[key] = 4 /* CONTEXT */;
8066
- return ctx[key];
8067
- }
8068
- else if (shouldCacheAccess) {
8069
- accessCache[key] = 0 /* OTHER */;
8070
- }
8071
- }
8072
- const publicGetter = publicPropertiesMap[key];
8073
- let cssModule, globalProperties;
8074
- // public $xxx properties
8075
- if (publicGetter) {
8076
- if (key === '$attrs') {
8077
- track(instance, "get" /* GET */, key);
8078
- markAttrsAccessed();
8079
- }
8080
- return publicGetter(instance);
8081
- }
8082
- else if (
8083
- // css module (injected by vue-loader)
8084
- (cssModule = type.__cssModules) &&
8085
- (cssModule = cssModule[key])) {
8086
- return cssModule;
8087
- }
8088
- else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8089
- // user may set custom properties to `this` that start with `$`
8090
- accessCache[key] = 4 /* CONTEXT */;
8091
- return ctx[key];
8092
- }
8093
- else if (
8094
- // global properties
8095
- ((globalProperties = appContext.config.globalProperties),
8096
- hasOwn(globalProperties, key))) {
8097
- {
8098
- return globalProperties[key];
8099
- }
8100
- }
8101
- else if (currentRenderingInstance &&
8102
- (!isString(key) ||
8103
- // #1091 avoid internal isRef/isVNode checks on component instance leading
8104
- // to infinite warning loop
8105
- key.indexOf('__v') !== 0)) {
8106
- if (data !== EMPTY_OBJ &&
8107
- (key[0] === '$' || key[0] === '_') &&
8108
- hasOwn(data, key)) {
8109
- warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
8110
- `character ("$" or "_") and is not proxied on the render context.`);
8111
- }
8112
- else if (instance === currentRenderingInstance) {
8113
- warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
8114
- `but is not defined on instance.`);
8232
+ function createStaticVNode(content, numberOfNodes) {
8233
+ // A static vnode can contain multiple stringified elements, and the number
8234
+ // of elements is necessary for hydration.
8235
+ const vnode = createVNode(Static, null, content);
8236
+ vnode.staticCount = numberOfNodes;
8237
+ return vnode;
8238
+ }
8239
+ /**
8240
+ * @private
8241
+ */
8242
+ function createCommentVNode(text = '',
8243
+ // when used as the v-else branch, the comment node must be created as a
8244
+ // block to ensure correct updates.
8245
+ asBlock = false) {
8246
+ return asBlock
8247
+ ? (openBlock(), createBlock(Comment, null, text))
8248
+ : createVNode(Comment, null, text);
8249
+ }
8250
+ function normalizeVNode(child) {
8251
+ if (child == null || typeof child === 'boolean') {
8252
+ // empty placeholder
8253
+ return createVNode(Comment);
8254
+ }
8255
+ else if (isArray(child)) {
8256
+ // fragment
8257
+ return createVNode(Fragment, null,
8258
+ // #3666, avoid reference pollution when reusing vnode
8259
+ child.slice());
8260
+ }
8261
+ else if (typeof child === 'object') {
8262
+ // already vnode, this should be the most common since compiled templates
8263
+ // always produce all-vnode children arrays
8264
+ return cloneIfMounted(child);
8265
+ }
8266
+ else {
8267
+ // strings and numbers
8268
+ return createVNode(Text, null, String(child));
8269
+ }
8270
+ }
8271
+ // optimized normalization for template-compiled render fns
8272
+ function cloneIfMounted(child) {
8273
+ return child.el === null || child.memo ? child : cloneVNode(child);
8274
+ }
8275
+ function normalizeChildren(vnode, children) {
8276
+ let type = 0;
8277
+ const { shapeFlag } = vnode;
8278
+ if (children == null) {
8279
+ children = null;
8280
+ }
8281
+ else if (isArray(children)) {
8282
+ type = 16 /* ARRAY_CHILDREN */;
8283
+ }
8284
+ else if (typeof children === 'object') {
8285
+ if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
8286
+ // Normalize slot to plain children for plain element and Teleport
8287
+ const slot = children.default;
8288
+ if (slot) {
8289
+ // _c marker is added by withCtx() indicating this is a compiled slot
8290
+ slot._c && (slot._d = false);
8291
+ normalizeChildren(vnode, slot());
8292
+ slot._c && (slot._d = true);
8115
8293
  }
8116
- }
8117
- },
8118
- set({ _: instance }, key, value) {
8119
- const { data, setupState, ctx } = instance;
8120
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8121
- setupState[key] = value;
8122
- return true;
8123
- }
8124
- else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8125
- data[key] = value;
8126
- return true;
8127
- }
8128
- else if (hasOwn(instance.props, key)) {
8129
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
8130
- return false;
8131
- }
8132
- if (key[0] === '$' && key.slice(1) in instance) {
8133
- warn$1(`Attempting to mutate public property "${key}". ` +
8134
- `Properties starting with $ are reserved and readonly.`, instance);
8135
- return false;
8294
+ return;
8136
8295
  }
8137
8296
  else {
8138
- if (key in instance.appContext.config.globalProperties) {
8139
- Object.defineProperty(ctx, key, {
8140
- enumerable: true,
8141
- configurable: true,
8142
- value
8143
- });
8297
+ type = 32 /* SLOTS_CHILDREN */;
8298
+ const slotFlag = children._;
8299
+ if (!slotFlag && !(InternalObjectKey in children)) {
8300
+ children._ctx = currentRenderingInstance;
8144
8301
  }
8145
- else {
8146
- ctx[key] = value;
8302
+ else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
8303
+ // a child component receives forwarded slots from the parent.
8304
+ // its slot type is determined by its parent's slot type.
8305
+ if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
8306
+ children._ = 1 /* STABLE */;
8307
+ }
8308
+ else {
8309
+ children._ = 2 /* DYNAMIC */;
8310
+ vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
8311
+ }
8147
8312
  }
8148
8313
  }
8149
- return true;
8150
- },
8151
- has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
8152
- let normalizedProps;
8153
- return (!!accessCache[key] ||
8154
- (data !== EMPTY_OBJ && hasOwn(data, key)) ||
8155
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
8156
- ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
8157
- hasOwn(ctx, key) ||
8158
- hasOwn(publicPropertiesMap, key) ||
8159
- hasOwn(appContext.config.globalProperties, key));
8160
- },
8161
- defineProperty(target, key, descriptor) {
8162
- if (descriptor.get != null) {
8163
- this.set(target, key, descriptor.get(), null);
8164
- }
8165
- else if (descriptor.value != null) {
8166
- this.set(target, key, descriptor.value, null);
8167
- }
8168
- return Reflect.defineProperty(target, key, descriptor);
8169
8314
  }
8170
- };
8171
- {
8172
- PublicInstanceProxyHandlers.ownKeys = (target) => {
8173
- warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
8174
- `The keys will be empty in production mode to avoid performance overhead.`);
8175
- return Reflect.ownKeys(target);
8176
- };
8177
- }
8178
- const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
8179
- get(target, key) {
8180
- // fast path for unscopables when using `with` block
8181
- if (key === Symbol.unscopables) {
8182
- return;
8315
+ else if (isFunction(children)) {
8316
+ children = { default: children, _ctx: currentRenderingInstance };
8317
+ type = 32 /* SLOTS_CHILDREN */;
8318
+ }
8319
+ else {
8320
+ children = String(children);
8321
+ // force teleport children to array so it can be moved around
8322
+ if (shapeFlag & 64 /* TELEPORT */) {
8323
+ type = 16 /* ARRAY_CHILDREN */;
8324
+ children = [createTextVNode(children)];
8183
8325
  }
8184
- return PublicInstanceProxyHandlers.get(target, key, target);
8185
- },
8186
- has(_, key) {
8187
- const has = key[0] !== '_' && !isGloballyWhitelisted(key);
8188
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
8189
- warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
8326
+ else {
8327
+ type = 8 /* TEXT_CHILDREN */;
8190
8328
  }
8191
- return has;
8192
- }
8193
- });
8194
- // dev only
8195
- // In dev mode, the proxy target exposes the same properties as seen on `this`
8196
- // for easier console inspection. In prod mode it will be an empty object so
8197
- // these properties definitions can be skipped.
8198
- function createDevRenderContext(instance) {
8199
- const target = {};
8200
- // expose internal instance for proxy handlers
8201
- Object.defineProperty(target, `_`, {
8202
- configurable: true,
8203
- enumerable: false,
8204
- get: () => instance
8205
- });
8206
- // expose public properties
8207
- Object.keys(publicPropertiesMap).forEach(key => {
8208
- Object.defineProperty(target, key, {
8209
- configurable: true,
8210
- enumerable: false,
8211
- get: () => publicPropertiesMap[key](instance),
8212
- // intercepted by the proxy so no need for implementation,
8213
- // but needed to prevent set errors
8214
- set: NOOP
8215
- });
8216
- });
8217
- return target;
8218
- }
8219
- // dev only
8220
- function exposePropsOnRenderContext(instance) {
8221
- const { ctx, propsOptions: [propsOptions] } = instance;
8222
- if (propsOptions) {
8223
- Object.keys(propsOptions).forEach(key => {
8224
- Object.defineProperty(ctx, key, {
8225
- enumerable: true,
8226
- configurable: true,
8227
- get: () => instance.props[key],
8228
- set: NOOP
8229
- });
8230
- });
8231
8329
  }
8330
+ vnode.children = children;
8331
+ vnode.shapeFlag |= type;
8232
8332
  }
8233
- // dev only
8234
- function exposeSetupStateOnRenderContext(instance) {
8235
- const { ctx, setupState } = instance;
8236
- Object.keys(toRaw(setupState)).forEach(key => {
8237
- if (!setupState.__isScriptSetup) {
8238
- if (key[0] === '$' || key[0] === '_') {
8239
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8240
- `which are reserved prefixes for Vue internals.`);
8241
- return;
8333
+ function mergeProps(...args) {
8334
+ const ret = {};
8335
+ for (let i = 0; i < args.length; i++) {
8336
+ const toMerge = args[i];
8337
+ for (const key in toMerge) {
8338
+ if (key === 'class') {
8339
+ if (ret.class !== toMerge.class) {
8340
+ ret.class = normalizeClass([ret.class, toMerge.class]);
8341
+ }
8342
+ }
8343
+ else if (key === 'style') {
8344
+ ret.style = normalizeStyle([ret.style, toMerge.style]);
8345
+ }
8346
+ else if (isOn(key)) {
8347
+ const existing = ret[key];
8348
+ const incoming = toMerge[key];
8349
+ if (incoming &&
8350
+ existing !== incoming &&
8351
+ !(isArray(existing) && existing.includes(incoming))) {
8352
+ ret[key] = existing
8353
+ ? [].concat(existing, incoming)
8354
+ : incoming;
8355
+ }
8356
+ }
8357
+ else if (key !== '') {
8358
+ ret[key] = toMerge[key];
8242
8359
  }
8243
- Object.defineProperty(ctx, key, {
8244
- enumerable: true,
8245
- configurable: true,
8246
- get: () => setupState[key],
8247
- set: NOOP
8248
- });
8249
8360
  }
8250
- });
8361
+ }
8362
+ return ret;
8363
+ }
8364
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8365
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8366
+ vnode,
8367
+ prevVNode
8368
+ ]);
8251
8369
  }
8252
8370
 
8253
8371
  const emptyAppContext = createAppContext();
@@ -8276,7 +8394,7 @@ var VueRuntimeDOM = (function (exports) {
8276
8394
  provides: parent ? parent.provides : Object.create(appContext.provides),
8277
8395
  accessCache: null,
8278
8396
  renderCache: [],
8279
- // local resovled assets
8397
+ // local resolved assets
8280
8398
  components: null,
8281
8399
  directives: null,
8282
8400
  // resolved props and emits options
@@ -8368,6 +8486,7 @@ var VueRuntimeDOM = (function (exports) {
8368
8486
  return setupResult;
8369
8487
  }
8370
8488
  function setupStatefulComponent(instance, isSSR) {
8489
+ var _a;
8371
8490
  const Component = instance.type;
8372
8491
  {
8373
8492
  if (Component.name) {
@@ -8425,6 +8544,13 @@ var VueRuntimeDOM = (function (exports) {
8425
8544
  // async setup returned Promise.
8426
8545
  // bail here and wait for re-entry.
8427
8546
  instance.asyncDep = setupResult;
8547
+ if (!instance.suspense) {
8548
+ const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
8549
+ warn$1(`Component <${name}>: setup function returned a promise, but no ` +
8550
+ `<Suspense> boundary was found in the parent component tree. ` +
8551
+ `A component with async setup() must be nested in a <Suspense> ` +
8552
+ `in order to be rendered.`);
8553
+ }
8428
8554
  }
8429
8555
  }
8430
8556
  else {
@@ -9024,7 +9150,7 @@ var VueRuntimeDOM = (function (exports) {
9024
9150
  return false;
9025
9151
  }
9026
9152
  for (let i = 0; i < prev.length; i++) {
9027
- if (prev[i] !== memo[i]) {
9153
+ if (hasChanged(prev[i], memo[i])) {
9028
9154
  return false;
9029
9155
  }
9030
9156
  }
@@ -9036,7 +9162,7 @@ var VueRuntimeDOM = (function (exports) {
9036
9162
  }
9037
9163
 
9038
9164
  // Core API ------------------------------------------------------------------
9039
- const version = "3.2.31";
9165
+ const version = "3.2.34-beta.1";
9040
9166
  /**
9041
9167
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9042
9168
  * @internal
@@ -9053,7 +9179,7 @@ var VueRuntimeDOM = (function (exports) {
9053
9179
 
9054
9180
  const svgNS = 'http://www.w3.org/2000/svg';
9055
9181
  const doc = (typeof document !== 'undefined' ? document : null);
9056
- const templateContainer = doc && doc.createElement('template');
9182
+ const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
9057
9183
  const nodeOps = {
9058
9184
  insert: (child, parent, anchor) => {
9059
9185
  parent.insertBefore(child, anchor || null);
@@ -9204,6 +9330,8 @@ var VueRuntimeDOM = (function (exports) {
9204
9330
  val.forEach(v => setStyle(style, name, v));
9205
9331
  }
9206
9332
  else {
9333
+ if (val == null)
9334
+ val = '';
9207
9335
  if (name.startsWith('--')) {
9208
9336
  // custom property definition
9209
9337
  style.setProperty(name, val);
@@ -9298,31 +9426,28 @@ var VueRuntimeDOM = (function (exports) {
9298
9426
  }
9299
9427
  return;
9300
9428
  }
9429
+ let needRemove = false;
9301
9430
  if (value === '' || value == null) {
9302
9431
  const type = typeof el[key];
9303
9432
  if (type === 'boolean') {
9304
9433
  // e.g. <select multiple> compiles to { multiple: '' }
9305
- el[key] = includeBooleanAttr(value);
9306
- return;
9434
+ value = includeBooleanAttr(value);
9307
9435
  }
9308
9436
  else if (value == null && type === 'string') {
9309
9437
  // e.g. <div :id="null">
9310
- el[key] = '';
9311
- el.removeAttribute(key);
9312
- return;
9438
+ value = '';
9439
+ needRemove = true;
9313
9440
  }
9314
9441
  else if (type === 'number') {
9315
9442
  // e.g. <img :width="null">
9316
9443
  // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9317
- try {
9318
- el[key] = 0;
9319
- }
9320
- catch (_a) { }
9321
- el.removeAttribute(key);
9322
- return;
9444
+ value = 0;
9445
+ needRemove = true;
9323
9446
  }
9324
9447
  }
9325
- // some properties perform value validation and throw
9448
+ // some properties perform value validation and throw,
9449
+ // some properties has getter, no setter, will error in 'use strict'
9450
+ // eg. <select :type="null"></select> <select :willValidate="null"></select>
9326
9451
  try {
9327
9452
  el[key] = value;
9328
9453
  }
@@ -9332,31 +9457,35 @@ var VueRuntimeDOM = (function (exports) {
9332
9457
  `value ${value} is invalid.`, e);
9333
9458
  }
9334
9459
  }
9460
+ needRemove && el.removeAttribute(key);
9335
9461
  }
9336
9462
 
9337
9463
  // Async edge case fix requires storing an event listener's attach timestamp.
9338
- let _getNow = Date.now;
9339
- let skipTimestampCheck = false;
9340
- if (typeof window !== 'undefined') {
9341
- // Determine what event timestamp the browser is using. Annoyingly, the
9342
- // timestamp can either be hi-res (relative to page load) or low-res
9343
- // (relative to UNIX epoch), so in order to compare time we have to use the
9344
- // same timestamp type when saving the flush timestamp.
9345
- if (_getNow() > document.createEvent('Event').timeStamp) {
9346
- // if the low-res timestamp which is bigger than the event timestamp
9347
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9348
- // and we need to use the hi-res version for event listeners as well.
9349
- _getNow = () => performance.now();
9350
- }
9351
- // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9352
- // and does not fire microtasks in between event propagation, so safe to exclude.
9353
- const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9354
- skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9355
- }
9464
+ const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
9465
+ let _getNow = Date.now;
9466
+ let skipTimestampCheck = false;
9467
+ if (typeof window !== 'undefined') {
9468
+ // Determine what event timestamp the browser is using. Annoyingly, the
9469
+ // timestamp can either be hi-res (relative to page load) or low-res
9470
+ // (relative to UNIX epoch), so in order to compare time we have to use the
9471
+ // same timestamp type when saving the flush timestamp.
9472
+ if (Date.now() > document.createEvent('Event').timeStamp) {
9473
+ // if the low-res timestamp which is bigger than the event timestamp
9474
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9475
+ // and we need to use the hi-res version for event listeners as well.
9476
+ _getNow = () => performance.now();
9477
+ }
9478
+ // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9479
+ // and does not fire microtasks in between event propagation, so safe to exclude.
9480
+ const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9481
+ skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9482
+ }
9483
+ return [_getNow, skipTimestampCheck];
9484
+ })();
9356
9485
  // To avoid the overhead of repeatedly calling performance.now(), we cache
9357
9486
  // and use the same timestamp for all event listeners attached in the same tick.
9358
9487
  let cachedNow = 0;
9359
- const p = Promise.resolve();
9488
+ const p = /*#__PURE__*/ Promise.resolve();
9360
9489
  const reset = () => {
9361
9490
  cachedNow = 0;
9362
9491
  };
@@ -9481,13 +9610,13 @@ var VueRuntimeDOM = (function (exports) {
9481
9610
  }
9482
9611
  return false;
9483
9612
  }
9484
- // spellcheck and draggable are numerated attrs, however their
9485
- // corresponding DOM properties are actually booleans - this leads to
9486
- // setting it with a string "false" value leading it to be coerced to
9487
- // `true`, so we need to always treat them as attributes.
9613
+ // these are enumerated attrs, however their corresponding DOM properties
9614
+ // are actually booleans - this leads to setting it with a string "false"
9615
+ // value leading it to be coerced to `true`, so we need to always treat
9616
+ // them as attributes.
9488
9617
  // Note that `contentEditable` doesn't have this problem: its DOM
9489
9618
  // property is also enumerated string values.
9490
- if (key === 'spellcheck' || key === 'draggable') {
9619
+ if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
9491
9620
  return false;
9492
9621
  }
9493
9622
  // #1787, #2840 form property on form elements is readonly and must be set as
@@ -9510,11 +9639,11 @@ var VueRuntimeDOM = (function (exports) {
9510
9639
  return key in el;
9511
9640
  }
9512
9641
 
9513
- function defineCustomElement(options, hydate) {
9642
+ function defineCustomElement(options, hydrate) {
9514
9643
  const Comp = defineComponent(options);
9515
9644
  class VueCustomElement extends VueElement {
9516
9645
  constructor(initialProps) {
9517
- super(Comp, initialProps, hydate);
9646
+ super(Comp, initialProps, hydrate);
9518
9647
  }
9519
9648
  }
9520
9649
  VueCustomElement.def = Comp;
@@ -9862,7 +9991,10 @@ var VueRuntimeDOM = (function (exports) {
9862
9991
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
9863
9992
  done && done();
9864
9993
  };
9994
+ let isLeaving = false;
9865
9995
  const finishLeave = (el, done) => {
9996
+ isLeaving = false;
9997
+ removeTransitionClass(el, leaveFromClass);
9866
9998
  removeTransitionClass(el, leaveToClass);
9867
9999
  removeTransitionClass(el, leaveActiveClass);
9868
10000
  done && done();
@@ -9895,12 +10027,17 @@ var VueRuntimeDOM = (function (exports) {
9895
10027
  onEnter: makeEnterHook(false),
9896
10028
  onAppear: makeEnterHook(true),
9897
10029
  onLeave(el, done) {
10030
+ isLeaving = true;
9898
10031
  const resolve = () => finishLeave(el, done);
9899
10032
  addTransitionClass(el, leaveFromClass);
9900
10033
  // force reflow so *-leave-from classes immediately take effect (#2593)
9901
10034
  forceReflow();
9902
10035
  addTransitionClass(el, leaveActiveClass);
9903
10036
  nextFrame(() => {
10037
+ if (!isLeaving) {
10038
+ // cancelled
10039
+ return;
10040
+ }
9904
10041
  removeTransitionClass(el, leaveFromClass);
9905
10042
  addTransitionClass(el, leaveToClass);
9906
10043
  if (!hasExplicitCallback(onLeave)) {
@@ -10192,7 +10329,8 @@ var VueRuntimeDOM = (function (exports) {
10192
10329
  }
10193
10330
 
10194
10331
  const getModelAssigner = (vnode) => {
10195
- const fn = vnode.props['onUpdate:modelValue'];
10332
+ const fn = vnode.props['onUpdate:modelValue'] ||
10333
+ (false );
10196
10334
  return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10197
10335
  };
10198
10336
  function onCompositionStart(e) {
@@ -10202,14 +10340,9 @@ var VueRuntimeDOM = (function (exports) {
10202
10340
  const target = e.target;
10203
10341
  if (target.composing) {
10204
10342
  target.composing = false;
10205
- trigger$1(target, 'input');
10343
+ target.dispatchEvent(new Event('input'));
10206
10344
  }
10207
10345
  }
10208
- function trigger$1(el, type) {
10209
- const e = document.createEvent('HTMLEvents');
10210
- e.initEvent(type, true, true);
10211
- el.dispatchEvent(e);
10212
- }
10213
10346
  // We are exporting the v-model runtime directly as vnode hooks so that it can
10214
10347
  // be tree-shaken in case v-model is never used.
10215
10348
  const vModelText = {
@@ -10223,7 +10356,7 @@ var VueRuntimeDOM = (function (exports) {
10223
10356
  if (trim) {
10224
10357
  domValue = domValue.trim();
10225
10358
  }
10226
- else if (castToNumber) {
10359
+ if (castToNumber) {
10227
10360
  domValue = toNumber(domValue);
10228
10361
  }
10229
10362
  el._assign(domValue);
@@ -10252,7 +10385,7 @@ var VueRuntimeDOM = (function (exports) {
10252
10385
  // avoid clearing unresolved text. #2302
10253
10386
  if (el.composing)
10254
10387
  return;
10255
- if (document.activeElement === el) {
10388
+ if (document.activeElement === el && el.type !== 'range') {
10256
10389
  if (lazy) {
10257
10390
  return;
10258
10391
  }
@@ -10542,7 +10675,7 @@ var VueRuntimeDOM = (function (exports) {
10542
10675
  el.style.display = value ? el._vod : 'none';
10543
10676
  }
10544
10677
 
10545
- const rendererOptions = extend({ patchProp }, nodeOps);
10678
+ const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
10546
10679
  // lazy create the renderer - this makes core renderer logic tree-shakable
10547
10680
  // in case the user only imports reactivity utilities from Vue.
10548
10681
  let renderer;