File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ exports.find = function (selectorOrHaystack) {
5252 var elems = reSiblingSelector . test ( selectorOrHaystack )
5353 ? context
5454 : context . reduce ( function ( newElems , elem ) {
55- return newElems . concat ( elem . children . filter ( isTag ) ) ;
55+ return Array . isArray ( elem . children )
56+ ? newElems . concat ( elem . children . filter ( isTag ) )
57+ : newElems ;
5658 } , [ ] ) ;
5759
5860 var options = Object . assign ( { context : context } , this . options ) ;
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ describe('$(...)', function () {
2929 expect ( $ ( '#fruits' ) . find ( '.apple' ) [ 0 ] . attribs [ 'class' ] ) . toBe ( 'apple' ) ;
3030 } ) ;
3131
32+ // #1679 - text tags not filtered
33+ it ( '(single) : should filter out text nodes' , function ( ) {
34+ var $root = $ ( '<html>\n' + fruits . replace ( / > < / g, '>\n<' ) + '\n</html>' ) ;
35+ expect ( $root . find ( '.apple' ) [ 0 ] . attribs [ 'class' ] ) . toBe ( 'apple' ) ;
36+ } ) ;
37+
3238 it ( '(many) : should find all matching descendant' , function ( ) {
3339 expect ( $ ( '#fruits' ) . find ( 'li' ) ) . toHaveLength ( 3 ) ;
3440 } ) ;
You can’t perform that action at this time.
0 commit comments