Skip to content

Commit 9191ee3

Browse files
Adovenmuehlescottgonzalez
authored andcommitted
Button: Batched class changes to improve performance. Fixes #6934. Button: Batch class changes to improve performance.
(cherry picked from commit 5b104db)
1 parent d14366a commit 9191ee3

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ui/jquery.ui.button.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -290,27 +290,32 @@ $.widget( "ui.button", {
290290
.appendTo( buttonElement.empty() )
291291
.text(),
292292
icons = this.options.icons,
293-
multipleIcons = icons.primary && icons.secondary;
293+
multipleIcons = icons.primary && icons.secondary,
294+
buttonClasses = [];
295+
294296
if ( icons.primary || icons.secondary ) {
295-
buttonElement.addClass( "ui-button-text-icon" +
296-
( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
297+
buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
298+
297299
if ( icons.primary ) {
298300
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
299301
}
302+
300303
if ( icons.secondary ) {
301304
buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
302305
}
306+
303307
if ( !this.options.text ) {
304-
buttonElement
305-
.addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
306-
.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
308+
buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
309+
buttonElement.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
310+
307311
if ( !this.hasTitle ) {
308312
buttonElement.attr( "title", buttonText );
309313
}
310314
}
311315
} else {
312-
buttonElement.addClass( "ui-button-text-only" );
316+
buttonClasses.push( "ui-button-text-only" );
313317
}
318+
buttonElement.addClass( buttonClasses.join( " " ) );
314319
}
315320
});
316321

0 commit comments

Comments
 (0)