@vue/runtime-dom 3.6.0-rc.10 → 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.10
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
  **/
@@ -398,7 +398,7 @@ function patchStyle(el, prev, next) {
398
398
  else el.removeAttribute("style");
399
399
  }
400
400
  if (vShowOriginalDisplay in el) {
401
- el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
401
+ if (!isCssString || prev !== next) el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
402
402
  if (el[vShowHidden]) style.display = "none";
403
403
  }
404
404
  }
@@ -703,7 +703,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
703
703
  this._resolveProps(def);
704
704
  if (this.shadowRoot) this._applyStyles(styles);
705
705
  else if (styles) (0, _vue_runtime_core.warn)("Custom element style injection is not supported when using shadowRoot: false");
706
- this._mountComponent(def);
706
+ if (this._connected) this._mountComponent(def);
707
707
  };
708
708
  const asyncDef = this._def.__asyncLoader;
709
709
  if (asyncDef) {
@@ -1021,6 +1021,7 @@ const positionMap = /* @__PURE__ */ new WeakMap();
1021
1021
  const newPositionMap = /* @__PURE__ */ new WeakMap();
1022
1022
  const moveCbKey = Symbol("_moveCb");
1023
1023
  const enterCbKey = Symbol("_enterCb");
1024
+ const pendingGroups = /* @__PURE__ */ new WeakMap();
1024
1025
  /**
1025
1026
  * Wrap logic that modifies TransitionGroup properties in a function
1026
1027
  * so that it can be annotated as pure
@@ -1040,15 +1041,24 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1040
1041
  const state = (0, _vue_runtime_core.useTransitionState)();
1041
1042
  let prevChildren;
1042
1043
  let children;
1044
+ let origins;
1045
+ let moves;
1046
+ const willMove = () => {
1047
+ if (moves === void 0) moves = prevChildren.length > 0 && hasCSSTransform(prevChildren[0].el, instance.vnode.el, resolveMoveClass(props));
1048
+ return moves;
1049
+ };
1043
1050
  (0, _vue_runtime_core.onUpdated)(() => {
1044
- if (!prevChildren.length) return;
1045
- const moveClass = props.moveClass || `${props.name || "v"}-move`;
1046
- if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
1051
+ pendingGroups.delete(instance);
1052
+ if (!willMove()) {
1047
1053
  prevChildren = [];
1054
+ origins = void 0;
1048
1055
  return;
1049
1056
  }
1057
+ const moveClass = resolveMoveClass(props);
1050
1058
  prevChildren.forEach((vnode) => callPendingCbs(vnode.el));
1051
- prevChildren.forEach(recordPosition);
1059
+ const shift = origins && getOriginShift(origins, instance.vnode.el);
1060
+ origins = void 0;
1061
+ prevChildren.forEach((c) => recordPosition(c, shift));
1052
1062
  const movedChildren = prevChildren.filter(applyTranslation);
1053
1063
  forceReflow(instance.vnode.el);
1054
1064
  movedChildren.forEach((c) => {
@@ -1062,6 +1072,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1062
1072
  const cssTransitionProps = resolveTransitionProps(rawProps);
1063
1073
  let tag = rawProps.tag || _vue_runtime_core.Fragment;
1064
1074
  prevChildren = [];
1075
+ moves = void 0;
1065
1076
  if (children) for (let i = 0; i < children.length; i++) {
1066
1077
  const child = children[i];
1067
1078
  if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
@@ -1076,6 +1087,14 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1076
1087
  if (child.key != null) (0, _vue_runtime_core.setTransitionHooks)(child, (0, _vue_runtime_core.resolveTransitionHooks)(child, cssTransitionProps, state, instance));
1077
1088
  else if (child.type !== _vue_runtime_core.Text) (0, _vue_runtime_core.warn)(`<TransitionGroup> children must be keyed.`);
1078
1089
  }
1090
+ if (prevChildren.length) {
1091
+ const root = instance.vnode.el;
1092
+ origins = getOrigins(instance, root);
1093
+ pendingGroups.set(instance, {
1094
+ root,
1095
+ willMove
1096
+ });
1097
+ }
1079
1098
  return (0, _vue_runtime_core.createVNode)(tag, null, children);
1080
1099
  };
1081
1100
  }
@@ -1084,8 +1103,11 @@ function callPendingCbs(el) {
1084
1103
  if (el[moveCbKey]) el[moveCbKey]();
1085
1104
  if (el[enterCbKey]) el[enterCbKey]();
1086
1105
  }
1087
- function recordPosition(c) {
1088
- newPositionMap.set(c, getPosition(c.el));
1106
+ function resolveMoveClass(props) {
1107
+ return props.moveClass || `${props.name || "v"}-move`;
1108
+ }
1109
+ function recordPosition(c, shift) {
1110
+ newPositionMap.set(c, getPosition(c.el, shift));
1089
1111
  }
1090
1112
  function applyTranslation(c) {
1091
1113
  if (baseApplyTranslation(positionMap.get(c), newPositionMap.get(c), c.el)) return c;
@@ -1110,13 +1132,36 @@ function baseApplyTranslation(oldPos, newPos, el) {
1110
1132
  }
1111
1133
  return false;
1112
1134
  }
1113
- function getPosition(el) {
1135
+ function getPosition(el, shift) {
1114
1136
  const rect = el.getBoundingClientRect();
1115
1137
  return {
1116
- left: rect.left,
1117
- top: rect.top
1138
+ left: rect.left - (shift ? shift.left : 0),
1139
+ top: rect.top - (shift ? shift.top : 0)
1118
1140
  };
1119
1141
  }
1142
+ function getOrigins(instance, root) {
1143
+ let origins;
1144
+ for (let group = instance.parent; group; group = group.parent) {
1145
+ const pending = pendingGroups.get(group);
1146
+ if (pending) {
1147
+ const item = findItem(pending.root, root);
1148
+ if (item) (origins || (origins = [])).push((0, _vue_shared.extend)(getPosition(item), {
1149
+ item,
1150
+ willMove: pending.willMove
1151
+ }));
1152
+ }
1153
+ }
1154
+ return origins;
1155
+ }
1156
+ function findItem(root, node) {
1157
+ const container = root.nodeType === 1 ? root : root.parentNode;
1158
+ while (node && node.parentNode !== container) node = node.parentNode;
1159
+ if (node && node.nodeType === 1) return node;
1160
+ }
1161
+ function getOriginShift(origins, root) {
1162
+ const origin = origins.find((o) => o.willMove() && o.item.contains(root));
1163
+ return origin && getPosition(origin.item, origin);
1164
+ }
1120
1165
  function hasCSSTransform(el, root, moveClass) {
1121
1166
  const clone = el.cloneNode();
1122
1167
  const _vtc = el[vtcKey];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.6.0-rc.10
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
  **/
@@ -394,7 +394,7 @@ function patchStyle(el, prev, next) {
394
394
  else el.removeAttribute("style");
395
395
  }
396
396
  if (vShowOriginalDisplay in el) {
397
- el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
397
+ if (!isCssString || prev !== next) el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
398
398
  if (el[vShowHidden]) style.display = "none";
399
399
  }
400
400
  }
