>> I'd really like to see John's modifications to pushStack
>> included in the jQuery core. Details here:
>> http://www.nabble.com/Non-Destructive-jQuery-tf2482924.html
>> 
>> I'm actually wondering if that modification would break any
>>  existing code, as end() works like before. I guess the only 
>> situation is in scenarios like this:
>> 
>> var jq = $();
>> var jq2 = jq.destructiveOperation();
>> var jq3 = jq.anotherDestructiveOperation();
>> 
>> With the non-destructive pushStack implementation, this would
>> give a different result. Is someone actually using such code?

> I use multiple destructive functions all the time:
> $('#share').children().not('h2').hide().end().end().slideUp('normal');

That code would still work. The difference is that today, the three
variables in Jörn's example would all be the _same_ object, which would have
been modified by two destructive operations. There have been several posts
lately that this is unexpected behavior--people want jq to be untouched by
the next two lines. With the new approach, you would have three separate
jQuery objects, linked so that .end() goes backwards to the previous object.
In essence, a chain of jQuery objects completely replaces the internal node
stack. 

I am pretty sure I don't have any code that would be broken by the new
behavior. The entire test suite passes with it, although that may be more an
indictment of the test suite than a stamp of approval. :-)



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to