@vue/compat 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.
@@ -458,7 +458,7 @@ var Vue = (function () {
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 Vue = (function () {
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)) {
@@ -1452,19 +1452,22 @@ var Vue = (function () {
1452
1452
  const id = instance.type.__hmrId;
1453
1453
  let record = map.get(id);
1454
1454
  if (!record) {
1455
- createRecord(id);
1455
+ createRecord(id, instance.type);
1456
1456
  record = map.get(id);
1457
1457
  }
1458
- record.add(instance);
1458
+ record.instances.add(instance);
1459
1459
  }
1460
1460
  function unregisterHMR(instance) {
1461
- map.get(instance.type.__hmrId).delete(instance);
1461
+ map.get(instance.type.__hmrId).instances.delete(instance);
1462
1462
  }
1463
- function createRecord(id) {
1463
+ function createRecord(id, initialDef) {
1464
1464
  if (map.has(id)) {
1465
1465
  return false;
1466
1466
  }
1467
- map.set(id, new Set());
1467
+ map.set(id, {
1468
+ initialDef: normalizeClassComponent(initialDef),
1469
+ instances: new Set()
1470
+ });
1468
1471
  return true;
1469
1472
  }
1470
1473
  function normalizeClassComponent(component) {
@@ -1475,7 +1478,9 @@ var Vue = (function () {
1475
1478
  if (!record) {
1476
1479
  return;
1477
1480
  }
1478
- [...record].forEach(instance => {
1481
+ // update initial record (for not-yet-rendered component)
1482
+ record.initialDef.render = newRender;
1483
+ [...record.instances].forEach(instance => {
1479
1484
  if (newRender) {
1480
1485
  instance.render = newRender;
1481
1486
  normalizeClassComponent(instance.type).render = newRender;
@@ -1492,17 +1497,16 @@ var Vue = (function () {
1492
1497
  if (!record)
1493
1498
  return;
1494
1499
  newComp = normalizeClassComponent(newComp);
1500
+ // update initial def (for not-yet-rendered components)
1501
+ updateComponentDef(record.initialDef, newComp);
1495
1502
  // create a snapshot which avoids the set being mutated during updates
1496
- const instances = [...record];
1503
+ const instances = [...record.instances];
1497
1504
  for (const instance of instances) {
1498
1505
  const oldComp = normalizeClassComponent(instance.type);
1499
1506
  if (!hmrDirtyComponents.has(oldComp)) {
1500
1507
  // 1. Update existing comp definition to match new one
1501
- extend(oldComp, newComp);
1502
- for (const key in oldComp) {
1503
- if (key !== '__file' && !(key in newComp)) {
1504
- delete oldComp[key];
1505
- }
1508
+ if (oldComp !== record.initialDef) {
1509
+ updateComponentDef(oldComp, newComp);
1506
1510
  }
1507
1511
  // 2. mark definition dirty. This forces the renderer to replace the
1508
1512
  // component on patch.
@@ -1548,6 +1552,14 @@ var Vue = (function () {
1548
1552
  }
1549
1553
  });
1550
1554
  }
1555
+ function updateComponentDef(oldComp, newComp) {
1556
+ extend(oldComp, newComp);
1557
+ for (const key in oldComp) {
1558
+ if (key !== '__file' && !(key in newComp)) {
1559
+ delete oldComp[key];
1560
+ }
1561
+ }
1562
+ }
1551
1563
  function tryWrap(fn) {
1552
1564
  return (id, arg) => {
1553
1565
  try {
@@ -1563,27 +1575,52 @@ var Vue = (function () {
1563
1575
 
1564
1576
  let devtools;
1565
1577
  let buffer = [];
1578
+ let devtoolsNotInstalled = false;
1566
1579
  function emit(event, ...args) {
1567
1580
  if (devtools) {
1568
1581
  devtools.emit(event, ...args);
1569
1582
  }
1570
- else {
1583
+ else if (!devtoolsNotInstalled) {
1571
1584
  buffer.push({ event, args });
1572
1585
  }
1573
1586
  }
1574
1587
  function setDevtoolsHook(hook, target) {
1588
+ var _a, _b;
1575
1589
  devtools = hook;
1576
1590
  if (devtools) {
1577
1591
  devtools.enabled = true;
1578
1592
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1579
1593
  buffer = [];
1580
1594
  }
1581
- else {
1595
+ else if (
1596
+ // handle late devtools injection - only do this if we are in an actual
1597
+ // browser environment to avoid the timer handle stalling test runner exit
1598
+ // (#4815)
1599
+ // eslint-disable-next-line no-restricted-globals
1600
+ typeof window !== 'undefined' &&
1601
+ // some envs mock window but not fully
1602
+ window.HTMLElement &&
1603
+ // also exclude jsdom
1604
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1582
1605
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1583
1606
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1584
1607
  replay.push((newHook) => {
1585
1608
  setDevtoolsHook(newHook, target);
1586
1609
  });
1610
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1611
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1612
+ setTimeout(() => {
1613
+ if (!devtools) {
1614
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1615
+ devtoolsNotInstalled = true;
1616
+ buffer = [];
1617
+ }
1618
+ }, 3000);
1619
+ }
1620
+ else {
1621
+ // non-browser env, assume not installed
1622
+ devtoolsNotInstalled = true;
1623
+ buffer = [];
1587
1624
  }
1588
1625
  }
1589
1626
  function devtoolsInitApp(app, version) {
@@ -3198,7 +3235,8 @@ var Vue = (function () {
3198
3235
  const rawProps = toRaw(props);
3199
3236
  const { mode } = rawProps;
3200
3237
  // check mode
3201
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3238
+ if (mode &&
3239
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3202
3240
  warn$1(`invalid <transition> mode: ${mode}`);
3203
3241
  }
3204
3242
  // at this point children has a guaranteed length of 1.
@@ -3844,7 +3882,7 @@ var Vue = (function () {
3844
3882
  }
3845
3883
  current = current.parent;
3846
3884
  }
3847
- hook();
3885
+ return hook();
3848
3886
  });
3849
3887
  injectHook(type, wrappedHook, target);
3850
3888
  // In addition to registering it on the target instance, we walk up the parent
@@ -5068,7 +5106,7 @@ var Vue = (function () {
5068
5106
  [bar, this.y]
5069
5107
  ])
5070
5108
  */
5071
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
5109
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5072
5110
  function validateDirectiveName(name) {
5073
5111
  if (isBuiltInDirective(name)) {
5074
5112
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5203,7 +5241,7 @@ var Vue = (function () {
5203
5241
  return vm;
5204
5242
  }
5205
5243
  }
5206
- Vue.version = "3.2.19";
5244
+ Vue.version = "3.2.23";
5207
5245
  Vue.config = singletonApp.config;
5208
5246
  Vue.use = (p, ...options) => {
5209
5247
  if (p && isFunction(p.install)) {
@@ -6649,7 +6687,7 @@ var Vue = (function () {
6649
6687
  }
6650
6688
  };
6651
6689
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
6652
- // 2.x compat may pre-creaate the component instance before actually
6690
+ // 2.x compat may pre-create the component instance before actually
6653
6691
  // mounting
6654
6692
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
6655
6693
  const instance = compatMountInstance ||
@@ -7529,8 +7567,8 @@ var Vue = (function () {
7529
7567
  *
7530
7568
  * #2080
7531
7569
  * Inside keyed `template` fragment static children, if a fragment is moved,
7532
- * the children will always moved so that need inherit el form previous nodes
7533
- * to ensure correct moved position.
7570
+ * the children will always be moved. Therefore, in order to ensure correct move
7571
+ * position, el should be inherited from previous nodes.
7534
7572
  */
7535
7573
  function traverseStaticChildren(n1, n2, shallow = false) {
7536
7574
  const ch1 = n1.children;
@@ -8657,7 +8695,8 @@ var Vue = (function () {
8657
8695
  else if (isOn(key)) {
8658
8696
  const existing = ret[key];
8659
8697
  const incoming = toMerge[key];
8660
- if (existing !== incoming) {
8698
+ if (existing !== incoming &&
8699
+ !(isArray(existing) && existing.includes(incoming))) {
8661
8700
  ret[key] = existing
8662
8701
  ? [].concat(existing, incoming)
8663
8702
  : incoming;
@@ -9101,23 +9140,23 @@ var Vue = (function () {
9101
9140
  const n = accessCache[key];
9102
9141
  if (n !== undefined) {
9103
9142
  switch (n) {
9104
- case 0 /* SETUP */:
9143
+ case 1 /* SETUP */:
9105
9144
  return setupState[key];
9106
- case 1 /* DATA */:
9145
+ case 2 /* DATA */:
9107
9146
  return data[key];
9108
- case 3 /* CONTEXT */:
9147
+ case 4 /* CONTEXT */:
9109
9148
  return ctx[key];
9110
- case 2 /* PROPS */:
9149
+ case 3 /* PROPS */:
9111
9150
  return props[key];
9112
9151
  // default: just fallthrough
9113
9152
  }
9114
9153
  }
9115
9154
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9116
- accessCache[key] = 0 /* SETUP */;
9155
+ accessCache[key] = 1 /* SETUP */;
9117
9156
  return setupState[key];
9118
9157
  }
9119
9158
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9120
- accessCache[key] = 1 /* DATA */;
9159
+ accessCache[key] = 2 /* DATA */;
9121
9160
  return data[key];
9122
9161
  }
9123
9162
  else if (
@@ -9125,15 +9164,15 @@ var Vue = (function () {
9125
9164
  // props
9126
9165
  (normalizedProps = instance.propsOptions[0]) &&
9127
9166
  hasOwn(normalizedProps, key)) {
9128
- accessCache[key] = 2 /* PROPS */;
9167
+ accessCache[key] = 3 /* PROPS */;
9129
9168
  return props[key];
9130
9169
  }
9131
9170
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9132
- accessCache[key] = 3 /* CONTEXT */;
9171
+ accessCache[key] = 4 /* CONTEXT */;
9133
9172
  return ctx[key];
9134
9173
  }
9135
9174
  else if (shouldCacheAccess) {
9136
- accessCache[key] = 4 /* OTHER */;
9175
+ accessCache[key] = 0 /* OTHER */;
9137
9176
  }
9138
9177
  }
9139
9178
  const publicGetter = publicPropertiesMap[key];
@@ -9154,7 +9193,7 @@ var Vue = (function () {
9154
9193
  }
9155
9194
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9156
9195
  // user may set custom properties to `this` that start with `$`
9157
- accessCache[key] = 3 /* CONTEXT */;
9196
+ accessCache[key] = 4 /* CONTEXT */;
9158
9197
  return ctx[key];
9159
9198
  }
9160
9199
  else if (
@@ -9222,7 +9261,7 @@ var Vue = (function () {
9222
9261
  },
9223
9262
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9224
9263
  let normalizedProps;
9225
- return (accessCache[key] !== undefined ||
9264
+ return (!!accessCache[key] ||
9226
9265
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9227
9266
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9228
9267
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -10465,15 +10504,21 @@ var Vue = (function () {
10465
10504
  * only.
10466
10505
  * @internal
10467
10506
  */
10468
- function mergeDefaults(
10469
- // the base props is compiler-generated and guaranteed to be in this shape.
10470
- props, defaults) {
10507
+ function mergeDefaults(raw, defaults) {
10508
+ const props = isArray(raw)
10509
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
10510
+ : raw;
10471
10511
  for (const key in defaults) {
10472
- const val = props[key];
10473
- if (val) {
10474
- val.default = defaults[key];
10512
+ const opt = props[key];
10513
+ if (opt) {
10514
+ if (isArray(opt) || isFunction(opt)) {
10515
+ props[key] = { type: opt, default: defaults[key] };
10516
+ }
10517
+ else {
10518
+ opt.default = defaults[key];
10519
+ }
10475
10520
  }
10476
- else if (val === null) {
10521
+ else if (opt === null) {
10477
10522
  props[key] = { default: defaults[key] };
10478
10523
  }
10479
10524
  else {
@@ -10482,6 +10527,23 @@ var Vue = (function () {
10482
10527
  }
10483
10528
  return props;
10484
10529
  }
10530
+ /**
10531
+ * Used to create a proxy for the rest element when destructuring props with
10532
+ * defineProps().
10533
+ * @internal
10534
+ */
10535
+ function createPropsRestProxy(props, excludedKeys) {
10536
+ const ret = {};
10537
+ for (const key in props) {
10538
+ if (!excludedKeys.includes(key)) {
10539
+ Object.defineProperty(ret, key, {
10540
+ enumerable: true,
10541
+ get: () => props[key]
10542
+ });
10543
+ }
10544
+ }
10545
+ return ret;
10546
+ }
10485
10547
  /**
10486
10548
  * `<script setup>` helper for persisting the current instance context over
10487
10549
  * async/await flows.
@@ -10769,7 +10831,7 @@ var Vue = (function () {
10769
10831
  }
10770
10832
 
10771
10833
  // Core API ------------------------------------------------------------------
10772
- const version = "3.2.19";
10834
+ const version = "3.2.23";
10773
10835
  /**
10774
10836
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10775
10837
  * @internal
@@ -10898,16 +10960,8 @@ var Vue = (function () {
10898
10960
 
10899
10961
  function patchStyle(el, prev, next) {
10900
10962
  const style = el.style;
10901
- const currentDisplay = style.display;
10902
- if (!next) {
10903
- el.removeAttribute('style');
10904
- }
10905
- else if (isString(next)) {
10906
- if (prev !== next) {
10907
- style.cssText = next;
10908
- }
10909
- }
10910
- else {
10963
+ const isCssString = isString(next);
10964
+ if (next && !isCssString) {
10911
10965
  for (const key in next) {
10912
10966
  setStyle(style, key, next[key]);
10913
10967
  }
@@ -10919,11 +10973,22 @@ var Vue = (function () {
10919
10973
  }
10920
10974
  }
10921
10975
  }
10922
- // indicates that the `display` of the element is controlled by `v-show`,
10923
- // so we always keep the current `display` value regardless of the `style` value,
10924
- // thus handing over control to `v-show`.
10925
- if ('_vod' in el) {
10926
- style.display = currentDisplay;
10976
+ else {
10977
+ const currentDisplay = style.display;
10978
+ if (isCssString) {
10979
+ if (prev !== next) {
10980
+ style.cssText = next;
10981
+ }
10982
+ }
10983
+ else if (prev) {
10984
+ el.removeAttribute('style');
10985
+ }
10986
+ // indicates that the `display` of the element is controlled by `v-show`,
10987
+ // so we always keep the current `display` value regardless of the `style`
10988
+ // value, thus handing over control to `v-show`.
10989
+ if ('_vod' in el) {
10990
+ style.display = currentDisplay;
10991
+ }
10927
10992
  }
10928
10993
  }
10929
10994
  const importantRE = /\s*!important$/;
@@ -11033,12 +11098,19 @@ var Vue = (function () {
11033
11098
  el[key] = value == null ? '' : value;
11034
11099
  return;
11035
11100
  }
11036
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11101
+ if (key === 'value' &&
11102
+ el.tagName !== 'PROGRESS' &&
11103
+ // custom elements may use _value internally
11104
+ !el.tagName.includes('-')) {
11037
11105
  // store value as _value as well since
11038
11106
  // non-string values will be stringified.
11039
11107
  el._value = value;
11040
11108
  const newValue = value == null ? '' : value;
11041
- if (el.value !== newValue) {
11109
+ if (el.value !== newValue ||
11110
+ // #4956: always set for OPTION elements because its value falls back to
11111
+ // textContent if no value attribute is present. And setting .value for
11112
+ // OPTION has no side effect
11113
+ el.tagName === 'OPTION') {
11042
11114
  el.value = newValue;
11043
11115
  }
11044
11116
  if (value == null) {
@@ -11306,22 +11378,11 @@ var Vue = (function () {
11306
11378
  }
11307
11379
  this.attachShadow({ mode: 'open' });
11308
11380
  }
11309
- // set initial attrs
11310
- for (let i = 0; i < this.attributes.length; i++) {
11311
- this._setAttr(this.attributes[i].name);
11312
- }
11313
- // watch future attr changes
11314
- new MutationObserver(mutations => {
11315
- for (const m of mutations) {
11316
- this._setAttr(m.attributeName);
11317
- }
11318
- }).observe(this, { attributes: true });
11319
11381
  }
11320
11382
  connectedCallback() {
11321
11383
  this._connected = true;
11322
11384
  if (!this._instance) {
11323
11385
  this._resolveDef();
11324
- this._update();
11325
11386
  }
11326
11387
  }
11327
11388
  disconnectedCallback() {
@@ -11340,8 +11401,18 @@ var Vue = (function () {
11340
11401
  if (this._resolved) {
11341
11402
  return;
11342
11403
  }
11404
+ this._resolved = true;
11405
+ // set initial attrs
11406
+ for (let i = 0; i < this.attributes.length; i++) {
11407
+ this._setAttr(this.attributes[i].name);
11408
+ }
11409
+ // watch future attr changes
11410
+ new MutationObserver(mutations => {
11411
+ for (const m of mutations) {
11412
+ this._setAttr(m.attributeName);
11413
+ }
11414
+ }).observe(this, { attributes: true });
11343
11415
  const resolve = (def) => {
11344
- this._resolved = true;
11345
11416
  const { props, styles } = def;
11346
11417
  const hasOptions = !isArray(props);
11347
11418
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -11356,14 +11427,11 @@ var Vue = (function () {
11356
11427
  }
11357
11428
  }
11358
11429
  }
11359
- if (numberProps) {
11360
- this._numberProps = numberProps;
11361
- this._update();
11362
- }
11430
+ this._numberProps = numberProps;
11363
11431
  // check if there are props set pre-upgrade or connect
11364
11432
  for (const key of Object.keys(this)) {
11365
11433
  if (key[0] !== '_') {
11366
- this._setProp(key, this[key]);
11434
+ this._setProp(key, this[key], true, false);
11367
11435
  }
11368
11436
  }
11369
11437
  // defining getter/setters on prototype
@@ -11377,7 +11445,10 @@ var Vue = (function () {
11377
11445
  }
11378
11446
  });
11379
11447
  }
11448
+ // apply CSS
11380
11449
  this._applyStyles(styles);
11450
+ // initial render
11451
+ this._update();
11381
11452
  };
11382
11453
  const asyncDef = this._def.__asyncLoader;
11383
11454
  if (asyncDef) {
@@ -11403,10 +11474,10 @@ var Vue = (function () {
11403
11474
  /**
11404
11475
  * @internal
11405
11476
  */
11406
- _setProp(key, val, shouldReflect = true) {
11477
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11407
11478
  if (val !== this._props[key]) {
11408
11479
  this._props[key] = val;
11409
- if (this._instance) {
11480
+ if (shouldUpdate && this._instance) {
11410
11481
  this._update();
11411
11482
  }
11412
11483
  // reflect
@@ -12590,6 +12661,7 @@ var Vue = (function () {
12590
12661
  defineExpose: defineExpose,
12591
12662
  withDefaults: withDefaults,
12592
12663
  mergeDefaults: mergeDefaults,
12664
+ createPropsRestProxy: createPropsRestProxy,
12593
12665
  withAsyncContext: withAsyncContext,
12594
12666
  getCurrentInstance: getCurrentInstance,
12595
12667
  h: h,