#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: |
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 (4)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Component: | unfiled → attributes |
---|---|
Keywords: | needsdocs added |
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
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
Keywords: | needsdocs removed |
---|
Note: See
TracTickets for help on using
tickets.
Further reduction: http://jsfiddle.net/rwaldron/H6nYK/
I'm on my mobile, so this is not a confirm or deny