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

Initialization of NavigateEvent info property #9634

Closed
ADKaster opened this issue Aug 24, 2023 · 2 comments
Closed

Initialization of NavigateEvent info property #9634

ADKaster opened this issue Aug 24, 2023 · 2 comments

Comments

@ADKaster
Copy link
Contributor

For non-synthetic NavigateEvents, the spec explicitly checks if there is an any related to any info/state and grabs it out of the incoming NavigationOptions

Let info be options["info"], if it exists; otherwise, undefined.

However, for synthetic events, there's no actual initialization defined?

The NavigateEventInitData dictionary leaves the initial value not set:

dictionary NavigateEventInit : EventInit {
  NavigationType navigationType = "push";
  required NavigationDestination destination;
  boolean canIntercept = false;
  boolean userInitiated = false;
  boolean hashChange = false;
  required AbortSignal signal;
  FormData? formData = null;
  DOMString? downloadRequest = null;
  any info;
  boolean hasUAVisualTransition = false;
};

The spec text for NavigateEvent just says that it has "the value it was initialized to"

https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-info

The navigationType, destination, canIntercept, userInitiated, hashChange, signal, formData, downloadRequest, info, and hasUAVisualTransition attributes must return the values they are initialized to.

If it's supposed to be implied that any info; creates an ECMAScript undefined value, then why do all of the places that look at NavigationOptions check for the existence of info in the dictionary first?

After chatting with @Lubrsi I think in order for the WPT test to be correct: https://github.com/web-platform-tests/wpt/blob/master/navigation-api/navigate-event/event-constructor.html#L95 there needs to be some spec language to initialize the info property to undefined if it's not provided in the NavigateEventInitData struct.

cc @domenic

@domenic
Copy link
Member

domenic commented Aug 24, 2023

This is specced in https://dom.spec.whatwg.org/#constructing-events, although note whatwg/dom#600 is still open and everyone is kind of just handwaving how that works.

I agree the "initialized to" language is confusing and unorthodox. It would be nice if we had a more-rigorous way of doing that. But it's what every event interface does right now.

Let me know if I missed something and there's something very specific to NavigateEvent here, and I'll reopen.

@ADKaster
Copy link
Contributor Author

Aha, I see. It looks like I have the exact same question that was asked in #5303 , which was also linked to dom#600.

i.e. "why are these EventInit any values undefined, when other any values are simply "not provided"".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants