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

Explainer for navigateEvent.sourceElement #264

Merged
merged 6 commits into from
Sep 14, 2023

Conversation

natechapin
Copy link
Collaborator

Explainer for #225

Copy link
Collaborator

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, simple enough! I guess we could consider adding an example, but I don't think it's necessary.

Should we merge this now, or wait to try to finalize the name, or...?

README.md Outdated Show resolved Hide resolved
@natechapin natechapin changed the title Explainer for navigateEvent.triggeringElement Explainer for navigateEvent.sourceElement May 4, 2023
@natechapin
Copy link
Collaborator Author

Updated the name and documented the cross-window case. I'm flexible as to when we declaring the naming discussion settled.

README.md Outdated
@@ -326,6 +326,8 @@ The event object has several useful properties:

- `info`: any value passed by `navigation.navigate(url, { state, info })`, `navigation.back({ info })`, or similar, if the navigation was initiated by one of those methods and the `info` option was supplied. Otherwise, undefined. See [the example below](#example-using-info) for more.

- `sourceElement`: an `HTMLElement` or null, indicating what element (if any) initiated this navigation. If the navigation was triggered by a link click, the `sourceElement` will be the `<a href="...">`. If the navigation was triggered by a form submission, the `sourceElement` will be the [the element that sent the `submit` event to the form](https://developer.mozilla.org/en-US/docs/Web/API/SubmitEvent/submitter), or if that is null, the `<form>` being submitted. The `sourceElement` will also be null when a targeting a different `window` (e.g., `<a href="..." target="otherWindow">`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be a SVGElement, due to <svg:a>?? Seems like a good thing to add web platform tests for!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will add that to the CL

@natechapin
Copy link
Collaborator Author

I added sourceElement to the example of processing a form submission. Is that sufficient, or do you think it needs a standalone example?

@domenic
Copy link
Collaborator

domenic commented Sep 14, 2023

That looks good! Just need to change HTMLElement to Element to deal with the SVG case.

@natechapin
Copy link
Collaborator Author

That looks good! Just need to change HTMLElement to Element to deal with the SVG case.

Oops, done.

@domenic domenic merged commit 85edaf1 into WICG:main Sep 14, 2023
1 check passed
@natechapin natechapin deleted the triggeringElement branch September 14, 2023 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants