Skip to content

Commit 5c7be47

Browse files
committed
Accordion: Use 'that' instead of 'self'. Partial fix for #5404 - remove uses of 'var self = this;'
1 parent 4f909c5 commit 5c7be47

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

ui/jquery.ui.accordion.js

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,18 @@ $.widget( "ui.accordion", {
3333
},
3434

3535
_create: function() {
36-
var self = this,
37-
options = self.options;
36+
var options = this.options;
3837

39-
self.lastToggle = {};
40-
self.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
38+
this.lastToggle = {};
39+
this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
4140

42-
self.headers = self.element.find( options.header )
41+
this.headers = this.element.find( options.header )
4342
.addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
44-
self._hoverable( self.headers );
45-
self._focusable( self.headers );
46-
self.headers.find( ":first-child" ).addClass( "ui-accordion-heading" );
43+
this._hoverable( this.headers );
44+
this._focusable( this.headers );
45+
this.headers.find( ":first-child" ).addClass( "ui-accordion-heading" );
4746

48-
self.headers.next()
47+
this.headers.next()
4948
.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
5049

5150
// don't allow collapsible: false and active: false
@@ -56,26 +55,26 @@ $.widget( "ui.accordion", {
5655
if ( options.active < 0 ) {
5756
options.active += this.headers.length;
5857
}
59-
self.active = self._findActive( options.active )
58+
this.active = this._findActive( options.active )
6059
.addClass( "ui-accordion-header-active ui-state-active" )
6160
.toggleClass( "ui-corner-all" )
6261
.toggleClass( "ui-corner-top" );
63-
self.active.next().addClass( "ui-accordion-content-active" );
62+
this.active.next().addClass( "ui-accordion-content-active" );
6463

65-
self._createIcons();
66-
self.refresh();
64+
this._createIcons();
65+
this.refresh();
6766

6867
// ARIA
69-
self.element.attr( "role", "tablist" );
68+
this.element.attr( "role", "tablist" );
7069

71-
self.headers
70+
this.headers
7271
.attr( "role", "tab" )
73-
.bind( "keydown.accordion", $.proxy( self, "_keydown" ) )
72+
.bind( "keydown.accordion", $.proxy( this, "_keydown" ) )
7473
.next()
7574
.attr( "role", "tabpanel" );
7675

77-
self.headers
78-
.not( self.active )
76+
this.headers
77+
.not( this.active )
7978
.attr({
8079
"aria-expanded": "false",
8180
"aria-selected": "false",
@@ -85,10 +84,10 @@ $.widget( "ui.accordion", {
8584
.hide();
8685

8786
// make sure at least one header is in the tab order
88-
if ( !self.active.length ) {
89-
self.headers.eq( 0 ).attr( "tabIndex", 0 );
87+
if ( !this.active.length ) {
88+
this.headers.eq( 0 ).attr( "tabIndex", 0 );
9089
} else {
91-
self.active.attr({
90+
this.active.attr({
9291
"aria-expanded": "true",
9392
"aria-selected": "true",
9493
tabIndex: 0
@@ -97,7 +96,7 @@ $.widget( "ui.accordion", {
9796

9897
// only need links in tab order for Safari
9998
if ( !$.browser.safari ) {
100-
self.headers.find( "a" ).attr( "tabIndex", -1 );
99+
this.headers.find( "a" ).attr( "tabIndex", -1 );
101100
}
102101

103102
this._setupEvents( options.event );
@@ -362,13 +361,13 @@ $.widget( "ui.accordion", {
362361
},
363362

364363
_toggle: function( data ) {
365-
var self = this,
366-
options = self.options,
364+
var that = this,
365+
options = this.options,
367366
toShow = data.newContent,
368367
toHide = data.oldContent;
369368

370369
function complete() {
371-
self._completed( data );
370+
that._completed( data );
372371
}
373372

374373
if ( options.animated ) {
@@ -385,11 +384,11 @@ $.widget( "ui.accordion", {
385384
}
386385

387386
animations[ animation ]({
388-
widget: self,
387+
widget: this,
389388
toShow: toShow,
390389
toHide: toHide,
391-
prevShow: self.lastToggle.toShow,
392-
prevHide: self.lastToggle.toHide,
390+
prevShow: this.lastToggle.toShow,
391+
prevHide: this.lastToggle.toHide,
393392
complete: complete,
394393
down: toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) )
395394
}, additional );
@@ -572,7 +571,7 @@ if ( $.uiBackCompat !== false ) {
572571
var _create = prototype._create;
573572
prototype._create = function() {
574573
if ( this.options.navigation ) {
575-
var self = this,
574+
var that = this,
576575
headers = this.element.find( this.options.header ),
577576
content = headers.next(),
578577
current = headers.add( content )
@@ -582,7 +581,7 @@ if ( $.uiBackCompat !== false ) {
582581
if ( current ) {
583582
headers.add( content ).each( function( index ) {
584583
if ( $.contains( this, current ) ) {
585-
self.options.active = Math.floor( index / 2 );
584+
that.options.active = Math.floor( index / 2 );
586585
return false;
587586
}
588587
});

0 commit comments

Comments
 (0)