<span data-cap="offline-keep" data-worker="/sw.js" data-scope="/"></span>
<!-- script fills it: -->
<span data-cap="offline-keep" data-worker="/sw.js" data-scope="/" data-cap-ready="">
<button type="button" class="cap-btn cap-keep" aria-pressed="false" title="Keep a copy that opens with no connection">Keep on this device</button>
<span class="cap-keep-status" role="status"></span>
</span>
Examples
Kept, with its status
<span data-cap="offline-keep" data-cap-ready="">
<button type="button" class="cap-btn cap-offline-keep-button" aria-pressed="true" title="Press to remove the copy kept on this device">Keep on this device</button>
<span class="cap-offline-keep-status" role="status">Kept on this device: it opens with no connection.</span>
</span>
The worker's address with the store's name, unless it is the default.
filesOfPage
(page: string): string[]
Every same-origin file this page uses: its stylesheets, scripts and module chunks, images, and the fonts and scripts the page loaded after. Each is stored as fetched, so the kept page draws as it does online.
isKept
(o: KeepOptions): Promise<boolean>
Looked up, never opened: opening a store creates it, and a reader who only views the page stores nothing.
keep
(o: KeepOptions): Promise<void>
remove
(o: KeepOptions): Promise<void>
enhance
(root?: ParentNode): () => void
Fills every empty [data-cap="offline-keep"] with the toggle and its status line.
Parts and data attributes
Class
Is
.cap-offline-keep-button
the root
.cap-offline-keep-status
its own class
Attribute
Values
data-cap
offline-keep
State
Read from
:empty
the platform
[aria-pressed="true"]
an attribute
Accessibility
Key
Does
Tab
Moves to the button
Enter, Space
Keeps the page, or removes the kept copy
A toggle button (aria-pressed) whose words change with its state; its title says what a press will do.
The result is a status line, read when it changes.