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

Specify target of progress events #246

Merged
merged 9 commits into from May 11, 2019
Merged

Conversation

jugglinmike
Copy link
Contributor

@jugglinmike jugglinmike commented Apr 17, 2019

The algorithm for "fire a progress event" requires a name and a target,
but only half of the 14 usages specify a target. This is ambiguous
because both the XMLHttpRequestEventTarget and the
XMLHttpRequestUpload support a "progress" event.

Consistently specify the intended target with each invocation. Also
modify a preposition in the algorithm's definition to match the
prevailing usage.


For those more familiar with the spec than I, the intended target may be clear in context. Still, it seems like the ambiguity may have allowed discrepancies amongst implementations. I'm wondering if resolving this will require a survey on what's currently deployed.


Preview | Diff

The algorithm for "fire a progress event" requires a name and a target,
but only half of the 14 usages specify a target. This is ambiguous
because both the `XMLHttpRequestEventTarget` and the
`XMLHttpRequestUpload` support a "progress" event.

Consistently specify the intended target with each invocation. Also
modify a preposition in the algorithm's definition to match the
prevailing usage.
Copy link
Member

@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.

Now that <b>this</b> is a thing, this should be rather easy to do. So either you want <b>this</b> or <b>this</b>'s XMLHttpRequestUpload object. I think that should work in most places. See also #99.

xhr.bs Outdated
@@ -1884,7 +1886,7 @@ attributes must return the value they were initialized to.

<h3 id=firing-events-using-the-progressevent-interface>Firing events using the {{ProgressEvent}} interface</h3>

<p>To <dfn id=concept-event-fire-progress>fire a progress event</dfn> named <var>e</var> at
<p>To <dfn id=concept-event-fire-progress>fire a progress event</dfn> named <var>e</var> on
Copy link
Member

Choose a reason for hiding this comment

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

The convention is "at", as established by fire an event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I'll use "at" in this patch and fix the existing uses of "on" in a follow-up.

@jugglinmike
Copy link
Contributor Author

So either you want <b>this</b> or <b>this</b>'s XMLHttpRequestUpload object.

My understanding is that the appropriate target is the XMLHttpRequestEventTarget in some cases and XMLHttpRequestUpload in others. If that's right, then I don't know how to choose between <b>this</b> or <b>this</b>'s XMLHttpRequestUpload object in each case.

@annevk
Copy link
Member

annevk commented Apr 18, 2019

A subclass of XMLHttpRequestEventTarget is <b>this</b> in most cases.

Copy link
Contributor Author

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

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

A subclass of XMLHttpRequestEventTarget is <b>this</b> in most cases.

Understood. My confusion isn't so much about what this refers to--it's that I don't know which target is intended in each case. I've taken a first shot at this using a mix of inference and observation. Please take care to verify each as my guesswork is likely flawed.

Also, I'm referencing the term with the Bikeshed syntax, [=this=] so that it is cross-linked to WebIDL.

xhr.bs Outdated Show resolved Hide resolved
xhr.bs Outdated
@@ -957,7 +957,7 @@ method must run these steps:
<a>state</a> changes.

<li><p><a>Fire a progress event</a> named
<a event><code>progress</code></a> with <var>response</var>'s
<a event><code>progress</code></a> at [=this=] with <var>response</var>'s
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intended target isn't clear in context. Firefox, Chrome, Edge, and Safari all fire this event at the request object.

xhr.bs Outdated
@@ -1039,7 +1039,7 @@ method must run these steps:
<a for=body>total bytes</a>.

<li><p>If the <a>synchronous flag</a> is unset, <a>fire a progress event</a> named
<a event><code>progress</code></a> with <var>transmitted</var> and <var>length</var>.
<a event><code>progress</code></a> at [=this=] with <var>transmitted</var> and <var>length</var>.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intended target isn't clear in context. Firefox, Chrome, Edge, and Safari all fire this event at the request object.

xhr.bs Outdated
@@ -1048,9 +1048,11 @@ method must run these steps:
<li><p><a>Fire an event</a> named <a event><code>readystatechange</code></a>.

