Skip to content

Commit 35564dd

Browse files
committed
Button: simplifying _create by setting label option first
1 parent fe00326 commit 35564dd

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

ui/button.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ $.widget( "ui.button", {
8383
.addClass( baseClasses )
8484
.attr( "role", "button" );
8585

86+
if ( this.options.label ){
87+
if ( this.isInput ) {
88+
this.element.val( this.options.label );
89+
} else {
90+
this.element.html( this.options.label );
91+
}
92+
}
93+
8694
if ( this.options.icon ) {
8795
this.icon = $( "<span>" );
8896
this.icon.addClass( " ui-icon " + this.options.icon );
@@ -95,20 +103,6 @@ $.widget( "ui.button", {
95103
this.element.append( this.icon );
96104
this._setTitle();
97105
}
98-
if ( this.options.label ){
99-
if ( this.isInput ) {
100-
this.element.val( this.options.label );
101-
} else {
102-
var textNode = this.element.contents().filter( function() {
103-
return this.nodeType === 3;
104-
})[ 0 ];
105-
if ( textNode !== undefined ) {
106-
textNode.nodeValue = this.options.label;
107-
} else {
108-
this.element.html( this.options.label + this.element.html() );
109-
}
110-
}
111-
}
112106

113107
if ( this.element.is("a") ) {
114108
this.element.keyup(function(event) {

0 commit comments

Comments
 (0)