Skip to content

Commit 5b104db

Browse files
Adovenmuehlescottgonzalez
authored andcommitted
Button: Batched class changes to improve performance. Fixes #6934. Button: Batch class changes to improve performance.
1 parent 92bae28 commit 5b104db

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ui/jquery.ui.button.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,27 +289,32 @@ $.widget( "ui.button", {
289289
.appendTo( buttonElement.empty() )
290290
.text(),
291291
icons = this.options.icons,
292-
multipleIcons = icons.primary && icons.secondary;
292+
multipleIcons = icons.primary && icons.secondary,
293+
buttonClasses = [];
294+
293295
if ( icons.primary || icons.secondary ) {
294-
buttonElement.addClass( "ui-button-text-icon" +
295-
( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
296+
buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
297+
296298
if ( icons.primary ) {
297299
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
298300
}
301+
299302
if ( icons.secondary ) {
300303
buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
301304
}
305+
302306
if ( !this.options.text ) {
303-
buttonElement
304-
.addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
305-
.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
307+
buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
308+
buttonElement.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
309+
306310
if ( !this.hasTitle ) {
307311
buttonElement.attr( "title", buttonText );
308312
}
309313
}
310314
} else {
311-
buttonElement.addClass( "ui-button-text-only" );
315+
buttonClasses.push( "ui-button-text-only" );
312316
}
317+
buttonElement.addClass( buttonClasses.join( " " ) );
313318
}
314319
});
315320

0 commit comments

Comments
 (0)