@@ -415,37 +415,45 @@ test("resizable", function() {
415415 el . remove ( ) ;
416416} ) ;
417417
418- test ( "title" , function ( ) {
419- expect ( 9 ) ;
418+ test ( "title" , function ( ) {
419+ expect ( 11 ) ;
420420
421421 function titleText ( ) {
422- return el . dialog ( 'widget' ) . find ( ".ui-dialog-title" ) . html ( ) ;
422+ return el . dialog ( 'widget' ) . find ( ".ui-dialog-title" ) . html ( ) ;
423423 }
424424
425- var el = $ ( '<div></div>' ) . dialog ( ) ;
425+ var el = $ ( '<div></div>' ) . dialog ( ) ;
426426 // some browsers return a non-breaking space and some return " "
427427 // so we generate a non-breaking space for comparison
428- equal ( titleText ( ) , $ ( "<span> </span>" ) . html ( ) , "[default]" ) ;
429- equal ( el . dialog ( "option" , "title" ) , "" , "option not changed" ) ;
428+ equal ( titleText ( ) , $ ( "<span> </span>" ) . html ( ) , "[default]" ) ;
429+ equal ( el . dialog ( "option" , "title" ) , null , "option not changed" ) ;
430+ el . remove ( ) ;
431+
432+ el = $ ( '<div title="foo">' ) . dialog ( ) ;
433+ equal ( titleText ( ) , "foo" , "title in element attribute" ) ;
434+ equal ( el . dialog ( "option" , "title" ) , "foo" , "option updated from attribute" ) ;
430435 el . remove ( ) ;
431436
432- el = $ ( '<div title="foo">' ) . dialog ( ) ;
433- equal ( titleText ( ) , "foo" , "title in element attribute" ) ;
434- equal ( el . dialog ( "option" , "title" ) , "foo" , "option updated from attribute" ) ;
437+ el = $ ( '<div></div>' ) . dialog ( { title : 'foo' } ) ;
438+ equal ( titleText ( ) , "foo" , "title in init options" ) ;
439+ equal ( el . dialog ( "option" , "title" ) , "foo" , "opiton set from options hash" ) ;
435440 el . remove ( ) ;
436441
437- el = $ ( '<div></div>' ) . dialog ( { title : 'foo ' } ) ;
438- equal ( titleText ( ) , "foo " , "title in init options" ) ;
439- equal ( el . dialog ( "option" , "title" ) , "foo " , "opiton set from options hash" ) ;
442+ el = $ ( '<div title="foo">' ) . dialog ( { title : 'bar ' } ) ;
443+ equal ( titleText ( ) , "bar " , "title in init options should override title in element attribute" ) ;
444+ equal ( el . dialog ( "option" , "title" ) , "bar " , "opiton set from options hash" ) ;
440445 el . remove ( ) ;
441446
442- el = $ ( '<div title="foo">' ) . dialog ( { title : 'bar' } ) ;
443- equal ( titleText ( ) , "bar" , "title in init options should override title in element attribute" ) ;
444- equal ( el . dialog ( "option" , "title" ) , "bar" , "opiton set from options hash" ) ;
447+ el = $ ( '<div></div>' ) . dialog ( ) . dialog ( 'option' , 'title' , 'foo' ) ;
448+ equal ( titleText ( ) , 'foo' , 'title after init' ) ;
445449 el . remove ( ) ;
446450
447- el = $ ( '<div></div>' ) . dialog ( ) . dialog ( 'option' , 'title' , 'foo' ) ;
448- equal ( titleText ( ) , 'foo' , 'title after init' ) ;
451+ // make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
452+ el = $ ( '<form><input name="title"></form>' ) . dialog ( ) ;
453+ // some browsers return a non-breaking space and some return " "
454+ // so we get the text to normalize to the actual non-breaking space
455+ equal ( titleText ( ) , $ ( "<span> </span>" ) . html ( ) , "[default]" ) ;
456+ equal ( el . dialog ( "option" , "title" ) , null , "option not changed" ) ;
449457 el . remove ( ) ;
450458} ) ;
451459
0 commit comments