Skip to content

Commit 52d9ec6

Browse files
jzaeffererarschmitz
authored andcommitted
Checkboxradio: Add ui-state-highlight class to icon on create
This was already toggled in _toggleClasses, but that isn't called on create.
1 parent 9ff3d8f commit 52d9ec6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

tests/unit/checkboxradio/options.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function assertIcon( checkbox, icon, assert ) {
6767
assert.hasClasses( iconElement, "ui-checkboxradio-icon ui-corner-all ui-icon " +
6868
"ui-icon-background ui-icon-" + icon,
6969
"Icon has proper classes" );
70+
if ( icon === "blank" ) {
71+
assert.lacksClasses( iconElement, "ui-icon-check ui-state-highlight" );
72+
}
7073
}
7174
test( "icon - false on init", function() {
7275
var checkbox = $( "#checkbox-option-icon" );
@@ -76,36 +79,43 @@ test( "icon - false on init", function() {
7679
checkbox.checkboxradio( { icon: false } );
7780
assertNoIcon( checkbox );
7881
} );
79-
8082
test( "icon - default unchecked", function( assert ) {
8183
var checkbox = $( "#checkbox-option-icon" );
8284

83-
expect( 2 );
85+
expect( 3 );
8486

8587
checkbox.checkboxradio();
8688
assertIcon( checkbox, false, assert );
8789
} );
90+
test( "icon - default checked", function( assert ) {
91+
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", true );
92+
93+
expect( 2 );
94+
95+
checkbox.checkboxradio();
96+
assertIcon( checkbox, "check ui-state-highlight", assert );
97+
} );
8898
test( "icon", function( assert ) {
8999
var checkbox = $( "#checkbox-option-icon" );
90100

91-
expect( 8 );
101+
expect( 9 );
92102

93103
checkbox.prop( "checked", true );
94104

95105
checkbox.checkboxradio();
96-
assertIcon( checkbox, "check", assert );
106+
assertIcon( checkbox, "check ui-state-highlight", assert );
97107

98108
checkbox.checkboxradio( "option", "icon", false );
99109
assertNoIcon( checkbox );
100110

101111
checkbox.checkboxradio( "option", "icon", true );
102-
assertIcon( checkbox, "check", assert );
112+
assertIcon( checkbox, "check ui-state-highlight", assert );
103113

104114
checkbox.checkboxradio( "option", "icon", false );
105115
assertNoIcon( checkbox );
106116

107-
checkbox.prop( "checked", false ).checkboxradio( "refresh" );
108117
checkbox.checkboxradio( "option", "icon", true );
118+
checkbox.prop( "checked", false ).checkboxradio( "refresh" );
109119
assertIcon( checkbox, false, assert );
110120

111121
} );

ui/widgets/checkboxradio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
226226
}
227227

228228
if ( this.type === "checkbox" ) {
229-
toAdd += checked ? "ui-icon-check" : "ui-icon-blank";
229+
toAdd += checked ? "ui-icon-check ui-state-highlight" : "ui-icon-blank";
230230
this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
231231
} else {
232232
toAdd += "ui-icon-blank";
233233
}
234234
this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
235235
if ( !checked ) {
236-
this._removeClass( this.icon, null, "ui-icon-check" );
236+
this._removeClass( this.icon, null, "ui-icon-check ui-state-highlight" );
237237
}
238238
this.icon.prependTo( this.label ).after( this.iconSpace );
239239
} else if ( this.icon !== undefined ) {

0 commit comments

Comments
 (0)