Permalink
Browse files

Fixed multiple class selectors and bug with nested tag selectors, e.g…

…. 'p p'
  • Loading branch information...
chriso authored and Harry Fuecks committed Nov 4, 2010
1 parent 0c7e885 commit 96baffb2d2e09b06aeee9f611017191936f7a5d6
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/soupselect.js
View
@@ -124,7 +124,7 @@ exports.select = function(dom, selector) {
if (!value) return false;
var classes = value.split(/\s+/);
for (var i = 1, len = parts.length; i < len; i++) {
- if (!~classes.indexOf(parts[i]) return false;
+ if (!~classes.indexOf(parts[i])) return false;
}
return true;
};
@@ -160,13 +160,13 @@ exports.select = function(dom, selector) {
found = [];
for ( var m = 0; m < currentContext.length; m++ ) {
// htmlparsers document itself has no child property - only nodes do...
- if ( typeof context.children !== 'undefined' ) {
+ if ( typeof currentContext[m].children !== 'undefined' ) {
found = found.concat(domUtils.getElementsByTagName(tokens[i], currentContext[m].children));
- } else {
+ } else if (i === 0) {
found = found.concat(domUtils.getElementsByTagName(tokens[i], currentContext[m]));
}
- });
+ };
currentContext = found;
}

0 comments on commit 96baffb

Please sign in to comment.