Permalink
Browse files

added NodeList#indexOf to solve issue 81

  • Loading branch information...
1 parent c314d6f commit ee24f5e5f30dcfe2470ed0c963f340df9aaec0a3 @karunasagark karunasagark committed Mar 5, 2011
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/jsdom/level1/core.js
@@ -161,6 +161,17 @@ core.NodeList.prototype = {
},
toString: function() {
return '[ jsdom NodeList ]: contains ' + this.length + ' items';
+ },
+ indexOf: function(node) {
+ var len = this.update().length;
+
+ for (var i = 0; i < len; i++) {
+ if (this[i] == node) {
+ return i;
+ }
+ }
+
+ return -1; // not found
}
};
@@ -457,9 +468,10 @@ core.Node.prototype = {
if (newChild._addIds) {
newChild._addIds();
}
+
+ this._modified();
}
- this._modified();
return newChild;
}, // raises(DOMException);

0 comments on commit ee24f5e

Please sign in to comment.