Skip to content

Commit a45a4af

Browse files
committed
fixup! Use the same function for selected getter and setter
1 parent 68c4213 commit a45a4af

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/attributes/prop.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ define( [
55
"../selector"
66
], function( jQuery, access, support ) {
77

8-
var rfocusable = /^(?:input|select|textarea|button)$/i,
8+
var accessIndex,
9+
rfocusable = /^(?:input|select|textarea|button)$/i,
910
rclickable = /^(?:a|area)$/i;
1011

1112
jQuery.fn.extend( {
@@ -86,25 +87,20 @@ jQuery.extend( {
8687
// The getter ensures a default option is selected
8788
// when in an optgroup
8889
if ( !support.optSelected ) {
89-
jQuery.propHooks.selected = {
90-
get: function( elem ) {
91-
var parent = elem.parentNode;
90+
accessIndex = function( elem ) {
91+
var parent = elem.parentNode;
92+
if ( parent ) {
93+
parent.selectedIndex;
94+
9295
if ( parent && parent.parentNode ) {
9396
parent.parentNode.selectedIndex;
9497
}
95-
return null;
96-
},
97-
set: function( elem ) {
98-
var parent = elem.parentNode;
99-
if ( parent ) {
100-
parent.selectedIndex;
101-
102-
if ( parent && parent.parentNode ) {
103-
parent.parentNode.selectedIndex;
104-
}
105-
}
10698
}
10799
};
100+
jQuery.propHooks.selected = {
101+
get: accessIndex,
102+
set: accessIndex
103+
};
108104
}
109105

110106
jQuery.each( [

0 commit comments

Comments
 (0)