Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate syntax errors caused by invalid selectors #177

Merged
merged 1 commit into from
Mar 31, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/api/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ var _ = require('underscore'),
isTag = utils.isTag;

var find = exports.find = function(selector) {
try {
var elem = select(selector, [].slice.call(this.children()));
return this.make(elem);
} catch(e) {
return this.make([]);
}
return this.make(select(selector, [].slice.call(this.children())));
};

var parent = exports.parent = function(elem) {
Expand Down
8 changes: 8 additions & 0 deletions test/api.traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ describe('$(...)', function() {
expect($('#fruits').find('li')).to.have.length(0);
});

it('should throw a SyntaxError if given an invalid selector', function() {
expect(function() {
$('#fruits').find(':bah');
}).to.throwException(function(err) {
expect(err).to.be.a(SyntaxError);
});
});

});

describe('.children', function() {
Expand Down