Side navigation
#8628 closed enhancement (duplicate)
Opened March 24, 2011 09:16PM UTC
Closed March 24, 2011 10:32PM UTC
Last modified March 24, 2011 10:32PM UTC
Improving getting and setting attributes on form
Reported by: | tomgrohl | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery is a bit buggy when it comes to setting and getting attributes on a form element. I've came up with some ideas that might make it work correctly.
//Getting
If a form has a child element with an id/ name of target, when accessing a attribute that is NOT set, jQuery checks if it is set and if not carry's on further down the code, and ends up returning an element when it should return null or undefined (I"m not sure is best to use).
When accessing a form attribute that is set this works fine.
So this:
// browsers index elements by id/name on forms, give priority to attributes. if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { return elem.getAttributeNode( name ).nodeValue; }
could become something this for example:
// browsers index elements by id/name on forms, give priority to attributes. if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { return elem.getAttributeNode( name ).nodeValue; } else { return undefined; }
//Setting
jQuery uses elem[attr] = value
which work work on forms with child elements with attribute names as there id/name.
This is already a bug, found here:
http://bugs.jquery.com/ticket/6562
I mentioned something on there that might fix that bug. So combining that with this might be useful
Attr is getting a rewrite in jquery 1.6 and 6562 will be examined. This ticket can be closed as dup.