Peter Woods schrieb:
> I'm not sure if this is the way it's supposed to work, but this makes 
> absolutely no sense to me as far as implementation goes. If I have 
> code like this: [...]
>
> Instead of printing the equivalent of: $(e).id(), $(e).parent().id(), 
> and $(e).parent().parent().id(), it prints $(e).parent.parent.id() 
> three times. Further digging seems to hint at the fact that every time 
> cell.parent() is called, it's the equivalent of cell = cell.parent() 
> and as such the original value of cell is lost.
>
> Is this behavior intentional, or is it a bug? It seems quite 
> counterintuitive to me, and while in the dumbed-down example above it 
> makes more sense to use $(e).parent() instead of cell.parent(), I find 
> it more intuitive to use cell.parent() in other instances and thus 
> discovered this behavior.
It is intentional. parent() is a destructive operation on the jQuery 
object like filter(), find() etc. and can be reverted with end().

There is the concept to pass an additional function to all desctructive 
operations: That function is executed for the modified stack and then 
returns an unmodified object. Maybe the discussion should be started 
again... There were several votes that said it would be unintuitive if a 
single method is once destructive and once it is not because an 
additional function is passed... What do you think?

-- Jörn

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to