Skip to content

Commit 240b22b

Browse files
committed
Dialog: Use new uniqueId method for generating id's
1 parent 9f59d01 commit 240b22b

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

tests/unit/dialog/dialog_core.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,11 @@ function margin(el, side) {
8989
module("dialog: core");
9090

9191
test("title id", function() {
92-
expect(3);
93-
94-
var titleId;
95-
96-
// reset the uuid so we know what values to expect
97-
$.ui.dialog.uuid = 0;
92+
expect(1);
9893

9994
el = $('<div></div>').dialog();
100-
titleId = dlg().find('.ui-dialog-title').attr('id');
101-
equal(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
102-
el.remove();
103-
104-
el = $('<div></div>').dialog();
105-
titleId = dlg().find('.ui-dialog-title').attr('id');
106-
equal(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
107-
el.remove();
108-
109-
el = $('<div id="foo">').dialog();
110-
titleId = dlg().find('.ui-dialog-title').attr('id');
111-
equal(titleId, 'ui-dialog-title-foo', 'carried over title id');
95+
var titleId = dlg().find('.ui-dialog-title').attr('id');
96+
ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
11297
el.remove();
11398
});
11499

ui/jquery.ui.dialog.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ $.widget("ui.dialog", {
8787
options = this.options,
8888

8989
title = options.title || "&#160;",
90-
titleId = $.ui.dialog.getTitleId( this.element ),
9190

9291
uiDialog = ( this.uiDialog = $( "<div>" ) )
9392
.addClass( uiDialogClasses + options.dialogClass )
@@ -105,10 +104,6 @@ $.widget("ui.dialog", {
105104
event.preventDefault();
106105
}
107106
})
108-
.attr({
109-
role: "dialog",
110-
"aria-labelledby": titleId
111-
})
112107
.mousedown(function( event ) {
113108
that.moveToTop( false, event );
114109
})
@@ -140,8 +135,8 @@ $.widget("ui.dialog", {
140135
.appendTo( uiDialogTitlebarClose ),
141136

142137
uiDialogTitle = $( "<span>" )
138+
.uniqueId()
143139
.addClass( "ui-dialog-title" )
144-
.attr( "id", titleId )
145140
.html( title )
146141
.prependTo( uiDialogTitlebar ),
147142

@@ -152,6 +147,11 @@ $.widget("ui.dialog", {
152147
.addClass( "ui-dialog-buttonset" )
153148
.appendTo( uiDialogButtonPane );
154149

150+
uiDialog.attr({
151+
role: "dialog",
152+
"aria-labelledby": uiDialogTitle.attr( "id" )
153+
});
154+
155155
uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
156156
this._hoverable( uiDialogTitlebarClose );
157157
this._focusable( uiDialogTitlebarClose );

0 commit comments

Comments
 (0)