From afad2c3c7e52b8938f71c3d2a1481481e7f24afc Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sun, 23 Jul 2017 11:10:57 +0900 Subject: [PATCH] fix(promise): fix #850, check Promise.then writable --- lib/common/promise.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/common/promise.ts b/lib/common/promise.ts index bad45acea..c0cf3eeba 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -330,6 +330,13 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr // Keep a reference to the original method. proto[symbolThen] = originalThen; + // check Ctor.prototype.then propertyDescritor is writable or not + // in meteor env, writable is false, we have to make it to be true. + const prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then'); + if (prop && prop.writable === false && prop.configurable) { + Object.defineProperty(Ctor.prototype, 'then', {writable: true}); + } + Ctor.prototype.then = function(onResolve: any, onReject: any) { const wrapped = new ZoneAwarePromise((resolve, reject) => { originalThen.call(this, resolve, reject);