Skip to content

Commit 9e66fe9

Browse files
authored
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
1 parent 437f389 commit 9e66fe9

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/attributes/attr.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,7 @@ jQuery.extend( {
6464
return ret == null ? undefined : ret;
6565
},
6666

67-
attrHooks: {
68-
type: {
69-
set: function( elem, value ) {
70-
71-
// Support: IE <=11+
72-
// An input loses its value after becoming a radio
73-
if ( isIE && value === "radio" && nodeName( elem, "input" ) ) {
74-
var val = elem.value;
75-
elem.setAttribute( "type", value );
76-
if ( val ) {
77-
elem.value = val;
78-
}
79-
return value;
80-
}
81-
}
82-
}
83-
},
67+
attrHooks: {},
8468

8569
removeAttr: function( elem, value ) {
8670
var name,
@@ -98,6 +82,23 @@ jQuery.extend( {
9882
}
9983
} );
10084

85+
// Support: IE <=11+
86+
// An input loses its value after becoming a radio
87+
if ( isIE ) {
88+
jQuery.attrHooks.type = {
89+
set: function( elem, value ) {
90+
if ( value === "radio" && nodeName( elem, "input" ) ) {
91+
var val = elem.value;
92+
elem.setAttribute( "type", value );
93+
if ( val ) {
94+
elem.value = val;
95+
}
96+
return value;
97+
}
98+
}
99+
};
100+
}
101+
101102
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
102103
jQuery.attrHooks[ name ] = {
103104
get: function( elem ) {

0 commit comments

Comments
 (0)