Skip to content

Commit 92c9808

Browse files
andyrjdevelopit
authored andcommitted
Missing returns for Node.{insertBefore, appendChild, replaceChild, removeChild} (#15)
* insertBefore should return childNode that was inserted, to match dom api. * correcting whitespace * missing returns for appendChild, replaceChild, removeChild
1 parent 896359d commit 92c9808

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/undom.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,24 @@ export default function undom() {
5151
}
5252
appendChild(child) {
5353
this.insertBefore(child);
54+
return child;
5455
}
5556
insertBefore(child, ref) {
5657
child.remove();
5758
child.parentNode = this;
58-
if (!ref) this.childNodes.push(child);
59-
else splice(this.childNodes, ref, child);
59+
!ref ? this.childNodes.push(child) : splice(this.childNodes, ref, child);
60+
return child;
6061
}
6162
replaceChild(child, ref) {
6263
if (ref.parentNode===this) {
6364
this.insertBefore(child, ref);
6465
ref.remove();
66+
return ref;
6567
}
6668
}
6769
removeChild(child) {
6870
splice(this.childNodes, child);
71+
return child;
6972
}
7073
remove() {
7174
if (this.parentNode) this.parentNode.removeChild(this);

0 commit comments

Comments
 (0)