@@ -227,6 +227,29 @@ export class App extends LitElement {
227
227
return new Set ( this . records . flatMap ( ( record ) => record . bugIds || [ ] ) ) . size ;
228
228
}
229
229
230
+ /**
231
+ * Handle anchor navigation. We need to do this via JS because native navigation
232
+ * does not traverse shadow DOM.
233
+ * @param event The event object.
234
+ */
235
+ private handleAnchorNavigation ( event : Event ) {
236
+ event . preventDefault ( ) ;
237
+ if ( ! ( event . target instanceof HTMLAnchorElement ) ) {
238
+ return ;
239
+ }
240
+
241
+ let target = event . target as HTMLAnchorElement ;
242
+
243
+ if ( ! target . hash . startsWith ( "#" ) ) {
244
+ return ;
245
+ }
246
+
247
+ const element = this . shadowRoot ?. querySelector ( target . hash ) ;
248
+ if ( element ) {
249
+ element . scrollIntoView ( { behavior : "smooth" } ) ;
250
+ }
251
+ }
252
+
230
253
/**
231
254
* Renders the main content of the app which is dependent on the fetched records.
232
255
* @returns The main content.
@@ -246,9 +269,11 @@ export class App extends LitElement {
246
269
return html `
247
270
< p >
248
271
There are currently a total of ${ this . records . length } exceptions on record.
249
- ${ this . records . filter ( ( e ) => ! e . topLevelUrlPattern ?. length ) . length } global exceptions and
250
- ${ this . records . filter ( ( e ) => e . topLevelUrlPattern ?. length ) . length } per-site exceptions.
251
- ${ this . records . filter ( ( e ) => e . category === "baseline" ) . length } of them are baseline
272
+ ${ this . records . filter ( ( e ) => ! e . topLevelUrlPattern ?. length ) . length }
273
+ < a href ="#global-exceptions " @click =${ this . handleAnchorNavigation } > global exceptions</ a > and
274
+ ${ this . records . filter ( ( e ) => e . topLevelUrlPattern ?. length ) . length }
275
+ < a href ="#per-site-exceptions " @click =${ this . handleAnchorNavigation } > per-site exceptions</ a
276
+ > . ${ this . records . filter ( ( e ) => e . category === "baseline" ) . length } of them are baseline
252
277
exceptions and ${ this . records . filter ( ( e ) => e . category === "convenience" ) . length }
253
278
convenience exceptions.
254
279
</ p >
@@ -258,7 +283,7 @@ export class App extends LitElement {
258
283
</ p >
259
284
260
285
< section style ="z-index: 10; ">
261
- < h2 style ="z-index: 20; "> Global Exceptions</ h2 >
286
+ < h2 id =" global-exceptions " style ="z-index: 20; "> Global Exceptions</ h2 >
262
287
< p >
263
288
Global exceptions are applied for sub-resources across all top level sites. They are
264
289
applied when blocking a resource breaks many sites.
@@ -284,7 +309,7 @@ export class App extends LitElement {
284
309
</ section >
285
310
286
311
< section style ="z-index: 50; ">
287
- < h2 style ="z-index: 60; "> Per-Site Exceptions</ h2 >
312
+ < h2 id =" per-site-exceptions " style ="z-index: 60; "> Per-Site Exceptions</ h2 >
288
313
< p >
289
314
Per-site exceptions are applied for sub-resources on a specific top level site. They are
290
315
applied for site specific breakage.
0 commit comments