@@ -15,7 +15,7 @@ $(function () {
1515 $ ( "a[href*='#']" )
1616 . not ( "[href='#']" )
1717 . not ( "[href='#0']" )
18- . click ( function ( event ) {
18+ . on ( 'click' , function ( event ) {
1919 if ( this . pathname . replace ( / ^ \/ / , "" ) !==
2020 location . pathname . replace ( / ^ \/ / , "" ) ) {
2121 return ;
@@ -64,28 +64,30 @@ $(function () {
6464 $ ( "html" ) . animate ( {
6565 scrollTop : destOffset
6666 } , 500 , ( ) => {
67- $target . focus ( ) ;
67+ $target . trigger ( "focus" ) ;
6868
6969 /* clean up old scroll mark */
70- if ( $ ( `[${ ATTR_SCROLL_FOCUS } =true]` ) . length ) {
71- $ ( `[${ ATTR_SCROLL_FOCUS } =true]` ) . attr ( ATTR_SCROLL_FOCUS , false ) ;
70+ const $scroll_focus = $ ( `[${ ATTR_SCROLL_FOCUS } =true]` ) ;
71+ if ( $scroll_focus . length ) {
72+ $scroll_focus . attr ( ATTR_SCROLL_FOCUS , "false" ) ;
7273 }
7374
7475 /* Clean :target links */
75- if ( $ ( ":target" ) . length ) { /* element that visited by the URL with hash */
76- $ ( ":target" ) . attr ( ATTR_SCROLL_FOCUS , false ) ;
76+ const $target_links = $ ( ":target" ) ;
77+ if ( $target_links . length ) { /* element that visited by the URL with hash */
78+ $target_links . attr ( ATTR_SCROLL_FOCUS , "false" ) ;
7779 }
7880
7981 /* set scroll mark to footnotes */
8082 if ( toFootnote || toFootnoteRef ) {
81- $target . attr ( ATTR_SCROLL_FOCUS , true ) ;
83+ $target . attr ( ATTR_SCROLL_FOCUS , " true" ) ;
8284 }
8385
8486 if ( $target . is ( ":focus" ) ) { /* Checking if the target was focused */
8587 return false ;
8688 } else {
8789 $target . attr ( "tabindex" , "-1" ) ; /* Adding tabindex for elements not focusable */
88- $target . focus ( ) ; /* Set focus again */
90+ $target . trigger ( "focus" ) ; /* Set focus again */
8991 }
9092
9193 if ( ScrollHelper . hasScrollUpTask ( ) ) {
0 commit comments