Bug Tracker

Modify

Ticket #12095 (closed bug: invalid)

Opened 11 months ago

Last modified 2 months ago

.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:
Blocking: Blocked by:

Description

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() :
                        undefined;
        },
//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

comment:1 Changed 11 months ago by rwaldron

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

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

comment:2 Changed 11 months ago by timmywil

  • Keywords needsdocs added
  • Priority changed from undecided to low
  • Status changed from new to closed
  • Component changed from unfiled to attributes
  • Resolution set to invalid

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 8 months ago by mikesherov

  • Keywords needsdocs removed

comment:4 Changed 2 months ago by m_gol

#13740 is a duplicate of this ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.