diff --git a/lib/api/traversing.js b/lib/api/traversing.js index 3af89b6bd5..df0c0558b7 100644 --- a/lib/api/traversing.js +++ b/lib/api/traversing.js @@ -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) { diff --git a/test/api.traversing.js b/test/api.traversing.js index 19efa3b746..4242337b51 100644 --- a/test/api.traversing.js +++ b/test/api.traversing.js @@ -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() {