<li><p><a>Fire a progress event</a> named <a event><code>load</code></a>
at [=this=]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intended target isn't clear in context. Firefox, Chrome, Edge, and Safari all fire this event at the request object.

xhr.bs Outdated
with <var>transmitted</var> and <var>length</var>.

<li><p><a>Fire a progress event</a> named <a event><code>loadend</code></a>
at [=this=]'s {{XMLHttpRequestUpload}} object
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intended target isn't clear in context. Firefox, Chrome, Edge, and Safari all fire this event at the request upload object.

xhr.bs Outdated
@@ -1122,10 +1124,10 @@ exception <var>exception</var> are:
</ol>

<li><p><a>Fire a progress event</a> named
<var>event</var> with 0 and 0.
<var>event</var> at [=this=] with 0 and 0.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since a corresponding event is fired at the request upload object in the previous step, I'm fairly certain the intended target here is the request object.

xhr.bs Outdated

<li><p><a>Fire a progress event</a> named
<a event><code>loadend</code></a> with 0 and 0.
<a event><code>loadend</code></a> at [=this=] with 0 and 0.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since a corresponding event is fired at the request upload object in the previous step, I'm fairly certain the intended target here is the request object.

@annevk
Copy link
Member

annevk commented Apr 23, 2019

I don't think <b>this</b> should be cross-linked. It adds too much noise.

@annevk
Copy link
Member

annevk commented Apr 23, 2019

Also, I think this will leave the specification in a confusing state as you're not changing all dispatch callers.

@jugglinmike
Copy link
Contributor Author

I'm happy to help fix those parts, too, but my preference is to do so with a distinct commit that can be labeled as "editorial." I've added another fixup commit which will limit the first change to the normative specification of the algorithm's parameters. The following commit updates the other call sites to use this, and the commit after that updates the preposition.

GitHub doesn't recognize fixup commits, but I can squash those first few and force push the result when/if this patch is otherwise ready.

@annevk
Copy link
Member

annevk commented Apr 23, 2019

I'm not sure how this is not editorial if the other one would be?

@jugglinmike
Copy link
Contributor Author

Prior to the commit titled "Specify target of progress events," the intended target could be interpreted as either the request object or its corresponding request upload object. I consider this change normative because it is resolving an ambiguity, and that could potentially conflict with an implementer's prior reading (and consequently, their implementation).

The following commits are editorial because they do not influence observable behavior.

@jugglinmike jugglinmike changed the title [do not merge] Specify target of progress events Specify target of progress events Apr 23, 2019
@annevk
Copy link
Member

annevk commented Apr 23, 2019

Why would it not be ambiguous for other events though?

@jugglinmike
Copy link
Contributor Author

I've been focused on "fire a progress event" because that's the text which brought me here. I've only just now realized that XHR's use of "fire an event" is likewise ambiguous.

@jugglinmike
Copy link
Contributor Author

That highlights another misunderstanding in our prior discussion. When you wrote,

you're not changing all dispatch callers

I interpreted this to mean

you're not changing all instances of 'fire a progress event' to use the this keyword

Now I see that you meant,

you're not changing all instances of event dispatch to specify the target

I've pushed up another commit to specify the target for the callers of "fire an event." I believe it is this in all cases. I'm more confident about this change because all events are "readystatechange", and the request upload object does not have a readyState attribute.

Since this expands the scope of the patch, we'll need to update the commit message as well.

Copy link
Member

@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.

Thanks, this looks good apart from a single instance.

xhr.bs Outdated
with <var>transmitted</var> and <var>length</var>.

<li><p><a>Fire a progress event</a> named <a event><code>loadend</code></a>
at <b>this</b>'s {{XMLHttpRequestUpload}} object
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong, this should be at this only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it

Copy link
Member

@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.

Sorry for the delay here. Did you want to add yourself to the Acknowledgments section?

@jugglinmike
Copy link
Contributor Author

Sure do :)

@annevk annevk merged commit fef8ebc into whatwg:master May 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants