cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (CB-13179) Cordova file plugin onEvent(such as onload) should be invoked with _realReader as this
Date Tue, 15 Aug 2017 13:58:00 GMT


ASF GitHub Bot commented on CB-13179:

GitHub user JiaLiPassion opened a pull request:

    CB-13179:(all) invoke onEvent listener with _realReader as applyThis

    Please make sure the checklist boxes are all checked before submitting the PR. The checklist
    is intended as a quick reference, for complete details please see our Contributor Guidelines:
    ### Platforms affected
    ### What does this PR do?
    FileReader.onEvent such as FileReader.onload should call with `this._realReader`
    ### What testing has been done on this change?
    Test with ios Application.
    ### Checklist
    - [x] [Reported an issue]( in the JIRA
    - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file
paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
    - [ ] Added automated test coverage as appropriate for this change.
    Fix CB-13179, FileReader should invoke onEvent listener with this._realReader as applyThis.

You can merge this pull request into a Git repository by running:

    $ git pull onevent

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #215
commit 5391ff89547e0a5bad3ee1652f31528c694e2820
Author: JiaLi.Passion <>
Date:   2017-08-15T13:22:30Z

    CB-13179:(all) invoke onEvent listener with _realReader as applyThis


> Cordova file plugin onEvent(such as onload) should be invoked with _realReader as this
> --------------------------------------------------------------------------------------
>                 Key: CB-13179
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-plugin-file
>         Environment: Android, ios, Browser
>            Reporter: Jia Li
>            Priority: Minor
>              Labels: features
> When `FileReader` add onEvent listener such as `onload`, it will add the listener to
inner `_realReader` , but when it invoke the listener, it use the FileReader as `this`.
> 1. When add onload listener in application code.
> ```javascript
> var fileReader = new FileReader();
> fileReader.onload = function() {};
> ```
> it will call `www/FileReader.js defineEvent`
> ```javascript
> function defineEvent(eventName) {
>     utils.defineGetterSetter(FileReader.prototype, eventName, function() {
>         return this._realReader[eventName] || null;
>     }, function(value) {
>         this._realReader[eventName] = value;
>     });
> }
> ```  
> the listener is added to `this._realReader`.
> And when the listener is triggered for example in `readSuccessCallback`
> it will invoke the method with `this`.
> ```javascript
> this.onload(new ProgressEvent("load", {target:this}));
> ```
> in the normal senario, it will ok, but when it work with some polyfilles such as `zone.js
of angular4`, it will fail because `zone.js` have some special handling which require the
`this` object be the same when add listener and invoke listener.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message