Modify ↓
Ticket #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: | ||
| 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: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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
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