Dialog: Remove attroperty workaround for title attribute. Make the default null, as it should be. No back-compat, as the behaviour doesn't change.

This commit is contained in:
Jörn Zaefferer 2012-11-09 18:26:30 +01:00
parent f7d3a51589
commit 6edce86733
3 changed files with 28 additions and 25 deletions

View File

@ -23,7 +23,7 @@ TestHelpers.commonWidgetTests( "dialog", {
}, },
resizable: true, resizable: true,
show: null, show: null,
title: '', title: null,
width: 300, width: 300,
// callbacks // callbacks

View File

@ -416,7 +416,7 @@ test("resizable", function() {
}); });
test( "title", function() { test( "title", function() {
expect(9); expect( 11 );
function titleText() { function titleText() {
return el.dialog('widget').find( ".ui-dialog-title" ).html(); return el.dialog('widget').find( ".ui-dialog-title" ).html();
@ -426,7 +426,7 @@ test("title", function() {
// some browsers return a non-breaking space and some return " " // some browsers return a non-breaking space and some return " "
// so we generate a non-breaking space for comparison // so we generate a non-breaking space for comparison
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" ); equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
equal(el.dialog("option", "title"), "", "option not changed"); equal( el.dialog( "option", "title" ), null, "option not changed" );
el.remove(); el.remove();
el = $( '<div title="foo">' ).dialog(); el = $( '<div title="foo">' ).dialog();
@ -447,6 +447,14 @@ test("title", function() {
el = $( '<div></div>' ).dialog().dialog( 'option', 'title', 'foo' ); el = $( '<div></div>' ).dialog().dialog( 'option', 'title', 'foo' );
equal( titleText(), 'foo', 'title after init' ); equal( titleText(), 'foo', 'title after init' );
el.remove(); el.remove();
// make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
el = $( '<form><input name="title"></form>' ).dialog();
// some browsers return a non-breaking space and some return "&nbsp;"
// so we get the text to normalize to the actual non-breaking space
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
equal( el.dialog( "option", "title" ), null, "option not changed" );
el.remove();
}); });
test("width", function() { test("width", function() {

View File

@ -67,7 +67,7 @@ $.widget("ui.dialog", {
}, },
resizable: true, resizable: true,
show: null, show: null,
title: "", title: null,
width: 300, width: 300,
// callbacks // callbacks
@ -85,16 +85,11 @@ $.widget("ui.dialog", {
_create: function() { _create: function() {
this.originalTitle = this.element.attr( "title" ); this.originalTitle = this.element.attr( "title" );
// #5742 - .attr() might return a DOMElement this.options.title = this.options.title || this.originalTitle;
// TODO WTF?
if ( typeof this.originalTitle !== "string" ) {
this.originalTitle = "";
}
this.oldPosition = { this.oldPosition = {
parent: this.element.parent(), parent: this.element.parent(),
index: this.element.parent().children().index( this.element ) index: this.element.parent().children().index( this.element )
}; };
this.options.title = this.options.title || this.originalTitle;
var that = this, var that = this,
options = this.options, options = this.options,