@vue/runtime-dom 3.6.0-alpha.2 → 3.6.0-alpha.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.6.0-alpha.2
2
+ * @vue/runtime-dom v3.6.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -216,11 +216,11 @@ function resolveTransitionProps(rawProps) {
216
216
  const resolve = () => finishLeave(el, done);
217
217
  addTransitionClass(el, leaveFromClass);
218
218
  if (!el._enterCancelled) {
219
- forceReflow();
219
+ forceReflow(el);
220
220
  addTransitionClass(el, leaveActiveClass);
221
221
  } else {
222
222
  addTransitionClass(el, leaveActiveClass);
223
- forceReflow();
223
+ forceReflow(el);
224
224
  }
225
225
  nextFrame(() => {
226
226
  if (!el._isLeaving) {
@@ -343,7 +343,7 @@ function getTransitionInfo(el, expectedType) {
343
343
  type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
344
344
  propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
345
345
  }
346
- const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
346
+ const hasTransform = type === TRANSITION && /\b(?:transform|all)(?:,|$)/.test(
347
347
  getStyleProperties(`${TRANSITION}Property`).toString()
348
348
  );
349
349
  return {
@@ -363,8 +363,9 @@ function toMs(s) {
363
363
  if (s === "auto") return 0;
364
364
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
365
365
  }
366
- function forceReflow() {
367
- return document.body.offsetHeight;
366
+ function forceReflow(el) {
367
+ const targetDocument = el ? el.ownerDocument : document;
368
+ return targetDocument.body.offsetHeight;
368
369
  }
369
370
 
370
371
  function patchClass(el, value, isSVG) {
@@ -384,6 +385,8 @@ function patchClass(el, value, isSVG) {
384
385
  const vShowOriginalDisplay = Symbol("_vod");
385
386
  const vShowHidden = Symbol("_vsh");
386
387
  const vShow = {
388
+ // used for prop mismatch check during hydration
389
+ name: "show",
387
390
  beforeMount(el, { value }, { transition }) {
388
391
  el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
389
392
  if (transition && value) {
@@ -434,7 +437,7 @@ function useCssVars(getter) {
434
437
  return;
435
438
  }
436
439
 
437
- const displayRE = /(^|;)\s*display\s*:/;
440
+ const displayRE = /(?:^|;)\s*display\s*:/;
438
441
  function patchStyle(el, prev, next) {
439
442
  const style = el.style;
440
443
  const isCssString = shared.isString(next);
@@ -715,11 +718,10 @@ function shouldSetAsProp(el, key, value, isSVG) {
715
718
  }
716
719
 
717
720
  const REMOVAL = {};
718
- /*! #__NO_SIDE_EFFECTS__ */
719
721
  // @__NO_SIDE_EFFECTS__
720
722
  function defineCustomElement(options, extraOptions, _createApp) {
721
- const Comp = runtimeCore.defineComponent(options, extraOptions);
722
- if (shared.isPlainObject(Comp)) shared.extend(Comp, extraOptions);
723
+ let Comp = runtimeCore.defineComponent(options, extraOptions);
724
+ if (shared.isPlainObject(Comp)) Comp = shared.extend({}, Comp, extraOptions);
723
725
  class VueCustomElement extends VueElement {
724
726
  constructor(initialProps) {
725
727
  super(Comp, initialProps, _createApp);
@@ -728,10 +730,9 @@ function defineCustomElement(options, extraOptions, _createApp) {
728
730
  VueCustomElement.def = Comp;
729
731
  return VueCustomElement;
730
732
  }
731
- /*! #__NO_SIDE_EFFECTS__ */
732
- const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
733
+ const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
733
734
  return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
734
- };
735
+ });
735
736
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
736
737
  };
737
738
  class VueElement extends BaseClass {
@@ -755,6 +756,8 @@ class VueElement extends BaseClass {
755
756
  this._nonce = this._def.nonce;
756
757
  this._connected = false;
757
758
  this._resolved = false;
759
+ this._patching = false;
760
+ this._dirty = false;
758
761
  this._numberProps = null;
759
762
  this._styleChildren = /* @__PURE__ */ new WeakSet();
760
763
  this._ob = null;
@@ -762,7 +765,11 @@ class VueElement extends BaseClass {
762
765
  this._root = this.shadowRoot;
763
766
  } else {
764
767
  if (_def.shadowRoot !== false) {
765
- this.attachShadow({ mode: "open" });
768
+ this.attachShadow(
769
+ shared.extend({}, _def.shadowRootOptions, {
770
+ mode: "open"
771
+ })
772
+ );
766
773
  this._root = this.shadowRoot;
767
774
  } else {
768
775
  this._root = this;
@@ -822,9 +829,18 @@ class VueElement extends BaseClass {
822
829
  this._app && this._app.unmount();
823
830
  if (this._instance) this._instance.ce = void 0;
824
831
  this._app = this._instance = null;
832
+ if (this._teleportTargets) {
833
+ this._teleportTargets.clear();
834
+ this._teleportTargets = void 0;
835
+ }
825
836
  }
826
837
  });
827
838
  }
839
+ _processMutations(mutations) {
840
+ for (const m of mutations) {
841
+ this._setAttr(m.attributeName);
842
+ }
843
+ }
828
844
  /**
829
845
  * resolve inner component definition (handle possible async component)
830
846
  */
@@ -835,11 +851,7 @@ class VueElement extends BaseClass {
835
851
  for (let i = 0; i < this.attributes.length; i++) {
836
852
  this._setAttr(this.attributes[i].name);
837
853
  }
838
- this._ob = new MutationObserver((mutations) => {
839
- for (const m of mutations) {
840
- this._setAttr(m.attributeName);
841
- }
842
- });
854
+ this._ob = new MutationObserver(this._processMutations.bind(this));
843
855
  this._ob.observe(this, { attributes: true });
844
856
  const resolve = (def, isAsync = false) => {
845
857
  this._resolved = true;
@@ -907,7 +919,7 @@ class VueElement extends BaseClass {
907
919
  return this._getProp(key);
908
920
  },
909
921
  set(val) {
910
- this._setProp(key, val, true, true);
922
+ this._setProp(key, val, true, !this._patching);
911
923
  }
912
924
  });
913
925
  }
@@ -933,6 +945,7 @@ class VueElement extends BaseClass {
933
945
  */
934
946
  _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
935
947
  if (val !== this._props[key]) {
948
+ this._dirty = true;
936
949
  if (val === REMOVAL) {
937
950
  delete this._props[key];
938
951
  } else {
@@ -946,7 +959,10 @@ class VueElement extends BaseClass {
946
959
  }
947
960
  if (shouldReflect) {
948
961
  const ob = this._ob;
949
- ob && ob.disconnect();
962
+ if (ob) {
963
+ this._processMutations(ob.takeRecords());
964
+ ob.disconnect();
965
+ }
950
966
  if (val === true) {
951
967
  this.setAttribute(shared.hyphenate(key), "");
952
968
  } else if (typeof val === "string" || typeof val === "number") {
@@ -1025,7 +1041,7 @@ class VueElement extends BaseClass {
1025
1041
  * Only called when shadowRoot is false
1026
1042
  */
1027
1043
  _renderSlots() {
1028
- const outlets = (this._teleportTarget || this).querySelectorAll("slot");
1044
+ const outlets = this._getSlots();
1029
1045
  const scopeId = this._instance.type.__scopeId;
1030
1046
  for (let i = 0; i < outlets.length; i++) {
1031
1047
  const o = outlets[i];
@@ -1051,12 +1067,45 @@ class VueElement extends BaseClass {
1051
1067
  parent.removeChild(o);
1052
1068
  }
1053
1069
  }
1070
+ /**
1071
+ * @internal
1072
+ */
1073
+ _getSlots() {
1074
+ const roots = [this];
1075
+ if (this._teleportTargets) {
1076
+ roots.push(...this._teleportTargets);
1077
+ }
1078
+ const slots = /* @__PURE__ */ new Set();
1079
+ for (const root of roots) {
1080
+ const found = root.querySelectorAll("slot");
1081
+ for (let i = 0; i < found.length; i++) {
1082
+ slots.add(found[i]);
1083
+ }
1084
+ }
1085
+ return Array.from(slots);
1086
+ }
1054
1087
  /**
1055
1088
  * @internal
1056
1089
  */
1057
1090
  _injectChildStyle(comp) {
1058
1091
  this._applyStyles(comp.styles, comp);
1059
1092
  }
1093
+ /**
1094
+ * @internal
1095
+ */
1096
+ _beginPatch() {
1097
+ this._patching = true;
1098
+ this._dirty = false;
1099
+ }
1100
+ /**
1101
+ * @internal
1102
+ */
1103
+ _endPatch() {
1104
+ this._patching = false;
1105
+ if (this._dirty && this._instance) {
1106
+ this._update();
1107
+ }
1108
+ }
1060
1109
  /**
1061
1110
  * @internal
1062
1111
  */
@@ -1126,26 +1175,13 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
1126
1175
  prevChildren = [];
1127
1176
  return;
1128
1177
  }
1129
- prevChildren.forEach(callPendingCbs);
1178
+ prevChildren.forEach((vnode) => callPendingCbs(vnode.el));
1130
1179
  prevChildren.forEach(recordPosition);
1131
1180
  const movedChildren = prevChildren.filter(applyTranslation);
1132
- forceReflow();
1181
+ forceReflow(instance.vnode.el);
1133
1182
  movedChildren.forEach((c) => {
1134
1183
  const el = c.el;
1135
- const style = el.style;
1136
- addTransitionClass(el, moveClass);
1137
- style.transform = style.webkitTransform = style.transitionDuration = "";
1138
- const cb = el[moveCbKey] = (e) => {
1139
- if (e && e.target !== el) {
1140
- return;
1141
- }
1142
- if (!e || /transform$/.test(e.propertyName)) {
1143
- el.removeEventListener("transitionend", cb);
1144
- el[moveCbKey] = null;
1145
- removeTransitionClass(el, moveClass);
1146
- }
1147
- };
1148
- el.addEventListener("transitionend", cb);
1184
+ handleMovedChildren(el, moveClass);
1149
1185
  });
1150
1186
  prevChildren = [];
1151
1187
  });
@@ -1168,10 +1204,10 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
1168
1204
  instance
1169
1205
  )
1170
1206
  );
1171
- positionMap.set(
1172
- child,
1173
- child.el.getBoundingClientRect()
1174
- );
1207
+ positionMap.set(child, {
1208
+ left: child.el.offsetLeft,
1209
+ top: child.el.offsetTop
1210
+ });
1175
1211
  }
1176
1212
  }
1177
1213
  }
@@ -1190,8 +1226,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
1190
1226
  }
1191
1227
  });
1192
1228
  const TransitionGroup = TransitionGroupImpl;
1193
- function callPendingCbs(c) {
1194
- const el = c.el;
1229
+ function callPendingCbs(el) {
1195
1230
  if (el[moveCbKey]) {
1196
1231
  el[moveCbKey]();
1197
1232
  }
@@ -1200,19 +1235,30 @@ function callPendingCbs(c) {
1200
1235
  }
1201
1236
  }
1202
1237
  function recordPosition(c) {
1203
- newPositionMap.set(c, c.el.getBoundingClientRect());
1238
+ newPositionMap.set(c, {
1239
+ left: c.el.offsetLeft,
1240
+ top: c.el.offsetTop
1241
+ });
1204
1242
  }
1205
1243
  function applyTranslation(c) {
1206
- const oldPos = positionMap.get(c);
1207
- const newPos = newPositionMap.get(c);
1244
+ if (baseApplyTranslation(
1245
+ positionMap.get(c),
1246
+ newPositionMap.get(c),
1247
+ c.el
1248
+ )) {
1249
+ return c;
1250
+ }
1251
+ }
1252
+ function baseApplyTranslation(oldPos, newPos, el) {
1208
1253
  const dx = oldPos.left - newPos.left;
1209
1254
  const dy = oldPos.top - newPos.top;
1210
1255
  if (dx || dy) {
1211
- const s = c.el.style;
1256
+ const s = el.style;
1212
1257
  s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1213
1258
  s.transitionDuration = "0s";
1214
- return c;
1259
+ return true;
1215
1260
  }
1261
+ return false;
1216
1262
  }
1217
1263
  function hasCSSTransform(el, root, moveClass) {
1218
1264
  const clone = el.cloneNode();
@@ -1230,6 +1276,22 @@ function hasCSSTransform(el, root, moveClass) {
1230
1276
  container.removeChild(clone);
1231
1277
  return hasTransform;
1232
1278
  }
1279
+ const handleMovedChildren = (el, moveClass) => {
1280
+ const style = el.style;
1281
+ addTransitionClass(el, moveClass);
1282
+ style.transform = style.webkitTransform = style.transitionDuration = "";
1283
+ const cb = el[moveCbKey] = (e) => {
1284
+ if (e && e.target !== el) {
1285
+ return;
1286
+ }
1287
+ if (!e || e.propertyName.endsWith("transform")) {
1288
+ el.removeEventListener("transitionend", cb);
1289
+ el[moveCbKey] = null;
1290
+ removeTransitionClass(el, moveClass);
1291
+ }
1292
+ };
1293
+ el.addEventListener("transitionend", cb);
1294
+ };
1233
1295
 
1234
1296
  const getModelAssigner = (vnode) => {
1235
1297
  const fn = vnode.props["onUpdate:modelValue"] || false;
@@ -1265,21 +1327,21 @@ const vModelText = {
1265
1327
  vModelTextUpdate(el, oldValue, value, trim, number, lazy);
1266
1328
  }
1267
1329
  };
1330
+ function castValue(value, trim, number) {
1331
+ if (trim) value = value.trim();
1332
+ if (number) value = shared.looseToNumber(value);
1333
+ return value;
1334
+ }
1268
1335
  const vModelTextInit = (el, trim, number, lazy, set) => {
1269
1336
  addEventListener(el, lazy ? "change" : "input", (e) => {
1270
1337
  if (e.target.composing) return;
1271
- let domValue = el.value;
1272
- if (trim) {
1273
- domValue = domValue.trim();
1274
- }
1275
- if (number || el.type === "number") {
1276
- domValue = shared.looseToNumber(domValue);
1277
- }
1278
- (0, el[assignKey])(domValue);
1338
+ (0, el[assignKey])(
1339
+ castValue(el.value, trim, number || el.type === "number")
1340
+ );
1279
1341
  });
1280
- if (trim) {
1342
+ if (trim || number) {
1281
1343
  addEventListener(el, "change", () => {
1282
- el.value = el.value.trim();
1344
+ el.value = castValue(el.value, trim, number || el.type === "number");
1283
1345
  });
1284
1346
  }
1285
1347
  if (!lazy) {
@@ -1559,13 +1621,13 @@ const modifierGuards = {
1559
1621
  const withModifiers = (fn, modifiers) => {
1560
1622
  const cache = fn._withMods || (fn._withMods = {});
1561
1623
  const cacheKey = modifiers.join(".");
1562
- return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
1624
+ return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
1563
1625
  for (let i = 0; i < modifiers.length; i++) {
1564
1626
  const guard = modifierGuards[modifiers[i]];
1565
1627
  if (guard && guard(event, modifiers)) return;
1566
1628
  }
1567
1629
  return fn(event, ...args);
1568
- });
1630
+ }));
1569
1631
  };
1570
1632
  const keyNames = {
1571
1633
  esc: "escape",
@@ -1579,7 +1641,7 @@ const keyNames = {
1579
1641
  const withKeys = (fn, modifiers) => {
1580
1642
  const cache = fn._withKeys || (fn._withKeys = {});
1581
1643
  const cacheKey = modifiers.join(".");
1582
- return cache[cacheKey] || (cache[cacheKey] = (event) => {
1644
+ return cache[cacheKey] || (cache[cacheKey] = ((event) => {
1583
1645
  if (!("key" in event)) {
1584
1646
  return;
1585
1647
  }
@@ -1589,7 +1651,7 @@ const withKeys = (fn, modifiers) => {
1589
1651
  )) {
1590
1652
  return fn(event);
1591
1653
  }
1592
- });
1654
+ }));
1593
1655
  };
1594
1656
 
1595
1657
  const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
@@ -1603,13 +1665,13 @@ function ensureHydrationRenderer() {
1603
1665
  enabledHydration = true;
1604
1666
  return renderer;
1605
1667
  }
1606
- const render = (...args) => {
1668
+ const render = ((...args) => {
1607
1669
  ensureRenderer().render(...args);
1608
- };
1609
- const hydrate = (...args) => {
1670
+ });
1671
+ const hydrate = ((...args) => {
1610
1672
  ensureHydrationRenderer().hydrate(...args);
1611
- };
1612
- const createApp = (...args) => {
1673
+ });
1674
+ const createApp = ((...args) => {
1613
1675
  const app = ensureRenderer().createApp(...args);
1614
1676
  const { mount } = app;
1615
1677
  app.mount = (containerOrSelector) => {
@@ -1630,8 +1692,8 @@ const createApp = (...args) => {
1630
1692
  return proxy;
1631
1693
  };
1632
1694
  return app;
1633
- };
1634
- const createSSRApp = (...args) => {
1695
+ });
1696
+ const createSSRApp = ((...args) => {
1635
1697
  const app = ensureHydrationRenderer().createApp(...args);
1636
1698
  const { mount } = app;
1637
1699
  app.mount = (containerOrSelector) => {
@@ -1641,7 +1703,7 @@ const createSSRApp = (...args) => {
1641
1703
  }
1642
1704
  };
1643
1705
  return app;
1644
- };
1706
+ });
1645
1707
  function resolveRootNamespace(container) {
1646
1708
  if (container instanceof SVGElement) {
1647
1709
  return "svg";