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

Commit

Permalink
fix(promise): fix #850, check Promise.then writable (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and mhevery committed Jul 27, 2017
1 parent 5900d3a commit 6e44cab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/common/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6e44cab

Please sign in to comment.