You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've been using the cheeriojs library with great success but have run into a strange behavior represented by this test case:
it('modifying nested selections should not impact the parent',function(){varapple=$('.apple'),pear=$('.pear');varapple_pear=apple.add(pear);// applies red to apple and pearapple_pear.addClass('red');expect(apple.hasClass('red')).to.be.ok();// this is trueexpect(pear.hasClass('red')).to.be.ok();// this is true// applies green to pear... AND applepear.addClass('green');expect(pear.hasClass('green')).to.be.ok();//currently this is trueexpect(apple.hasClass('green')).to.be.ok();// and this is true!});=><ulid="fruits"><liclass="apple red green">Apple</li><liclass="orange">Orange</li><liclass="pear red green">Pear</li></ul>
Inside exports.add(), modifying the code to create a clone of the "other" selection seemed to work (any further modifications to pear applied to pear as intended), but this seemed to break the uniqSort functionality, so the result was not sorted as expected and adding a class to the new selection still only modified the first object in the selection. Besides breaking many things since other is not always clone-able)
Passing a clone'd pear to the add method fixes this odd behavior (child elements can then be modified without modifying the parent), but no changes to the apple_pear selection are applied to the pear elements:
Hello,
We've been using the cheeriojs library with great success but have run into a strange behavior represented by this test case:
Inside exports.add(), modifying the code to create a clone of the "other" selection seemed to work (any further modifications to pear applied to pear as intended), but this seemed to break the uniqSort functionality, so the result was not sorted as expected and adding a class to the new selection still only modified the first object in the selection. Besides breaking many things since other is not always clone-able)
Passing a clone'd pear to the add method fixes this odd behavior (child elements can then be modified without modifying the parent), but no changes to the apple_pear selection are applied to the pear elements:
Curious if anyone has run into this before.
In nontrivial examples, this has a large impact on the way we modify nested table and list elements.
Reproduced on Node 0.12.7 and on 4.4.0
The text was updated successfully, but these errors were encountered: