@vue/runtime-dom 3.2.17 → 3.2.21

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,11 +1574,12 @@ 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
  }
@@ -1577,12 +1590,32 @@ var VueRuntimeDOM = (function (exports) {
1577
1590
  buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
1578
1591
  buffer = [];
1579
1592
  }
1580
- else {
1593
+ else if (
1594
+ // handle late devtools injection - only do this if we are in an actual
1595
+ // browser environment to avoid the timer handle stalling test runner exit
1596
+ // (#4815)
1597
+ // eslint-disable-next-line no-restricted-globals
1598
+ typeof window !== 'undefined' &&
1599
+ !navigator.userAgent.includes('jsdom')) {
1581
1600
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1582
1601
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1583
1602
  replay.push((newHook) => {
1584
1603
  setDevtoolsHook(newHook, target);
1585
1604
  });
1605
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1606
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1607
+ setTimeout(() => {
1608
+ if (!exports.devtools) {
1609
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1610
+ devtoolsNotInstalled = true;
1611
+ buffer = [];
1612
+ }
1613
+ }, 3000);
1614
+ }
1615
+ else {
1616
+ // non-browser env, assume not installed
1617
+ devtoolsNotInstalled = true;
1618
+ buffer = [];
1586
1619
  }
1587
1620
  }
1588
1621
  function devtoolsInitApp(app, version) {
@@ -4371,7 +4404,7 @@ var VueRuntimeDOM = (function (exports) {
4371
4404
  [bar, this.y]
4372
4405
  ])
4373
4406
  */
4374
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4407
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4375
4408
  function validateDirectiveName(name) {
4376
4409
  if (isBuiltInDirective(name)) {
4377
4410
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -8601,15 +8634,21 @@ var VueRuntimeDOM = (function (exports) {
8601
8634
  * only.
8602
8635
  * @internal
8603
8636
  */
8604
- function mergeDefaults(
8605
- // the base props is compiler-generated and guaranteed to be in this shape.
8606
- props, defaults) {
8637
+ function mergeDefaults(raw, defaults) {
8638
+ const props = isArray(raw)
8639
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8640
+ : raw;
8607
8641
  for (const key in defaults) {
8608
- const val = props[key];
8609
- if (val) {
8610
- val.default = defaults[key];
8642
+ const opt = props[key];
8643
+ if (opt) {
8644
+ if (isArray(opt) || isFunction(opt)) {
8645
+ props[key] = { type: opt, default: defaults[key] };
8646
+ }
8647
+ else {
8648
+ opt.default = defaults[key];
8649
+ }
8611
8650
  }
8612
- else if (val === null) {
8651
+ else if (opt === null) {
8613
8652
  props[key] = { default: defaults[key] };
8614
8653
  }
8615
8654
  else {
@@ -8618,6 +8657,23 @@ var VueRuntimeDOM = (function (exports) {
8618
8657
  }
8619
8658
  return props;
8620
8659
  }
8660
+ /**
8661
+ * Used to create a proxy for the rest element when destructuring props with
8662
+ * defineProps().
8663
+ * @internal
8664
+ */
8665
+ function createPropsRestProxy(props, excludedKeys) {
8666
+ const ret = {};
8667
+ for (const key in props) {
8668
+ if (!excludedKeys.includes(key)) {
8669
+ Object.defineProperty(ret, key, {
8670
+ enumerable: true,
8671
+ get: () => props[key]
8672
+ });
8673
+ }
8674
+ }
8675
+ return ret;
8676
+ }
8621
8677
  /**
8622
8678
  * `<script setup>` helper for persisting the current instance context over
8623
8679
  * async/await flows.
@@ -8905,7 +8961,7 @@ var VueRuntimeDOM = (function (exports) {
8905
8961
  }
8906
8962
 
8907
8963
  // Core API ------------------------------------------------------------------
8908
- const version = "3.2.17";
8964
+ const version = "3.2.21";
8909
8965
  /**
8910
8966
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8911
8967
  * @internal
@@ -9027,16 +9083,8 @@ var VueRuntimeDOM = (function (exports) {
9027
9083
 
9028
9084
  function patchStyle(el, prev, next) {
9029
9085
  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 {
9086
+ const isCssString = isString(next);
9087
+ if (next && !isCssString) {
9040
9088
  for (const key in next) {
9041
9089
  setStyle(style, key, next[key]);
9042
9090
  }
@@ -9048,11 +9096,22 @@ var VueRuntimeDOM = (function (exports) {
9048
9096
  }
9049
9097
  }
9050
9098
  }
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;
9099
+ else {
9100
+ const currentDisplay = style.display;
9101
+ if (isCssString) {
9102
+ if (prev !== next) {
9103
+ style.cssText = next;
9104
+ }
9105
+ }
9106
+ else if (prev) {
9107
+ el.removeAttribute('style');
9108
+ }
9109
+ // indicates that the `display` of the element is controlled by `v-show`,
9110
+ // so we always keep the current `display` value regardless of the `style`
9111
+ // value, thus handing over control to `v-show`.
9112
+ if ('_vod' in el) {
9113
+ style.display = currentDisplay;
9114
+ }
9056
9115
  }
9057
9116
  }
9058
9117
  const importantRE = /\s*!important$/;
@@ -9398,22 +9457,11 @@ var VueRuntimeDOM = (function (exports) {
9398
9457
  }
9399
9458
  this.attachShadow({ mode: 'open' });
9400
9459
  }
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
9460
  }
9412
9461
  connectedCallback() {
9413
9462
  this._connected = true;
9414
9463
  if (!this._instance) {
9415
9464
  this._resolveDef();
9416
- this._update();
9417
9465
  }
9418
9466
  }
9419
9467
  disconnectedCallback() {
@@ -9432,8 +9480,18 @@ var VueRuntimeDOM = (function (exports) {
9432
9480
  if (this._resolved) {
9433
9481
  return;
9434
9482
  }
9483
+ this._resolved = true;
9484
+ // set initial attrs
9485
+ for (let i = 0; i < this.attributes.length; i++) {
9486
+ this._setAttr(this.attributes[i].name);
9487
+ }
9488
+ // watch future attr changes
9489
+ new MutationObserver(mutations => {
9490
+ for (const m of mutations) {
9491
+ this._setAttr(m.attributeName);
9492
+ }
9493
+ }).observe(this, { attributes: true });
9435
9494
  const resolve = (def) => {
9436
- this._resolved = true;
9437
9495
  const { props, styles } = def;
9438
9496
  const hasOptions = !isArray(props);
9439
9497
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9448,14 +9506,11 @@ var VueRuntimeDOM = (function (exports) {
9448
9506
  }
9449
9507
  }
9450
9508
  }
9451
- if (numberProps) {
9452
- this._numberProps = numberProps;
9453
- this._update();
9454
- }
9509
+ this._numberProps = numberProps;
9455
9510
  // check if there are props set pre-upgrade or connect
9456
9511
  for (const key of Object.keys(this)) {
9457
9512
  if (key[0] !== '_') {
9458
- this._setProp(key, this[key]);
9513
+ this._setProp(key, this[key], true, false);
9459
9514
  }
9460
9515
  }
9461
9516
  // defining getter/setters on prototype
@@ -9469,7 +9524,10 @@ var VueRuntimeDOM = (function (exports) {
9469
9524
  }
9470
9525
  });
9471
9526
  }
9527
+ // apply CSS
9472
9528
  this._applyStyles(styles);
9529
+ // initial render
9530
+ this._update();
9473
9531
  };
9474
9532
  const asyncDef = this._def.__asyncLoader;
9475
9533
  if (asyncDef) {
@@ -9495,10 +9553,10 @@ var VueRuntimeDOM = (function (exports) {
9495
9553
  /**
9496
9554
  * @internal
9497
9555
  */
9498
- _setProp(key, val, shouldReflect = true) {
9556
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9499
9557
  if (val !== this._props[key]) {
9500
9558
  this._props[key] = val;
9501
- if (this._instance) {
9559
+ if (shouldUpdate && this._instance) {
9502
9560
  this._update();
9503
9561
  }
9504
9562
  // reflect
@@ -10547,6 +10605,7 @@ var VueRuntimeDOM = (function (exports) {
10547
10605
  exports.createElementBlock = createElementBlock;
10548
10606
  exports.createElementVNode = createBaseVNode;
10549
10607
  exports.createHydrationRenderer = createHydrationRenderer;
10608
+ exports.createPropsRestProxy = createPropsRestProxy;
10550
10609
  exports.createRenderer = createRenderer;
10551
10610
  exports.createSSRApp = createSSRApp;
10552
10611
  exports.createSlots = createSlots;