@lvce-editor/virtual-dom 6.5.0 → 6.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.
Files changed (2) hide show
  1. package/dist/index.js +8 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -721,18 +721,15 @@ const replace = ($Element, nodes, eventMap = {}) => {
721
721
  // Create a temporary container to render the new nodes
722
722
  const $Temp = document.createElement('div');
723
723
  renderInternal($Temp, nodes, eventMap, eventMap);
724
- // Replace the current element with the new ones
725
- let $NewElement = $Temp.firstElementChild;
726
- if (!$NewElement) {
727
- // If no element was created (e.g., only text nodes), we need to create a wrapper
728
- // In this case, we create a div and move all children to it
729
- $NewElement = document.createElement('div');
730
- while ($Temp.firstChild) {
731
- $NewElement.append($Temp.firstChild);
732
- }
724
+ // Replace the current element with the new node(s)
725
+ const $NewNode = $Temp.firstChild;
726
+ if (!$NewNode) {
727
+ // No node was created, just remove the old element
728
+ $Element.remove();
729
+ return $Element;
733
730
  }
734
- $Element.replaceWith($NewElement);
735
- return $NewElement;
731
+ $Element.replaceWith($NewNode);
732
+ return $NewNode;
736
733
  };
737
734
 
738
735
  const SetText = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "6.5.0",
3
+ "version": "6.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/virtual-dom.git"