]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Batched class changes to improve performance. Fixes #6934. Button: Batch...
authorAlex Dovenmuehle <adovenmuehle@gmail.com>
Fri, 11 Feb 2011 03:11:59 +0000 (22:11 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 11 Feb 2011 03:11:59 +0000 (22:11 -0500)
ui/jquery.ui.button.js

index e19a68bfeab07068c7bbcfc613dcd9edf3b80a16..d2458aa3ca1d380d08756873a683157657d45b0e 100644 (file)
@@ -289,27 +289,32 @@ $.widget( "ui.button", {
                                .appendTo( buttonElement.empty() )
                                .text(),
                        icons = this.options.icons,
-                       multipleIcons = icons.primary && icons.secondary;
+                       multipleIcons = icons.primary && icons.secondary,
+                       buttonClasses = [];  
+
                if ( icons.primary || icons.secondary ) {
-                       buttonElement.addClass( "ui-button-text-icon" +
-                               ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
+                       buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
+
                        if ( icons.primary ) {
                                buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
                        }
+
                        if ( icons.secondary ) {
                                buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
                        }
+
                        if ( !this.options.text ) {
-                               buttonElement
-                                       .addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
-                                       .removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
+                               buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
+                               buttonElement.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
+
                                if ( !this.hasTitle ) {
                                        buttonElement.attr( "title", buttonText );
                                }
                        }
                } else {
-                       buttonElement.addClass( "ui-button-text-only" );
+                       buttonClasses.push( "ui-button-text-only" );
                }
+               buttonElement.addClass( buttonClasses.join( " " ) );
        }
 });