File tree 2 files changed +9
-1
lines changed
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) {
52
52
var elems = reSiblingSelector . test ( selectorOrHaystack )
53
53
? context
54
54
: 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 ;
56
58
} , [ ] ) ;
57
59
58
60
var options = Object . assign ( { context : context } , this . options ) ;
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ describe('$(...)', function () {
29
29
expect ( $ ( '#fruits' ) . find ( '.apple' ) [ 0 ] . attribs [ 'class' ] ) . toBe ( 'apple' ) ;
30
30
} ) ;
31
31
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
+
32
38
it ( '(many) : should find all matching descendant' , function ( ) {
33
39
expect ( $ ( '#fruits' ) . find ( 'li' ) ) . toHaveLength ( 3 ) ;
34
40
} ) ;
You can’t perform that action at this time.
0 commit comments