@vue/runtime-dom 3.6.0-rc.11 → 3.6.0-rc.12

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-rc.11
2
+ * @vue/runtime-dom v3.6.0-rc.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -470,7 +470,7 @@ function patchStyle(el, prev, next) {
470
470
  else el.removeAttribute("style");
471
471
  }
472
472
  if (vShowOriginalDisplay in el) {
473
- el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
473
+ if (!isCssString || prev !== next) el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
474
474
  if (el[vShowHidden]) style.display = "none";
475
475
  }
476
476
  }
@@ -777,7 +777,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
777
777
  this._resolveProps(def);
778
778
  if (this.shadowRoot) this._applyStyles(styles);
779
779
  else if (!!(process.env.NODE_ENV !== "production") && styles) warn("Custom element style injection is not supported when using shadowRoot: false");
780
- this._mountComponent(def);
780
+ if (this._connected) this._mountComponent(def);
781
781
  };
782
782
  const asyncDef = this._def.__asyncLoader;
783
783
  if (asyncDef) {
@@ -1101,6 +1101,7 @@ const positionMap = /* @__PURE__ */ new WeakMap();
1101
1101
  const newPositionMap = /* @__PURE__ */ new WeakMap();
1102
1102
  const moveCbKey = Symbol("_moveCb");
1103
1103
  const enterCbKey = Symbol("_enterCb");
1104
+ const pendingGroups = /* @__PURE__ */ new WeakMap();
1104
1105
  /**
1105
1106
  * Wrap logic that modifies TransitionGroup properties in a function
1106
1107
  * so that it can be annotated as pure
@@ -1120,15 +1121,24 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1120
1121
  const state = useTransitionState();
1121
1122
  let prevChildren;
1122
1123
  let children;
1124
+ let origins;
1125
+ let moves;
1126
+ const willMove = () => {
1127
+ if (moves === void 0) moves = prevChildren.length > 0 && hasCSSTransform(prevChildren[0].el, instance.vnode.el, resolveMoveClass(props));
1128
+ return moves;
1129
+ };
1123
1130
  onUpdated(() => {
1124
- if (!prevChildren.length) return;
1125
- const moveClass = props.moveClass || `${props.name || "v"}-move`;
1126
- if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
1131
+ pendingGroups.delete(instance);
1132
+ if (!willMove()) {
1127
1133
  prevChildren = [];
1134
+ origins = void 0;
1128
1135
  return;
1129
1136
  }
1137
+ const moveClass = resolveMoveClass(props);
1130
1138
  prevChildren.forEach((vnode) => callPendingCbs(vnode.el));
1131
- prevChildren.forEach(recordPosition);
1139
+ const shift = origins && getOriginShift(origins, instance.vnode.el);
1140
+ origins = void 0;
1141
+ prevChildren.forEach((c) => recordPosition(c, shift));
1132
1142
  const movedChildren = prevChildren.filter(applyTranslation);
1133
1143
  forceReflow(instance.vnode.el);
1134
1144
  movedChildren.forEach((c) => {
@@ -1142,6 +1152,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1142
1152
  const cssTransitionProps = resolveTransitionProps(rawProps);
1143
1153
  let tag = rawProps.tag || Fragment;
1144
1154
  prevChildren = [];
1155
+ moves = void 0;
1145
1156
  if (children) for (let i = 0; i < children.length; i++) {
1146
1157
  const child = children[i];
1147
1158
  if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
@@ -1156,6 +1167,14 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1156
1167
  if (child.key != null) setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
1157
1168
  else if (!!(process.env.NODE_ENV !== "production") && child.type !== Text) warn(`<TransitionGroup> children must be keyed.`);
1158
1169
  }
1170
+ if (prevChildren.length) {
1171
+ const root = instance.vnode.el;
1172
+ origins = getOrigins(instance, root);
1173
+ pendingGroups.set(instance, {
1174
+ root,
1175
+ willMove
1176
+ });
1177
+ }
1159
1178
  return createVNode(tag, null, children);
1160
1179
  };
1161
1180
  }
@@ -1164,8 +1183,11 @@ function callPendingCbs(el) {
1164
1183
  if (el[moveCbKey]) el[moveCbKey]();
1165
1184
  if (el[enterCbKey]) el[enterCbKey]();
1166
1185
  }
1167
- function recordPosition(c) {
1168
- newPositionMap.set(c, getPosition(c.el));
1186
+ function resolveMoveClass(props) {
1187
+ return props.moveClass || `${props.name || "v"}-move`;
1188
+ }
1189
+ function recordPosition(c, shift) {
1190
+ newPositionMap.set(c, getPosition(c.el, shift));
1169
1191
  }
1170
1192
  function applyTranslation(c) {
1171
1193
  if (baseApplyTranslation(positionMap.get(c), newPositionMap.get(c), c.el)) return c;
@@ -1190,13 +1212,36 @@ function baseApplyTranslation(oldPos, newPos, el) {
1190
1212
  }
1191
1213
  return false;
1192
1214
  }
1193
- function getPosition(el) {
1215
+ function getPosition(el, shift) {
1194
1216
  const rect = el.getBoundingClientRect();
1195
1217
  return {
1196
- left: rect.left,
1197
- top: rect.top
1218
+ left: rect.left - (shift ? shift.left : 0),
1219
+ top: rect.top - (shift ? shift.top : 0)
1198
1220
  };
1199
1221
  }
1222
+ function getOrigins(instance, root) {
1223
+ let origins;
1224
+ for (let group = instance.parent; group; group = group.parent) {
1225
+ const pending = pendingGroups.get(group);
1226
+ if (pending) {
1227
+ const item = findItem(pending.root, root);
1228
+ if (item) (origins || (origins = [])).push(extend(getPosition(item), {
1229
+ item,
1230
+ willMove: pending.willMove
1231
+ }));
1232
+ }
1233
+ }
1234
+ return origins;
1235
+ }
1236
+ function findItem(root, node) {
1237
+ const container = root.nodeType === 1 ? root : root.parentNode;
1238
+ while (node && node.parentNode !== container) node = node.parentNode;
1239
+ if (node && node.nodeType === 1) return node;
1240
+ }
1241
+ function getOriginShift(origins, root) {
1242
+ const origin = origins.find((o) => o.willMove() && o.item.contains(root));
1243
+ return origin && getPosition(origin.item, origin);
1244
+ }
1200
1245
  function hasCSSTransform(el, root, moveClass) {
1201
1246
  const clone = el.cloneNode();
1202
1247
  const _vtc = el[vtcKey];
@@ -1677,4 +1722,4 @@ const initDirectivesForSSR = () => {
1677
1722
  }
1678
1723
  };
1679
1724
  //#endregion
1680
- export { Transition, TransitionGroup, TransitionPropsValidators, VueElement, VueElementBase, baseApplyTranslation, callPendingCbs, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureHydrationRenderer, ensureRenderer, forceReflow, handleMovedChildren, hasCSSTransform, hydrate, initDirectivesForSSR, nodeOps, normalizeContainer, parseEventName, patchClass, patchProp, patchStyle, render, resolveTransitionProps, setVarsOnNode, shouldSetAsProp, shouldSetAsPropForVueCE, svgNS, unsafeToTrustedHTML, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers, xlinkNS };
1725
+ export { Transition, TransitionGroup, TransitionPropsValidators, VueElement, VueElementBase, baseApplyTranslation, callPendingCbs, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureHydrationRenderer, ensureRenderer, forceReflow, getOrigins as getTransitionGroupOrigins, getPosition as getTransitionGroupPosition, getOriginShift as getTransitionGroupShift, handleMovedChildren, hasCSSTransform, hydrate, initDirectivesForSSR, nodeOps, normalizeContainer, parseEventName, patchClass, patchProp, patchStyle, pendingGroups as pendingTransitionGroups, render, resolveTransitionProps, setVarsOnNode, shouldSetAsProp, shouldSetAsPropForVueCE, svgNS, unsafeToTrustedHTML, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers, xlinkNS };