Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 0c7e8856ab5bd2bf14468171bb3793cd842b0b6f 1 parent 64e55d8
@chriso chriso authored Harry Fuecks committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/soupselect.js
View
9 lib/soupselect.js
@@ -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 = [];
Please sign in to comment.
Something went wrong with that request. Please try again.