Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Zone-binds FileReader#onEventName listeners #174

Closed
wants to merge 1 commit into from
Closed

Zone-binds FileReader#onEventName listeners #174

wants to merge 1 commit into from

Conversation

matthewjh
Copy link
Contributor

I took a stab at making the changes to close #137.

No issues as far as I can tell, as utils.patchClass does all the leg work. For some reason though, Android 4.3's native browser's FileReader doesn't have addEventListener or removeEventListener, so there's a work around for that.

@matthewjh
Copy link
Contributor Author

@vicb can you take a look at this?


it('should have correct readyState', function (done) {
fileReader.onloadend = function () {
expect(fileReader.readyState).toBe(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

pls change 2 for FileReader.DONE (everywhere this is applicable)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

var utils = require('../utils');

function apply() {
utils.patchClass('FileReader');
Copy link
Contributor

Choose a reason for hiding this comment

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

Quick review, not much time this week:

  • What if the patch has been applied in lib/patch/event-target.js already ?
  • patchClass('FileReader') will new FileReader(), is that allowed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • What if the patch has been applied in lib/patch/event-target.js already ?

The event target patch patches addEventListener and removeEventListener, which patchClass will wrap in addition to taking care of onXXXX listeners / other function setters that need to be bound. The two patches achieve separate things and the order in which they're applied shouldn't matter.

  • patchClass('FileReader') will new FileReader(), is that allowed ?

Yes. There's a guard in patchClass for environments where the class is falsey. I'm not aware of any other scenarios in which you can't new a FileReader.

@vicb
Copy link
Contributor

vicb commented Sep 11, 2015

LGTM, thanks !

@vicb
Copy link
Contributor

vicb commented Sep 11, 2015

closed via #178

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileReader events aren't zoned
2 participants