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
Conversation
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.
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.
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 |
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.
The convention is "at", as established by fire an event.
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.
Got it. I'll use "at" in this patch and fix the existing uses of "on" in a follow-up.
My understanding is that the appropriate target is the |
A subclass of |
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.
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
@@ -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 |
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.
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>. |
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.
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=] |
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.
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 |
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.
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. |
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.
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. |
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.
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.
I don't think |
Also, I think this will leave the specification in a confusing state as you're not changing all dispatch callers. |
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 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. |
I'm not sure how this is not editorial if the other one would be? |
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. |
Why would it not be ambiguous for other events though? |
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. |
That highlights another misunderstanding in our prior discussion. When you wrote,
I interpreted this to mean
Now I see that you meant,
I've pushed up another commit to specify the target for the callers of "fire an event." I believe it is Since this expands the scope of the patch, we'll need to update the commit message as well. |
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.
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 |
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 wrong, this should be at this only.
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.
Got it
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.
Sorry for the delay here. Did you want to add yourself to the Acknowledgments section?
Sure do :) |
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 theXMLHttpRequestUpload
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