Skip to content

Commit 894c9dd

Browse files
Andy Stanford-BluntishAlastair Pharo
authored andcommitted
Set currentTarget on progress events
Set the event target for the progress event via the constructor, for consistency with other events. Also ensures currentTarget is set at the same time.
1 parent 388da6f commit 894c9dd

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

fake_xml_http_request.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@
192192
Triggers an `onprogress` event with the given parameters.
193193
*/
194194
_progress: function _progress(lengthComputable, loaded, total) {
195-
var event = new _Event('progress');
196-
event.target = this;
195+
var event = new _Event("progress", false, false, this);
197196
event.lengthComputable = lengthComputable;
198197
event.loaded = loaded;
199198
event.total = total;

src/fake-xml-http-request.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ EventedObject.prototype = {
186186
Triggers an `onprogress` event with the given parameters.
187187
*/
188188
_progress: function _progress(lengthComputable, loaded, total) {
189-
var event = new _Event('progress');
190-
event.target = this;
189+
var event = new _Event("progress", false, false, this);
191190
event.lengthComputable = lengthComputable;
192191
event.loaded = loaded;
193192
event.total = total;

test/upload_test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ test("_progress triggers the onprogress event", function() {
2222
ok(event.lengthComputable, "ProgressEvent.lengthComputable");
2323
equal(event.loaded, 10, "ProgressEvent.loaded");
2424
equal(event.total, 100, "ProgressEvent.total");
25+
strictEqual(event.target, upload, "ProgressEvent.target is the upload object");
26+
strictEqual(event.target, event.currentTarget,
27+
"ProgressEvent.target matches ProgressEvent.currentTarget");
2528
});

0 commit comments

Comments
 (0)