Skip to content

Commit 8ac5da2

Browse files
committed
Accordion: Cleanup.
1 parent f1ff9b8 commit 8ac5da2

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

ui/jquery.ui.accordion.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ $.widget( "ui.accordion", {
3737

3838
self.headers = self.element.find( options.header )
3939
.addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
40-
4140
self._hoverable( self.headers );
4241
self._focusable( self.headers );
43-
42+
self.headers.find( ":first-child" ).addClass( "ui-accordion-heading" );
43+
4444
self.headers.next()
4545
.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
46-
self.headers.find( ":first-child" ).addClass( "ui-accordion-heading" );
4746

4847
self.active = self._findActive( options.active )
4948
.addClass( "ui-state-default ui-state-active" )
@@ -53,7 +52,7 @@ $.widget( "ui.accordion", {
5352

5453
self._createIcons();
5554
self.refresh();
56-
55+
5756
// ARIA
5857
self.element.attr( "role", "tablist" );
5958

@@ -64,7 +63,7 @@ $.widget( "ui.accordion", {
6463
.attr( "role", "tabpanel" );
6564

6665
self.headers
67-
.not( self.active || "" )
66+
.not( self.active )
6867
.attr({
6968
"aria-expanded": "false",
7069
tabIndex: -1
@@ -89,7 +88,7 @@ $.widget( "ui.accordion", {
8988
}
9089

9190
if ( options.event ) {
92-
self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion",
91+
self.headers.bind( options.event.split( " " ).join( ".accordion " ) + ".accordion",
9392
$.proxy( self, "_eventHandler" ) );
9493
}
9594
},
@@ -124,11 +123,14 @@ $.widget( "ui.accordion", {
124123
.removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
125124
.removeAttr( "role" )
126125
.removeAttr( "aria-expanded" )
127-
.removeAttr( "tabIndex" );
128-
129-
this.headers.find( "a" ).removeAttr( "tabIndex" );
126+
.removeAttr( "tabIndex" )
127+
.find( "a" )
128+
.removeAttr( "tabIndex" )
129+
.end()
130+
.find( ".ui-accordion-heading" )
131+
.removeClass( "ui-accordion-heading" );
130132
this._destroyIcons();
131-
this.headers.find( "a:first-child" ).removeClass( "ui-accordion-heading" );
133+
132134
var contents = this.headers.next()
133135
.css( "display", "" )
134136
.removeAttr( "role" )
@@ -139,23 +141,23 @@ $.widget( "ui.accordion", {
139141
},
140142

141143
_setOption: function( key, value ) {
142-
if ( key == "active" ) {
144+
if ( key === "active" ) {
143145
// _activate() will handle invalid values and update this.options
144146
this._activate( value );
145147
return;
146148
}
147-
149+
148150
this._super( "_setOption", key, value );
149-
150-
if ( key == "icons" ) {
151+
152+
if ( key === "icons" ) {
151153
this._destroyIcons();
152154
if ( value ) {
153155
this._createIcons();
154156
}
155157
}
156158
// #5332 - opacity doesn't cascade to positioned elements in IE
157159
// so we need to add the disabled class to the headers and panels
158-
if ( key == "disabled" ) {
160+
if ( key === "disabled" ) {
159161
this.headers.add(this.headers.next())
160162
.toggleClass( "ui-accordion-disabled ui-state-disabled", !!value );
161163
}

0 commit comments

Comments
 (0)