Skip to content

Commit de39d50

Browse files
committed
feat: improved handling of valueType outerHtml
1 parent bec6b7f commit de39d50

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/setValue.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,13 @@ const setValue = (el, value, dispatch) => {
116116
if (valueType == 'outerHTML') {
117117
let parentNode = el.parentNode;
118118
if (parentNode) {
119-
if (newElement.children[0]) {
120-
parentNode.replaceChild(newElement.children[0], el);
121-
}
122-
else {
119+
if (newElement.children.length > 0) {
120+
let fragment = document.createDocumentFragment();
121+
while (newElement.firstChild) {
122+
fragment.appendChild(newElement.firstChild);
123+
}
124+
parentNode.replaceChild(fragment, el);
125+
} else {
123126
parentNode.replaceChild(newElement, el);
124127
}
125128
}

0 commit comments

Comments
 (0)