Skip to main content

Bug Tracker

Side navigation

#12095 closed bug (invalid)

Opened July 17, 2012 02:28PM UTC

Closed July 18, 2012 11:13AM UTC

Last modified April 06, 2013 02:50AM UTC

.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:

#!div style="font-size: 100%"
Code highlighting:
  {{{#!python
  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:

#!div style="font-size: 100%"
Code highlighting:
  {{{#!python
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/ ?

Attachments (0)
Change History (4)

Changed July 17, 2012 02:53PM UTC by rwaldron comment:1

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

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

Changed July 18, 2012 11:13AM UTC by timmywil comment:2

component: unfiledattributes
keywords: → needsdocs
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.

Changed October 15, 2012 09:12PM UTC by mikesherov comment:3

keywords: needsdocs

Changed April 06, 2013 02:50AM UTC by m_gol comment:4

#13740 is a duplicate of this ticket.