@lvce-editor/renderer-process 21.4.0 → 21.6.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.
@@ -695,8 +695,10 @@ const setText$3 = ($Element, value) => {
695
695
  $Element.nodeValue = value;
696
696
  };
697
697
  const removeChild = ($Element, index) => {
698
- const $Child = $Element.children[index];
699
- $Child.remove();
698
+ const $Child = $Element.childNodes[index];
699
+ if ($Child) {
700
+ $Child.remove();
701
+ }
700
702
  };
701
703
  const add$1 = ($Element, nodes, eventMap = {}) => {
702
704
  renderInternal($Element, nodes, eventMap, eventMap);
@@ -705,18 +707,15 @@ const replace = ($Element, nodes, eventMap = {}) => {
705
707
  // Create a temporary container to render the new nodes
706
708
  const $Temp = document.createElement('div');
707
709
  renderInternal($Temp, nodes, eventMap, eventMap);
708
- // Replace the current element with the new ones
709
- let $NewElement = $Temp.firstElementChild;
710
- if (!$NewElement) {
711
- // If no element was created (e.g., only text nodes), we need to create a wrapper
712
- // In this case, we create a div and move all children to it
713
- $NewElement = document.createElement('div');
714
- while ($Temp.firstChild) {
715
- $NewElement.append($Temp.firstChild);
716
- }
717
- }
718
- $Element.replaceWith($NewElement);
719
- return $NewElement;
710
+ // Replace the current element with the new node(s)
711
+ const $NewNode = $Temp.firstChild;
712
+ if (!$NewNode) {
713
+ // No node was created, just remove the old element
714
+ $Element.remove();
715
+ return $Element;
716
+ }
717
+ $Element.replaceWith($NewNode);
718
+ return $NewNode;
720
719
  };
721
720
  const SetText = 1;
722
721
  const Replace = 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "21.4.0",
3
+ "version": "21.6.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"