Skip to content

Commit 66f07c0

Browse files
authored
Merge pull request #6 from vakrilov/testing
fix(zone): Fix zone patching Promise prop descriptor and breaking a…
2 parents 5619247 + c89d617 commit 66f07c0

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

Diff for: nativescript-angular/zone-js/dist/zone-nativescript.js

+36-35
Original file line numberDiff line numberDiff line change
@@ -1019,41 +1019,42 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) {
10191019
ZoneAwarePromise['all'] = ZoneAwarePromise.all;
10201020
var NativePromise = global[symbolPromise] = global['Promise'];
10211021
var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise');
1022-
var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise');
1023-
if (!desc || desc.configurable) {
1024-
desc && delete desc.writable;
1025-
desc && delete desc.value;
1026-
if (!desc) {
1027-
desc = { configurable: true, enumerable: true };
1028-
}
1029-
desc.get = function () {
1030-
// if we already set ZoneAwarePromise, use patched one
1031-
// otherwise return native one.
1032-
return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise];
1033-
};
1034-
desc.set = function (NewNativePromise) {
1035-
if (NewNativePromise === ZoneAwarePromise) {
1036-
// if the NewNativePromise is ZoneAwarePromise
1037-
// save to global
1038-
global[ZONE_AWARE_PROMISE] = NewNativePromise;
1039-
}
1040-
else {
1041-
// if the NewNativePromise is not ZoneAwarePromise
1042-
// for example: after load zone.js, some library just
1043-
// set es6-promise to global, if we set it to global
1044-
// directly, assertZonePatched will fail and angular
1045-
// will not loaded, so we just set the NewNativePromise
1046-
// to global[symbolPromise], so the result is just like
1047-
// we load ES6 Promise before zone.js
1048-
global[symbolPromise] = NewNativePromise;
1049-
if (!NewNativePromise.prototype[symbolThen]) {
1050-
patchThen(NewNativePromise);
1051-
}
1052-
api.setNativePromise(NewNativePromise);
1053-
}
1054-
};
1055-
ObjectDefineProperty(global, 'Promise', desc);
1056-
}
1022+
// NOTE(NativeScript): Defining the Promise property descriptor this way causes
1023+
// problems with V8 snapshot for Android. Just skip it.
1024+
// let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise');
1025+
// if (!desc || desc.configurable) {
1026+
// desc && delete desc.writable;
1027+
// desc && delete desc.value;
1028+
// if (!desc) {
1029+
// desc = {configurable: true, enumerable: true};
1030+
// }
1031+
// desc.get = function() {
1032+
// // if we already set ZoneAwarePromise, use patched one
1033+
// // otherwise return native one.
1034+
// return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise];
1035+
// };
1036+
// desc.set = function(NewNativePromise) {
1037+
// if (NewNativePromise === ZoneAwarePromise) {
1038+
// // if the NewNativePromise is ZoneAwarePromise
1039+
// // save to global
1040+
// global[ZONE_AWARE_PROMISE] = NewNativePromise;
1041+
// } else {
1042+
// // if the NewNativePromise is not ZoneAwarePromise
1043+
// // for example: after load zone.js, some library just
1044+
// // set es6-promise to global, if we set it to global
1045+
// // directly, assertZonePatched will fail and angular
1046+
// // will not loaded, so we just set the NewNativePromise
1047+
// // to global[symbolPromise], so the result is just like
1048+
// // we load ES6 Promise before zone.js
1049+
// global[symbolPromise] = NewNativePromise;
1050+
// if (!NewNativePromise.prototype[symbolThen]) {
1051+
// patchThen(NewNativePromise);
1052+
// }
1053+
// api.setNativePromise(NewNativePromise);
1054+
// }
1055+
// };
1056+
// ObjectDefineProperty(global, 'Promise', desc);
1057+
// }
10571058
global['Promise'] = ZoneAwarePromise;
10581059
var symbolThenPatched = __symbol__('thenPatched');
10591060
function patchThen(Ctor) {

0 commit comments

Comments
 (0)