Permalink
Browse files

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

  • Loading branch information...
1 parent 2e629d9 commit 31d2d77bb52c7be551710793cbeb8a724e462431 @chriso chriso committed 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 31d2d77

Please sign in to comment.