vue 3.2.19 → 3.2.23

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.
@@ -533,7 +533,7 @@ var Vue = (function (exports) {
533
533
  let effectTrackDepth = 0;
534
534
  let trackOpBit = 1;
535
535
  /**
536
- * The bitwise track markers support at most 30 levels op recursion.
536
+ * The bitwise track markers support at most 30 levels of recursion.
537
537
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
538
538
  * When recursion depth is greater, fall back to using a full cleanup.
539
539
  */
@@ -854,7 +854,7 @@ var Vue = (function (exports) {
854
854
  function createSetter(shallow = false) {
855
855
  return function set(target, key, value, receiver) {
856
856
  let oldValue = target[key];
857
- if (!shallow) {
857
+ if (!shallow && !isReadonly(value)) {
858
858
  value = toRaw(value);
859
859
  oldValue = toRaw(oldValue);
860
860
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1527,19 +1527,22 @@ var Vue = (function (exports) {
1527
1527
  const id = instance.type.__hmrId;
1528
1528
  let record = map.get(id);
1529
1529
  if (!record) {
1530
- createRecord(id);
1530
+ createRecord(id, instance.type);
1531
1531
  record = map.get(id);
1532
1532
  }
1533
- record.add(instance);
1533
+ record.instances.add(instance);
1534
1534
  }
1535
1535
  function unregisterHMR(instance) {
1536
- map.get(instance.type.__hmrId).delete(instance);
1536
+ map.get(instance.type.__hmrId).instances.delete(instance);
1537
1537
  }
1538
- function createRecord(id) {
1538
+ function createRecord(id, initialDef) {
1539
1539
  if (map.has(id)) {
1540
1540
  return false;
1541
1541
  }
1542
- map.set(id, new Set());
1542
+ map.set(id, {
1543
+ initialDef: normalizeClassComponent(initialDef),
1544
+ instances: new Set()
1545
+ });
1543
1546
  return true;
1544
1547
  }
1545
1548
  function normalizeClassComponent(component) {
@@ -1550,7 +1553,9 @@ var Vue = (function (exports) {
1550
1553
  if (!record) {
1551
1554
  return;
1552
1555
  }
1553
- [...record].forEach(instance => {
1556
+ // update initial record (for not-yet-rendered component)
1557
+ record.initialDef.render = newRender;
1558
+ [...record.instances].forEach(instance => {
1554
1559
  if (newRender) {
1555
1560
  instance.render = newRender;
1556
1561
  normalizeClassComponent(instance.type).render = newRender;
@@ -1567,17 +1572,16 @@ var Vue = (function (exports) {
1567
1572
  if (!record)
1568
1573
  return;
1569
1574
  newComp = normalizeClassComponent(newComp);
1575
+ // update initial def (for not-yet-rendered components)
1576
+ updateComponentDef(record.initialDef, newComp);
1570
1577
  // create a snapshot which avoids the set being mutated during updates
1571
- const instances = [...record];
1578
+ const instances = [...record.instances];
1572
1579
  for (const instance of instances) {
1573
1580
  const oldComp = normalizeClassComponent(instance.type);
1574
1581
  if (!hmrDirtyComponents.has(oldComp)) {
1575
1582
  // 1. Update existing comp definition to match new one
1576
- extend(oldComp, newComp);
1577
- for (const key in oldComp) {
1578
- if (key !== '__file' && !(key in newComp)) {
1579
- delete oldComp[key];
1580
- }
1583
+ if (oldComp !== record.initialDef) {
1584
+ updateComponentDef(oldComp, newComp);
1581
1585
  }
1582
1586
  // 2. mark definition dirty. This forces the renderer to replace the
1583
1587
  // component on patch.
@@ -1623,6 +1627,14 @@ var Vue = (function (exports) {
1623
1627
  }
1624
1628
  });
1625
1629
  }
1630
+ function updateComponentDef(oldComp, newComp) {
1631
+ extend(oldComp, newComp);
1632
+ for (const key in oldComp) {
1633
+ if (key !== '__file' && !(key in newComp)) {
1634
+ delete oldComp[key];
1635
+ }
1636
+ }
1637
+ }
1626
1638
  function tryWrap(fn) {
1627
1639
  return (id, arg) => {
1628
1640
  try {
@@ -1637,27 +1649,52 @@ var Vue = (function (exports) {
1637
1649
  }
1638
1650
 
1639
1651
  let buffer = [];
1652
+ let devtoolsNotInstalled = false;
1640
1653
  function emit(event, ...args) {
1641
1654
  if (exports.devtools) {
1642
1655
  exports.devtools.emit(event, ...args);
1643
1656
  }
1644
- else {
1657
+ else if (!devtoolsNotInstalled) {
1645
1658
  buffer.push({ event, args });
1646
1659
  }
1647
1660
  }
1648
1661
  function setDevtoolsHook(hook, target) {
1662
+ var _a, _b;
1649
1663
  exports.devtools = hook;
1650
1664
  if (exports.devtools) {
1651
1665
  exports.devtools.enabled = true;
1652
1666
  buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
1653
1667
  buffer = [];
1654
1668
  }
1655
- else {
1669
+ else if (
1670
+ // handle late devtools injection - only do this if we are in an actual
1671
+ // browser environment to avoid the timer handle stalling test runner exit
1672
+ // (#4815)
1673
+ // eslint-disable-next-line no-restricted-globals
1674
+ typeof window !== 'undefined' &&
1675
+ // some envs mock window but not fully
1676
+ window.HTMLElement &&
1677
+ // also exclude jsdom
1678
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1656
1679
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1657
1680
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1658
1681
  replay.push((newHook) => {
1659
1682
  setDevtoolsHook(newHook, target);
1660
1683
  });
1684
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1685
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1686
+ setTimeout(() => {
1687
+ if (!exports.devtools) {
1688
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1689
+ devtoolsNotInstalled = true;
1690
+ buffer = [];
1691
+ }
1692
+ }, 3000);
1693
+ }
1694
+ else {
1695
+ // non-browser env, assume not installed
1696
+ devtoolsNotInstalled = true;
1697
+ buffer = [];
1661
1698
  }
1662
1699
  }
1663
1700
  function devtoolsInitApp(app, version) {
@@ -2732,7 +2769,8 @@ var Vue = (function (exports) {
2732
2769
  const rawProps = toRaw(props);
2733
2770
  const { mode } = rawProps;
2734
2771
  // check mode
2735
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2772
+ if (mode &&
2773
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
2736
2774
  warn$1(`invalid <transition> mode: ${mode}`);
2737
2775
  }
2738
2776
  // at this point children has a guaranteed length of 1.
@@ -3372,7 +3410,7 @@ var Vue = (function (exports) {
3372
3410
  }
3373
3411
  current = current.parent;
3374
3412
  }
3375
- hook();
3413
+ return hook();
3376
3414
  });
3377
3415
  injectHook(type, wrappedHook, target);
3378
3416
  // In addition to registering it on the target instance, we walk up the parent
@@ -4446,7 +4484,7 @@ var Vue = (function (exports) {
4446
4484
  [bar, this.y]
4447
4485
  ])
4448
4486
  */
4449
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4487
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4450
4488
  function validateDirectiveName(name) {
4451
4489
  if (isBuiltInDirective(name)) {
4452
4490
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -6363,8 +6401,8 @@ var Vue = (function (exports) {
6363
6401
  *
6364
6402
  * #2080
6365
6403
  * Inside keyed `template` fragment static children, if a fragment is moved,
6366
- * the children will always moved so that need inherit el form previous nodes
6367
- * to ensure correct moved position.
6404
+ * the children will always be moved. Therefore, in order to ensure correct move
6405
+ * position, el should be inherited from previous nodes.
6368
6406
  */
6369
6407
  function traverseStaticChildren(n1, n2, shallow = false) {
6370
6408
  const ch1 = n1.children;
@@ -7144,7 +7182,8 @@ var Vue = (function (exports) {
7144
7182
  else if (isOn(key)) {
7145
7183
  const existing = ret[key];
7146
7184
  const incoming = toMerge[key];
7147
- if (existing !== incoming) {
7185
+ if (existing !== incoming &&
7186
+ !(isArray(existing) && existing.includes(incoming))) {
7148
7187
  ret[key] = existing
7149
7188
  ? [].concat(existing, incoming)
7150
7189
  : incoming;
@@ -7347,23 +7386,23 @@ var Vue = (function (exports) {
7347
7386
  const n = accessCache[key];
7348
7387
  if (n !== undefined) {
7349
7388
  switch (n) {
7350
- case 0 /* SETUP */:
7389
+ case 1 /* SETUP */:
7351
7390
  return setupState[key];
7352
- case 1 /* DATA */:
7391
+ case 2 /* DATA */:
7353
7392
  return data[key];
7354
- case 3 /* CONTEXT */:
7393
+ case 4 /* CONTEXT */:
7355
7394
  return ctx[key];
7356
- case 2 /* PROPS */:
7395
+ case 3 /* PROPS */:
7357
7396
  return props[key];
7358
7397
  // default: just fallthrough
7359
7398
  }
7360
7399
  }
7361
7400
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7362
- accessCache[key] = 0 /* SETUP */;
7401
+ accessCache[key] = 1 /* SETUP */;
7363
7402
  return setupState[key];
7364
7403
  }
7365
7404
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7366
- accessCache[key] = 1 /* DATA */;
7405
+ accessCache[key] = 2 /* DATA */;
7367
7406
  return data[key];
7368
7407
  }
7369
7408
  else if (
@@ -7371,15 +7410,15 @@ var Vue = (function (exports) {
7371
7410
  // props
7372
7411
  (normalizedProps = instance.propsOptions[0]) &&
7373
7412
  hasOwn(normalizedProps, key)) {
7374
- accessCache[key] = 2 /* PROPS */;
7413
+ accessCache[key] = 3 /* PROPS */;
7375
7414
  return props[key];
7376
7415
  }
7377
7416
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7378
- accessCache[key] = 3 /* CONTEXT */;
7417
+ accessCache[key] = 4 /* CONTEXT */;
7379
7418
  return ctx[key];
7380
7419
  }
7381
7420
  else if (shouldCacheAccess) {
7382
- accessCache[key] = 4 /* OTHER */;
7421
+ accessCache[key] = 0 /* OTHER */;
7383
7422
  }
7384
7423
  }
7385
7424
  const publicGetter = publicPropertiesMap[key];
@@ -7400,7 +7439,7 @@ var Vue = (function (exports) {
7400
7439
  }
7401
7440
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7402
7441
  // user may set custom properties to `this` that start with `$`
7403
- accessCache[key] = 3 /* CONTEXT */;
7442
+ accessCache[key] = 4 /* CONTEXT */;
7404
7443
  return ctx[key];
7405
7444
  }
7406
7445
  else if (
@@ -7461,7 +7500,7 @@ var Vue = (function (exports) {
7461
7500
  },
7462
7501
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7463
7502
  let normalizedProps;
7464
- return (accessCache[key] !== undefined ||
7503
+ return (!!accessCache[key] ||
7465
7504
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7466
7505
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7467
7506
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -8676,15 +8715,21 @@ var Vue = (function (exports) {
8676
8715
  * only.
8677
8716
  * @internal
8678
8717
  */
8679
- function mergeDefaults(
8680
- // the base props is compiler-generated and guaranteed to be in this shape.
8681
- props, defaults) {
8718
+ function mergeDefaults(raw, defaults) {
8719
+ const props = isArray(raw)
8720
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8721
+ : raw;
8682
8722
  for (const key in defaults) {
8683
- const val = props[key];
8684
- if (val) {
8685
- val.default = defaults[key];
8723
+ const opt = props[key];
8724
+ if (opt) {
8725
+ if (isArray(opt) || isFunction(opt)) {
8726
+ props[key] = { type: opt, default: defaults[key] };
8727
+ }
8728
+ else {
8729
+ opt.default = defaults[key];
8730
+ }
8686
8731
  }
8687
- else if (val === null) {
8732
+ else if (opt === null) {
8688
8733
  props[key] = { default: defaults[key] };
8689
8734
  }
8690
8735
  else {
@@ -8693,6 +8738,23 @@ var Vue = (function (exports) {
8693
8738
  }
8694
8739
  return props;
8695
8740
  }
8741
+ /**
8742
+ * Used to create a proxy for the rest element when destructuring props with
8743
+ * defineProps().
8744
+ * @internal
8745
+ */
8746
+ function createPropsRestProxy(props, excludedKeys) {
8747
+ const ret = {};
8748
+ for (const key in props) {
8749
+ if (!excludedKeys.includes(key)) {
8750
+ Object.defineProperty(ret, key, {
8751
+ enumerable: true,
8752
+ get: () => props[key]
8753
+ });
8754
+ }
8755
+ }
8756
+ return ret;
8757
+ }
8696
8758
  /**
8697
8759
  * `<script setup>` helper for persisting the current instance context over
8698
8760
  * async/await flows.
@@ -8980,7 +9042,7 @@ var Vue = (function (exports) {
8980
9042
  }
8981
9043
 
8982
9044
  // Core API ------------------------------------------------------------------
8983
- const version = "3.2.19";
9045
+ const version = "3.2.23";
8984
9046
  /**
8985
9047
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8986
9048
  * @internal
@@ -9102,16 +9164,8 @@ var Vue = (function (exports) {
9102
9164
 
9103
9165
  function patchStyle(el, prev, next) {
9104
9166
  const style = el.style;
9105
- const currentDisplay = style.display;
9106
- if (!next) {
9107
- el.removeAttribute('style');
9108
- }
9109
- else if (isString(next)) {
9110
- if (prev !== next) {
9111
- style.cssText = next;
9112
- }
9113
- }
9114
- else {
9167
+ const isCssString = isString(next);
9168
+ if (next && !isCssString) {
9115
9169
  for (const key in next) {
9116
9170
  setStyle(style, key, next[key]);
9117
9171
  }
@@ -9123,11 +9177,22 @@ var Vue = (function (exports) {
9123
9177
  }
9124
9178
  }
9125
9179
  }
9126
- // indicates that the `display` of the element is controlled by `v-show`,
9127
- // so we always keep the current `display` value regardless of the `style` value,
9128
- // thus handing over control to `v-show`.
9129
- if ('_vod' in el) {
9130
- style.display = currentDisplay;
9180
+ else {
9181
+ const currentDisplay = style.display;
9182
+ if (isCssString) {
9183
+ if (prev !== next) {
9184
+ style.cssText = next;
9185
+ }
9186
+ }
9187
+ else if (prev) {
9188
+ el.removeAttribute('style');
9189
+ }
9190
+ // indicates that the `display` of the element is controlled by `v-show`,
9191
+ // so we always keep the current `display` value regardless of the `style`
9192
+ // value, thus handing over control to `v-show`.
9193
+ if ('_vod' in el) {
9194
+ style.display = currentDisplay;
9195
+ }
9131
9196
  }
9132
9197
  }
9133
9198
  const importantRE = /\s*!important$/;
@@ -9210,12 +9275,19 @@ var Vue = (function (exports) {
9210
9275
  el[key] = value == null ? '' : value;
9211
9276
  return;
9212
9277
  }
9213
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9278
+ if (key === 'value' &&
9279
+ el.tagName !== 'PROGRESS' &&
9280
+ // custom elements may use _value internally
9281
+ !el.tagName.includes('-')) {
9214
9282
  // store value as _value as well since
9215
9283
  // non-string values will be stringified.
9216
9284
  el._value = value;
9217
9285
  const newValue = value == null ? '' : value;
9218
- if (el.value !== newValue) {
9286
+ if (el.value !== newValue ||
9287
+ // #4956: always set for OPTION elements because its value falls back to
9288
+ // textContent if no value attribute is present. And setting .value for
9289
+ // OPTION has no side effect
9290
+ el.tagName === 'OPTION') {
9219
9291
  el.value = newValue;
9220
9292
  }
9221
9293
  if (value == null) {
@@ -9473,22 +9545,11 @@ var Vue = (function (exports) {
9473
9545
  }
9474
9546
  this.attachShadow({ mode: 'open' });
9475
9547
  }
9476
- // set initial attrs
9477
- for (let i = 0; i < this.attributes.length; i++) {
9478
- this._setAttr(this.attributes[i].name);
9479
- }
9480
- // watch future attr changes
9481
- new MutationObserver(mutations => {
9482
- for (const m of mutations) {
9483
- this._setAttr(m.attributeName);
9484
- }
9485
- }).observe(this, { attributes: true });
9486
9548
  }
9487
9549
  connectedCallback() {
9488
9550
  this._connected = true;
9489
9551
  if (!this._instance) {
9490
9552
  this._resolveDef();
9491
- this._update();
9492
9553
  }
9493
9554
  }
9494
9555
  disconnectedCallback() {
@@ -9507,8 +9568,18 @@ var Vue = (function (exports) {
9507
9568
  if (this._resolved) {
9508
9569
  return;
9509
9570
  }
9571
+ this._resolved = true;
9572
+ // set initial attrs
9573
+ for (let i = 0; i < this.attributes.length; i++) {
9574
+ this._setAttr(this.attributes[i].name);
9575
+ }
9576
+ // watch future attr changes
9577
+ new MutationObserver(mutations => {
9578
+ for (const m of mutations) {
9579
+ this._setAttr(m.attributeName);
9580
+ }
9581
+ }).observe(this, { attributes: true });
9510
9582
  const resolve = (def) => {
9511
- this._resolved = true;
9512
9583
  const { props, styles } = def;
9513
9584
  const hasOptions = !isArray(props);
9514
9585
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9523,14 +9594,11 @@ var Vue = (function (exports) {
9523
9594
  }
9524
9595
  }
9525
9596
  }
9526
- if (numberProps) {
9527
- this._numberProps = numberProps;
9528
- this._update();
9529
- }
9597
+ this._numberProps = numberProps;
9530
9598
  // check if there are props set pre-upgrade or connect
9531
9599
  for (const key of Object.keys(this)) {
9532
9600
  if (key[0] !== '_') {
9533
- this._setProp(key, this[key]);
9601
+ this._setProp(key, this[key], true, false);
9534
9602
  }
9535
9603
  }
9536
9604
  // defining getter/setters on prototype
@@ -9544,7 +9612,10 @@ var Vue = (function (exports) {
9544
9612
  }
9545
9613
  });
9546
9614
  }
9615
+ // apply CSS
9547
9616
  this._applyStyles(styles);
9617
+ // initial render
9618
+ this._update();
9548
9619
  };
9549
9620
  const asyncDef = this._def.__asyncLoader;
9550
9621
  if (asyncDef) {
@@ -9570,10 +9641,10 @@ var Vue = (function (exports) {
9570
9641
  /**
9571
9642
  * @internal
9572
9643
  */
9573
- _setProp(key, val, shouldReflect = true) {
9644
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9574
9645
  if (val !== this._props[key]) {
9575
9646
  this._props[key] = val;
9576
- if (this._instance) {
9647
+ if (shouldUpdate && this._instance) {
9577
9648
  this._update();
9578
9649
  }
9579
9650
  // reflect
@@ -11006,7 +11077,7 @@ var Vue = (function (exports) {
11006
11077
  const isMemberExpression = isMemberExpressionBrowser
11007
11078
  ;
11008
11079
  function getInnerRange(loc, offset, length) {
11009
- const source = loc.source.substr(offset, length);
11080
+ const source = loc.source.slice(offset, offset + length);
11010
11081
  const newLoc = {
11011
11082
  source,
11012
11083
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -11833,10 +11904,10 @@ var Vue = (function (exports) {
11833
11904
  isStatic = false;
11834
11905
  if (!content.endsWith(']')) {
11835
11906
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
11836
- content = content.substr(1);
11907
+ content = content.slice(1);
11837
11908
  }
11838
11909
  else {
11839
- content = content.substr(1, content.length - 2);
11910
+ content = content.slice(1, content.length - 1);
11840
11911
  }
11841
11912
  }
11842
11913
  else if (isSlot) {
@@ -11862,7 +11933,7 @@ var Vue = (function (exports) {
11862
11933
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
11863
11934
  valueLoc.source = valueLoc.source.slice(1, -1);
11864
11935
  }
11865
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
11936
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
11866
11937
  if (isPropShorthand)
11867
11938
  modifiers.push('prop');
11868
11939
  return {
@@ -12072,7 +12143,7 @@ var Vue = (function (exports) {
12072
12143
  }
12073
12144
  function startsWithEndTagOpen(source, tag) {
12074
12145
  return (startsWith(source, '</') &&
12075
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
12146
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
12076
12147
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
12077
12148
  }
12078
12149
 
@@ -14478,7 +14549,7 @@ var Vue = (function (exports) {
14478
14549
  return propsNamesString + `]`;
14479
14550
  }
14480
14551
  function isComponentTag(tag) {
14481
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
14552
+ return tag === 'component' || tag === 'Component';
14482
14553
  }
14483
14554
 
14484
14555
  const transformSlotOutlet = (node, context) => {
@@ -15469,6 +15540,7 @@ var Vue = (function (exports) {
15469
15540
  exports.createElementBlock = createElementBlock;
15470
15541
  exports.createElementVNode = createBaseVNode;
15471
15542
  exports.createHydrationRenderer = createHydrationRenderer;
15543
+ exports.createPropsRestProxy = createPropsRestProxy;
15472
15544
  exports.createRenderer = createRenderer;
15473
15545
  exports.createSSRApp = createSSRApp;
15474
15546
  exports.createSlots = createSlots;