@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.
- package/dist/index.js +8 -11
- 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
|
|
725
|
-
|
|
726
|
-
if (!$
|
|
727
|
-
//
|
|
728
|
-
|
|
729
|
-
$
|
|
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($
|
|
735
|
-
return $
|
|
731
|
+
$Element.replaceWith($NewNode);
|
|
732
|
+
return $NewNode;
|
|
736
733
|
};
|
|
737
734
|
|
|
738
735
|
const SetText = 1;
|