@lvce-editor/renderer-process 24.4.0 → 24.5.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.
@@ -1167,12 +1167,14 @@ const SetReferenceNodeUid = 11;
1167
1167
  const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
1168
1168
  const events = getEventListenerMap(id) || eventMap;
1169
1169
  let $Current = $Element;
1170
+ let hasAppliedMutation = false;
1170
1171
  for (let patchIndex = 0; patchIndex < patches.length; patchIndex++) {
1171
1172
  const patch = patches[patchIndex];
1172
1173
  try {
1173
1174
  switch (patch.type) {
1174
1175
  case Add:
1175
1176
  add($Current, patch.nodes, events);
1177
+ hasAppliedMutation = true;
1176
1178
  break;
1177
1179
  case NavigateChild:
1178
1180
  {
@@ -1217,7 +1219,11 @@ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
1217
1219
  });
1218
1220
  return;
1219
1221
  }
1220
- $Current = $Parent.childNodes[patch.index];
1222
+ let $Sibling = $Parent.childNodes[patch.index];
1223
+ if (!$Sibling && !hasAppliedMutation && $Current !== $Element) {
1224
+ $Sibling = $Element.childNodes[patch.index];
1225
+ }
1226
+ $Current = $Sibling;
1221
1227
  if (!$Current) {
1222
1228
  console.error('Cannot navigate to sibling: sibling not found at index', {
1223
1229
  $Parent,
@@ -1230,15 +1236,19 @@ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
1230
1236
  }
1231
1237
  case RemoveAttribute:
1232
1238
  removeAttribute($Current, patch.key);
1239
+ hasAppliedMutation = true;
1233
1240
  break;
1234
1241
  case RemoveChild:
1235
1242
  removeChild($Current, patch.index);
1243
+ hasAppliedMutation = true;
1236
1244
  break;
1237
1245
  case Replace:
1238
1246
  $Current = replace($Current, patch.nodes, events);
1247
+ hasAppliedMutation = true;
1239
1248
  break;
1240
1249
  case SetAttribute:
1241
1250
  setProp($Current, patch.key, patch.value, events);
1251
+ hasAppliedMutation = true;
1242
1252
  break;
1243
1253
  case SetReferenceNodeUid:
1244
1254
  {
@@ -1255,10 +1265,12 @@ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
1255
1265
  // @ts-ignore
1256
1266
  $Current.replaceWith($NewNode);
1257
1267
  $Current = $NewNode;
1268
+ hasAppliedMutation = true;
1258
1269
  break;
1259
1270
  }
1260
1271
  case SetText:
1261
1272
  setText$3($Current, patch.value);
1273
+ hasAppliedMutation = true;
1262
1274
  break;
1263
1275
  default:
1264
1276
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "24.4.0",
3
+ "version": "24.5.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"