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:

function someFunction( e )
{
var cell = $(e);

var cellParent = cell.parent();

var cellParent2 = cell.parent();

alert("[" + cell.id() + "] [" + cellParent.id() + "] [" + cellParent2.id() + "]");
}

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.

If it's unintentional, I'll start trying to find a fix and whip up some test cases too, I just wanted to check before I go fixing something that's not a bug in the first place.

Cheers,
~Peter
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to