-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
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) { |
There was a problem hiding this comment.
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
anddownloadRequestFilename
. (Feels like a lot of API surface for such an edge case.)
There was a problem hiding this 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.
Yeah, that's fair. I'll also propose a slight renaming in #76. |
Co-authored-by: Anne van Kesteren <[email protected]>
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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