@vue/runtime-dom 3.2.22 → 3.2.26

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.
@@ -37,7 +37,7 @@ var VueRuntimeDOM = (function (exports) {
37
37
  const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
38
38
  /**
39
39
  * Boolean attributes should be included if the value is truthy or ''.
40
- * e.g. <select multiple> compiles to { multiple: '' }
40
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
41
41
  */
42
42
  function includeBooleanAttr(value) {
43
43
  return !!value || value === '';
@@ -269,7 +269,7 @@ var VueRuntimeDOM = (function (exports) {
269
269
  '' + parseInt(key, 10) === key;
270
270
  const isReservedProp = /*#__PURE__*/ makeMap(
271
271
  // the leading comma is intentional so empty string "" is also included
272
- ',key,ref,' +
272
+ ',key,ref,ref_for,ref_key,' +
273
273
  'onVnodeBeforeMount,onVnodeMounted,' +
274
274
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
275
275
  'onVnodeBeforeUnmount,onVnodeUnmounted');
@@ -458,7 +458,7 @@ var VueRuntimeDOM = (function (exports) {
458
458
  let effectTrackDepth = 0;
459
459
  let trackOpBit = 1;
460
460
  /**
461
- * The bitwise track markers support at most 30 levels op recursion.
461
+ * The bitwise track markers support at most 30 levels of recursion.
462
462
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
463
463
  * When recursion depth is greater, fall back to using a full cleanup.
464
464
  */
@@ -779,7 +779,7 @@ var VueRuntimeDOM = (function (exports) {
779
779
  function createSetter(shallow = false) {
780
780
  return function set(target, key, value, receiver) {
781
781
  let oldValue = target[key];
782
- if (!shallow) {
782
+ if (!shallow && !isReadonly(value)) {
783
783
  value = toRaw(value);
784
784
  oldValue = toRaw(oldValue);
785
785
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1364,21 +1364,25 @@ var VueRuntimeDOM = (function (exports) {
1364
1364
  return ret;
1365
1365
  }
1366
1366
  class ObjectRefImpl {
1367
- constructor(_object, _key) {
1367
+ constructor(_object, _key, _defaultValue) {
1368
1368
  this._object = _object;
1369
1369
  this._key = _key;
1370
+ this._defaultValue = _defaultValue;
1370
1371
  this.__v_isRef = true;
1371
1372
  }
1372
1373
  get value() {
1373
- return this._object[this._key];
1374
+ const val = this._object[this._key];
1375
+ return val === undefined ? this._defaultValue : val;
1374
1376
  }
1375
1377
  set value(newVal) {
1376
1378
  this._object[this._key] = newVal;
1377
1379
  }
1378
1380
  }
1379
- function toRef(object, key) {
1381
+ function toRef(object, key, defaultValue) {
1380
1382
  const val = object[key];
1381
- return isRef(val) ? val : new ObjectRefImpl(object, key);
1383
+ return isRef(val)
1384
+ ? val
1385
+ : new ObjectRefImpl(object, key, defaultValue);
1382
1386
  }
1383
1387
 
1384
1388
  class ComputedRefImpl {
@@ -2694,7 +2698,8 @@ var VueRuntimeDOM = (function (exports) {
2694
2698
  const rawProps = toRaw(props);
2695
2699
  const { mode } = rawProps;
2696
2700
  // check mode
2697
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2701
+ if (mode &&
2702
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
2698
2703
  warn$1(`invalid <transition> mode: ${mode}`);
2699
2704
  }
2700
2705
  // at this point children has a guaranteed length of 1.
@@ -3334,7 +3339,7 @@ var VueRuntimeDOM = (function (exports) {
3334
3339
  }
3335
3340
  current = current.parent;
3336
3341
  }
3337
- hook();
3342
+ return hook();
3338
3343
  });
3339
3344
  injectHook(type, wrappedHook, target);
3340
3345
  // In addition to registering it on the target instance, we walk up the parent
@@ -3996,7 +4001,7 @@ var VueRuntimeDOM = (function (exports) {
3996
4001
  }
3997
4002
  }
3998
4003
  else if (!isEmitListener(instance.emitsOptions, key)) {
3999
- if (value !== attrs[key]) {
4004
+ if (!(key in attrs) || value !== attrs[key]) {
4000
4005
  attrs[key] = value;
4001
4006
  hasAttrsChanged = true;
4002
4007
  }
@@ -4636,6 +4641,102 @@ var VueRuntimeDOM = (function (exports) {
4636
4641
  };
4637
4642
  }
4638
4643
 
4644
+ /**
4645
+ * Function for handling a template ref
4646
+ */
4647
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
4648
+ if (isArray(rawRef)) {
4649
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
4650
+ return;
4651
+ }
4652
+ if (isAsyncWrapper(vnode) && !isUnmount) {
4653
+ // when mounting async components, nothing needs to be done,
4654
+ // because the template ref is forwarded to inner component
4655
+ return;
4656
+ }
4657
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
4658
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
4659
+ : vnode.el;
4660
+ const value = isUnmount ? null : refValue;
4661
+ const { i: owner, r: ref } = rawRef;
4662
+ if (!owner) {
4663
+ warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
4664
+ `A vnode with ref must be created inside the render function.`);
4665
+ return;
4666
+ }
4667
+ const oldRef = oldRawRef && oldRawRef.r;
4668
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
4669
+ const setupState = owner.setupState;
4670
+ // dynamic ref changed. unset old ref
4671
+ if (oldRef != null && oldRef !== ref) {
4672
+ if (isString(oldRef)) {
4673
+ refs[oldRef] = null;
4674
+ if (hasOwn(setupState, oldRef)) {
4675
+ setupState[oldRef] = null;
4676
+ }
4677
+ }
4678
+ else if (isRef(oldRef)) {
4679
+ oldRef.value = null;
4680
+ }
4681
+ }
4682
+ if (isFunction(ref)) {
4683
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
4684
+ }
4685
+ else {
4686
+ const _isString = isString(ref);
4687
+ const _isRef = isRef(ref);
4688
+ if (_isString || _isRef) {
4689
+ const doSet = () => {
4690
+ if (rawRef.f) {
4691
+ const existing = _isString ? refs[ref] : ref.value;
4692
+ if (isUnmount) {
4693
+ isArray(existing) && remove(existing, refValue);
4694
+ }
4695
+ else {
4696
+ if (!isArray(existing)) {
4697
+ if (_isString) {
4698
+ refs[ref] = [refValue];
4699
+ }
4700
+ else {
4701
+ ref.value = [refValue];
4702
+ if (rawRef.k)
4703
+ refs[rawRef.k] = ref.value;
4704
+ }
4705
+ }
4706
+ else if (!existing.includes(refValue)) {
4707
+ existing.push(refValue);
4708
+ }
4709
+ }
4710
+ }
4711
+ else if (_isString) {
4712
+ refs[ref] = value;
4713
+ if (hasOwn(setupState, ref)) {
4714
+ setupState[ref] = value;
4715
+ }
4716
+ }
4717
+ else if (isRef(ref)) {
4718
+ ref.value = value;
4719
+ if (rawRef.k)
4720
+ refs[rawRef.k] = value;
4721
+ }
4722
+ else {
4723
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
4724
+ }
4725
+ };
4726
+ if (value) {
4727
+ doSet.id = -1;
4728
+ queuePostRenderEffect(doSet, parentSuspense);
4729
+ }
4730
+ else {
4731
+ doSet();
4732
+ }
4733
+ }
4734
+ else {
4735
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
4736
+ }
4737
+ }
4738
+ }
4739
+
4639
4740
  let hasMismatch = false;
4640
4741
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
4641
4742
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -5268,12 +5369,15 @@ var VueRuntimeDOM = (function (exports) {
5268
5369
  const oldProps = n1.props || EMPTY_OBJ;
5269
5370
  const newProps = n2.props || EMPTY_OBJ;
5270
5371
  let vnodeHook;
5372
+ // disable recurse in beforeUpdate hooks
5373
+ parentComponent && toggleRecurse(parentComponent, false);
5271
5374
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
5272
5375
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
5273
5376
  }
5274
5377
  if (dirs) {
5275
5378
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
5276
5379
  }
5380
+ parentComponent && toggleRecurse(parentComponent, true);
5277
5381
  if (isHmrUpdating) {
5278
5382
  // HMR updated, force full diff
5279
5383
  patchFlag = 0;
@@ -5553,7 +5657,7 @@ var VueRuntimeDOM = (function (exports) {
5553
5657
  const { el, props } = initialVNode;
5554
5658
  const { bm, m, parent } = instance;
5555
5659
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
5556
- effect.allowRecurse = false;
5660
+ toggleRecurse(instance, false);
5557
5661
  // beforeMount hook
5558
5662
  if (bm) {
5559
5663
  invokeArrayFns(bm);
@@ -5563,7 +5667,7 @@ var VueRuntimeDOM = (function (exports) {
5563
5667
  (vnodeHook = props && props.onVnodeBeforeMount)) {
5564
5668
  invokeVNodeHook(vnodeHook, parent, initialVNode);
5565
5669
  }
5566
- effect.allowRecurse = true;
5670
+ toggleRecurse(instance, true);
5567
5671
  if (el && hydrateNode) {
5568
5672
  // vnode has adopted host node - perform hydration instead of mount.
5569
5673
  const hydrateSubTree = () => {
@@ -5645,7 +5749,7 @@ var VueRuntimeDOM = (function (exports) {
5645
5749
  pushWarningContext(next || instance.vnode);
5646
5750
  }
5647
5751
  // Disallow component effect recursion during pre-lifecycle hooks.
5648
- effect.allowRecurse = false;
5752
+ toggleRecurse(instance, false);
5649
5753
  if (next) {
5650
5754
  next.el = vnode.el;
5651
5755
  updateComponentPreRender(instance, next, optimized);
@@ -5661,7 +5765,7 @@ var VueRuntimeDOM = (function (exports) {
5661
5765
  if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
5662
5766
  invokeVNodeHook(vnodeHook, parent, next, vnode);
5663
5767
  }
5664
- effect.allowRecurse = true;
5768
+ toggleRecurse(instance, true);
5665
5769
  // render
5666
5770
  {
5667
5771
  startMeasure(instance, `render`);
@@ -5707,13 +5811,13 @@ var VueRuntimeDOM = (function (exports) {
5707
5811
  }
5708
5812
  };
5709
5813
  // create reactive effect for rendering
5710
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
5711
- );
5814
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
5815
+ ));
5712
5816
  const update = (instance.update = effect.run.bind(effect));
5713
5817
  update.id = instance.uid;
5714
5818
  // allowRecurse
5715
5819
  // #1801, #2043 component render effects should allow recursive updates
5716
- effect.allowRecurse = update.allowRecurse = true;
5820
+ toggleRecurse(instance, true);
5717
5821
  {
5718
5822
  effect.onTrack = instance.rtc
5719
5823
  ? e => invokeArrayFns(instance.rtc, e)
@@ -6237,85 +6341,8 @@ var VueRuntimeDOM = (function (exports) {
6237
6341
  createApp: createAppAPI(render, hydrate)
6238
6342
  };
6239
6343
  }
6240
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
6241
- if (isArray(rawRef)) {
6242
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
6243
- return;
6244
- }
6245
- if (isAsyncWrapper(vnode) && !isUnmount) {
6246
- // when mounting async components, nothing needs to be done,
6247
- // because the template ref is forwarded to inner component
6248
- return;
6249
- }
6250
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
6251
- ? getExposeProxy(vnode.component) || vnode.component.proxy
6252
- : vnode.el;
6253
- const value = isUnmount ? null : refValue;
6254
- const { i: owner, r: ref } = rawRef;
6255
- if (!owner) {
6256
- warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
6257
- `A vnode with ref must be created inside the render function.`);
6258
- return;
6259
- }
6260
- const oldRef = oldRawRef && oldRawRef.r;
6261
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
6262
- const setupState = owner.setupState;
6263
- // dynamic ref changed. unset old ref
6264
- if (oldRef != null && oldRef !== ref) {
6265
- if (isString(oldRef)) {
6266
- refs[oldRef] = null;
6267
- if (hasOwn(setupState, oldRef)) {
6268
- setupState[oldRef] = null;
6269
- }
6270
- }
6271
- else if (isRef(oldRef)) {
6272
- oldRef.value = null;
6273
- }
6274
- }
6275
- if (isString(ref)) {
6276
- const doSet = () => {
6277
- {
6278
- refs[ref] = value;
6279
- }
6280
- if (hasOwn(setupState, ref)) {
6281
- setupState[ref] = value;
6282
- }
6283
- };
6284
- // #1789: for non-null values, set them after render
6285
- // null values means this is unmount and it should not overwrite another
6286
- // ref with the same key
6287
- if (value) {
6288
- doSet.id = -1;
6289
- queuePostRenderEffect(doSet, parentSuspense);
6290
- }
6291
- else {
6292
- doSet();
6293
- }
6294
- }
6295
- else if (isRef(ref)) {
6296
- const doSet = () => {
6297
- ref.value = value;
6298
- };
6299
- if (value) {
6300
- doSet.id = -1;
6301
- queuePostRenderEffect(doSet, parentSuspense);
6302
- }
6303
- else {
6304
- doSet();
6305
- }
6306
- }
6307
- else if (isFunction(ref)) {
6308
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
6309
- }
6310
- else {
6311
- warn$1('Invalid template ref type:', value, `(${typeof value})`);
6312
- }
6313
- }
6314
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6315
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
6316
- vnode,
6317
- prevVNode
6318
- ]);
6344
+ function toggleRecurse({ effect, update }, allowed) {
6345
+ effect.allowRecurse = update.allowRecurse = allowed;
6319
6346
  }
6320
6347
  /**
6321
6348
  * #1156
@@ -6774,10 +6801,10 @@ var VueRuntimeDOM = (function (exports) {
6774
6801
  };
6775
6802
  const InternalObjectKey = `__vInternal`;
6776
6803
  const normalizeKey = ({ key }) => key != null ? key : null;
6777
- const normalizeRef = ({ ref }) => {
6804
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
6778
6805
  return (ref != null
6779
6806
  ? isString(ref) || isRef(ref) || isFunction(ref)
6780
- ? { i: currentRenderingInstance, r: ref }
6807
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
6781
6808
  : ref
6782
6809
  : null);
6783
6810
  };
@@ -7119,6 +7146,12 @@ var VueRuntimeDOM = (function (exports) {
7119
7146
  }
7120
7147
  }
7121
7148
  return ret;
7149
+ }
7150
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7151
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7152
+ vnode,
7153
+ prevVNode
7154
+ ]);
7122
7155
  }
7123
7156
 
7124
7157
  /**
@@ -7310,23 +7343,23 @@ var VueRuntimeDOM = (function (exports) {
7310
7343
  const n = accessCache[key];
7311
7344
  if (n !== undefined) {
7312
7345
  switch (n) {
7313
- case 0 /* SETUP */:
7346
+ case 1 /* SETUP */:
7314
7347
  return setupState[key];
7315
- case 1 /* DATA */:
7348
+ case 2 /* DATA */:
7316
7349
  return data[key];
7317
- case 3 /* CONTEXT */:
7350
+ case 4 /* CONTEXT */:
7318
7351
  return ctx[key];
7319
- case 2 /* PROPS */:
7352
+ case 3 /* PROPS */:
7320
7353
  return props[key];
7321
7354
  // default: just fallthrough
7322
7355
  }
7323
7356
  }
7324
7357
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7325
- accessCache[key] = 0 /* SETUP */;
7358
+ accessCache[key] = 1 /* SETUP */;
7326
7359
  return setupState[key];
7327
7360
  }
7328
7361
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7329
- accessCache[key] = 1 /* DATA */;
7362
+ accessCache[key] = 2 /* DATA */;
7330
7363
  return data[key];
7331
7364
  }
7332
7365
  else if (
@@ -7334,15 +7367,15 @@ var VueRuntimeDOM = (function (exports) {
7334
7367
  // props
7335
7368
  (normalizedProps = instance.propsOptions[0]) &&
7336
7369
  hasOwn(normalizedProps, key)) {
7337
- accessCache[key] = 2 /* PROPS */;
7370
+ accessCache[key] = 3 /* PROPS */;
7338
7371
  return props[key];
7339
7372
  }
7340
7373
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7341
- accessCache[key] = 3 /* CONTEXT */;
7374
+ accessCache[key] = 4 /* CONTEXT */;
7342
7375
  return ctx[key];
7343
7376
  }
7344
7377
  else if (shouldCacheAccess) {
7345
- accessCache[key] = 4 /* OTHER */;
7378
+ accessCache[key] = 0 /* OTHER */;
7346
7379
  }
7347
7380
  }
7348
7381
  const publicGetter = publicPropertiesMap[key];
@@ -7363,7 +7396,7 @@ var VueRuntimeDOM = (function (exports) {
7363
7396
  }
7364
7397
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7365
7398
  // user may set custom properties to `this` that start with `$`
7366
- accessCache[key] = 3 /* CONTEXT */;
7399
+ accessCache[key] = 4 /* CONTEXT */;
7367
7400
  return ctx[key];
7368
7401
  }
7369
7402
  else if (
@@ -7424,7 +7457,7 @@ var VueRuntimeDOM = (function (exports) {
7424
7457
  },
7425
7458
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7426
7459
  let normalizedProps;
7427
- return (accessCache[key] !== undefined ||
7460
+ return (!!accessCache[key] ||
7428
7461
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7429
7462
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7430
7463
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -7530,6 +7563,7 @@ var VueRuntimeDOM = (function (exports) {
7530
7563
  root: null,
7531
7564
  next: null,
7532
7565
  subTree: null,
7566
+ effect: null,
7533
7567
  update: null,
7534
7568
  scope: new EffectScope(true /* detached */),
7535
7569
  render: null,
@@ -8966,7 +9000,7 @@ var VueRuntimeDOM = (function (exports) {
8966
9000
  }
8967
9001
 
8968
9002
  // Core API ------------------------------------------------------------------
8969
- const version = "3.2.22";
9003
+ const version = "3.2.26";
8970
9004
  /**
8971
9005
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8972
9006
  * @internal
@@ -9199,12 +9233,19 @@ var VueRuntimeDOM = (function (exports) {
9199
9233
  el[key] = value == null ? '' : value;
9200
9234
  return;
9201
9235
  }
9202
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9236
+ if (key === 'value' &&
9237
+ el.tagName !== 'PROGRESS' &&
9238
+ // custom elements may use _value internally
9239
+ !el.tagName.includes('-')) {
9203
9240
  // store value as _value as well since
9204
9241
  // non-string values will be stringified.
9205
9242
  el._value = value;
9206
9243
  const newValue = value == null ? '' : value;
9207
- if (el.value !== newValue) {
9244
+ if (el.value !== newValue ||
9245
+ // #4956: always set for OPTION elements because its value falls back to
9246
+ // textContent if no value attribute is present. And setting .value for
9247
+ // OPTION has no side effect
9248
+ el.tagName === 'OPTION') {
9208
9249
  el.value = newValue;
9209
9250
  }
9210
9251
  if (value == null) {
@@ -9590,7 +9631,7 @@ var VueRuntimeDOM = (function (exports) {
9590
9631
  // HMR
9591
9632
  {
9592
9633
  instance.ceReload = newStyles => {
9593
- // alawys reset styles
9634
+ // always reset styles
9594
9635
  if (this._styles) {
9595
9636
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
9596
9637
  this._styles.length = 0;