Skip to content

Commit

Permalink
Dialog: Escape closeText option before passing it to button
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer committed Oct 28, 2015
1 parent 3e9e9d5 commit 9644e7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion tests/unit/dialog/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ test( "closeOnEscape", function() {
} );

test( "closeText", function() {
expect( 3 );
expect( 4 );

var element = $( "<div></div>" ).dialog();
equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "Close",
Expand All @@ -222,6 +222,11 @@ test( "closeText", function() {
equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "bar",
"closeText via option method" );
element.remove();

element = $( "<div></div>" ).dialog( { closeText: "<span>foo</span>" } );
equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "<span>foo</span>",
"closeText is escaped" );
element.remove();
} );

test( "draggable", function() {
Expand Down
4 changes: 2 additions & 2 deletions ui/widgets/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ $.widget( "ui.dialog", {
// dialog in IE (#9312)
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
.button( {
label: this.options.closeText,
label: $( "<a>" ).text( this.options.closeText ).html(),
icon: "ui-icon-closethick",
showLabel: false
} )
Expand Down Expand Up @@ -715,7 +715,7 @@ $.widget( "ui.dialog", {
this.uiDialogTitlebarClose.button( {

// Ensure that we always pass a string
label: "" + value
label: $( "<a>" ).text( "" + this.options.closeText ).html()
} );
}

Expand Down

0 comments on commit 9644e7b

Please sign in to comment.