[jQuery] Strange behavior with append() and nested DOM nodes...
> [When I] try to append that single node like this
> $("#np-login").append(form);
> that doesn't work correctly. But if I am passing the
> form as a single list item, everything is fine:
> $("#np-login").append([form]);
Ah, I think I understand this one now. Follow the trail.
Forms have a length property:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/ref
erence/properties/form.asp
$().append() calls $.clean(arguments) to get the list of nodes to use.
Because the arguments array is not a "proper" Array, $.clean() uses the
existence of the .length property to infer that it has been passed either an
arguments array or a real Array.
What should happen in this situation is that the single DOM form node should
be pushed onto the list. However, since the form node has a .length
property, it mistakenly tries to index the form node from 0 to form.length
and push on elements form.1, form.2, etc.
A quick workaround might be to change this line:
} else if ( a[i].length )
To this:
} else if ( a[i].length && !a[i].nodeType )
This is all from a quick look, I haven't tested anything...sorry.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/