Permalink
Browse files

Land: when Node#insertBefore should do nothing when both params are t…

…he same node (Jason Davies)
  • Loading branch information...
tmpvar committed Sep 21, 2011
2 parents a4ab554 + 00b278c commit 8bc448a156952b4e2f26ccdc5f5ee755fbd64c1e
Showing with 18 additions and 0 deletions.
  1. +2 −0 lib/jsdom/level1/core.js
  2. +16 −0 test/level1/core.js
View
@@ -481,6 +481,8 @@ core.Node.prototype = {
tmpNode = newChild.removeChild(newChild.firstChild);
this.insertBefore(tmpNode, refChild);
}
+ } else if (newChild === refChild) {
+ return newChild;
} else {
// if the newChild is already in the tree elsewhere, remove it first
if (newChild._parentNode) {
View
@@ -13135,6 +13135,22 @@ exports.tests = {
test.done();
},
+ /**
+ * If the "refChild" is the same as the "newChild" then don't do anything.
+ */
+ hc_nodeinsertbeforerefchildequal: function(test) {
+ var doc = hc_staff.hc_staff();
+ var elementList = doc.getElementsByTagName("p");
+ var employeeNode = elementList.item(1);
+ var childList = employeeNode.childNodes;
+
+ var refChild = childList.item(3);
+
+ employeeNode.insertBefore(refChild, refChild);
+
+ test.done();
+ },
+
/**
*
If the "refChild" is null then the

0 comments on commit 8bc448a

Please sign in to comment.