Browse files

fix for empty dialog titles

Change-Id: I50ecaa8ea0c62392206048055ac3f72a76e3c61a
Reviewed-on: https://gerrit.instructure.com/4110
Tested-by: Hudson <hudson@instructure.com>
Tested-by: Selenium <selenium@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
  • Loading branch information...
1 parent 2a67911 commit 83639ecacefa8f765fee85a5a805dd01a5533ac8 @jenseng jenseng committed Jun 8, 2011
Showing with 24 additions and 3 deletions.
  1. +5 −3 public/javascripts/jquery-ui-1.8.js
  2. +19 −0 spec/selenium/jquery_ui_sel.rb
View
8 public/javascripts/jquery-ui-1.8.js
@@ -5838,7 +5838,7 @@ $.widget("ui.dialog", {
var self = this,
options = self.options,
- title = options.title || '&#160;',
+ title = options.title || $('<span>&#160;</span>'),
titleId = $.ui.dialog.getTitleId(self.element),
uiDialog = (self.uiDialog = $('<div></div>'))
@@ -6373,11 +6373,13 @@ $.widget("ui.dialog", {
}
break;
case "title":
+ if (!value) {
+ value = $('<span>&#160;</span>');
+ }
if ( value.jquery ) {
$(".ui-dialog-title", self.uiDialogTitlebar).html('').append(value);
} else {
- // convert whatever was passed in to a string, for text() not to throw up
- $(".ui-dialog-title", self.uiDialogTitlebar).text("" + (value || '&#160;'));
+ $(".ui-dialog-title", self.uiDialogTitlebar).text("" + value);
}
break;
}
View
19 spec/selenium/jquery_ui_sel.rb
@@ -25,6 +25,25 @@
JS
end
+ it "should use a non-breaking space for empty titles" do
+ driver.execute_script(<<-JS).should == "\302\240"
+ return $('<div id="jqueryui_test">hello</div>')
+ .dialog()
+ .parent('.ui-dialog')
+ .find('.ui-dialog-title')
+ .text();
+ JS
+
+ driver.execute_script(<<-JS).should == "\302\240"
+ return $('#jqueryui_test')
+ .dialog('option', 'title', 'foo')
+ .dialog('option', 'title', '')
+ .parent('.ui-dialog')
+ .find('.ui-dialog-title')
+ .text();
+ JS
+ end
+
it "should html-escape explicit string dialog titles" do
title = "<b>this</b> is the title"
driver.execute_script(<<-JS).should == title

0 comments on commit 83639ec

Please sign in to comment.