@@ -280,7 +280,7 @@ var Zone$1 = (function (global) {
280
280
} ;
281
281
var ZoneDelegate = ( function ( ) {
282
282
function ZoneDelegate ( zone , parentDelegate , zoneSpec ) {
283
- this . _taskCounts = { microTask : 0 , macroTask : 0 , eventTask : 0 } ;
283
+ this . _taskCounts = { ' microTask' : 0 , ' macroTask' : 0 , ' eventTask' : 0 } ;
284
284
this . zone = zone ;
285
285
this . _parentDelegate = parentDelegate ;
286
286
this . _forkZS = zoneSpec && ( zoneSpec && zoneSpec . onFork ? zoneSpec : parentDelegate . _forkZS ) ;
@@ -919,112 +919,6 @@ var Zone$1 = (function (global) {
919
919
var zoneAwareErrorStartFrames = [ ] ;
920
920
global . Error = ZoneAwareError ;
921
921
var stackRewrite = 'stackRewrite' ;
922
- // fix #595, create property descriptor
923
- // for error properties
924
- var createProperty = function ( props , key ) {
925
- // if property is already defined, skip it.
926
- if ( props [ key ] ) {
927
- return ;
928
- }
929
- // define a local property
930
- // in case error property is not settable
931
- var name = __symbol__ ( key ) ;
932
- props [ key ] = {
933
- configurable : true ,
934
- enumerable : true ,
935
- get : function ( ) {
936
- // if local property has no value
937
- // use internal error's property value
938
- if ( ! this [ name ] ) {
939
- var error_2 = this [ __symbol__ ( 'error' ) ] ;
940
- if ( error_2 ) {
941
- this [ name ] = error_2 [ key ] ;
942
- }
943
- }
944
- return this [ name ] ;
945
- } ,
946
- set : function ( value ) {
947
- // setter will set value to local property value
948
- this [ name ] = value ;
949
- }
950
- } ;
951
- } ;
952
- // fix #595, create property descriptor
953
- // for error method properties
954
- var createMethodProperty = function ( props , key ) {
955
- if ( props [ key ] ) {
956
- return ;
957
- }
958
- props [ key ] = {
959
- configurable : true ,
960
- enumerable : true ,
961
- writable : true ,
962
- value : function ( ) {
963
- var error = this [ __symbol__ ( 'error' ) ] ;
964
- var errorMethod = ( error && error [ key ] ) || this [ key ] ;
965
- if ( errorMethod ) {
966
- return errorMethod . apply ( error , arguments ) ;
967
- }
968
- }
969
- } ;
970
- } ;
971
- var createErrorProperties = function ( ) {
972
- var props = Object . create ( null ) ;
973
- var error = new NativeError ( ) ;
974
- var keys = Object . getOwnPropertyNames ( error ) ;
975
- for ( var i = 0 ; i < keys . length ; i ++ ) {
976
- var key = keys [ i ] ;
977
- // Avoid bugs when hasOwnProperty is shadowed
978
- if ( Object . prototype . hasOwnProperty . call ( error , key ) ) {
979
- createProperty ( props , key ) ;
980
- }
981
- }
982
- var proto = NativeError . prototype ;
983
- if ( proto ) {
984
- var pKeys = Object . getOwnPropertyNames ( proto ) ;
985
- for ( var i = 0 ; i < pKeys . length ; i ++ ) {
986
- var key = pKeys [ i ] ;
987
- // skip constructor
988
- if ( key !== 'constructor' && key !== 'toString' && key !== 'toSource' ) {
989
- createProperty ( props , key ) ;
990
- }
991
- }
992
- }
993
- // some other properties are not
994
- // in NativeError
995
- createProperty ( props , 'originalStack' ) ;
996
- createProperty ( props , 'zoneAwareStack' ) ;
997
- // in IE, stack is not in prototype
998
- createProperty ( props , 'stack' ) ;
999
- // define toString, toSource as method property
1000
- createMethodProperty ( props , 'toString' ) ;
1001
- createMethodProperty ( props , 'toSource' ) ;
1002
- return props ;
1003
- } ;
1004
- var errorProperties = createErrorProperties ( ) ;
1005
- // for derived Error class which extends ZoneAwareError
1006
- // we should not override the derived class's property
1007
- // so we create a new props object only copy the properties
1008
- // from errorProperties which not exist in derived Error's prototype
1009
- var getErrorPropertiesForPrototype = function ( prototype ) {
1010
- // if the prototype is ZoneAwareError.prototype
1011
- // we just return the prebuilt errorProperties.
1012
- if ( prototype === ZoneAwareError . prototype ) {
1013
- return errorProperties ;
1014
- }
1015
- var newProps = Object . create ( null ) ;
1016
- var cKeys = Object . getOwnPropertyNames ( errorProperties ) ;
1017
- var keys = Object . getOwnPropertyNames ( prototype ) ;
1018
- cKeys . forEach ( function ( cKey ) {
1019
- if ( keys . filter ( function ( key ) {
1020
- return key === cKey ;
1021
- } )
1022
- . length === 0 ) {
1023
- newProps [ cKey ] = errorProperties [ cKey ] ;
1024
- }
1025
- } ) ;
1026
- return newProps ;
1027
- } ;
1028
922
// some functions are not easily to be detected here,
1029
923
// for example Timeout.ZoneTask.invoke, if we want to detect those functions
1030
924
// by detect zone, we have to run all patched APIs, it is too risky
@@ -1033,7 +927,7 @@ var Zone$1 = (function (global) {
1033
927
'ZoneTask.invoke' , 'ZoneAware' , 'getStacktraceWithUncaughtError' , 'new LongStackTrace' ,
1034
928
'long-stack-trace'
1035
929
] ;
1036
- function attachZoneAndRemoveInternalZoneFrames ( error , zoneAwareError ) {
930
+ function attachZoneAndRemoveInternalZoneFrames ( error ) {
1037
931
// Save original stack trace
1038
932
error . originalStack = error . stack ;
1039
933
// Process the stack trace and rewrite the frames.
@@ -1087,7 +981,6 @@ var Zone$1 = (function (global) {
1087
981
catch ( nonWritableErr ) {
1088
982
// in some browser, the error.stack is readonly such as PhantomJS
1089
983
// so we need to store the stack frames to zoneAwareError directly
1090
- zoneAwareError . stack = finalStack ;
1091
984
}
1092
985
}
1093
986
}
@@ -1096,14 +989,7 @@ var Zone$1 = (function (global) {
1096
989
* adds zone information to it.
1097
990
*/
1098
991
function ZoneAwareError ( ) {
1099
- // make sure we have a valid this
1100
- // if this is undefined(call Error without new) or this is global
1101
- // or this is some other objects, we should force to create a
1102
- // valid ZoneAwareError by call Object.create()
1103
- if ( ! ( this instanceof ZoneAwareError ) ) {
1104
- return ZoneAwareError . apply ( Object . create ( ZoneAwareError . prototype ) , arguments ) ;
1105
- }
1106
- // Create an Error.
992
+ // We always have to return native error otherwise the browser console will not work.
1107
993
var error = NativeError . apply ( this , arguments ) ;
1108
994
if ( ! error . stack ) {
1109
995
// in IE, the error.stack will be undefined
@@ -1116,15 +1002,10 @@ var Zone$1 = (function (global) {
1116
1002
error = err ;
1117
1003
}
1118
1004
}
1119
- this [ __symbol__ ( 'error' ) ] = error ;
1120
1005
// 1. attach zone information to stack frame
1121
1006
// 2. remove zone internal stack frames
1122
- attachZoneAndRemoveInternalZoneFrames ( error , this ) ;
1123
- // use defineProperties here instead of copy property value
1124
- // because of issue #595 which will break angular2.
1125
- var props = getErrorPropertiesForPrototype ( Object . getPrototypeOf ( this ) ) ;
1126
- Object . defineProperties ( this , props ) ;
1127
- return this ;
1007
+ attachZoneAndRemoveInternalZoneFrames ( error ) ;
1008
+ return error ;
1128
1009
}
1129
1010
// Copy the prototype so that instanceof operator works as expected
1130
1011
ZoneAwareError . prototype = NativeError . prototype ;
@@ -1258,8 +1139,6 @@ var Zone$1 = (function (global) {
1258
1139
// 1. IE issue, the error.stack can only be not undefined after throw
1259
1140
// 2. handle Error(...) without new options
1260
1141
var throwError = function ( message , withNew ) {
1261
- if ( withNew === void 0 ) { withNew = true ; }
1262
- var error ;
1263
1142
try {
1264
1143
if ( withNew ) {
1265
1144
throw new Error ( message ) ;
@@ -1269,9 +1148,8 @@ var Zone$1 = (function (global) {
1269
1148
}
1270
1149
}
1271
1150
catch ( err ) {
1272
- error = err ;
1151
+ return err ;
1273
1152
}
1274
- return error ;
1275
1153
} ;
1276
1154
var nativeStackTraceLimit = NativeError . stackTraceLimit ;
1277
1155
// in some system/browser, some additional stack frames
@@ -1284,14 +1162,14 @@ var Zone$1 = (function (global) {
1284
1162
var detectRunFn = function ( ) {
1285
1163
detectZone . run ( function ( ) {
1286
1164
detectZone . runGuarded ( function ( ) {
1287
- throw throwError ( 'blacklistStackFrames' ) ;
1165
+ throw throwError ( 'blacklistStackFrames' , true ) ;
1288
1166
} ) ;
1289
1167
} ) ;
1290
1168
} ;
1291
1169
var detectRunWithoutNewFn = function ( ) {
1292
1170
detectZone . run ( function ( ) {
1293
1171
detectZone . runGuarded ( function ( ) {
1294
- throw throwError ( 'blacklistStackFrames' , false ) ;
1172
+ throw throwError ( 'blacklistStackFrames' ) ;
1295
1173
} ) ;
1296
1174
} ) ;
1297
1175
} ;
@@ -1440,7 +1318,7 @@ var Zone$1 = (function (global) {
1440
1318
detectZoneWithCallbacks . runGuarded ( detectPromiseCaughtWithoutNewFn ) ;
1441
1319
NativeError . stackTraceLimit = nativeStackTraceLimit ;
1442
1320
return global [ 'Zone' ] = Zone ;
1443
- } ) ( typeof window === 'object ' && window || typeof self === 'object ' && self || global ) ;
1321
+ } ) ( typeof window !== 'undefined ' && window || typeof self !== 'undefined ' && self || global ) ;
1444
1322
1445
1323
/**
1446
1324
* @license
@@ -1945,14 +1823,16 @@ function patchTimer(window, setName, cancelName, nameSuffix) {
1945
1823
var tasksByHandleId = { } ;
1946
1824
function scheduleTask ( task ) {
1947
1825
var data = task . data ;
1948
- data . args [ 0 ] = function ( ) {
1826
+ function timer ( ) {
1949
1827
try {
1950
1828
task . invoke . apply ( this , arguments ) ;
1951
1829
}
1952
1830
finally {
1953
1831
delete tasksByHandleId [ data . handleId ] ;
1954
1832
}
1955
- } ;
1833
+ }
1834
+
1835
+ data . args [ 0 ] = timer ;
1956
1836
data . handleId = setNative . apply ( window , data . args ) ;
1957
1837
tasksByHandleId [ data . handleId ] = task ;
1958
1838
return task ;
@@ -2330,7 +2210,7 @@ function registerElementPatch(_global) {
2330
2210
var set = 'set' ;
2331
2211
var clear = 'clear' ;
2332
2212
var blockingMethods = [ 'alert' , 'prompt' , 'confirm' ] ;
2333
- var _global = typeof window === 'object ' && window || typeof self === 'object ' && self || global ;
2213
+ var _global = typeof window !== 'undefined ' && window || typeof self !== 'undefined ' && self || global ;
2334
2214
patchTimer ( _global , set , clear , 'Timeout' ) ;
2335
2215
patchTimer ( _global , set , clear , 'Interval' ) ;
2336
2216
patchTimer ( _global , set , clear , 'Immediate' ) ;
0 commit comments