-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
1030 lines (956 loc) · 64.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<title>Supporting BFCached Documents</title>
<meta content="UD" name="w3c-status">
<link href="https://www.w3.org/StyleSheets/TR/2021/W3C-UD" rel="stylesheet">
<link href="https://www.w3.org/2008/site/images/favicon.ico" rel="icon">
<meta content="Bikeshed version d9bd89757, updated Thu Mar 23 10:06:53 2023 -0700" name="generator">
<link href="https://w3ctag.github.io/bfcache-guide/" rel="canonical">
<style>/* style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: var(--a-normal-text);
font-size: inherit;
font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
content: "‘";
}
.css::after, .property::after, .descriptor::after {
content: "’";
}
.property, .descriptor {
/* Don't wrap property and descriptor names */
white-space: nowrap;
}
.type { /* CSS value <type> */
font-style: italic;
}
pre .property::before, pre .property::after {
content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
content: "’";
}
[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
content: "";
}
[data-link-type=element],
[data-link-type=element-attr] {
font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after { content: ">" }
[data-link-type=biblio] {
white-space: pre;
}
</style>
<style>/* style-colors */
/* Any --*-text not paired with a --*-bg is assumed to have a transparent bg */
:root {
color-scheme: light dark;
--text: black;
--bg: white;
--unofficial-watermark: url(https://www.w3.org/StyleSheets/TR/2016/logos/UD-watermark);
--logo-bg: #1a5e9a;
--logo-active-bg: #c00;
--logo-text: white;
--tocnav-normal-text: #707070;
--tocnav-normal-bg: var(--bg);
--tocnav-hover-text: var(--tocnav-normal-text);
--tocnav-hover-bg: #f8f8f8;
--tocnav-active-text: #c00;
--tocnav-active-bg: var(--tocnav-normal-bg);
--tocsidebar-text: var(--text);
--tocsidebar-bg: #f7f8f9;
--tocsidebar-shadow: rgba(0,0,0,.1);
--tocsidebar-heading-text: hsla(203,20%,40%,.7);
--toclink-text: var(--text);
--toclink-underline: #3980b5;
--toclink-visited-text: var(--toclink-text);
--toclink-visited-underline: #054572;
--heading-text: #005a9c;
--hr-text: var(--text);
--algo-border: #def;
--del-text: red;
--del-bg: transparent;
--ins-text: #080;
--ins-bg: transparent;
--a-normal-text: #034575;
--a-normal-underline: #bbb;
--a-visited-text: var(--a-normal-text);
--a-visited-underline: #707070;
--a-hover-bg: rgba(75%, 75%, 75%, .25);
--a-active-text: #c00;
--a-active-underline: #c00;
--blockquote-border: silver;
--blockquote-bg: transparent;
--blockquote-text: currentcolor;
--issue-border: #e05252;
--issue-bg: #fbe9e9;
--issue-text: var(--text);
--issueheading-text: #831616;
--example-border: #e0cb52;
--example-bg: #fcfaee;
--example-text: var(--text);
--exampleheading-text: #574b0f;
--note-border: #52e052;
--note-bg: #e9fbe9;
--note-text: var(--text);
--noteheading-text: hsl(120, 70%, 30%);
--notesummary-underline: silver;
--assertion-border: #aaa;
--assertion-bg: #eee;
--assertion-text: black;
--advisement-border: orange;
--advisement-bg: #fec;
--advisement-text: var(--text);
--advisementheading-text: #b35f00;
--warning-border: red;
--warning-bg: hsla(40,100%,50%,0.95);
--warning-text: var(--text);
--amendment-border: #330099;
--amendment-bg: #F5F0FF;
--amendment-text: var(--text);
--amendmentheading-text: #220066;
--def-border: #8ccbf2;
--def-bg: #def;
--def-text: var(--text);
--defrow-border: #bbd7e9;
--datacell-border: silver;
--indexinfo-text: #707070;
--indextable-hover-text: black;
--indextable-hover-bg: #f7f8f9;
--outdatedspec-bg: rgba(0, 0, 0, .5);
--outdatedspec-text: black;
--outdated-bg: maroon;
--outdated-text: white;
--outdated-shadow: red;
--editedrec-bg: darkorange;
}
</style>
<style>/* style-counters */
body {
counter-reset: example figure issue;
}
.issue {
counter-increment: issue;
}
.issue:not(.no-marker)::before {
content: "Issue " counter(issue);
}
.example {
counter-increment: example;
}
.example:not(.no-marker)::before {
content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
content: "Invalid Example" counter(example);
}
figcaption {
counter-increment: figure;
}
figcaption:not(.no-marker)::before {
content: "Figure " counter(figure) " ";
}
</style>
<style>/* style-dfn-panel */
:root {
--dfnpanel-bg: #ddd;
--dfnpanel-text: var(--text);
}
.dfn-panel {
position: absolute;
z-index: 35;
width: 20em;
min-width: min-content;
max-width: 300px;
height: auto;
max-height: 500px;
overflow: auto;
padding: 0.5em 0.75em;
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
background: var(--dfnpanel-bg);
color: var(--dfnpanel-text);
border: outset 0.2em;
white-space: normal; /* in case it's moved into a pre */
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: var(--dfnpanel-text); }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
display: inline-block;
position: fixed;
left: .5em;
bottom: 2em;
margin: 0 auto;
max-width: calc(100vw - 1.5em - .4em - .5em);
max-height: 30vh;
}
.dfn-paneled { cursor: pointer; }
</style>
<style>/* style-issues */
a[href].issue-return {
float: right;
float: inline-end;
color: var(--issueheading-text);
font-weight: bold;
text-decoration: none;
}
</style>
<style>/* style-md-lists */
/* This is a weird hack for me not yet following the commonmark spec
regarding paragraph and lists. */
[data-md] > :first-child {
margin-top: 0;
}
[data-md] > :last-child {
margin-bottom: 0;
}
</style>
<style>/* style-selflinks */
:root {
--selflink-text: white;
--selflink-bg: gray;
--selflink-hover-text: black;
}
.heading, .issue, .note, .example, li, dt {
position: relative;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
}
a.self-link:hover {
opacity: 1;
}
.heading > a.self-link {
font-size: 83%;
}
.example > a.self-link,
.note > a.self-link,
.issue > a.self-link {
/* These blocks are overflow:auto, so positioning outside
doesn't work. */
left: auto;
right: 0;
}
li > a.self-link {
left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
top: auto;
left: auto;
opacity: 0;
width: 1.5em;
height: 1.5em;
background: var(--selflink-bg);
color: var(--selflink-text);
font-style: normal;
transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
opacity: 1;
}
dfn > a.self-link:hover {
color: var(--selflink-hover-text);
}
a.self-link::before { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before { content: "#"; }
</style>
<style>/* style-darkmode */
@media (prefers-color-scheme: dark) {
:root {
--text: #ddd;
--bg: black;
--unofficial-watermark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cg fill='%23100808' transform='translate(200 200) rotate(-45) translate(-200 -200)' stroke='%23100808' stroke-width='3'%3E%3Ctext x='50%25' y='220' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EUNOFFICIAL%3C/text%3E%3Ctext x='50%25' y='305' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EDRAFT%3C/text%3E%3C/g%3E%3C/svg%3E");
--logo-bg: #1a5e9a;
--logo-active-bg: #c00;
--logo-text: white;
--tocnav-normal-text: #999;
--tocnav-normal-bg: var(--bg);
--tocnav-hover-text: var(--tocnav-normal-text);
--tocnav-hover-bg: #080808;
--tocnav-active-text: #f44;
--tocnav-active-bg: var(--tocnav-normal-bg);
--tocsidebar-text: var(--text);
--tocsidebar-bg: #080808;
--tocsidebar-shadow: rgba(255,255,255,.1);
--tocsidebar-heading-text: hsla(203,20%,40%,.7);
--toclink-text: var(--text);
--toclink-underline: #6af;
--toclink-visited-text: var(--toclink-text);
--toclink-visited-underline: #054572;
--heading-text: #8af;
--hr-text: var(--text);
--algo-border: #456;
--del-text: #f44;
--del-bg: transparent;
--ins-text: #4a4;
--ins-bg: transparent;
--a-normal-text: #6af;
--a-normal-underline: #555;
--a-visited-text: var(--a-normal-text);
--a-visited-underline: var(--a-normal-underline);
--a-hover-bg: rgba(25%, 25%, 25%, .2);
--a-active-text: #f44;
--a-active-underline: var(--a-active-text);
--borderedblock-bg: rgba(255, 255, 255, .05);
--blockquote-border: silver;
--blockquote-bg: var(--borderedblock-bg);
--blockquote-text: currentcolor;
--issue-border: #e05252;
--issue-bg: var(--borderedblock-bg);
--issue-text: var(--text);
--issueheading-text: hsl(0deg, 70%, 70%);
--example-border: hsl(50deg, 90%, 60%);
--example-bg: var(--borderedblock-bg);
--example-text: var(--text);
--exampleheading-text: hsl(50deg, 70%, 70%);
--note-border: hsl(120deg, 100%, 35%);
--note-bg: var(--borderedblock-bg);
--note-text: var(--text);
--noteheading-text: hsl(120, 70%, 70%);
--notesummary-underline: silver;
--assertion-border: #444;
--assertion-bg: var(--borderedblock-bg);
--assertion-text: var(--text);
--advisement-border: orange;
--advisement-bg: #222218;
--advisement-text: var(--text);
--advisementheading-text: #f84;
--warning-border: red;
--warning-bg: hsla(40,100%,20%,0.95);
--warning-text: var(--text);
--amendment-border: #330099;
--amendment-bg: #080010;
--amendment-text: var(--text);
--amendmentheading-text: #cc00ff;
--def-border: #8ccbf2;
--def-bg: #080818;
--def-text: var(--text);
--defrow-border: #136;
--datacell-border: silver;
--indexinfo-text: #aaa;
--indextable-hover-text: var(--text);
--indextable-hover-bg: #181818;
--outdatedspec-bg: rgba(255, 255, 255, .5);
--outdatedspec-text: black;
--outdated-bg: maroon;
--outdated-text: white;
--outdated-shadow: red;
--editedrec-bg: darkorange;
}
/* In case a transparent-bg image doesn't expect to be on a dark bg,
which is quite common in practice... */
img { background: white; }
}
@media (prefers-color-scheme: dark) {
:root {
--selflink-text: black;
--selflink-bg: silver;
--selflink-hover-text: white;
}
}
@media (prefers-color-scheme: dark) {
:root {
--dfnpanel-bg: #222;
--dfnpanel-text: var(--text);
}
}
</style>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a> </p>
<h1 class="p-name no-ref" id="title">Supporting BFCached Documents</h1>
<p id="w3c-state"><a href="https://www.w3.org/standards/types#UD">Unofficial Proposal Draft</a>, <time class="dt-updated" datetime="2023-04-02">2 April 2023</time></p>
<details open>
<summary>More details about this document</summary>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://w3ctag.github.io/bfcache-guide/">https://w3ctag.github.io/bfcache-guide/</a>
<dt>Issue Tracking:
<dd><a href="https://github.com/w3ctag/bfcache-guide/issues/">GitHub</a>
<dt class="editor">Editor:
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:rakina@google.com">Rakina Zata Amni</a> (<a class="p-org org" href="https://www.google.com/">Google</a>)
</dl>
</div>
</details>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="https://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2023 <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document" rel="license">permissive document license</a> rules apply. </p>
<hr title="Separator for header">
</div>
<div class="p-summary" data-fill-with="abstract">
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<p>This document gives guidance on how to write specifications that
handle BFCached documents, where a document is kept alive (instead of
getting destroyed) after navigation, and potentially gets reused on
future navigations back to the document.</p>
</div>
<h2 class="no-num no-toc no-ref heading settled" id="sotd"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p> <em>This section describes the status of this document at the time of its
publication. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the
latest revision of this technical report can be found in the <a href="https://www.w3.org/TR/"><abbr title="World Wide Web
Consortium">W3C</abbr> technical reports index</a>.</em> </p>
<p> This document was published by the <a href="https://www.w3.org/2001/tag/">W3C Technical Architecture Group
(TAG)</a> as an Unofficial Proposal Draft.
Publication as an Unofficial Proposal Draft does not imply endorsement by <abbr title="World Wide Web Consortium">W3C</abbr> and its Members. This is a
draft document and may be updated, replaced or obsoleted by other documents
at any time. It is inappropriate to cite this document as other than work in
progress. </p>
<p></p>
<p> Feedback and comments on this specification are welcome. Please <a href="https://github.com/w3ctag/bfcache-guide/issues">file an issue</a> in this document’s <a href="https://github.com/w3ctag/bfcache-guide/">GitHub repository</a>. </p>
<p> This document is governed by the <a href="https://www.w3.org/2019/Process-20190301/" id="w3c_process_revision">1 March 2019 W3C Process
Document</a>. </p>
</div>
<div data-fill-with="at-risk"></div>
<nav data-fill-with="table-of-contents" id="toc">
<h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<ol class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content">Introduction</span></a>
<li>
<a href="#when-to-use"><span class="secno">2</span> <span class="content">When should features care about BFCache?</span></a>
<ol class="toc">
<li>
<a href="#api-design-guide"><span class="secno">2.1</span> <span class="content">API Design Guidance</span></a>
<ol class="toc">
<li><a href="#gate-fully-active"><span class="secno">2.1.1</span> <span class="content">Gate actions with <span>fully active</span> checks</span></a>
<li><a href="#listen-fully-active"><span class="secno">2.1.2</span> <span class="content">Listen for changes to <span>fully active</span> status</span></a>
<li><a href="#omit-non-fully-active"><span class="secno">2.1.3</span> <span class="content">Omit non-<span>fully active</span> documents from APIs that span multiple documents</span></a>
<li><a href="#discard"><span class="secno">2.1.4</span> <span class="content">Discard non-<span>fully active</span> documents for situations that can’t be supported</span></a>
<li><a href="#per-document-state"><span class="secno">2.1.5</span> <span class="content">Be aware that per-document state/data might persist after navigation</span></a>
</ol>
<li><a href="#antipatterns"><span class="secno">2.2</span> <span class="content">Antipatterns</span></a>
</ol>
<li>
<a href="#w3c-conformance"><span class="secno"></span> <span class="content">Conformance</span></a>
<ol class="toc">
<li><a href="#w3c-conventions"><span class="secno"></span> <span class="content">Document conventions</span></a>
<li><a href="#w3c-conformant-algorithms"><span class="secno"></span> <span class="content">Conformant Algorithms</span></a>
</ol>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ol class="toc">
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ol>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
</ol>
</ol>
</nav>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#intro"></a></h2>
<p>Browser implementations may have a back/forward cache, or "BFCache" for short.
After a user navigates away from a document, the document might be cached in a non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active">fully active</a> state,
and might be reused when the user navigates back.
In the past, many APIs have missed specifying support for non-fully active documents,
making them hard to support in various user agents that cache pages in the BFCache,
effectively making the user experience of navigating back and forth less optimal,
or even introducing breakages or differences in behavior in various different implementations of BFCache.</p>
<p>By specifying BFCache support for new APIs,
web developers do not need to choose between using the API and giving a more performant browsing experience through instant history navigations.
Going forward, <b>all features should have BFCache support by default</b>,
as documents are actually BFCached on navigation instead of getting destroyed for a sizable chunk of navigations.</p>
<p class="note" role="note"><span class="marker">Note:</span> It is possible for a document to become non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①">fully active</a> for other reasons
not related to BFcaching, such as when the iframe holding the document gets
detached. Some advice below might not be relevant for those cases, since the
document will never return to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②">fully active</a> again.</p>
<h2 class="heading settled" data-level="2" id="when-to-use"><span class="secno">2. </span><span class="content">When should features care about BFCache?</span><a class="self-link" href="#when-to-use"></a></h2>
<p>If your API does things that fall into <b>any</b> of the below categories:</p>
<ul>
<li data-md>
<p>Interacts with a document from the "outside" (e.g. sends information to a
document)</p>
<li data-md>
<p>Makes cross-document interaction/resource sharing possible (e.g. holding
locks)</p>
<li data-md>
<p>May malfunction when a document is kept in a non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③">fully active</a> (BFCached) state (instead of getting destroyed) after the user navigates
away from it or gets restored (e.g. expects that a state saved in the
document won’t span multiple navigations)</p>
</ul>
<p>You should specify how it works with non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④">fully active</a> (BFCached)
documents, following the guidelines below.
See also the <a href="#antipatterns">§ 2.2 Antipatterns</a> section to avoid common antipatterns.</p>
<h3 class="heading settled" data-level="2.1" id="api-design-guide"><span class="secno">2.1. </span><span class="content">API Design Guidance</span><a class="self-link" href="#api-design-guide"></a></h3>
<h4 class="heading settled" data-level="2.1.1" id="gate-fully-active"><span class="secno">2.1.1. </span><span class="content">Gate actions with <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active⑤">fully active</a> checks</span><a class="self-link" href="#gate-fully-active"></a></h4>
<p>When performing actions that might update the state of a document,
be aware that the document might not be <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active⑥">fully active</a> and is considered as "non-existent" from the user’s perspective.
This means they should not receive updates or perform actions.</p>
<p class="note" role="note"><span class="marker">Note:</span> It is possible for a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active⑦">fully active</a> document to be perceived as "non-existent" by users,
such as when the document is <a href="https://wicg.github.io/nav-speculation/prerendering.html">displaying prerendered content</a>.
These documents might behave differently than non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active⑧">fully active</a> documents,
and the guidelines here might not be applicable to them,
as it is written only for handling non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active⑨">fully active</a> (BFCached) documents.</p>
<p>In many cases,
anything that happens while the document is not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①⓪">fully active</a> should be treated as if it never happened.
If it makes more sense to "update" a document to ensure it does not hold stale information
after it becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①①">fully active</a> again, consider the <a href="#listen-fully-active">§ 2.1.2 Listen for changes to fully active status</a> pattern below.</p>
<div class="example" id="example-be5edf6e"><a class="self-link" href="#example-be5edf6e"></a> APIs that periodically send information updates,
such as Geolocation API’s <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/geolocation-api/#dom-geolocation-watchposition" id="ref-for-dom-geolocation-watchposition">watchPosition()</a></code> should not send updates if the document is no longer fully active.
They also should not queue those updates to arrive later.
Instead, they should only resume sending updates when the document becomes active again,
possibly sending one update with the latest information then. </div>
<p class="note" role="note"><span class="marker">Note:</span> If the actions are already protected by certain checks that can only be satisfied if the document is <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①②">fully active</a>,
such as checking if the top-level browsing context has <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#system-focus" id="ref-for-system-focus">system focus</a>,
fully active checks might not be needed.
However, be careful of certain checks like transient user activation,
which can be true even if a document is not fully active.
See also the <a href="#per-document-state">§ 2.1.5 Be aware that per-document state/data might persist after navigation</a> section.</p>
<h4 class="heading settled" data-level="2.1.2" id="listen-fully-active"><span class="secno">2.1.2. </span><span class="content">Listen for changes to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①③">fully active</a> status</span><a class="self-link" href="#listen-fully-active"></a></h4>
<p>When a document goes from <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①④">fully active</a> to non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①⑤">fully active</a>,
it should be treated similarly to the way discarded documents are treated.
The document must not retain exclusive access to shared resources
and must ensure that no new requests are issued
and that connections that allow for new incoming requests are terminated.
When a document goes from non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①⑥">fully active</a> to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①⑦">fully active</a> again,
it can restore connections if appropriate.</p>
<p>To listen to changes from <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①⑧">fully active</a> to non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active①⑨">fully active</a>,
add a step in <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-lifecycle.html#unloading-document-cleanup-steps" id="ref-for-unloading-document-cleanup-steps">unloading document cleanup steps</a>.
Meanwhile, to listen to changes from non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②⓪">fully active</a> to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②①">fully active</a>,
add a step to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#reactivate-a-document" id="ref-for-reactivate-a-document">reactivate</a> a document.</p>
<p>While web authors can manually do cleanup (e.g. release the resources, sever connections)
from within the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/indices.html#event-pagehide" id="ref-for-event-pagehide">pagehide</a></code> event and restore them from the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/indices.html#event-pageshow" id="ref-for-event-pageshow">pageshow</a></code> event themselves,
doing this automatically from the API design allows the document to be kept alive after navigation by default,
and is more likely to lead to well-functioning web applications.</p>
<div class="example" id="example-76ebae04"><a class="self-link" href="#example-76ebae04"></a> APIs that create live connections can pause/close the connection and possibly resume/reopen it later.
It’s also possible to let the connection stay open to complete existing ongoing requests,
and later update the document with the result when it gets restored, if appropriate (e.g.
resource loads). </div>
<div class="example" id="example-1dfbe459"><a class="self-link" href="#example-1dfbe459"></a> APIs that hold non-exclusive resources
may be able to release the resource when the document becomes not fully active,
and re-acquire them when it becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②②">fully active</a> again
(Screen Wake Lock API is already <a href="https://w3c.github.io/screen-wake-lock/#handling-document-loss-of-full-activity">doing</a> the first part). </div>
<p class="note" role="note"><span class="marker">Note:</span> this might not be appropriate for all types of resources,
e.g. if an exclusive lock is held,
we cannot just release it and reacquire when <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②③">fully active</a> since another page could then take that lock.
If there is an API to signal to the page that this has happened,
it may be acceptable but beware that if the only time this happens is with BFCache,
then it’s likely many pages are not prepared for it. If it is not possible to support BFCache,
follow the <a href="#discard">§ 2.1.4 Discard non-fully active documents for situations that can’t be supported</a> pattern described below.</p>
<p>Additionally, when a document becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②④">fully active</a> again,
it can be useful to update it with the current state of the world,
if anything has changed while it is in the non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②⑤">fully active</a> state.
However, care needs to be taken with events that occurred while in the BFCache.
When not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②⑥">fully active</a>, for some cases, all events should be dropped,
in some the latest state should be delivered in a single event,
in others it may be appropriate to queue events or deliver a combined event.
The correct approach is case by case and should consider privacy,
correctness, performance and ergonomics.</p>
<p class="note" role="note"><span class="marker">Note:</span> Making sure the latest state is sent to a document that becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②⑦">fully active</a> again is especially important when retrofitting existing APIs.
This is because current users of these APIs expect to always have the latest information.
Dropping state updates can leave the document with stale information,
which can lead to unexpected and hard-to-detect breakage of existing sites.</p>
<div class="example" id="example-32a4ab83"><a class="self-link" href="#example-32a4ab83"></a> The <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/gamepad/#dfn-gamepadconnected" id="ref-for-dfn-gamepadconnected">gamepadconnected</a></code> event
can be sent to a document that becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②⑧">fully active</a> again
if a gamepad is connected while the document is not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active②⑨">fully active</a>.
If the gamepad was repeatedly connected and disconnected,
only the final connected event should be delivered.
(This is not specified yet, see <a href="https://github.com/w3c/gamepad/issues/149">issue</a>) </div>
<div class="example" id="example-46b7099c"><a class="self-link" href="#example-46b7099c"></a> For geolocation or other physical sensors,
no information about what happened while not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③⓪">fully active</a> should be delivered.
The events should simply resume from when the document became <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③①">fully active</a>.
However, these APIs should check the state when the document becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③②">fully active</a> again,
to determine if a status update should be sent (e.g. is the current location far away from the
location when the document becomes not fully active?), to ensure the document has the latest
information, as guaranteed by the API normally. </div>
<div class="example" id="example-3f8cc6e6"><a class="self-link" href="#example-3f8cc6e6"></a> For network connections or streams,
the data received while not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③③">fully active</a> should be delivered only
when the document becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③④">fully active</a> again,
but whereas a stream might have created many events with a small amount of data each,
it could be delivered as smaller number of events with more data in each. </div>
<h4 class="heading settled" data-level="2.1.3" id="omit-non-fully-active"><span class="secno">2.1.3. </span><span class="content">Omit non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③⑤">fully active</a> documents from APIs that span multiple documents</span><a class="self-link" href="#omit-non-fully-active"></a></h4>
Non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③⑥">fully active</a> documents should not be observable,
so APIs should treat them as if they no longer exist.
They should not be visible to the "outside world" through document-spanning APIs
(e.g. <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/ServiceWorker/#dom-clients-matchall" id="ref-for-dom-clients-matchall">clients.matchAll()</a></code>, <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-opener" id="ref-for-dom-opener">window.opener</a></code>).
<p class="note" role="note"><span class="marker">Note:</span> This should be rare since cross-document-spanning APIs are themselves relatively rare.</p>
<div class="example" id="example-20998cac"><a class="self-link" href="#example-20998cac"></a> <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/web-messaging.html#broadcastchannel" id="ref-for-broadcastchannel">BroadcastChannel</a></code> <a href="https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts:fully-active">checks</a> for <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③⑦">fully active</a> before sending messages to other browsing contexts. </div>
<div class="example" id="example-1a865af0"><a class="self-link" href="#example-1a865af0"></a> <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/ServiceWorker/#dom-clients-matchall" id="ref-for-dom-clients-matchall①">clients.matchAll()</a></code> currently does not distinguish between <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③⑧">fully active</a> and non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active③⑨">fully active</a> clients,
but correct implementations should only return <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④⓪">fully active</a> clients.
(See <a href="https://github.com/w3c/ServiceWorker/issues/1594">issue</a>) </div>
<h4 class="heading settled" data-level="2.1.4" id="discard"><span class="secno">2.1.4. </span><span class="content">Discard non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④①">fully active</a> documents for situations that can’t be supported</span><a class="self-link" href="#discard"></a></h4>
If supporting non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④②">fully active</a> documents is not possible for certain cases,
explicitly specify it by <a data-link-type="dfn">discarding the document|</a> if the situation happens after the user navigated away,
or setting the document’s <a href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#concept-document-salvageable">salvageable</a>)
bit to false if the situation happens before or during the navigation away from the document,
to cause it to be automatically discarded after navigation.
<p class="note" role="note"><span class="marker">Note:</span> this should be rare and probably should only be used when retrofitting old APIs,
as new APIs should always strive to work well with BFCache.</p>
<div class="example" id="example-94d4ddf4"><a class="self-link" href="#example-94d4ddf4"></a> WebSockets <a href="https://html.spec.whatwg.org/#unloading-documents:concept-document-salvageable-7">sets the salvageable bit to false</a> during unload. </div>
<div class="example" id="example-47c778e3"><a class="self-link" href="#example-47c778e3"></a> Calling <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/ServiceWorker/#dom-clients-claim" id="ref-for-dom-clients-claim">clients.claim()</a></code> should not wait for non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④③">fully active</a> clients,
instead it should cause the non-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④④">fully active</a> client documents to be discarded.
(This is currently not specified, see <a href="https://github.com/w3c/ServiceWorker/issues/1594">issue</a>) </div>
<h4 class="heading settled" data-level="2.1.5" id="per-document-state"><span class="secno">2.1.5. </span><span class="content">Be aware that per-document state/data might persist after navigation</span><a class="self-link" href="#per-document-state"></a></h4>
As a document might be reused even after navigation,
be aware that tying something to a document’s lifetime
also means reusing it after navigations.
If this is not desirable,
consider listening to changes to the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active" id="ref-for-fully-active④⑤">fully active</a> state
and doing cleanup as necessary (see the <a href="#listen-fully-active">§ 2.1.2 Listen for changes to fully active status</a> pattern above).
<div class="example" id="example-957129a3"><a class="self-link" href="#example-957129a3"></a> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation" id="ref-for-sticky-activation">Sticky activation</a> is determined by the "last activation timestamp",
which is tied to a document.
This means after a user triggers activation once on a document,
the document will have sticky activation forever,
even after the user navigated away and back to it again.
The <a href="https://github.com/whatwg/html/issues/6588#issuecomment-1157244943">discussion</a> around this concluded that this is OK after comparing with other behaviors (e.g. focus),
but every feature specification should think about this and decide what works best for the feature. </div>
<h3 class="heading settled" data-level="2.2" id="antipatterns"><span class="secno">2.2. </span><span class="content">Antipatterns</span><a class="self-link" href="#antipatterns"></a></h3>
<p>This is basically the reverse of what is mentioned in the design guidance.
When writing specifications, <b>do not do these</b>:</p>
<ul>
<li data-md>
<p>Expect that things kept alive in the document (connections, etc) or that are otherwise tied to the document lifetime
will be automatically destroyed/disconnected/etc on navigation along with document destruction.
This is wrong because documents might be kept alive in the BFCache after navigation,
and can potentially get restored later.
See these guides on how to handle this:</p>
<ul>
<li data-md>
<p><a href="#gate-fully-active">§ 2.1.1 Gate actions with fully active checks</a></p>
<li data-md>
<p><a href="#listen-fully-active">§ 2.1.2 Listen for changes to fully active status</a></p>
</ul>
<li data-md>
<p>Expect that if a document is alive, it is also perceived as alive by the user,
and thus can be treated like any other document.
This is wrong because documents that are BFCached are “alive”,
but they’re actually gone from the perspective of the users (as they have navigated away),
and thus shouldn’t be treated the same way as other documents.
See these guides on how to handle this:</p>
<ul>
<li data-md>
<p><a href="#omit-non-fully-active">§ 2.1.3 Omit non-fully active documents from APIs that span multiple documents</a></p>
<li data-md>
<p><a href="#gate-fully-active">§ 2.1.1 Gate actions with fully active checks</a></p>
</ul>
<li data-md>
<p>Expect that a document is only “shown”/navigated to once.
This is wrong because documents can potentially get restored on future history navigations,
and thus the user can navigate to and reuse the same document multiple times with multiple navigations.
See these guides on how to handle this:</p>
<ul>
<li data-md>
<p><a href="#listen-fully-active">§ 2.1.2 Listen for changes to fully active status</a></p>
<li data-md>
<p><a href="#per-document-state">§ 2.1.5 Be aware that per-document state/data might persist after navigation</a></p>
</ul>
</ul>
</main>
<div data-fill-with="conformance">
<h2 class="no-ref no-num heading settled" id="w3c-conformance"><span class="content">Conformance</span><a class="self-link" href="#w3c-conformance"></a></h2>
<h3 class="no-ref no-num heading settled" id="w3c-conventions"><span class="content">Document conventions</span><a class="self-link" href="#w3c-conventions"></a></h3>
<p>Conformance requirements are expressed
with a combination of descriptive assertions
and RFC 2119 terminology.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL”
in the normative parts of this document
are to be interpreted as described in RFC 2119.
However, for readability,
these words do not appear in all uppercase letters in this specification. </p>
<p>All of the text of this specification is normative
except sections explicitly marked as non-normative, examples, and notes. <a data-link-type="biblio" href="#biblio-rfc2119" title="Key words for use in RFCs to Indicate Requirement Levels">[RFC2119]</a> </p>
<p>Examples in this specification are introduced with the words “for example”
or are set apart from the normative text
with <code>class="example"</code>,
like this: </p>
<div class="example" id="w3c-example">
<a class="self-link" href="#w3c-example"></a>
<p>This is an example of an informative example. </p>
</div>
<p>Informative notes begin with the word “Note”
and are set apart from the normative text
with <code>class="note"</code>,
like this: </p>
<p class="note" role="note">Note, this is an informative note.</p>
<h3 class="no-ref no-num heading settled" id="w3c-conformant-algorithms"><span class="content">Conformant Algorithms</span><a class="self-link" href="#w3c-conformant-algorithms"></a></h3>
<p>Requirements phrased in the imperative as part of algorithms
(such as "strip any leading space characters"
or "return false and abort these steps")
are to be interpreted with the meaning of the key word
("must", "should", "may", etc)
used in introducing the algorithm. </p>
<p>Conformance requirements phrased as algorithms or specific steps
can be implemented in any manner,
so long as the end result is equivalent.
In particular, the algorithms defined in this specification
are intended to be easy to understand
and are not intended to be performant.
Implementers are encouraged to optimize. </p>
</div>
<script src="https://www.w3.org/scripts/TR/2021/fixup.js"></script>
<h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2>
<aside aria-labelledby="infopaneltitle-for-6d0578ffdf5f512c436348fdc7085334" class="dfn-panel" data-for="6d0578ffdf5f512c436348fdc7085334" id="infopanel-for-6d0578ffdf5f512c436348fdc7085334">
<span id="infopaneltitle-for-6d0578ffdf5f512c436348fdc7085334" style="display:none">Info about the 'gamepadconnected' external reference.</span><a href="https://w3c.github.io/gamepad/#dfn-gamepadconnected">https://w3c.github.io/gamepad/#dfn-gamepadconnected</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dfn-gamepadconnected">2.1.2. Listen for changes to fully active status</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-5f721c0a6f3beaadea199c80f8358c22" class="dfn-panel" data-for="5f721c0a6f3beaadea199c80f8358c22" id="infopanel-for-5f721c0a6f3beaadea199c80f8358c22">
<span id="infopaneltitle-for-5f721c0a6f3beaadea199c80f8358c22" style="display:none">Info about the 'watchPosition()' external reference.</span><a href="https://w3c.github.io/geolocation-api/#dom-geolocation-watchposition">https://w3c.github.io/geolocation-api/#dom-geolocation-watchposition</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-geolocation-watchposition">2.1.1. Gate actions with fully active checks</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-9110f806bb5fdbbb16bc9c04252670d5" class="dfn-panel" data-for="9110f806bb5fdbbb16bc9c04252670d5" id="infopanel-for-9110f806bb5fdbbb16bc9c04252670d5">
<span id="infopaneltitle-for-9110f806bb5fdbbb16bc9c04252670d5" style="display:none">Info about the 'BroadcastChannel' external reference.</span><a href="https://html.spec.whatwg.org/multipage/web-messaging.html#broadcastchannel">https://html.spec.whatwg.org/multipage/web-messaging.html#broadcastchannel</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-broadcastchannel">2.1.3. Omit non-fully active documents from APIs that span multiple documents</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-7594a09aa0c77c9e24726559a3a6da9d" class="dfn-panel" data-for="7594a09aa0c77c9e24726559a3a6da9d" id="infopanel-for-7594a09aa0c77c9e24726559a3a6da9d">
<span id="infopaneltitle-for-7594a09aa0c77c9e24726559a3a6da9d" style="display:none">Info about the 'fully active' external reference.</span><a href="https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active">https://html.spec.whatwg.org/multipage/document-sequences.html#fully-active</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-fully-active">1. Introduction</a> <a href="#ref-for-fully-active①">(2)</a> <a href="#ref-for-fully-active②">(3)</a>
<li><a href="#ref-for-fully-active③">2. When should features care about BFCache?</a> <a href="#ref-for-fully-active④">(2)</a>
<li><a href="#ref-for-fully-active⑤">2.1.1. Gate actions with fully active checks</a> <a href="#ref-for-fully-active⑥">(2)</a> <a href="#ref-for-fully-active⑦">(3)</a> <a href="#ref-for-fully-active⑧">(4)</a> <a href="#ref-for-fully-active⑨">(5)</a> <a href="#ref-for-fully-active①⓪">(6)</a> <a href="#ref-for-fully-active①①">(7)</a> <a href="#ref-for-fully-active①②">(8)</a>
<li><a href="#ref-for-fully-active①③">2.1.2. Listen for changes to fully active status</a> <a href="#ref-for-fully-active①④">(2)</a> <a href="#ref-for-fully-active①⑤">(3)</a> <a href="#ref-for-fully-active①⑥">(4)</a> <a href="#ref-for-fully-active①⑦">(5)</a> <a href="#ref-for-fully-active①⑧">(6)</a> <a href="#ref-for-fully-active①⑨">(7)</a> <a href="#ref-for-fully-active②⓪">(8)</a> <a href="#ref-for-fully-active②①">(9)</a> <a href="#ref-for-fully-active②②">(10)</a> <a href="#ref-for-fully-active②③">(11)</a> <a href="#ref-for-fully-active②④">(12)</a> <a href="#ref-for-fully-active②⑤">(13)</a> <a href="#ref-for-fully-active②⑥">(14)</a> <a href="#ref-for-fully-active②⑦">(15)</a> <a href="#ref-for-fully-active②⑧">(16)</a> <a href="#ref-for-fully-active②⑨">(17)</a> <a href="#ref-for-fully-active③⓪">(18)</a> <a href="#ref-for-fully-active③①">(19)</a> <a href="#ref-for-fully-active③②">(20)</a> <a href="#ref-for-fully-active③③">(21)</a> <a href="#ref-for-fully-active③④">(22)</a>
<li><a href="#ref-for-fully-active③⑤">2.1.3. Omit non-fully active documents from APIs that span multiple documents</a> <a href="#ref-for-fully-active③⑥">(2)</a> <a href="#ref-for-fully-active③⑦">(3)</a> <a href="#ref-for-fully-active③⑧">(4)</a> <a href="#ref-for-fully-active③⑨">(5)</a> <a href="#ref-for-fully-active④⓪">(6)</a>
<li><a href="#ref-for-fully-active④①">2.1.4. Discard non-fully active documents for situations that can’t be supported</a> <a href="#ref-for-fully-active④②">(2)</a> <a href="#ref-for-fully-active④③">(3)</a> <a href="#ref-for-fully-active④④">(4)</a>
<li><a href="#ref-for-fully-active④⑤">2.1.5. Be aware that per-document state/data might persist after navigation</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-9d8ff05d06644943ae33e1c8cddde31d" class="dfn-panel" data-for="9d8ff05d06644943ae33e1c8cddde31d" id="infopanel-for-9d8ff05d06644943ae33e1c8cddde31d">
<span id="infopaneltitle-for-9d8ff05d06644943ae33e1c8cddde31d" style="display:none">Info about the 'opener' external reference.</span><a href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-opener">https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-opener</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-opener">2.1.3. Omit non-fully active documents from APIs that span multiple documents</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-ff9f6ed4f290e15aa3c0172b660aeeac" class="dfn-panel" data-for="ff9f6ed4f290e15aa3c0172b660aeeac" id="infopanel-for-ff9f6ed4f290e15aa3c0172b660aeeac">
<span id="infopaneltitle-for-ff9f6ed4f290e15aa3c0172b660aeeac" style="display:none">Info about the 'pagehide' external reference.</span><a href="https://html.spec.whatwg.org/multipage/indices.html#event-pagehide">https://html.spec.whatwg.org/multipage/indices.html#event-pagehide</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-event-pagehide">2.1.2. Listen for changes to fully active status</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-54f0bfa77c123404411d9b8b462c6b35" class="dfn-panel" data-for="54f0bfa77c123404411d9b8b462c6b35" id="infopanel-for-54f0bfa77c123404411d9b8b462c6b35">
<span id="infopaneltitle-for-54f0bfa77c123404411d9b8b462c6b35" style="display:none">Info about the 'pageshow' external reference.</span><a href="https://html.spec.whatwg.org/multipage/indices.html#event-pageshow">https://html.spec.whatwg.org/multipage/indices.html#event-pageshow</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-event-pageshow">2.1.2. Listen for changes to fully active status</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-845bffcb8707bbb2a1459536eecf13cc" class="dfn-panel" data-for="845bffcb8707bbb2a1459536eecf13cc" id="infopanel-for-845bffcb8707bbb2a1459536eecf13cc">
<span id="infopaneltitle-for-845bffcb8707bbb2a1459536eecf13cc" style="display:none">Info about the 'reactivate' external reference.</span><a href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#reactivate-a-document">https://html.spec.whatwg.org/multipage/browsing-the-web.html#reactivate-a-document</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-reactivate-a-document">2.1.2. Listen for changes to fully active status</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-83418513ea93980e95697432d0d33474" class="dfn-panel" data-for="83418513ea93980e95697432d0d33474" id="infopanel-for-83418513ea93980e95697432d0d33474">
<span id="infopaneltitle-for-83418513ea93980e95697432d0d33474" style="display:none">Info about the 'sticky activation' external reference.</span><a href="https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation">https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-sticky-activation">2.1.5. Be aware that per-document state/data might persist after navigation</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-877bb12103715513886b6cf42f954d68" class="dfn-panel" data-for="877bb12103715513886b6cf42f954d68" id="infopanel-for-877bb12103715513886b6cf42f954d68">
<span id="infopaneltitle-for-877bb12103715513886b6cf42f954d68" style="display:none">Info about the 'system focus' external reference.</span><a href="https://html.spec.whatwg.org/multipage/interaction.html#system-focus">https://html.spec.whatwg.org/multipage/interaction.html#system-focus</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-system-focus">2.1.1. Gate actions with fully active checks</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-5002247a1e0aa38a7705419d947c6884" class="dfn-panel" data-for="5002247a1e0aa38a7705419d947c6884" id="infopanel-for-5002247a1e0aa38a7705419d947c6884">
<span id="infopaneltitle-for-5002247a1e0aa38a7705419d947c6884" style="display:none">Info about the 'unloading document cleanup steps' external reference.</span><a href="https://html.spec.whatwg.org/multipage/document-lifecycle.html#unloading-document-cleanup-steps">https://html.spec.whatwg.org/multipage/document-lifecycle.html#unloading-document-cleanup-steps</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-unloading-document-cleanup-steps">2.1.2. Listen for changes to fully active status</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-7808c50882de287be786a89ce9b734f8" class="dfn-panel" data-for="7808c50882de287be786a89ce9b734f8" id="infopanel-for-7808c50882de287be786a89ce9b734f8">
<span id="infopaneltitle-for-7808c50882de287be786a89ce9b734f8" style="display:none">Info about the 'claim()' external reference.</span><a href="https://w3c.github.io/ServiceWorker/#dom-clients-claim">https://w3c.github.io/ServiceWorker/#dom-clients-claim</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-clients-claim">2.1.4. Discard non-fully active documents for situations that can’t be supported</a>
</ul>
</aside>
<aside aria-labelledby="infopaneltitle-for-61e5a5724014b37dec6c6bfee7ccaf27" class="dfn-panel" data-for="61e5a5724014b37dec6c6bfee7ccaf27" id="infopanel-for-61e5a5724014b37dec6c6bfee7ccaf27">
<span id="infopaneltitle-for-61e5a5724014b37dec6c6bfee7ccaf27" style="display:none">Info about the 'matchAll()' external reference.</span><a href="https://w3c.github.io/ServiceWorker/#dom-clients-matchall">https://w3c.github.io/ServiceWorker/#dom-clients-matchall</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-dom-clients-matchall">2.1.3. Omit non-fully active documents from APIs that span multiple documents</a> <a href="#ref-for-dom-clients-matchall①">(2)</a>
</ul>
</aside>
<h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
<ul class="index">
<li>
<a data-link-type="biblio">[GAMEPAD]</a> defines the following terms:
<ul>
<li><span class="dfn-paneled" id="6d0578ffdf5f512c436348fdc7085334">gamepadconnected</span>
</ul>
<li>
<a data-link-type="biblio">[GEOLOCATION]</a> defines the following terms:
<ul>
<li><span class="dfn-paneled" id="5f721c0a6f3beaadea199c80f8358c22">watchPosition()</span>
</ul>
<li>
<a data-link-type="biblio">[HTML]</a> defines the following terms:
<ul>
<li><span class="dfn-paneled" id="9110f806bb5fdbbb16bc9c04252670d5">BroadcastChannel</span>
<li><span class="dfn-paneled" id="7594a09aa0c77c9e24726559a3a6da9d">fully active</span>
<li><span class="dfn-paneled" id="9d8ff05d06644943ae33e1c8cddde31d">opener</span>
<li><span class="dfn-paneled" id="ff9f6ed4f290e15aa3c0172b660aeeac">pagehide</span>
<li><span class="dfn-paneled" id="54f0bfa77c123404411d9b8b462c6b35">pageshow</span>
<li><span class="dfn-paneled" id="845bffcb8707bbb2a1459536eecf13cc">reactivate</span>
<li><span class="dfn-paneled" id="83418513ea93980e95697432d0d33474">sticky activation</span>
<li><span class="dfn-paneled" id="877bb12103715513886b6cf42f954d68">system focus</span>
<li><span class="dfn-paneled" id="5002247a1e0aa38a7705419d947c6884">unloading document cleanup steps</span>
</ul>
<li>
<a data-link-type="biblio">[SERVICE-WORKERS]</a> defines the following terms:
<ul>
<li><span class="dfn-paneled" id="7808c50882de287be786a89ce9b734f8">claim()</span>
<li><span class="dfn-paneled" id="61e5a5724014b37dec6c6bfee7ccaf27">matchAll()</span>
</ul>
</ul>
<h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>
<h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3>
<dl>
<dt id="biblio-html">[HTML]
<dd>Anne van Kesteren; et al. <a href="https://html.spec.whatwg.org/multipage/"><cite>HTML Standard</cite></a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
<dt id="biblio-rfc2119">[RFC2119]
<dd>S. Bradner. <a href="https://datatracker.ietf.org/doc/html/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. March 1997. Best Current Practice. URL: <a href="https://datatracker.ietf.org/doc/html/rfc2119">https://datatracker.ietf.org/doc/html/rfc2119</a>
<dt id="biblio-service-workers">[SERVICE-WORKERS]
<dd>Jake Archibald; Marijn Kruisselbrink. <a href="https://w3c.github.io/ServiceWorker/"><cite>Service Workers</cite></a>. URL: <a href="https://w3c.github.io/ServiceWorker/">https://w3c.github.io/ServiceWorker/</a>
</dl>
<h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3>
<dl>
<dt id="biblio-gamepad">[GAMEPAD]
<dd>Steve Agoston; Matthew Reynolds. <a href="https://w3c.github.io/gamepad/"><cite>Gamepad</cite></a>. URL: <a href="https://w3c.github.io/gamepad/">https://w3c.github.io/gamepad/</a>
<dt id="biblio-geolocation">[GEOLOCATION]
<dd>Marcos Caceres; Reilly Grant. <a href="https://w3c.github.io/geolocation-api/"><cite>Geolocation API</cite></a>. URL: <a href="https://w3c.github.io/geolocation-api/">https://w3c.github.io/geolocation-api/</a>
</dl>
<script>/* script-dfn-panel */
"use strict";
{
function queryAll(sel) {
return [].slice.call(document.querySelectorAll(sel));
}
// Add popup behavior to all dfns to show the corresponding dfn-panel.
var dfns = document.querySelectorAll('.dfn-paneled');
for (let dfn of dfns) { insertDfnPopupAction(dfn); }
document.body.addEventListener("click", (e) => {
// If not handled already, just hide all dfn panels.
hideAllDfnPanels();
});
function hideAllDfnPanels() {
// Turn off any currently "on" or "activated" panels.
queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(el=>hideDfnPanel(el));
}
function showDfnPanel(dfnPanel, dfn) {
hideAllDfnPanels(); // Only display one at this time.
dfn.setAttribute("aria-expanded", "true");
dfnPanel.classList.add("on");
dfnPanel.style.left = "5px";
dfnPanel.style.top = "0px";
const panelRect = dfnPanel.getBoundingClientRect();
const panelWidth = panelRect.right - panelRect.left;
if (panelRect.right > document.body.scrollWidth) {
// Panel's overflowing the screen.
// Just drop it below the dfn and flip it rightward instead.
// This still wont' fix things if the screen is *really* wide,
// but fixing that's a lot harder without 'anchor()'.
dfnPanel.style.top = "1.5em";
dfnPanel.style.left = "auto";
dfnPanel.style.right = "0px";
}
}
function pinDfnPanel(dfnPanel) {
// Switch it to "activated" state, which pins it.
dfnPanel.classList.add("activated");
dfnPanel.style.left = null;
dfnPanel.style.top = null;
}
function hideDfnPanel(dfnPanel, dfn) {
if(!dfn) {
dfn = document.getElementById(dfnPanel.getAttribute("data-for"));
}
dfn.setAttribute("aria-expanded", "false")
dfnPanel.classList.remove("on");
dfnPanel.classList.remove("activated");
}
function toggleDfnPanel(dfnPanel, dfn) {
if(dfnPanel.classList.contains("on")) {
hideDfnPanel(dfnPanel, dfn);
} else {
showDfnPanel(dfnPanel, dfn);
}
}
function insertDfnPopupAction(dfn) {
// Find dfn panel
const dfnPanel = document.querySelector(`.dfn-panel[data-for='${dfn.id}']`);
if (dfnPanel) {
const panelWrapper = document.createElement('span');
panelWrapper.appendChild(dfnPanel);
panelWrapper.style.position = "relative";
panelWrapper.style.height = "0px";
dfn.insertAdjacentElement("afterend", panelWrapper);
dfn.setAttribute('role', 'button');
dfn.setAttribute('aria-expanded', 'false')
dfn.tabIndex = 0;
dfn.classList.add('has-dfn-panel');
dfn.addEventListener('click', (event) => {
showDfnPanel(dfnPanel, dfn);
event.stopPropagation();