@vuact/runtime-dom 3.5.28-vuact.2 → 3.5.29-vuact.0

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
- * @vuact/runtime-dom v3.5.16
2
+ * @vue/runtime-dom v3.5.29
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -93,7 +93,7 @@ const nodeOps = {
93
93
 
94
94
  const TRANSITION = "transition";
95
95
  const ANIMATION = "animation";
96
- const vtcKey = Symbol("_vtc");
96
+ const vtcKey = /* @__PURE__ */ Symbol("_vtc");
97
97
  const DOMTransitionPropsValidators = {
98
98
  name: String,
99
99
  type: String,
@@ -217,11 +217,11 @@ function resolveTransitionProps(rawProps) {
217
217
  const resolve = () => finishLeave(el, done);
218
218
  addTransitionClass(el, leaveFromClass);
219
219
  if (!el._enterCancelled) {
220
- forceReflow();
220
+ forceReflow(el);
221
221
  addTransitionClass(el, leaveActiveClass);
222
222
  } else {
223
223
  addTransitionClass(el, leaveActiveClass);
224
- forceReflow();
224
+ forceReflow(el);
225
225
  }
226
226
  nextFrame(() => {
227
227
  if (!el._isLeaving) {
@@ -347,7 +347,7 @@ function getTransitionInfo(el, expectedType) {
347
347
  type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
348
348
  propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
349
349
  }
350
- const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
350
+ const hasTransform = type === TRANSITION && /\b(?:transform|all)(?:,|$)/.test(
351
351
  getStyleProperties(`${TRANSITION}Property`).toString()
352
352
  );
353
353
  return {
@@ -367,8 +367,9 @@ function toMs(s) {
367
367
  if (s === "auto") return 0;
368
368
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
369
369
  }
370
- function forceReflow() {
371
- return document.body.offsetHeight;
370
+ function forceReflow(el) {
371
+ const targetDocument = el ? el.ownerDocument : document;
372
+ return targetDocument.body.offsetHeight;
372
373
  }
373
374
 
374
375
  function patchClass(el, value, isSVG) {
@@ -385,9 +386,11 @@ function patchClass(el, value, isSVG) {
385
386
  }
386
387
  }
387
388
 
388
- const vShowOriginalDisplay = Symbol("_vod");
389
- const vShowHidden = Symbol("_vsh");
389
+ const vShowOriginalDisplay = /* @__PURE__ */ Symbol("_vod");
390
+ const vShowHidden = /* @__PURE__ */ Symbol("_vsh");
390
391
  const vShow = {
392
+ // used for prop mismatch check during hydration
393
+ name: "show",
391
394
  beforeMount(el, { value }, { transition }) {
392
395
  el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
393
396
  if (transition && value) {
@@ -421,9 +424,6 @@ const vShow = {
421
424
  setDisplay(el, value);
422
425
  }
423
426
  };
424
- {
425
- vShow.name = "show";
426
- }
427
427
  function setDisplay(el, value) {
428
428
  el.style.display = value ? el[vShowOriginalDisplay] : "none";
429
429
  el[vShowHidden] = !value;
@@ -436,12 +436,12 @@ function initVShowForSSR() {
436
436
  };
437
437
  }
438
438
 
439
- const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
439
+ const CSS_VAR_TEXT = /* @__PURE__ */ Symbol("CSS_VAR_TEXT" );
440
440
  function useCssVars(getter) {
441
441
  return;
442
442
  }
443
443
 
444
- const displayRE = /(^|;)\s*display\s*:/;
444
+ const displayRE = /(?:^|;)\s*display\s*:/;
445
445
  function patchStyle(el, prev, next) {
446
446
  const style = el.style;
447
447
  const isCssString = shared.isString(next);
@@ -618,7 +618,7 @@ function addEventListener(el, event, handler, options) {
618
618
  function removeEventListener(el, event, handler, options) {
619
619
  el.removeEventListener(event, handler, options);
620
620
  }
621
- const veiKey = Symbol("_vei");
621
+ const veiKey = /* @__PURE__ */ Symbol("_vei");
622
622
  function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
623
623
  const invokers = el[veiKey] || (el[veiKey] = {});
624
624
  const existingInvoker = invokers[rawName];
@@ -742,6 +742,9 @@ function shouldSetAsProp(el, key, value, isSVG) {
742
742
  if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
743
743
  return false;
744
744
  }
745
+ if (key === "sandbox" && el.tagName === "IFRAME") {
746
+ return false;
747
+ }
745
748
  if (key === "form") {
746
749
  return false;
747
750
  }
@@ -764,11 +767,10 @@ function shouldSetAsProp(el, key, value, isSVG) {
764
767
  }
765
768
 
766
769
  const REMOVAL = {};
767
- /*! #__NO_SIDE_EFFECTS__ */
768
770
  // @__NO_SIDE_EFFECTS__
769
771
  function defineCustomElement(options, extraOptions, _createApp) {
770
- const Comp = runtimeCore.defineComponent(options, extraOptions);
771
- if (shared.isPlainObject(Comp)) shared.extend(Comp, extraOptions);
772
+ let Comp = runtimeCore.defineComponent(options, extraOptions);
773
+ if (shared.isPlainObject(Comp)) Comp = shared.extend({}, Comp, extraOptions);
772
774
  class VueCustomElement extends VueElement {
773
775
  constructor(initialProps) {
774
776
  super(Comp, initialProps, _createApp);
@@ -777,10 +779,9 @@ function defineCustomElement(options, extraOptions, _createApp) {
777
779
  VueCustomElement.def = Comp;
778
780
  return VueCustomElement;
779
781
  }
780
- /*! #__NO_SIDE_EFFECTS__ */
781
- const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
782
+ const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
782
783
  return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
783
- };
784
+ });
784
785
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
785
786
  };
786
787
  class VueElement extends BaseClass {
@@ -804,6 +805,8 @@ class VueElement extends BaseClass {
804
805
  this._nonce = this._def.nonce;
805
806
  this._connected = false;
806
807
  this._resolved = false;
808
+ this._patching = false;
809
+ this._dirty = false;
807
810
  this._numberProps = null;
808
811
  this._styleChildren = /* @__PURE__ */ new WeakSet();
809
812
  this._ob = null;
@@ -816,7 +819,11 @@ class VueElement extends BaseClass {
816
819
  );
817
820
  }
818
821
  if (_def.shadowRoot !== false) {
819
- this.attachShadow({ mode: "open" });
822
+ this.attachShadow(
823
+ shared.extend({}, _def.shadowRootOptions, {
824
+ mode: "open"
825
+ })
826
+ );
820
827
  this._root = this.shadowRoot;
821
828
  } else {
822
829
  this._root = this;
@@ -876,9 +883,18 @@ class VueElement extends BaseClass {
876
883
  this._app && this._app.unmount();
877
884
  if (this._instance) this._instance.ce = void 0;
878
885
  this._app = this._instance = null;
886
+ if (this._teleportTargets) {
887
+ this._teleportTargets.clear();
888
+ this._teleportTargets = void 0;
889
+ }
879
890
  }
880
891
  });
881
892
  }
893
+ _processMutations(mutations) {
894
+ for (const m of mutations) {
895
+ this._setAttr(m.attributeName);
896
+ }
897
+ }
882
898
  /**
883
899
  * resolve inner component definition (handle possible async component)
884
900
  */
@@ -889,11 +905,7 @@ class VueElement extends BaseClass {
889
905
  for (let i = 0; i < this.attributes.length; i++) {
890
906
  this._setAttr(this.attributes[i].name);
891
907
  }
892
- this._ob = new MutationObserver((mutations) => {
893
- for (const m of mutations) {
894
- this._setAttr(m.attributeName);
895
- }
896
- });
908
+ this._ob = new MutationObserver(this._processMutations.bind(this));
897
909
  this._ob.observe(this, { attributes: true });
898
910
  const resolve = (def, isAsync = false) => {
899
911
  this._resolved = true;
@@ -924,9 +936,10 @@ class VueElement extends BaseClass {
924
936
  };
925
937
  const asyncDef = this._def.__asyncLoader;
926
938
  if (asyncDef) {
927
- this._pendingResolve = asyncDef().then(
928
- (def) => resolve(this._def = def, true)
929
- );
939
+ this._pendingResolve = asyncDef().then((def) => {
940
+ def.configureApp = this._def.configureApp;
941
+ resolve(this._def = def, true);
942
+ });
930
943
  } else {
931
944
  resolve(this._def);
932
945
  }
@@ -969,7 +982,7 @@ class VueElement extends BaseClass {
969
982
  return this._getProp(key);
970
983
  },
971
984
  set(val) {
972
- this._setProp(key, val, true, true);
985
+ this._setProp(key, val, true, !this._patching);
973
986
  }
974
987
  });
975
988
  }
@@ -995,6 +1008,7 @@ class VueElement extends BaseClass {
995
1008
  */
996
1009
  _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
997
1010
  if (val !== this._props[key]) {
1011
+ this._dirty = true;
998
1012
  if (val === REMOVAL) {
999
1013
  delete this._props[key];
1000
1014
  } else {
@@ -1008,7 +1022,10 @@ class VueElement extends BaseClass {
1008
1022
  }
1009
1023
  if (shouldReflect) {
1010
1024
  const ob = this._ob;
1011
- ob && ob.disconnect();
1025
+ if (ob) {
1026
+ this._processMutations(ob.takeRecords());
1027
+ ob.disconnect();
1028
+ }
1012
1029
  if (val === true) {
1013
1030
  this.setAttribute(shared.hyphenate(key), "");
1014
1031
  } else if (typeof val === "string" || typeof val === "number") {
@@ -1112,7 +1129,7 @@ class VueElement extends BaseClass {
1112
1129
  * Only called when shadowRoot is false
1113
1130
  */
1114
1131
  _renderSlots() {
1115
- const outlets = (this._teleportTarget || this).querySelectorAll("slot");
1132
+ const outlets = this._getSlots();
1116
1133
  const scopeId = this._instance.type.__scopeId;
1117
1134
  for (let i = 0; i < outlets.length; i++) {
1118
1135
  const o = outlets[i];
@@ -1138,12 +1155,51 @@ class VueElement extends BaseClass {
1138
1155
  parent.removeChild(o);
1139
1156
  }
1140
1157
  }
1158
+ /**
1159
+ * @internal
1160
+ */
1161
+ _getSlots() {
1162
+ const roots = [this];
1163
+ if (this._teleportTargets) {
1164
+ roots.push(...this._teleportTargets);
1165
+ }
1166
+ const slots = /* @__PURE__ */ new Set();
1167
+ for (const root of roots) {
1168
+ const found = root.querySelectorAll("slot");
1169
+ for (let i = 0; i < found.length; i++) {
1170
+ slots.add(found[i]);
1171
+ }
1172
+ }
1173
+ return Array.from(slots);
1174
+ }
1141
1175
  /**
1142
1176
  * @internal
1143
1177
  */
1144
1178
  _injectChildStyle(comp) {
1145
1179
  this._applyStyles(comp.styles, comp);
1146
1180
  }
1181
+ /**
1182
+ * @internal
1183
+ */
1184
+ _beginPatch() {
1185
+ this._patching = true;
1186
+ this._dirty = false;
1187
+ }
1188
+ /**
1189
+ * @internal
1190
+ */
1191
+ _endPatch() {
1192
+ this._patching = false;
1193
+ if (this._dirty && this._instance) {
1194
+ this._update();
1195
+ }
1196
+ }
1197
+ /**
1198
+ * @internal
1199
+ */
1200
+ _hasShadowRoot() {
1201
+ return this._def.shadowRoot !== false;
1202
+ }
1147
1203
  /**
1148
1204
  * @internal
1149
1205
  */
@@ -1206,8 +1262,8 @@ function useCssModule(name = "$style") {
1206
1262
 
1207
1263
  const positionMap = /* @__PURE__ */ new WeakMap();
1208
1264
  const newPositionMap = /* @__PURE__ */ new WeakMap();
1209
- const moveCbKey = Symbol("_moveCb");
1210
- const enterCbKey = Symbol("_enterCb");
1265
+ const moveCbKey = /* @__PURE__ */ Symbol("_moveCb");
1266
+ const enterCbKey = /* @__PURE__ */ Symbol("_enterCb");
1211
1267
  const decorate = (t) => {
1212
1268
  delete t.props.mode;
1213
1269
  return t;
@@ -1239,7 +1295,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
1239
1295
  prevChildren.forEach(callPendingCbs);
1240
1296
  prevChildren.forEach(recordPosition);
1241
1297
  const movedChildren = prevChildren.filter(applyTranslation);
1242
- forceReflow();
1298
+ forceReflow(instance.vnode.el);
1243
1299
  movedChildren.forEach((c) => {
1244
1300
  const el = c.el;
1245
1301
  const style = el.style;
@@ -1249,7 +1305,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
1249
1305
  if (e && e.target !== el) {
1250
1306
  return;
1251
1307
  }
1252
- if (!e || /transform$/.test(e.propertyName)) {
1308
+ if (!e || e.propertyName.endsWith("transform")) {
1253
1309
  el.removeEventListener("transitionend", cb);
1254
1310
  el[moveCbKey] = null;
1255
1311
  removeTransitionClass(el, moveClass);
@@ -1278,10 +1334,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
1278
1334
  instance
1279
1335
  )
1280
1336
  );
1281
- positionMap.set(
1282
- child,
1283
- child.el.getBoundingClientRect()
1284
- );
1337
+ positionMap.set(child, getPosition(child.el));
1285
1338
  }
1286
1339
  }
1287
1340
  }
@@ -1312,7 +1365,7 @@ function callPendingCbs(c) {
1312
1365
  }
1313
1366
  }
1314
1367
  function recordPosition(c) {
1315
- newPositionMap.set(c, c.el.getBoundingClientRect());
1368
+ newPositionMap.set(c, getPosition(c.el));
1316
1369
  }
1317
1370
  function applyTranslation(c) {
1318
1371
  const oldPos = positionMap.get(c);
@@ -1320,12 +1373,29 @@ function applyTranslation(c) {
1320
1373
  const dx = oldPos.left - newPos.left;
1321
1374
  const dy = oldPos.top - newPos.top;
1322
1375
  if (dx || dy) {
1323
- const s = c.el.style;
1324
- s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1376
+ const el = c.el;
1377
+ const s = el.style;
1378
+ const rect = el.getBoundingClientRect();
1379
+ let scaleX = 1;
1380
+ let scaleY = 1;
1381
+ if (el.offsetWidth) scaleX = rect.width / el.offsetWidth;
1382
+ if (el.offsetHeight) scaleY = rect.height / el.offsetHeight;
1383
+ if (!Number.isFinite(scaleX) || scaleX === 0) scaleX = 1;
1384
+ if (!Number.isFinite(scaleY) || scaleY === 0) scaleY = 1;
1385
+ if (Math.abs(scaleX - 1) < 0.01) scaleX = 1;
1386
+ if (Math.abs(scaleY - 1) < 0.01) scaleY = 1;
1387
+ s.transform = s.webkitTransform = `translate(${dx / scaleX}px,${dy / scaleY}px)`;
1325
1388
  s.transitionDuration = "0s";
1326
1389
  return c;
1327
1390
  }
1328
1391
  }
1392
+ function getPosition(el) {
1393
+ const rect = el.getBoundingClientRect();
1394
+ return {
1395
+ left: rect.left,
1396
+ top: rect.top
1397
+ };
1398
+ }
1329
1399
  function hasCSSTransform(el, root, moveClass) {
1330
1400
  const clone = el.cloneNode();
1331
1401
  const _vtc = el[vtcKey];
@@ -1357,25 +1427,23 @@ function onCompositionEnd(e) {
1357
1427
  target.dispatchEvent(new Event("input"));
1358
1428
  }
1359
1429
  }
1360
- const assignKey = Symbol("_assign");
1430
+ const assignKey = /* @__PURE__ */ Symbol("_assign");
1431
+ function castValue(value, trim, number) {
1432
+ if (trim) value = value.trim();
1433
+ if (number) value = shared.looseToNumber(value);
1434
+ return value;
1435
+ }
1361
1436
  const vModelText = {
1362
1437
  created(el, { modifiers: { lazy, trim, number } }, vnode) {
1363
1438
  el[assignKey] = getModelAssigner(vnode);
1364
1439
  const castToNumber = number || vnode.props && vnode.props.type === "number";
1365
1440
  addEventListener(el, lazy ? "change" : "input", (e) => {
1366
1441
  if (e.target.composing) return;
1367
- let domValue = el.value;
1368
- if (trim) {
1369
- domValue = domValue.trim();
1370
- }
1371
- if (castToNumber) {
1372
- domValue = shared.looseToNumber(domValue);
1373
- }
1374
- el[assignKey](domValue);
1442
+ el[assignKey](castValue(el.value, trim, castToNumber));
1375
1443
  });
1376
- if (trim) {
1444
+ if (trim || castToNumber) {
1377
1445
  addEventListener(el, "change", () => {
1378
- el.value = el.value.trim();
1446
+ el.value = castValue(el.value, trim, castToNumber);
1379
1447
  });
1380
1448
  }
1381
1449
  if (!lazy) {
@@ -1638,15 +1706,16 @@ const modifierGuards = {
1638
1706
  exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1639
1707
  };
1640
1708
  const withModifiers = (fn, modifiers) => {
1709
+ if (!fn) return fn;
1641
1710
  const cache = fn._withMods || (fn._withMods = {});
1642
1711
  const cacheKey = modifiers.join(".");
1643
- return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
1712
+ return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
1644
1713
  for (let i = 0; i < modifiers.length; i++) {
1645
1714
  const guard = modifierGuards[modifiers[i]];
1646
1715
  if (guard && guard(event, modifiers)) return;
1647
1716
  }
1648
1717
  return fn(event, ...args);
1649
- });
1718
+ }));
1650
1719
  };
1651
1720
  const keyNames = {
1652
1721
  esc: "escape",
@@ -1660,7 +1729,7 @@ const keyNames = {
1660
1729
  const withKeys = (fn, modifiers) => {
1661
1730
  const cache = fn._withKeys || (fn._withKeys = {});
1662
1731
  const cacheKey = modifiers.join(".");
1663
- return cache[cacheKey] || (cache[cacheKey] = (event) => {
1732
+ return cache[cacheKey] || (cache[cacheKey] = ((event) => {
1664
1733
  if (!("key" in event)) {
1665
1734
  return;
1666
1735
  }
@@ -1670,7 +1739,7 @@ const withKeys = (fn, modifiers) => {
1670
1739
  )) {
1671
1740
  return fn(event);
1672
1741
  }
1673
- });
1742
+ }));
1674
1743
  };
1675
1744
 
1676
1745
  const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
@@ -1684,13 +1753,13 @@ function ensureHydrationRenderer() {
1684
1753
  enabledHydration = true;
1685
1754
  return renderer;
1686
1755
  }
1687
- const render = (...args) => {
1756
+ const render = ((...args) => {
1688
1757
  ensureRenderer().render(...args);
1689
- };
1690
- const hydrate = (...args) => {
1758
+ });
1759
+ const hydrate = ((...args) => {
1691
1760
  ensureHydrationRenderer().hydrate(...args);
1692
- };
1693
- const createApp = (...args) => {
1761
+ });
1762
+ const createApp = ((...args) => {
1694
1763
  const app = ensureRenderer().createApp(...args);
1695
1764
  {
1696
1765
  injectNativeTagCheck(app);
@@ -1715,8 +1784,8 @@ const createApp = (...args) => {
1715
1784
  return proxy;
1716
1785
  };
1717
1786
  return app;
1718
- };
1719
- const createSSRApp = (...args) => {
1787
+ });
1788
+ const createSSRApp = ((...args) => {
1720
1789
  const app = ensureHydrationRenderer().createApp(...args);
1721
1790
  {
1722
1791
  injectNativeTagCheck(app);
@@ -1730,7 +1799,7 @@ const createSSRApp = (...args) => {
1730
1799
  }
1731
1800
  };
1732
1801
  return app;
1733
- };
1802
+ });
1734
1803
  function resolveRootNamespace(container) {
1735
1804
  if (container instanceof SVGElement) {
1736
1805
  return "svg";
@@ -1809,6 +1878,8 @@ exports.defineCustomElement = defineCustomElement;
1809
1878
  exports.defineSSRCustomElement = defineSSRCustomElement;
1810
1879
  exports.hydrate = hydrate;
1811
1880
  exports.initDirectivesForSSR = initDirectivesForSSR;
1881
+ exports.nodeOps = nodeOps;
1882
+ exports.patchProp = patchProp;
1812
1883
  exports.render = render;
1813
1884
  exports.rendererOptions = rendererOptions;
1814
1885
  exports.useCssModule = useCssModule;