Skip to content

Commit

Permalink
Added support for multiple class selectors - p.class1.class2
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso authored and Harry Fuecks committed Nov 9, 2010
1 parent 64e55d8 commit 0c7e885
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/soupselect.js
Expand Up @@ -117,11 +117,16 @@ exports.select = function(dom, selector) {

// Class selector
else if ( tokens[i].indexOf('.') !== -1 ) {
var parts = tokens[i].split('.', 2);
var parts = tokens[i].split('.');
tag = parts[0];
options = {};
options['class'] = function (value) {
return (value && value.split(/\s+/).indexOf(parts[1]) > -1);
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;
}
return true;
};

found = [];
Expand Down

0 comments on commit 0c7e885

Please sign in to comment.