@lvce-editor/virtual-dom 6.4.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 +12 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -709,8 +709,10 @@ const setText = ($Element, value) => {
|
|
|
709
709
|
$Element.nodeValue = value;
|
|
710
710
|
};
|
|
711
711
|
const removeChild = ($Element, index) => {
|
|
712
|
-
const $Child = $Element.
|
|
713
|
-
$Child
|
|
712
|
+
const $Child = $Element.childNodes[index];
|
|
713
|
+
if ($Child) {
|
|
714
|
+
$Child.remove();
|
|
715
|
+
}
|
|
714
716
|
};
|
|
715
717
|
const add$1 = ($Element, nodes, eventMap = {}) => {
|
|
716
718
|
renderInternal($Element, nodes, eventMap, eventMap);
|
|
@@ -719,18 +721,15 @@ const replace = ($Element, nodes, eventMap = {}) => {
|
|
|
719
721
|
// Create a temporary container to render the new nodes
|
|
720
722
|
const $Temp = document.createElement('div');
|
|
721
723
|
renderInternal($Temp, nodes, eventMap, eventMap);
|
|
722
|
-
// Replace the current element with the new
|
|
723
|
-
|
|
724
|
-
if (!$
|
|
725
|
-
//
|
|
726
|
-
|
|
727
|
-
$
|
|
728
|
-
while ($Temp.firstChild) {
|
|
729
|
-
$NewElement.append($Temp.firstChild);
|
|
730
|
-
}
|
|
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;
|
|
731
730
|
}
|
|
732
|
-
$Element.replaceWith($
|
|
733
|
-
return $
|
|
731
|
+
$Element.replaceWith($NewNode);
|
|
732
|
+
return $NewNode;
|
|
734
733
|
};
|
|
735
734
|
|
|
736
735
|
const SetText = 1;
|