Visitar URL original
fix(core): update FakeNavigation to match WHATWG HTML spec · angular/angular@a823323 · GitHub
Skip to content

Commit a823323

Browse files
authored
fix(core): update FakeNavigation to match WHATWG HTML spec
Update FakeNavigation and Navigation API type definitions to match the latest WHATWG HTML specification (https://html.spec.whatwg.org/multipage/nav-history-apis.html): - Add NavigationPrecommitController.addHandler() and support dynamic post-commit handler registration (https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationprecommitcontroller-addhandler). - Include precommitHandler directly in NavigationInterceptOptions (https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-intercept). - Add hasUAVisualTransition and sourceElement properties to NavigateEvent (https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-navigateevent-interface). - Fix FakeNavigationHistoryEntry dispose event name from 'disposed' to 'dispose' and implement ondispose (https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationhistoryentry-ondispose). - Implement Navigation.prototype.updateCurrentEntry (https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-updatecurrententry). - Implement Navigation.prototype.reload (https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-reload) and share "performing a non-traverse navigation" (https://html.spec.whatwg.org/multipage/nav-history-apis.html#performing-a-non-traverse-navigation) logic with navigate(). - Implement standard event handler IDL properties (onnavigate, onnavigatesuccess, onnavigateerror, oncurrententrychange). - Update internal specification comments and links from legacy PR draft URLs to official WHATWG multipage URLs.
1 parent d0ed76c commit a823323

4 files changed

Lines changed: 579 additions & 158 deletions

File tree

‎packages/core/primitives/dom-navigation/src/navigation_types.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export declare class NavigateEvent extends Event {
152152
readonly formData: FormData | null;
153153
readonly downloadRequest: string | null;
154154
readonly info?: unknown;
155+
readonly sourceElement: Element | null;
155156

156157
intercept(options?: NavigationInterceptOptions): void;
157158
scroll(): void;
@@ -168,10 +169,22 @@ export interface NavigateEventInit extends EventInit {
168169
formData?: FormData | null;
169170
downloadRequest?: string | null;
170171
info?: unknown;
172+
sourceElement?: Element | null;
173+
}
174+
175+
export type NavigationInterceptHandler = () => PromiseLike<void> | void;
176+
export type NavigationPrecommitHandler = (
177+
controller: NavigationPrecommitController,
178+
) => PromiseLike<void> | void;
179+
180+
export interface NavigationPrecommitController {
181+
redirect: (url: string, options?: NavigationNavigateOptions) => void;
182+
addHandler: (handler: NavigationInterceptHandler) => void;
171183
}
172184

173185
export interface NavigationInterceptOptions {
174-
handler?: () => Promise<void>;
186+
precommitHandler?: NavigationPrecommitHandler;
187+
handler?: NavigationInterceptHandler;
175188
focusReset?: 'after-transition' | 'manual';
176189
scroll?: 'after-transition' | 'manual';
177190
}

0 commit comments

Comments
 (0)