Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button: Escape label option as text #1632

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/unit/button/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ test( "label, explicit value", function() {
deepEqual( button.button( "option", "label" ), "xxx" );
} );

test( "label, escape html", function() {
expect( 4 );
var label = "<div>bloob</div>";
var button = $( "#button" ).button( {
label: label
} );

deepEqual( button.text(), label );
deepEqual( button.button( "option", "label" ), label );

button.button( "option", "label", label );
deepEqual( button.text(), label );
deepEqual( button.button( "option", "label" ), label );
} );

test( "label, default, with input type submit", function() {
expect( 2 );
var button = $( "#submit" ).button();
Expand Down
4 changes: 2 additions & 2 deletions ui/widgets/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ $.widget( "ui.button", {
if ( this.isInput ) {
this.element.val( this.options.label );
} else {
this.element.html( this.options.label );
this.element.text( this.options.label );
}
}
this._addClass( "ui-button", "ui-widget" );
Expand Down Expand Up @@ -249,7 +249,7 @@ $.widget( "ui.button", {

// If there is an icon, append it, else nothing then append the value
// this avoids removal of the icon when setting label text
this.element.html( value );
this.element.text( value );
if ( this.icon ) {
this._attachIcon( this.options.iconPosition );
this._attachIconSpace( this.options.iconPosition );
Expand Down