From e9450c941b60915869364894c8f2e3a0cef16ef6 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Fri, 18 Aug 2017 03:40:45 +0900 Subject: [PATCH] feat(cordova): fix #868, patch cordova FileReader --- lib/extra/cordova.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/extra/cordova.ts b/lib/extra/cordova.ts index 6331f73eb..5f8518ce5 100644 --- a/lib/extra/cordova.ts +++ b/lib/extra/cordova.ts @@ -21,4 +21,21 @@ Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => return nativeExec.apply(self, args); }); } +}); + +Zone.__load_patch('cordova.FileReader', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + if (global.cordova && typeof global['FileReader'] !== 'undefined') { + document.addEventListener('deviceReady', () => { + const FileReader = global['FileReader']; + ['abort', 'error', 'load', 'loadstart', 'loadend', 'progress'].forEach(prop => { + const eventNameSymbol = Zone.__symbol__('ON_PROPERTY' + prop); + Object.defineProperty(FileReader.prototype, eventNameSymbol, { + configurable: true, + get: function() { + return this._realReader && this._realReader[eventNameSymbol]; + } + }); + }); + }); + } }); \ No newline at end of file