diff --git a/src/undom.js b/src/undom.js index 71d7fa8..74d4a88 100644 --- a/src/undom.js +++ b/src/undom.js @@ -51,21 +51,24 @@ export default function undom() { } appendChild(child) { this.insertBefore(child); + return child; } insertBefore(child, ref) { child.remove(); child.parentNode = this; - if (!ref) this.childNodes.push(child); - else splice(this.childNodes, ref, child); + !ref ? this.childNodes.push(child) : splice(this.childNodes, ref, child); + return child; } replaceChild(child, ref) { if (ref.parentNode===this) { this.insertBefore(child, ref); ref.remove(); + return ref; } } removeChild(child) { splice(this.childNodes, child); + return child; } remove() { if (this.parentNode) this.parentNode.removeChild(this);