Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#8628 closed enhancement (duplicate)

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

Change History (3)

comment:1 Changed 13 years ago by Timmy Willison

Attr is getting a rewrite in jquery 1.6 and 6562 will be examined. This ticket can be closed as dup.

comment:2 Changed 13 years ago by addyosmani

Resolution: duplicate
Status: newclosed

Dupe. Also closing as we'll be addressing several attr issues in the 1.6 rewrite.

comment:3 Changed 13 years ago by addyosmani

Duplicate of #6562.

Note: See TracTickets for help on using tickets.