aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-01-13 19:22:08 +0100
committerGitHub <noreply@github.com>2020-01-13 19:22:08 +0100
commit9e66fe9acf0ef27681f5a21149fc61678f791641 (patch)
tree2506ed128bce16827adbdf4fd26e83b0a206a184
parent437f389a24a6bef213d4df507909e7e69062300b (diff)
downloadjquery-9e66fe9acf0ef27681f5a21149fc61678f791641.tar.gz
jquery-9e66fe9acf0ef27681f5a21149fc61678f791641.zip
Attributes: Don't set the type attr hook at all outside of IE
This removes a needless function call in modern browsers. Closes gh-4587
-rw-r--r--src/attributes/attr.js35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/attributes/attr.js b/src/attributes/attr.js
index cd34860e1..2773a383c 100644
--- a/src/attributes/attr.js
+++ b/src/attributes/attr.js
@@ -64,23 +64,7 @@ jQuery.extend( {
return ret == null ? undefined : ret;
},
- attrHooks: {
- type: {
- set: function( elem, value ) {
-
- // Support: IE <=11+
- // An input loses its value after becoming a radio
- if ( isIE && value === "radio" && nodeName( elem, "input" ) ) {
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
- },
+ attrHooks: {},
removeAttr: function( elem, value ) {
var name,
@@ -98,6 +82,23 @@ jQuery.extend( {
}
} );
+// Support: IE <=11+
+// An input loses its value after becoming a radio
+if ( isIE ) {
+ jQuery.attrHooks.type = {
+ set: function( elem, value ) {
+ if ( value === "radio" && nodeName( elem, "input" ) ) {
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ };
+}
+
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
jQuery.attrHooks[ name ] = {
get: function( elem ) {