File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -169,6 +169,9 @@ <h1>Python Friendly Error Messages - Demo</h1>
169169 </div>
170170 </section>
171171 ` ;
172+
173+ applyHashTarget ( ) ;
174+ window . addEventListener ( 'hashchange' , applyHashTarget ) ;
172175 } catch ( err ) {
173176 container . innerHTML = `<div class="demo__error">Failed to load demo: ${ escapeHtml ( err . message ) } </div>` ;
174177 }
@@ -188,6 +191,24 @@ <h1>Python Friendly Error Messages - Demo</h1>
188191 return `example-${ index + 1 } -${ slug } ` ;
189192 }
190193
194+ function applyHashTarget ( ) {
195+ document . querySelectorAll ( '.demo__row-target' ) . forEach ( ( el ) => {
196+ el . classList . remove ( 'demo__row-target' ) ;
197+ } ) ;
198+
199+ const hash = window . location . hash ;
200+ if ( ! hash || hash . length <= 1 ) return ;
201+
202+ const targetId = decodeURIComponent ( hash . slice ( 1 ) ) ;
203+ const targetRow = document . getElementById ( targetId ) ;
204+ if ( ! targetRow ) return ;
205+
206+ targetRow . classList . add ( 'demo__row-target' ) ;
207+ requestAnimationFrame ( ( ) => {
208+ targetRow . scrollIntoView ( { block : 'center' , behavior : 'auto' } ) ;
209+ } ) ;
210+ }
211+
191212 initDemo ( ) ;
192213 </ script >
193214</ body >
Original file line number Diff line number Diff line change @@ -231,6 +231,12 @@ h1 {
231231 background : # fff8eb ;
232232}
233233
234+ .demo__table tbody tr .demo__row-target {
235+ outline : 2px solid # c98a2e ;
236+ outline-offset : -2px ;
237+ background : # fff8eb ;
238+ }
239+
234240.demo__row-link {
235241 color : # 8a5a00 ;
236242 text-decoration : underline;
You can’t perform that action at this time.
0 commit comments