@vue/runtime-dom 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 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)) {
@@ -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) {
@@ -2657,7 +2694,8 @@ var VueRuntimeDOM = (function (exports) {
2657
2694
  const rawProps = toRaw(props);
2658
2695
  const { mode } = rawProps;
2659
2696
  // check mode
2660
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2697
+ if (mode &&
2698
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
2661
2699
  warn$1(`invalid <transition> mode: ${mode}`);
2662
2700
  }
2663
2701
  // at this point children has a guaranteed length of 1.
@@ -3297,7 +3335,7 @@ var VueRuntimeDOM = (function (exports) {
3297
3335
  }
3298
3336
  current = current.parent;
3299
3337
  }
3300
- hook();
3338
+ return hook();
3301
3339
  });
3302
3340
  injectHook(type, wrappedHook, target);
3303
3341
  // In addition to registering it on the target instance, we walk up the parent
@@ -4371,7 +4409,7 @@ var VueRuntimeDOM = (function (exports) {
4371
4409
  [bar, this.y]
4372
4410
  ])
4373
4411
  */
4374
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4412
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4375
4413
  function validateDirectiveName(name) {
4376
4414
  if (isBuiltInDirective(name)) {
4377
4415
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -6288,8 +6326,8 @@ var VueRuntimeDOM = (function (exports) {
6288
6326
  *
6289
6327
  * #2080
6290
6328
  * 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.
6329
+ * the children will always be moved. Therefore, in order to ensure correct move
6330
+ * position, el should be inherited from previous nodes.
6293
6331
  */
6294
6332
  function traverseStaticChildren(n1, n2, shallow = false) {
6295
6333
  const ch1 = n1.children;
@@ -7069,7 +7107,8 @@ var VueRuntimeDOM = (function (exports) {
7069
7107
  else if (isOn(key)) {
7070
7108
  const existing = ret[key];
7071
7109
  const incoming = toMerge[key];
7072
- if (existing !== incoming) {
7110
+ if (existing !== incoming &&
7111
+ !(isArray(existing) && existing.includes(incoming))) {
7073
7112
  ret[key] = existing
7074
7113
  ? [].concat(existing, incoming)
7075
7114
  : incoming;
@@ -7272,23 +7311,23 @@ var VueRuntimeDOM = (function (exports) {
7272
7311
  const n = accessCache[key];
7273
7312
  if (n !== undefined) {
7274
7313
  switch (n) {
7275
- case 0 /* SETUP */:
7314
+ case 1 /* SETUP */:
7276
7315
  return setupState[key];
7277
- case 1 /* DATA */:
7316
+ case 2 /* DATA */:
7278
7317
  return data[key];
7279
- case 3 /* CONTEXT */:
7318
+ case 4 /* CONTEXT */:
7280
7319
  return ctx[key];
7281
- case 2 /* PROPS */:
7320
+ case 3 /* PROPS */:
7282
7321
  return props[key];
7283
7322
  // default: just fallthrough
7284
7323
  }
7285
7324
  }
7286
7325
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7287
- accessCache[key] = 0 /* SETUP */;
7326
+ accessCache[key] = 1 /* SETUP */;
7288
7327
  return setupState[key];
7289
7328
  }
7290
7329
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7291
- accessCache[key] = 1 /* DATA */;
7330
+ accessCache[key] = 2 /* DATA */;
7292
7331
  return data[key];
7293
7332
  }
7294
7333
  else if (
@@ -7296,15 +7335,15 @@ var VueRuntimeDOM = (function (exports) {
7296
7335
  // props
7297
7336
  (normalizedProps = instance.propsOptions[0]) &&
7298
7337
  hasOwn(normalizedProps, key)) {
7299
- accessCache[key] = 2 /* PROPS */;
7338
+ accessCache[key] = 3 /* PROPS */;
7300
7339
  return props[key];
7301
7340
  }
7302
7341
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7303
- accessCache[key] = 3 /* CONTEXT */;
7342
+ accessCache[key] = 4 /* CONTEXT */;
7304
7343
  return ctx[key];
7305
7344
  }
7306
7345
  else if (shouldCacheAccess) {
7307
- accessCache[key] = 4 /* OTHER */;
7346
+ accessCache[key] = 0 /* OTHER */;
7308
7347
  }
7309
7348
  }
7310
7349
  const publicGetter = publicPropertiesMap[key];
@@ -7325,7 +7364,7 @@ var VueRuntimeDOM = (function (exports) {
7325
7364
  }
7326
7365
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7327
7366
  // user may set custom properties to `this` that start with `$`
7328
- accessCache[key] = 3 /* CONTEXT */;
7367
+ accessCache[key] = 4 /* CONTEXT */;
7329
7368
  return ctx[key];
7330
7369
  }
7331
7370
  else if (
@@ -7386,7 +7425,7 @@ var VueRuntimeDOM = (function (exports) {
7386
7425
  },
7387
7426
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7388
7427
  let normalizedProps;
7389
- return (accessCache[key] !== undefined ||
7428
+ return (!!accessCache[key] ||
7390
7429
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7391
7430
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7392
7431
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -8601,15 +8640,21 @@ var VueRuntimeDOM = (function (exports) {
8601
8640
  * only.
8602
8641
  * @internal
8603
8642
  */
8604
- function mergeDefaults(
8605
- // the base props is compiler-generated and guaranteed to be in this shape.
8606
- props, defaults) {
8643
+ function mergeDefaults(raw, defaults) {
8644
+ const props = isArray(raw)
8645
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8646
+ : raw;
8607
8647
  for (const key in defaults) {
8608
- const val = props[key];
8609
- if (val) {
8610
- val.default = defaults[key];
8648
+ const opt = props[key];
8649
+ if (opt) {
8650
+ if (isArray(opt) || isFunction(opt)) {
8651
+ props[key] = { type: opt, default: defaults[key] };
8652
+ }
8653
+ else {
8654
+ opt.default = defaults[key];
8655
+ }
8611
8656
  }
8612
- else if (val === null) {
8657
+ else if (opt === null) {
8613
8658
  props[key] = { default: defaults[key] };
8614
8659
  }
8615
8660
  else {
@@ -8618,6 +8663,23 @@ var VueRuntimeDOM = (function (exports) {
8618
8663
  }
8619
8664
  return props;
8620
8665
  }
8666
+ /**
8667
+ * Used to create a proxy for the rest element when destructuring props with
8668
+ * defineProps().
8669
+ * @internal
8670
+ */
8671
+ function createPropsRestProxy(props, excludedKeys) {
8672
+ const ret = {};
8673
+ for (const key in props) {
8674
+ if (!excludedKeys.includes(key)) {
8675
+ Object.defineProperty(ret, key, {
8676
+ enumerable: true,
8677
+ get: () => props[key]
8678
+ });
8679
+ }
8680
+ }
8681
+ return ret;
8682
+ }
8621
8683
  /**
8622
8684
  * `<script setup>` helper for persisting the current instance context over
8623
8685
  * async/await flows.
@@ -8905,7 +8967,7 @@ var VueRuntimeDOM = (function (exports) {
8905
8967
  }
8906
8968
 
8907
8969
  // Core API ------------------------------------------------------------------
8908
- const version = "3.2.19";
8970
+ const version = "3.2.23";
8909
8971
  /**
8910
8972
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8911
8973
  * @internal
@@ -9027,16 +9089,8 @@ var VueRuntimeDOM = (function (exports) {
9027
9089
 
9028
9090
  function patchStyle(el, prev, next) {
9029
9091
  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 {
9092
+ const isCssString = isString(next);
9093
+ if (next && !isCssString) {
9040
9094
  for (const key in next) {
9041
9095
  setStyle(style, key, next[key]);
9042
9096
  }
@@ -9048,11 +9102,22 @@ var VueRuntimeDOM = (function (exports) {
9048
9102
  }
9049
9103
  }
9050
9104
  }
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;
9105
+ else {
9106
+ const currentDisplay = style.display;
9107
+ if (isCssString) {
9108
+ if (prev !== next) {
9109
+ style.cssText = next;
9110
+ }
9111
+ }
9112
+ else if (prev) {
9113
+ el.removeAttribute('style');
9114
+ }
9115
+ // indicates that the `display` of the element is controlled by `v-show`,
9116
+ // so we always keep the current `display` value regardless of the `style`
9117
+ // value, thus handing over control to `v-show`.
9118
+ if ('_vod' in el) {
9119
+ style.display = currentDisplay;
9120
+ }
9056
9121
  }
9057
9122
  }
9058
9123
  const importantRE = /\s*!important$/;
@@ -9135,12 +9200,19 @@ var VueRuntimeDOM = (function (exports) {
9135
9200
  el[key] = value == null ? '' : value;
9136
9201
  return;
9137
9202
  }
9138
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9203
+ if (key === 'value' &&
9204
+ el.tagName !== 'PROGRESS' &&
9205
+ // custom elements may use _value internally
9206
+ !el.tagName.includes('-')) {
9139
9207
  // store value as _value as well since
9140
9208
  // non-string values will be stringified.
9141
9209
  el._value = value;
9142
9210
  const newValue = value == null ? '' : value;
9143
- if (el.value !== newValue) {
9211
+ if (el.value !== newValue ||
9212
+ // #4956: always set for OPTION elements because its value falls back to
9213
+ // textContent if no value attribute is present. And setting .value for
9214
+ // OPTION has no side effect
9215
+ el.tagName === 'OPTION') {
9144
9216
  el.value = newValue;
9145
9217
  }
9146
9218
  if (value == null) {
@@ -9398,22 +9470,11 @@ var VueRuntimeDOM = (function (exports) {
9398
9470
  }
9399
9471
  this.attachShadow({ mode: 'open' });
9400
9472
  }
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
9473
  }
9412
9474
  connectedCallback() {
9413
9475
  this._connected = true;
9414
9476
  if (!this._instance) {
9415
9477
  this._resolveDef();
9416
- this._update();
9417
9478
  }
9418
9479
  }
9419
9480
  disconnectedCallback() {
@@ -9432,8 +9493,18 @@ var VueRuntimeDOM = (function (exports) {
9432
9493
  if (this._resolved) {
9433
9494
  return;
9434
9495
  }
9496
+ this._resolved = true;
9497
+ // set initial attrs
9498
+ for (let i = 0; i < this.attributes.length; i++) {
9499
+ this._setAttr(this.attributes[i].name);
9500
+ }
9501
+ // watch future attr changes
9502
+ new MutationObserver(mutations => {
9503
+ for (const m of mutations) {
9504
+ this._setAttr(m.attributeName);
9505
+ }
9506
+ }).observe(this, { attributes: true });
9435
9507
  const resolve = (def) => {
9436
- this._resolved = true;
9437
9508
  const { props, styles } = def;
9438
9509
  const hasOptions = !isArray(props);
9439
9510
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9448,14 +9519,11 @@ var VueRuntimeDOM = (function (exports) {
9448
9519
  }
9449
9520
  }
9450
9521
  }
9451
- if (numberProps) {
9452
- this._numberProps = numberProps;
9453
- this._update();
9454
- }
9522
+ this._numberProps = numberProps;
9455
9523
  // check if there are props set pre-upgrade or connect
9456
9524
  for (const key of Object.keys(this)) {
9457
9525
  if (key[0] !== '_') {
9458
- this._setProp(key, this[key]);
9526
+ this._setProp(key, this[key], true, false);
9459
9527
  }
9460
9528
  }
9461
9529
  // defining getter/setters on prototype
@@ -9469,7 +9537,10 @@ var VueRuntimeDOM = (function (exports) {
9469
9537
  }
9470
9538
  });
9471
9539
  }
9540
+ // apply CSS
9472
9541
  this._applyStyles(styles);
9542
+ // initial render
9543
+ this._update();
9473
9544
  };
9474
9545
  const asyncDef = this._def.__asyncLoader;
9475
9546
  if (asyncDef) {
@@ -9495,10 +9566,10 @@ var VueRuntimeDOM = (function (exports) {
9495
9566
  /**
9496
9567
  * @internal
9497
9568
  */
9498
- _setProp(key, val, shouldReflect = true) {
9569
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9499
9570
  if (val !== this._props[key]) {
9500
9571
  this._props[key] = val;
9501
- if (this._instance) {
9572
+ if (shouldUpdate && this._instance) {
9502
9573
  this._update();
9503
9574
  }
9504
9575
  // reflect
@@ -10547,6 +10618,7 @@ var VueRuntimeDOM = (function (exports) {
10547
10618
  exports.createElementBlock = createElementBlock;
10548
10619
  exports.createElementVNode = createBaseVNode;
10549
10620
  exports.createHydrationRenderer = createHydrationRenderer;
10621
+ exports.createPropsRestProxy = createPropsRestProxy;
10550
10622
  exports.createRenderer = createRenderer;
10551
10623
  exports.createSSRApp = createSSRApp;
10552
10624
  exports.createSlots = createSlots;