From 1cc8dfdff4f3bcb8ce4788737d9d42870549b477 Mon Sep 17 00:00:00 2001 From: Andy Johnson Date: Mon, 2 Oct 2017 11:22:12 -0700 Subject: [PATCH 1/3] insertBefore should return childNode that was inserted, to match dom api. --- src/undom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/undom.js b/src/undom.js index 71d7fa8..2f7b776 100644 --- a/src/undom.js +++ b/src/undom.js @@ -55,8 +55,8 @@ export default function undom() { 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) { From a460f0a14c64ae4a125d1c1264f47629636514ad Mon Sep 17 00:00:00 2001 From: Andy Johnson Date: Mon, 2 Oct 2017 11:25:11 -0700 Subject: [PATCH 2/3] correcting whitespace --- src/undom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/undom.js b/src/undom.js index 2f7b776..c2a7491 100644 --- a/src/undom.js +++ b/src/undom.js @@ -56,7 +56,7 @@ export default function undom() { child.remove(); child.parentNode = this; !ref ? this.childNodes.push(child) : splice(this.childNodes, ref, child); - return child; + return child; } replaceChild(child, ref) { if (ref.parentNode===this) { From 6408cdafb19df268f6a7e78010d01a282a4a2b67 Mon Sep 17 00:00:00 2001 From: Andy Johnson Date: Mon, 2 Oct 2017 11:54:26 -0700 Subject: [PATCH 3/3] missing returns for appendChild, replaceChild, removeChild --- src/undom.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/undom.js b/src/undom.js index c2a7491..74d4a88 100644 --- a/src/undom.js +++ b/src/undom.js @@ -51,6 +51,7 @@ export default function undom() { } appendChild(child) { this.insertBefore(child); + return child; } insertBefore(child, ref) { child.remove(); @@ -62,10 +63,12 @@ export default function undom() { 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);