Skip to content

Commit

Permalink
.item(index) //index support 1 or "1". Fixes #658
Browse files Browse the repository at this point in the history
  • Loading branch information
代军 authored and yiminghe committed Jul 1, 2014
1 parent 13a9c71 commit de7ee90
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/node/src/node/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,8 @@ Node.prototype = {
*/
item: function (index) {
var self = this;
if (typeof index === 'number') {
if (index >= self.length) {
return null;
} else {
return new Node(self[index]);
}
} else {
return new Node(index);
}
index = parseInt(index);
return typeof index === 'number' && !isNaN(index) && index < self.length ? new Node(self[index]) : null;
},

/**
Expand Down

0 comments on commit de7ee90

Please sign in to comment.