Skip to content

Commit 79ee6f0

Browse files
committed
Dialog: When using the title attribute, update the title option. Fixes #5877 - Dialog: when using the title attribute, the title option should be updated.
1 parent af9864d commit 79ee6f0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/unit/dialog/dialog_options.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,26 +369,30 @@ test("stack", function() {
369369
});
370370

371371
test("title", function() {
372-
expect(5);
372+
expect(9);
373373

374374
function titleText() {
375375
return dlg().find(".ui-dialog-title").html();
376376
}
377377

378378
el = $('<div></div>').dialog();
379379
equals(titleText(), "&nbsp;", "[default]");
380+
equals(el.dialog("option", "title"), "", "option not changed");
380381
el.remove();
381382

382383
el = $('<div title="foo"/>').dialog();
383384
equals(titleText(), "foo", "title in element attribute");
385+
equals(el.dialog("option", "title"), "foo", "option updated from attribute");
384386
el.remove();
385387

386388
el = $('<div></div>').dialog({ title: 'foo' });
387389
equals(titleText(), "foo", "title in init options");
390+
equals(el.dialog("option", "title"), "foo", "opiton set from options hash");
388391
el.remove();
389392

390393
el = $('<div title="foo"/>').dialog({ title: 'bar' });
391394
equals(titleText(), "bar", "title in init options should override title in element attribute");
395+
equals(el.dialog("option", "title"), "bar", "opiton set from options hash");
392396
el.remove();
393397

394398
el = $('<div></div>').dialog().dialog('option', 'title', 'foo');

ui/jquery.ui.dialog.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ $.widget("ui.dialog", {
6767
this.originalTitle = "";
6868
}
6969

70+
this.options.title = this.options.title || this.originalTitle;
7071
var self = this,
7172
options = self.options,
7273

73-
title = options.title || self.originalTitle || '&#160;',
74+
title = options.title || '&#160;',
7475
titleId = $.ui.dialog.getTitleId(self.element),
7576

7677
uiDialog = (self.uiDialog = $('<div></div>'))

0 commit comments

Comments
 (0)