@@ -347,8 +347,26 @@ $.widget( "ui.accordion", {
347347 return ;
348348 }
349349
350+ // find elements to show and hide
351+ var active = this . active ,
352+ toShow = clicked . next ( ) ,
353+ toHide = this . active . next ( ) ,
354+ data = {
355+ options : options ,
356+ newHeader : clickedIsActive && options . collapsible ? $ ( [ ] ) : clicked ,
357+ oldHeader : this . active ,
358+ newContent : clickedIsActive && options . collapsible ? $ ( [ ] ) : toShow ,
359+ oldContent : toHide
360+ } ,
361+ down = this . headers . index ( this . active [ 0 ] ) > this . headers . index ( clicked [ 0 ] ) ;
362+
363+ // when the call to ._toggle() comes after the class changes
364+ // it causes a very odd bug in IE 8 (see #6720)
365+ this . active = clickedIsActive ? $ ( [ ] ) : clicked ;
366+ this . _toggle ( toShow , toHide , data , clickedIsActive , down ) ;
367+
350368 // switch classes
351- this . active
369+ active
352370 . removeClass ( "ui-state-active ui-corner-top" )
353371 . addClass ( "ui-state-default ui-corner-all" )
354372 . children ( ".ui-icon" )
@@ -366,21 +384,6 @@ $.widget( "ui.accordion", {
366384 . addClass ( "ui-accordion-content-active" ) ;
367385 }
368386
369- // find elements to show and hide
370- var toShow = clicked . next ( ) ,
371- toHide = this . active . next ( ) ,
372- data = {
373- options : options ,
374- newHeader : clickedIsActive && options . collapsible ? $ ( [ ] ) : clicked ,
375- oldHeader : this . active ,
376- newContent : clickedIsActive && options . collapsible ? $ ( [ ] ) : toShow ,
377- oldContent : toHide
378- } ,
379- down = this . headers . index ( this . active [ 0 ] ) > this . headers . index ( clicked [ 0 ] ) ;
380-
381- this . active = clickedIsActive ? $ ( [ ] ) : clicked ;
382- this . _toggle ( toShow , toHide , data , clickedIsActive , down ) ;
383-
384387 return ;
385388 } ,
386389
0 commit comments