@vue/runtime-dom 3.2.18 → 3.2.22

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.
@@ -1452,19 +1452,22 @@ var VueRuntimeDOM = (function (exports) {
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 VueRuntimeDOM = (function (exports) {
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 VueRuntimeDOM = (function (exports) {
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 VueRuntimeDOM = (function (exports) {
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 {
@@ -1562,27 +1574,52 @@ var VueRuntimeDOM = (function (exports) {
1562
1574
  }
1563
1575
 
1564
1576
  let buffer = [];
1577
+ let devtoolsNotInstalled = false;
1565
1578
  function emit(event, ...args) {
1566
1579
  if (exports.devtools) {
1567
1580
  exports.devtools.emit(event, ...args);
1568
1581
  }
1569
- else {
1582
+ else if (!devtoolsNotInstalled) {
1570
1583
  buffer.push({ event, args });
1571
1584
  }
1572
1585
  }
1573
1586
  function setDevtoolsHook(hook, target) {
1587
+ var _a, _b;
1574
1588
  exports.devtools = hook;
1575
1589
  if (exports.devtools) {
1576
1590
  exports.devtools.enabled = true;
1577
1591
  buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
1578
1592
  buffer = [];
1579
1593
  }
1580
- else {
1594
+ else if (
1595
+ // handle late devtools injection - only do this if we are in an actual
1596
+ // browser environment to avoid the timer handle stalling test runner exit
1597
+ // (#4815)
1598
+ // eslint-disable-next-line no-restricted-globals
1599
+ typeof window !== 'undefined' &&
1600
+ // some envs mock window but not fully
1601
+ window.HTMLElement &&
1602
+ // also exclude jsdom
1603
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1581
1604
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1582
1605
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1583
1606
  replay.push((newHook) => {
1584
1607
  setDevtoolsHook(newHook, target);
1585
1608
  });
1609
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1610
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1611
+ setTimeout(() => {
1612
+ if (!exports.devtools) {
1613
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1614
+ devtoolsNotInstalled = true;
1615
+ buffer = [];
1616
+ }
1617
+ }, 3000);
1618
+ }
1619
+ else {
1620
+ // non-browser env, assume not installed
1621
+ devtoolsNotInstalled = true;
1622
+ buffer = [];
1586
1623
  }
1587
1624
  }
1588
1625
  function devtoolsInitApp(app, version) {
@@ -4371,7 +4408,7 @@ var VueRuntimeDOM = (function (exports) {
4371
4408
  [bar, this.y]
4372
4409
  ])
4373
4410
  */
4374
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4411
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4375
4412
  function validateDirectiveName(name) {
4376
4413
  if (isBuiltInDirective(name)) {
4377
4414
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -6288,8 +6325,8 @@ var VueRuntimeDOM = (function (exports) {
6288
6325
  *
6289
6326
  * #2080
6290
6327
  * Inside keyed `template` fragment static children, if a fragment is moved,
6291
- * the children will always moved so that need inherit el form previous nodes
6292
- * to ensure correct moved position.
6328
+ * the children will always be moved. Therefore, in order to ensure correct move
6329
+ * position, el should be inherited from previous nodes.
6293
6330
  */
6294
6331
  function traverseStaticChildren(n1, n2, shallow = false) {
6295
6332
  const ch1 = n1.children;
@@ -7069,7 +7106,8 @@ var VueRuntimeDOM = (function (exports) {
7069
7106
  else if (isOn(key)) {
7070
7107
  const existing = ret[key];
7071
7108
  const incoming = toMerge[key];
7072
- if (existing !== incoming) {
7109
+ if (existing !== incoming &&
7110
+ !(isArray(existing) && existing.includes(incoming))) {
7073
7111
  ret[key] = existing
7074
7112
  ? [].concat(existing, incoming)
7075
7113
  : incoming;
@@ -8601,15 +8639,21 @@ var VueRuntimeDOM = (function (exports) {
8601
8639
  * only.
8602
8640
  * @internal
8603
8641
  */
8604
- function mergeDefaults(
8605
- // the base props is compiler-generated and guaranteed to be in this shape.
8606
- props, defaults) {
8642
+ function mergeDefaults(raw, defaults) {
8643
+ const props = isArray(raw)
8644
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8645
+ : raw;
8607
8646
  for (const key in defaults) {
8608
- const val = props[key];
8609
- if (val) {
8610
- val.default = defaults[key];
8647
+ const opt = props[key];
8648
+ if (opt) {
8649
+ if (isArray(opt) || isFunction(opt)) {
8650
+ props[key] = { type: opt, default: defaults[key] };
8651
+ }
8652
+ else {
8653
+ opt.default = defaults[key];
8654
+ }
8611
8655
  }
8612
- else if (val === null) {
8656
+ else if (opt === null) {
8613
8657
  props[key] = { default: defaults[key] };
8614
8658
  }
8615
8659
  else {
@@ -8618,6 +8662,23 @@ var VueRuntimeDOM = (function (exports) {
8618
8662
  }
8619
8663
  return props;
8620
8664
  }
8665
+ /**
8666
+ * Used to create a proxy for the rest element when destructuring props with
8667
+ * defineProps().
8668
+ * @internal
8669
+ */
8670
+ function createPropsRestProxy(props, excludedKeys) {
8671
+ const ret = {};
8672
+ for (const key in props) {
8673
+ if (!excludedKeys.includes(key)) {
8674
+ Object.defineProperty(ret, key, {
8675
+ enumerable: true,
8676
+ get: () => props[key]
8677
+ });
8678
+ }
8679
+ }
8680
+ return ret;
8681
+ }
8621
8682
  /**
8622
8683
  * `<script setup>` helper for persisting the current instance context over
8623
8684
  * async/await flows.
@@ -8905,7 +8966,7 @@ var VueRuntimeDOM = (function (exports) {
8905
8966
  }
8906
8967
 
8907
8968
  // Core API ------------------------------------------------------------------
8908
- const version = "3.2.18";
8969
+ const version = "3.2.22";
8909
8970
  /**
8910
8971
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8911
8972
  * @internal
@@ -9027,16 +9088,8 @@ var VueRuntimeDOM = (function (exports) {
9027
9088
 
9028
9089
  function patchStyle(el, prev, next) {
9029
9090
  const style = el.style;
9030
- const currentDisplay = style.display;
9031
- if (!next) {
9032
- el.removeAttribute('style');
9033
- }
9034
- else if (isString(next)) {
9035
- if (prev !== next) {
9036
- style.cssText = next;
9037
- }
9038
- }
9039
- else {
9091
+ const isCssString = isString(next);
9092
+ if (next && !isCssString) {
9040
9093
  for (const key in next) {
9041
9094
  setStyle(style, key, next[key]);
9042
9095
  }
@@ -9048,11 +9101,22 @@ var VueRuntimeDOM = (function (exports) {
9048
9101
  }
9049
9102
  }
9050
9103
  }
9051
- // indicates that the `display` of the element is controlled by `v-show`,
9052
- // so we always keep the current `display` value regardless of the `style` value,
9053
- // thus handing over control to `v-show`.
9054
- if ('_vod' in el) {
9055
- style.display = currentDisplay;
9104
+ else {
9105
+ const currentDisplay = style.display;
9106
+ if (isCssString) {
9107
+ if (prev !== next) {
9108
+ style.cssText = next;
9109
+ }
9110
+ }
9111
+ else if (prev) {
9112
+ el.removeAttribute('style');
9113
+ }
9114
+ // indicates that the `display` of the element is controlled by `v-show`,
9115
+ // so we always keep the current `display` value regardless of the `style`
9116
+ // value, thus handing over control to `v-show`.
9117
+ if ('_vod' in el) {
9118
+ style.display = currentDisplay;
9119
+ }
9056
9120
  }
9057
9121
  }
9058
9122
  const importantRE = /\s*!important$/;
@@ -9398,22 +9462,11 @@ var VueRuntimeDOM = (function (exports) {
9398
9462
  }
9399
9463
  this.attachShadow({ mode: 'open' });
9400
9464
  }
9401
- // set initial attrs
9402
- for (let i = 0; i < this.attributes.length; i++) {
9403
- this._setAttr(this.attributes[i].name);
9404
- }
9405
- // watch future attr changes
9406
- new MutationObserver(mutations => {
9407
- for (const m of mutations) {
9408
- this._setAttr(m.attributeName);
9409
- }
9410
- }).observe(this, { attributes: true });
9411
9465
  }
9412
9466
  connectedCallback() {
9413
9467
  this._connected = true;
9414
9468
  if (!this._instance) {
9415
9469
  this._resolveDef();
9416
- this._update();
9417
9470
  }
9418
9471
  }
9419
9472
  disconnectedCallback() {
@@ -9432,8 +9485,18 @@ var VueRuntimeDOM = (function (exports) {
9432
9485
  if (this._resolved) {
9433
9486
  return;
9434
9487
  }
9488
+ this._resolved = true;
9489
+ // set initial attrs
9490
+ for (let i = 0; i < this.attributes.length; i++) {
9491
+ this._setAttr(this.attributes[i].name);
9492
+ }
9493
+ // watch future attr changes
9494
+ new MutationObserver(mutations => {
9495
+ for (const m of mutations) {
9496
+ this._setAttr(m.attributeName);
9497
+ }
9498
+ }).observe(this, { attributes: true });
9435
9499
  const resolve = (def) => {
9436
- this._resolved = true;
9437
9500
  const { props, styles } = def;
9438
9501
  const hasOptions = !isArray(props);
9439
9502
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9448,14 +9511,11 @@ var VueRuntimeDOM = (function (exports) {
9448
9511
  }
9449
9512
  }
9450
9513
  }
9451
- if (numberProps) {
9452
- this._numberProps = numberProps;
9453
- this._update();
9454
- }
9514
+ this._numberProps = numberProps;
9455
9515
  // check if there are props set pre-upgrade or connect
9456
9516
  for (const key of Object.keys(this)) {
9457
9517
  if (key[0] !== '_') {
9458
- this._setProp(key, this[key]);
9518
+ this._setProp(key, this[key], true, false);
9459
9519
  }
9460
9520
  }
9461
9521
  // defining getter/setters on prototype
@@ -9469,7 +9529,10 @@ var VueRuntimeDOM = (function (exports) {
9469
9529
  }
9470
9530
  });
9471
9531
  }
9532
+ // apply CSS
9472
9533
  this._applyStyles(styles);
9534
+ // initial render
9535
+ this._update();
9473
9536
  };
9474
9537
  const asyncDef = this._def.__asyncLoader;
9475
9538
  if (asyncDef) {
@@ -9495,10 +9558,10 @@ var VueRuntimeDOM = (function (exports) {
9495
9558
  /**
9496
9559
  * @internal
9497
9560
  */
9498
- _setProp(key, val, shouldReflect = true) {
9561
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9499
9562
  if (val !== this._props[key]) {
9500
9563
  this._props[key] = val;
9501
- if (this._instance) {
9564
+ if (shouldUpdate && this._instance) {
9502
9565
  this._update();
9503
9566
  }
9504
9567
  // reflect
@@ -10547,6 +10610,7 @@ var VueRuntimeDOM = (function (exports) {
10547
10610
  exports.createElementBlock = createElementBlock;
10548
10611
  exports.createElementVNode = createBaseVNode;
10549
10612
  exports.createHydrationRenderer = createHydrationRenderer;
10613
+ exports.createPropsRestProxy = createPropsRestProxy;
10550
10614
  exports.createRenderer = createRenderer;
10551
10615
  exports.createSSRApp = createSSRApp;
10552
10616
  exports.createSlots = createSlots;