Skip to content

Commit

Permalink
Missing returns for Node.{insertBefore, appendChild, replaceChild, re…
Browse files Browse the repository at this point in the history
…moveChild} (#15)

* insertBefore should return childNode that was inserted, to match dom api.

* correcting whitespace

* missing returns for appendChild, replaceChild, removeChild
  • Loading branch information
andyrj authored and developit committed Jan 22, 2018
1 parent 896359d commit 92c9808
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/undom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 92c9808

Please sign in to comment.