Skip to content

Commit a26f7ed

Browse files
committed
improved: id handling (follow-up), destroy method
1 parent 0703a99 commit a26f7ed

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ui/jquery.ui.selectmenu.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ $.widget("ui.selectmenu", {
3838
var self = this, o = this.options;
3939

4040
// set a default id value, generate a new random one if not set by developer
41-
var selectmenuId = this.element.attr( 'id' ).replace(/(:|\.)/g,'\\$1') || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 );
41+
var selectmenuId = this.element.attr( 'id' ).replace(':', '\\:') || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 );
4242

4343
// quick array of button and menu id's
44-
this.ids = [ selectmenuId + '-button', selectmenuId + '-menu' ];
44+
this.ids = [ selectmenuId, selectmenuId + '-button', selectmenuId + '-menu' ];
4545

4646
// define safe mouseup for future toggling
4747
this._safemouseup = true;
4848

4949
// create menu button wrapper
5050
this.newelement = $( '<a />', {
5151
'class': this.widgetBaseClass + ' ui-widget ui-state-default ui-corner-all',
52-
'id' : this.ids[ 0 ],
52+
'id' : this.ids[ 1 ],
5353
'role': 'button',
5454
'href': '#nogo',
5555
'tabindex': this.element.attr( 'disabled' ) ? 1 : 0,
5656
'aria-haspopup': true,
57-
'aria-owns': this.ids[ 1 ]
57+
'aria-owns': this.ids[ 2 ]
5858
});
5959
this.newelementWrap = $( o.wrapperElement )
6060
.append( this.newelement )
@@ -78,7 +78,7 @@ $.widget("ui.selectmenu", {
7878

7979
// make associated form label trigger focus
8080
$( 'label[for="' + selectmenuId + '"]' )
81-
.attr( 'for', this.ids[0] )
81+
.attr( 'for', this.ids[1] )
8282
.bind( 'click.selectmenu', function() {
8383
self.newelement[0].focus();
8484
return false;
@@ -183,8 +183,8 @@ $.widget("ui.selectmenu", {
183183
'class': 'ui-widget ui-widget-content',
184184
'aria-hidden': true,
185185
'role': 'listbox',
186-
'aria-labelledby': this.ids[0],
187-
'id': this.ids[1]
186+
'aria-labelledby': this.ids[1],
187+
'id': this.ids[2]
188188
});
189189
this.listWrap = $( o.wrapperElement )
190190
.addClass( self.widgetBaseClass + '-menu' )
@@ -447,8 +447,8 @@ $.widget("ui.selectmenu", {
447447
$( document ).unbind( ".selectmenu" );
448448

449449
// unbind click on label, reset its for attr
450-
$( 'label[for=' + this.newelement.attr('id') + ']' )
451-
.attr( 'for', this.element.attr( 'id' ) )
450+
$( 'label[for=' + this.ids[0] + ']' )
451+
.attr( 'for', this.ids[0] )
452452
.unbind( '.selectmenu' );
453453

454454
this.newelementWrap.remove();

0 commit comments

Comments
 (0)