@@ -338,8 +338,26 @@ $.widget( "ui.accordion", {
338338 return ;
339339 }
340340
341+ // find elements to show and hide
342+ var active = this . active ,
343+ toShow = clicked . next ( ) ,
344+ toHide = this . active . next ( ) ,
345+ data = {
346+ options : options ,
347+ newHeader : clickedIsActive && options . collapsible ? $ ( [ ] ) : clicked ,
348+ oldHeader : this . active ,
349+ newContent : clickedIsActive && options . collapsible ? $ ( [ ] ) : toShow ,
350+ oldContent : toHide
351+ } ,
352+ down = this . headers . index ( this . active [ 0 ] ) > this . headers . index ( clicked [ 0 ] ) ;
353+
354+ // when the call to ._toggle() comes after the class changes
355+ // it causes a very odd bug in IE 8 (see #6720)
356+ this . active = clickedIsActive ? $ ( [ ] ) : clicked ;
357+ this . _toggle ( toShow , toHide , data , clickedIsActive , down ) ;
358+
341359 // switch classes
342- this . active
360+ active
343361 . removeClass ( "ui-state-active ui-corner-top" )
344362 . addClass ( "ui-state-default ui-corner-all" )
345363 . children ( ".ui-icon" )
@@ -357,21 +375,6 @@ $.widget( "ui.accordion", {
357375 . addClass ( "ui-accordion-content-active" ) ;
358376 }
359377
360- // find elements to show and hide
361- var toShow = clicked . next ( ) ,
362- toHide = this . active . next ( ) ,
363- data = {
364- options : options ,
365- newHeader : clickedIsActive && options . collapsible ? $ ( [ ] ) : clicked ,
366- oldHeader : this . active ,
367- newContent : clickedIsActive && options . collapsible ? $ ( [ ] ) : toShow ,
368- oldContent : toHide
369- } ,
370- down = this . headers . index ( this . active [ 0 ] ) > this . headers . index ( clicked [ 0 ] ) ;
371-
372- this . active = clickedIsActive ? $ ( [ ] ) : clicked ;
373- this . _toggle ( toShow , toHide , data , clickedIsActive , down ) ;
374-
375378 return ;
376379 } ,
377380
0 commit comments