@lvce-editor/virtual-dom 8.8.0 → 8.9.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.
Files changed (2) hide show
  1. package/dist/index.js +10 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1133,12 +1133,20 @@ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
1133
1133
  break;
1134
1134
  case NavigateChild:
1135
1135
  {
1136
- const $Child = $Current.childNodes[patch.index];
1136
+ const $Children = $Current.childNodes;
1137
+ const $Child = $Children[patch.index];
1137
1138
  if (!$Child) {
1139
+ const nextPatch = patches[patchIndex + 1];
1140
+ if (nextPatch && nextPatch.type === Replace && patch.index === $Children.length) {
1141
+ const $Placeholder = document.createComment('virtual-dom-placeholder');
1142
+ $Current.append($Placeholder);
1143
+ $Current = $Placeholder;
1144
+ break;
1145
+ }
1138
1146
  console.error('Cannot navigate to child: child not found at index', {
1139
1147
  $Current,
1140
1148
  index: patch.index,
1141
- childCount: $Current.childNodes.length
1149
+ childCount: $Children.length
1142
1150
  });
1143
1151
  return;
1144
1152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "8.8.0",
3
+ "version": "8.9.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/virtual-dom.git"