Permalink
Browse files

Added support for multiple class selectors - p.class1.class2

  • Loading branch information...
1 parent 64e55d8 commit 0c7e8856ab5bd2bf14468171bb3793cd842b0b6f @chriso chriso committed with Harry Fuecks Nov 2, 2010
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/soupselect.js
View
@@ -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 = [];

0 comments on commit 0c7e885

Please sign in to comment.