Commit 6e19d2a0 authored by Timmy Willison's avatar Timmy Willison

Make the attr handles a little more readable (+4 bytes)

parent dc0d3b42
...@@ -8,6 +8,7 @@ define([ ...@@ -8,6 +8,7 @@ define([
], function( jQuery, rnotwhite, strundefined ) { ], function( jQuery, rnotwhite, strundefined ) {
var nodeHook, boolHook, var nodeHook, boolHook,
attrHandle = jQuery.expr.attrHandle,
ruseDefault = /^(?:checked|selected)$/i, ruseDefault = /^(?:checked|selected)$/i,
getSetAttribute = jQuery.support.getSetAttribute, getSetAttribute = jQuery.support.getSetAttribute,
getSetInput = jQuery.support.input; getSetInput = jQuery.support.input;
...@@ -143,28 +144,27 @@ boolHook = { ...@@ -143,28 +144,27 @@ boolHook = {
// Retrieve booleans specially // Retrieve booleans specially
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ? var getter = attrHandle[ name ] || jQuery.find.attr,
fn = attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
function( elem, name, isXML ) { function( elem, name, isXML ) {
var fn = jQuery.expr.attrHandle[ name ], var ret;
ret = isXML ? if ( !isXML ) {
undefined : // Avoid an infinite loop by temporarily removing this function from the getter
/* jshint eqeqeq: false */ attrHandle[ name ] = ret;
(jQuery.expr.attrHandle[ name ] = undefined) != ret = getter( elem, name, isXML ) != null ?
getter( elem, name, isXML ) ? name.toLowerCase() :
null;
name.toLowerCase() : attrHandle[ name ] = fn;
null; }
jQuery.expr.attrHandle[ name ] = fn;
return ret; return ret;
} : } :
function( elem, name, isXML ) { function( elem, name, isXML ) {
return isXML ? if ( !isXML ) {
undefined : return elem[ jQuery.camelCase( "default-" + name ) ] ?
elem[ jQuery.camelCase( "default-" + name ) ] ?
name.toLowerCase() : name.toLowerCase() :
null; null;
}
}; };
}); });
...@@ -201,30 +201,30 @@ if ( !getSetAttribute ) { ...@@ -201,30 +201,30 @@ if ( !getSetAttribute ) {
ret.value = value += ""; ret.value = value += "";
// Break association with cloned elements by also using setAttribute (#9646) // Break association with cloned elements by also using setAttribute (#9646)
return name === "value" || value === elem.getAttribute( name ) ? if ( name === "value" || value === elem.getAttribute( name ) ) {
value : return value;
undefined; }
} }
}; };
// Some attributes are constructed with empty-string values when not defined // Some attributes are constructed with empty-string values when not defined
jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords = attrHandle.id = attrHandle.name = attrHandle.coords =
function( elem, name, isXML ) { function( elem, name, isXML ) {
var ret; var ret;
return isXML ? if ( !isXML ) {
undefined : return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
(ret = elem.getAttributeNode( name )) && ret.value !== "" ?
ret.value : ret.value :
null; null;
}
}; };
// Fixing value retrieval on a button requires this module // Fixing value retrieval on a button requires this module
jQuery.valHooks.button = { jQuery.valHooks.button = {
get: function( elem, name ) { get: function( elem, name ) {
var ret = elem.getAttributeNode( name ); var ret = elem.getAttributeNode( name );
return ret && ret.specified ? if ( ret && ret.specified ) {
ret.value : return ret.value;
undefined; }
}, },
set: nodeHook.set set: nodeHook.set
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment