Skip to content
Browse files

mutation methods should return DOM nodes

  • Loading branch information...
1 parent d3dc59c commit 3c823876bbac99638c56bc27ab043481587357c6 @Raynos Raynos committed
Showing with 11 additions and 5 deletions.
  1. +1 −1 after.js
  2. +1 −1 append.js
  3. +1 −1 before.js
  4. +1 −1 prepend.js
  5. +6 −0 remove.js
  6. +1 −1 replace.js
View
2 after.js
@@ -9,5 +9,5 @@ function after(sibling) {
, parent = sibling.parentNode
, child = sibling.nextSibling
- parent.insertBefore(node, child)
+ return parent.insertBefore(node, child)
}
View
2 append.js
@@ -6,5 +6,5 @@ module.exports = append
function append(parent) {
var node = mutation(toArray(arguments, 1))
- parent.appendChild(node)
+ return parent.appendChild(node)
}
View
2 before.js
@@ -8,5 +8,5 @@ function before(sibling) {
var node = mutation(toArray(arguments, 1))
, parent = sibling.parentNode
- parent.insertBefore(node, sibling)
+ return parent.insertBefore(node, sibling)
}
View
2 prepend.js
@@ -6,5 +6,5 @@ module.exports = prepend
function prepend(parent) {
var node = mutation(toArray(arguments, 1))
- parent.insertBefore(node, parent.firstChild)
+ return parent.insertBefore(node, parent.firstChild)
}
View
6 remove.js
@@ -7,6 +7,12 @@ module.exports = remove
function remove() {
var list = toArray(arguments)
list.forEach(removeFromParent)
+
+ if (list.length === 1) {
+ return list[0]
+ } else {
+ return document.createDocumentFragment()
+ }
}
function removeFromParent(elem) {
View
2 replace.js
@@ -7,5 +7,5 @@ function replace(target) {
var node = mutation(toArray(arguments, 1))
, parent = target.parentNode
- parent.replaceChild(node, target)
+ return parent.replaceChild(node, target)
}

0 comments on commit 3c82387

Please sign in to comment.
Something went wrong with that request. Please try again.