File tree 2 files changed +17
-8
lines changed
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -902,14 +902,8 @@ exports.end = function () {
902
902
*/
903
903
exports . add = function ( other , context ) {
904
904
var selection = this . _make ( other , context ) ;
905
- var contents = uniqueSort ( selection . get ( ) . concat ( this . get ( ) ) ) ;
906
-
907
- for ( var i = 0 ; i < contents . length ; ++ i ) {
908
- selection [ i ] = contents [ i ] ;
909
- }
910
- selection . length = contents . length ;
911
-
912
- return selection ;
905
+ var contents = uniqueSort ( this . get ( ) . concat ( selection . get ( ) ) ) ;
906
+ return this . _make ( contents ) ;
913
907
} ;
914
908
915
909
/**
Original file line number Diff line number Diff line change @@ -1383,6 +1383,21 @@ describe('$(...)', function () {
1383
1383
expect ( $selection [ 3 ] ) . toBe ( $pear [ 0 ] ) ;
1384
1384
} ) ;
1385
1385
} ) ;
1386
+
1387
+ it ( 'modifying nested selections should not impact the parent [#834]' , function ( ) {
1388
+ var apple_pear = $apple . add ( $pear ) ;
1389
+
1390
+ // applies red to apple and pear
1391
+ apple_pear . addClass ( 'red' ) ;
1392
+
1393
+ expect ( $apple . hasClass ( 'red' ) ) . toBe ( true ) ; // this is true
1394
+ expect ( $pear . hasClass ( 'red' ) ) . toBe ( true ) ; // this is true
1395
+
1396
+ // applies green to pear... AND should not affect apple
1397
+ $pear . addClass ( 'green' ) ;
1398
+ expect ( $pear . hasClass ( 'green' ) ) . toBe ( true ) ; //currently this is true
1399
+ expect ( $apple . hasClass ( 'green' ) ) . toBe ( false ) ; // and this should be false!
1400
+ } ) ;
1386
1401
} ) ;
1387
1402
} ) ;
1388
1403
You can’t perform that action at this time.
0 commit comments