From 1169b5445691e1495354d235a3badf05240e3904 Mon Sep 17 00:00:00 2001 From: Hubert SABLONNIÈRE Date: Fri, 25 Oct 2013 21:52:49 +0200 Subject: fix(jqLite): ignore incompatible nodes on find() When a jqLite collection contains text nodes, find() does not work :-( This fix ignores all nodes than can't do getElementsByTagName() It seems a little bit faster than testing nodeType : http://jsperf.com/nodetype-vs-duck-typing Closes #4120 --- test/jqLiteSpec.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/jqLiteSpec.js') diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 02a17df8..09be1c1c 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -1335,6 +1335,12 @@ describe('jqLite', function() { expect(innerDiv.length).toEqual(1); expect(innerDiv.html()).toEqual('text'); }); + + it('should find child by name and not care about text nodes', function() { + var divs = jqLite('
aa
text
bb
'); + var innerSpan = divs.find('span'); + expect(innerSpan.length).toEqual(2); + }); }); -- cgit v1.2.3