cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13179) Cordova file plugin onEvent(such as onload) should be invoked with _realReader as this
Date Mon, 17 Sep 2018 17:54:00 GMT

    [ https://issues.apache.org/jira/browse/CB-13179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16617912#comment-16617912
] 

ASF GitHub Bot commented on CB-13179:
-------------------------------------

raphinesse commented on issue #215: CB-13179:(all) invoke onEvent listener with _realReader
as applyThis
URL: https://github.com/apache/cordova-plugin-file/pull/215#issuecomment-422110071
 
 
   @JiaLiPassion you can also set up Travis for your fork of the repo. Might be less work
and you can make use of the CI config

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Cordova file plugin onEvent(such as onload) should be invoked with _realReader as this
> --------------------------------------------------------------------------------------
>
>                 Key: CB-13179
>                 URL: https://issues.apache.org/jira/browse/CB-13179
>             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.
> https://github.com/angular/zone.js/issues/868



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message