diff --git a/src/generators/dom/mountChildren.ts b/src/generators/dom/mountChildren.ts index ba39d10403..3e032a5282 100644 --- a/src/generators/dom/mountChildren.ts +++ b/src/generators/dom/mountChildren.ts @@ -11,17 +11,9 @@ export default function mountChildren(node: Node, parentNode?: string) { if (consecutiveNodes.length === 0) return; if (parentNode) { - if (consecutiveNodes.length === 1) { - builder.addLine(`@append(${parentNode}, ${consecutiveNodes[0]});`); - } else { - builder.addLine(`@appendAll(${parentNode}, [${consecutiveNodes.join(', ')}]);`); - } + builder.addLine(`@append(${parentNode}, ${consecutiveNodes.join(', ')});`); } else { - if (consecutiveNodes.length === 1) { - builder.addLine(`@insert(#target, anchor, ${consecutiveNodes[0]});`); - } else { - builder.addLine(`@insertAll(#target, anchor, [${consecutiveNodes.join(', ')}]);`); - } + builder.addLine(`@insert(#target, anchor, ${consecutiveNodes.join(', ')});`); } consecutiveNodes = []; diff --git a/src/shared/dom.js b/src/shared/dom.js index e6754975c5..2d0f672dd4 100644 --- a/src/shared/dom.js +++ b/src/shared/dom.js @@ -1,32 +1,15 @@ -export function append(parent, child) { - parent.appendChild(child); -} - -export function appendAll(parent, children) { - for (var i = 0; i < children.length; i += 1) { - parent.appendChild(children[i]); +export function append(parent) { + for (var i = 1; i < arguments.length; i += 1) { + parent.appendChild(arguments[i]); } } -// TODO remove -export function appendNode(node, target) { - target.appendChild(node); -} - -export function insert(parent, next, child) { - parent.insertBefore(child, next); -} - -export function insertAll(parent, next, children) { - for (var i = 0; i < children.length; i += 1) { - parent.insertBefore(children[i], next); +export function insert(parent, next) { + for (var i = 2; i < arguments.length; i += 1) { + parent.insertBefore(arguments[i], next); } } -export function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - export function detachNode(node) { node.parentNode.removeChild(node); }