Skip to content

Commit bde24f8

Browse files
committed
Dialog: Escape closeText option before passing it to button
Fixes jquery/api.jqueryui.com#281
1 parent 6e0b2a5 commit bde24f8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tests/unit/dialog/options.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ test( "closeOnEscape", function() {
206206
} );
207207

208208
test( "closeText", function() {
209-
expect( 3 );
209+
expect( 4 );
210210

211211
var element = $( "<div></div>" ).dialog();
212212
equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "Close",
@@ -222,6 +222,11 @@ test( "closeText", function() {
222222
equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "bar",
223223
"closeText via option method" );
224224
element.remove();
225+
226+
element = $( "<div></div>" ).dialog( { closeText: "<span>foo</span>" } );
227+
equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "<span>foo</span>",
228+
"closeText is escaped" );
229+
element.remove();
225230
} );
226231

227232
test( "draggable", function() {

ui/widgets/dialog.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ $.widget( "ui.dialog", {
426426
// dialog in IE (#9312)
427427
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
428428
.button( {
429-
label: this.options.closeText,
429+
label: $( "<a>" ).text( this.options.closeText ).html(),
430430
icon: "ui-icon-closethick",
431431
showLabel: false
432432
} )
@@ -715,7 +715,7 @@ $.widget( "ui.dialog", {
715715
this.uiDialogTitlebarClose.button( {
716716

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

0 commit comments

Comments
 (0)