File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,19 @@ function init() {
5454 // and the call to fetch those is in fetchComments()
5555 isso_thread . append ( heading ) ;
5656 isso_thread . append ( '<div id="isso-root"></div>' ) ;
57+
58+ window . addEventListener ( 'hashchange' , function ( ) {
59+ if ( ! window . location . hash . match ( "^#isso-[0-9]+$" ) ) {
60+ return ;
61+ }
62+
63+ var existingTarget = $ ( ".isso-target" ) ;
64+ if ( existingTarget != null ) {
65+ existingTarget . classList . remove ( "isso-target" ) ;
66+ }
67+
68+ $ ( window . location . hash + " > .isso-text-wrapper" ) . classList . add ( "isso-target" ) ;
69+ } ) ;
5770}
5871
5972function fetchComments ( ) {
@@ -105,6 +118,11 @@ function fetchComments() {
105118 if ( window . location . hash . length > 0 &&
106119 window . location . hash . match ( "^#isso-[0-9]+$" ) ) {
107120 $ ( window . location . hash ) . scrollIntoView ( ) ;
121+
122+ // We can't just set the id to `#isso-target` because it's already set to `#isso-[number]`
123+ // So a class `.isso-target` has to be used instead, and then we can manually remove the
124+ // class from the old target comment in the `hashchange` listener.
125+ $ ( window . location . hash + " > .isso-text-wrapper" ) . classList . add ( "isso-target" ) ;
108126 }
109127 } ,
110128 function ( err ) {
You can’t perform that action at this time.
0 commit comments