@@ -689,7 +689,7 @@ var VueElementBase = class VueElementBase extends BaseClass {
689
689
  this._numberProps = numberProps;
690
690
  this._resolveProps(def);
691
691
  if (this.shadowRoot) this._applyStyles(styles);
692
- this._mountComponent(def);
692
+ if (this._connected) this._mountComponent(def);
693
693
  };
694
694
  const asyncDef = this._def.__asyncLoader;
695
695
  if (asyncDef) {
@@ -962,6 +962,7 @@ const positionMap = /* @__PURE__ */ new WeakMap();
962
962
  const newPositionMap = /* @__PURE__ */ new WeakMap();
963
963
  const moveCbKey = Symbol("_moveCb");
964
964
  const enterCbKey = Symbol("_enterCb");
965
+ const pendingGroups = /* @__PURE__ */ new WeakMap();
965
966
  /**
966
967
  * Wrap logic that modifies TransitionGroup properties in a function
967
968
  * so that it can be annotated as pure
@@ -981,15 +982,24 @@ const TransitionGroup = /* @__PURE__ */ decorate({
981
982
  const state = (0, _vue_runtime_core.useTransitionState)();
982
983
  let prevChildren;
983
984
  let children;
985
+ let origins;
986
+ let moves;
987
+ const willMove = () => {
988
+ if (moves === void 0) moves = prevChildren.length > 0 && hasCSSTransform(prevChildren[0].el, instance.vnode.el, resolveMoveClass(props));
989
+ return moves;
990
+ };
984
991
  (0, _vue_runtime_core.onUpdated)(() => {
985
- if (!prevChildren.length) return;
986
- const moveClass = props.moveClass || `${props.name || "v"}-move`;
987
- if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
992
+ pendingGroups.delete(instance);
993
+ if (!willMove()) {
988
994
  prevChildren = [];
995
+ origins = void 0;
989
996
  return;
990
997
  }
998
+ const moveClass = resolveMoveClass(props);
991
999
  prevChildren.forEach((vnode) => callPendingCbs(vnode.el));
992
- prevChildren.forEach(recordPosition);
1000
+ const shift = origins && getOriginShift(origins, instance.vnode.el);
1001
+ origins = void 0;
1002
+ prevChildren.forEach((c) => recordPosition(c, shift));
993
1003
  const movedChildren = prevChildren.filter(applyTranslation);
994
1004
  forceReflow(instance.vnode.el);
995
1005
  movedChildren.forEach((c) => {
@@ -1003,6 +1013,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1003
1013
  const cssTransitionProps = resolveTransitionProps(rawProps);
1004
1014
  let tag = rawProps.tag || _vue_runtime_core.Fragment;
1005
1015
  prevChildren = [];
1016
+ moves = void 0;
1006
1017
  if (children) for (let i = 0; i < children.length; i++) {
1007
1018
  const child = children[i];
1008
1019
  if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
@@ -1016,6 +1027,14 @@ const TransitionGroup = /* @__PURE__ */ decorate({
1016
1027
  const child = children[i];
1017
1028
  if (child.key != null) (0, _vue_runtime_core.setTransitionHooks)(child, (0, _vue_runtime_core.resolveTransitionHooks)(child, cssTransitionProps, state, instance));
1018
1029
  }
1030
+ if (prevChildren.length) {
1031
+ const root = instance.vnode.el;
1032
+ origins = getOrigins(instance, root);
1033
+ pendingGroups.set(instance, {
1034
+ root,
1035
+ willMove
1036
+ });
1037
+ }
1019
1038
  return (0, _vue_runtime_core.createVNode)(tag, null, children);
1020
1039
  };
1021
1040
  }
@@ -1024,8 +1043,11 @@ function callPendingCbs(el) {
1024
1043
  if (el[moveCbKey]) el[moveCbKey]();
1025
1044
  if (el[enterCbKey]) el[enterCbKey]();
1026
1045
  }
1027
- function recordPosition(c) {
1028
- newPositionMap.set(c, getPosition(c.el));
1046
+ function resolveMoveClass(props) {
1047
+ return props.moveClass || `${props.name || "v"}-move`;
1048
+ }
1049
+ function recordPosition(c, shift) {
1050
+ newPositionMap.set(c, getPosition(c.el, shift));
1029
1051
  }
1030
1052
  function applyTranslation(c) {
1031
1053
  if (baseApplyTranslation(positionMap.get(c), newPositionMap.get(c), c.el)) return c;
@@ -1050,13 +1072,36 @@ function baseApplyTranslation(oldPos, newPos, el) {
1050
1072
  }
1051
1073
  return false;
1052
1074
  }
1053
- function getPosition(el) {
1075
+ function getPosition(el, shift) {
1054
1076
  const rect = el.getBoundingClientRect();
1055
1077
  return {
1056
- left: rect.left,
1057
- top: rect.top
1078
+ left: rect.left - (shift ? shift.left : 0),
1079
+ top: rect.top - (shift ? shift.top : 0)
1058
1080
  };
1059
1081
  }
1082
+ function getOrigins(instance, root) {
1083
+ let origins;
1084
+ for (let group = instance.parent; group; group = group.parent) {
1085
+ const pending = pendingGroups.get(group);
1086
+ if (pending) {
1087
+ const item = findItem(pending.root, root);
1088
+ if (item) (origins || (origins = [])).push((0, _vue_shared.extend)(getPosition(item), {
1089
+ item,
1090
+ willMove: pending.willMove
1091
+ }));
1092
+ }
1093
+ }
1094
+ return origins;
1095
+ }
1096
+ function findItem(root, node) {
1097
+ const container = root.nodeType === 1 ? root : root.parentNode;
1098
+ while (node && node.parentNode !== container) node = node.parentNode;
1099
+ if (node && node.nodeType === 1) return node;
1100
+ }
1101
+ function getOriginShift(origins, root) {
1102
+ const origin = origins.find((o) => o.willMove() && o.item.contains(root));
1103
+ return origin && getPosition(origin.item, origin);
1104
+ }
1060
1105
  function hasCSSTransform(el, root, moveClass) {
1061
1106
  const clone = el.cloneNode();
1062
1107
  const _vtc = el[vtcKey];