Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'restore' as a navigationType #284

Merged
merged 5 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ interface PerformanceEntryMap {

// Update built-in types to be more accurate.
declare global {
// https://wicg.github.io/nav-speculation/prerendering.html#document-prerendering
interface Document {
prerendering?: boolean
// https://wicg.github.io/nav-speculation/prerendering.html#document-prerendering
prerendering?: boolean;
// https://github.com/WICG/page-lifecycle/blob/main/README.md
tunetheweb marked this conversation as resolved.
Show resolved Hide resolved
wasDiscarded?: boolean;
}

interface Performance {
Expand Down
9 changes: 0 additions & 9 deletions src/types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,3 @@ export interface ReportOpts {
* loading. This is equivalent to the corresponding `readyState` value.
*/
export type LoadState = 'loading' | 'dom-interactive' | 'dom-content-loaded' | 'complete';

/**
* Extend the document with the new wasDiscarded boolean which is not supported
* in typescript yet
* https://github.com/WICG/page-lifecycle/blob/main/README.md
*/
declare global {
interface Document { wasDiscarded?: boolean; }
}
1 change: 0 additions & 1 deletion test/views/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
*/
self.__stubWasDiscarded = () => {
return new Promise((resolve) => {
const navEntry = performance.getEntriesByType('navigation')[0];
// Only stub if the page isn't actually discarded.
if (!document.wasDiscarded) {
Object.defineProperty(document, 'wasDiscarded', {
Expand Down