diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-08-16 09:59:58 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-09-07 20:03:50 +0300 |
commit | 10fdad742a2a6aa9f0e00b3e04fc5264797c53c7 (patch) | |
tree | 6b6d7b1375ff88f4bebbfa0703f7b595eb485df9 /src/attributes/attr.js | |
parent | 7aa46e0df8a673e6b00550bbbbed21eed50108b7 (diff) | |
download | jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.tar.gz jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.zip |
Build: Update jscs and lint files
Fixes gh-2056
Diffstat (limited to 'src/attributes/attr.js')
-rw-r--r-- | src/attributes/attr.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 07576738a..f88808324 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -1,4 +1,4 @@ -define([ +define( [ "../core", "../core/access", "./support", @@ -9,19 +9,19 @@ define([ var boolHook, attrHandle = jQuery.expr.attrHandle; -jQuery.fn.extend({ +jQuery.fn.extend( { attr: function( name, value ) { return access( this, jQuery.attr, name, value, arguments.length > 1 ); }, removeAttr: function( name ) { - return this.each(function() { + return this.each( function() { jQuery.removeAttr( this, name ); - }); + } ); } -}); +} ); -jQuery.extend({ +jQuery.extend( { attr: function( elem, name, value ) { var ret, hooks, nType = elem.nodeType; @@ -91,7 +91,7 @@ jQuery.extend({ attrNames = value && value.match( rnotwhite ); if ( attrNames && elem.nodeType === 1 ) { - while ( ( name = attrNames[i++] ) ) { + while ( ( name = attrNames[ i++ ] ) ) { propName = jQuery.propFix[ name ] || name; // Boolean attributes get special treatment (#10870) @@ -105,12 +105,13 @@ jQuery.extend({ } } } -}); +} ); // Hooks for boolean attributes boolHook = { set: function( elem, value, name ) { if ( value === false ) { + // Remove boolean attributes when set to false jQuery.removeAttr( elem, name ); } else { @@ -125,6 +126,7 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) attrHandle[ name ] = function( elem, name, isXML ) { var ret, handle; if ( !isXML ) { + // Avoid an infinite loop by temporarily removing this function from the getter handle = attrHandle[ name ]; attrHandle[ name ] = ret; @@ -135,6 +137,6 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) } return ret; }; -}); +} ); -}); +} ); |