Skip to content

Commit

Permalink
Merge pull request cheeriojs#796 from Delgan/fix_780
Browse files Browse the repository at this point in the history
Fix unexpected behavior while querying child
  • Loading branch information
fb55 committed Jan 28, 2016
2 parents b27bed6 + 4779762 commit 8c9b2e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/api/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ exports.find = function(selectorOrHaystack) {
}, this));
}

return this._make(select(selectorOrHaystack, elems, this.options));
var options = {__proto__: this.options, context: this.toArray()};

return this._make(select(selectorOrHaystack, elems, options));
};

// Get the parent of each element in the current set of matched elements,
Expand Down
5 changes: 5 additions & 0 deletions test/api/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ describe('$(...)', function() {
expect($('#fruits').find('LI')).to.have.length(3);
});

it('should query immediate descendant only', function() {
var $ = cheerio.load('<foo><bar><bar></bar><bar></bar></bar></foo>');
expect($('foo').find('> bar')).to.have.length(1);
});

it('should query case-sensitively when in xmlMode', function() {
var q = cheerio.load('<caseSenSitive allTheWay>', {xmlMode: true});
expect(q('caseSenSitive')).to.have.length(1);
Expand Down

0 comments on commit 8c9b2e0

Please sign in to comment.