Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#12095 closed bug (invalid)

.attr method returns element name, for attributes mached in rboolean property

Reported by: anonymous Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


example: http://jsfiddle.net/gbJZE/5/

.attr method contains:

Code highlighting:

  if ( notxml ) {
                        name = name.toLowerCase();
                        hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
//rboolean.test( name ) = true -->hooks = boolHook 

than the boolHook method is called:

Code highlighting:

boolHook = {
        get: function( elem, name ) {
                // Align boolean attributes with corresponding properties
                // Fall back to attribute presence where some booleans are not supported
                var attrNode,
                        property = jQuery.prop( elem, name );
                return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
                        name.toLowerCase() :
//method returns the name.toLowerCase()

May be it should return boolean value?

If not may be it should be pointed in documentation to .attr method http://api.jquery.com/attr/ ?

Change History (4)

comment:1 Changed 11 years ago by Rick Waldron

Further reduction: http://jsfiddle.net/rwaldron/H6nYK/

I'm on my mobile, so this is not a confirm or deny

comment:2 Changed 11 years ago by Timmy Willison

Component: unfiledattributes
Keywords: needsdocs added
Priority: undecidedlow
Resolution: invalid
Status: newclosed

This is intended behavior and is explained in the documentation for prop http://api.jquery.com/prop/, which is the proper method for manipulating dynamic values. We could add a note to the attr docs tho.

comment:3 Changed 11 years ago by mikesherov

Keywords: needsdocs removed

comment:4 Changed 10 years ago by m_gol

#13740 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.