Skip to content

Specify navigateEvent.downloadRequest #218

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

Merged
merged 4 commits into from
Mar 25, 2022
Merged

Specify navigateEvent.downloadRequest #218

merged 4 commits into from
Mar 25, 2022

Conversation

domenic
Copy link
Collaborator

@domenic domenic commented Mar 23, 2022

Closes #76.

@natechapin, please review!

@smaug---- @annevk any review you have time to provide would help validate that this is precise enough to be implemented interoperably, despite building on shaky foundations.


Preview | Diff

README.md Outdated
@@ -405,7 +407,7 @@ Sometimes it's desirable to handle back/forward navigations specially, e.g. reus
```js
navigation.addEventListener("navigate", e => {
// As before.
if (!e.canTransition || e.hashChange) {
if (!e.canTransition || e.hashChange || e.requestDownload !== null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wish there were a way to make this truthy for <a download href="...">. I feel like if (!e.requestDownload) might be a common mistake, which such no-filename download=""s would trigger.

The only things I can think of are:

  • Use a sentinel filename like "unknown" for the <a download> case. (Ick.)
  • Use two fields, downloadRequested and downloadRequestFilename. (Feels like a lot of API surface for such an edge case.)

Copy link

@annevk annevk 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 like a reasonable summary to me.

As for the API, maybe we could expose other getter(s) that group things folks typically want to filter these events on? Might be easier to judge once there's a bunch of code in the wild.

@domenic
Copy link
Collaborator Author

domenic commented Mar 24, 2022

Yeah, that's fair. I'll also propose a slight renaming in #76.

@domenic domenic changed the title Specify navigateEvent.requestDownload Specify navigateEvent.downloadRequest Mar 24, 2022
@domenic domenic requested a review from natechapin March 24, 2022 15:49
@@ -1216,6 +1240,7 @@ The <dfn attribute for="NavigationDestination">sameDocument</dfn> getter steps a
To <dfn>fire a traversal `navigate` event</dfn> at a {{Navigation}} |navigation| given a [=session history entry=] <dfn for="fire a traversal navigate event">|destinationEntry|</dfn>, and an optional [=user navigation involvement=] <dfn for="fire a traversal navigate event">|userInvolvement|</dfn> (default "<code>[=user navigation involvement/none=]</code>"):

1. Let |event| be the result of [=creating an event=] given {{NavigateEvent}}, in |navigation|'s [=relevant Realm=].
1. Set |event|'s [=NavigateEvent/classic history API serialized data=] to null.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't immediately see why this is necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is kind of an unrelated bug fix where I'm trying to initialize all the fields of NavigateEvent every time I create it. Previously the language around classic history API serialized data was imprecisely talking about being "used conditionally" and then assuming that meant it was OK to not initialize it.

@domenic domenic merged commit c302264 into main Mar 25, 2022
@domenic domenic deleted the requestDownload branch March 25, 2022 16:05
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.

<a download> is a navigation; how does it interact with the navigation API?
3 participants