@@ -280,7 +280,7 @@ var Zone$1 = (function (global) {
280280 } ;
281281 var ZoneDelegate = ( function ( ) {
282282 function ZoneDelegate ( zone , parentDelegate , zoneSpec ) {
283- this . _taskCounts = { microTask : 0 , macroTask : 0 , eventTask : 0 } ;
283+ this . _taskCounts = { ' microTask' : 0 , ' macroTask' : 0 , ' eventTask' : 0 } ;
284284 this . zone = zone ;
285285 this . _parentDelegate = parentDelegate ;
286286 this . _forkZS = zoneSpec && ( zoneSpec && zoneSpec . onFork ? zoneSpec : parentDelegate . _forkZS ) ;
@@ -919,112 +919,6 @@ var Zone$1 = (function (global) {
919919 var zoneAwareErrorStartFrames = [ ] ;
920920 global . Error = ZoneAwareError ;
921921 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- } ;
1028922 // some functions are not easily to be detected here,
1029923 // for example Timeout.ZoneTask.invoke, if we want to detect those functions
1030924 // by detect zone, we have to run all patched APIs, it is too risky
@@ -1033,7 +927,7 @@ var Zone$1 = (function (global) {
1033927 'ZoneTask.invoke' , 'ZoneAware' , 'getStacktraceWithUncaughtError' , 'new LongStackTrace' ,
1034928 'long-stack-trace'
1035929 ] ;
1036- function attachZoneAndRemoveInternalZoneFrames ( error , zoneAwareError ) {
930+ function attachZoneAndRemoveInternalZoneFrames ( error ) {
1037931 // Save original stack trace
1038932 error . originalStack = error . stack ;
1039933 // Process the stack trace and rewrite the frames.
@@ -1087,7 +981,6 @@ var Zone$1 = (function (global) {
1087981 catch ( nonWritableErr ) {
1088982 // in some browser, the error.stack is readonly such as PhantomJS
1089983 // so we need to store the stack frames to zoneAwareError directly
1090- zoneAwareError . stack = finalStack ;
1091984 }
1092985 }
1093986 }
@@ -1096,14 +989,7 @@ var Zone$1 = (function (global) {
1096989 * adds zone information to it.
1097990 */
1098991 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.
1107993 var error = NativeError . apply ( this , arguments ) ;
1108994 if ( ! error . stack ) {
1109995 // in IE, the error.stack will be undefined
@@ -1116,15 +1002,10 @@ var Zone$1 = (function (global) {
11161002 error = err ;
11171003 }
11181004 }
1119- this [ __symbol__ ( 'error' ) ] = error ;
11201005 // 1. attach zone information to stack frame
11211006 // 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 ;
11281009 }
11291010 // Copy the prototype so that instanceof operator works as expected
11301011 ZoneAwareError . prototype = NativeError . prototype ;
@@ -1258,8 +1139,6 @@ var Zone$1 = (function (global) {
12581139 // 1. IE issue, the error.stack can only be not undefined after throw
12591140 // 2. handle Error(...) without new options
12601141 var throwError = function ( message , withNew ) {
1261- if ( withNew === void 0 ) { withNew = true ; }
1262- var error ;
12631142 try {
12641143 if ( withNew ) {
12651144 throw new Error ( message ) ;
@@ -1269,9 +1148,8 @@ var Zone$1 = (function (global) {
12691148 }
12701149 }
12711150 catch ( err ) {
1272- error = err ;
1151+ return err ;
12731152 }
1274- return error ;
12751153 } ;
12761154 var nativeStackTraceLimit = NativeError . stackTraceLimit ;
12771155 // in some system/browser, some additional stack frames
@@ -1284,14 +1162,14 @@ var Zone$1 = (function (global) {
12841162 var detectRunFn = function ( ) {
12851163 detectZone . run ( function ( ) {
12861164 detectZone . runGuarded ( function ( ) {
1287- throw throwError ( 'blacklistStackFrames' ) ;
1165+ throw throwError ( 'blacklistStackFrames' , true ) ;
12881166 } ) ;
12891167 } ) ;
12901168 } ;
12911169 var detectRunWithoutNewFn = function ( ) {
12921170 detectZone . run ( function ( ) {
12931171 detectZone . runGuarded ( function ( ) {
1294- throw throwError ( 'blacklistStackFrames' , false ) ;
1172+ throw throwError ( 'blacklistStackFrames' ) ;
12951173 } ) ;
12961174 } ) ;
12971175 } ;
@@ -1440,7 +1318,7 @@ var Zone$1 = (function (global) {
14401318 detectZoneWithCallbacks . runGuarded ( detectPromiseCaughtWithoutNewFn ) ;
14411319 NativeError . stackTraceLimit = nativeStackTraceLimit ;
14421320 return global [ 'Zone' ] = Zone ;
1443- } ) ( typeof window === 'object ' && window || typeof self === 'object ' && self || global ) ;
1321+ } ) ( typeof window !== 'undefined ' && window || typeof self !== 'undefined ' && self || global ) ;
14441322
14451323/**
14461324 * @license
@@ -1945,14 +1823,16 @@ function patchTimer(window, setName, cancelName, nameSuffix) {
19451823 var tasksByHandleId = { } ;
19461824 function scheduleTask ( task ) {
19471825 var data = task . data ;
1948- data . args [ 0 ] = function ( ) {
1826+ function timer ( ) {
19491827 try {
19501828 task . invoke . apply ( this , arguments ) ;
19511829 }
19521830 finally {
19531831 delete tasksByHandleId [ data . handleId ] ;
19541832 }
1955- } ;
1833+ }
1834+
1835+ data . args [ 0 ] = timer ;
19561836 data . handleId = setNative . apply ( window , data . args ) ;
19571837 tasksByHandleId [ data . handleId ] = task ;
19581838 return task ;
@@ -2330,7 +2210,7 @@ function registerElementPatch(_global) {
23302210var set = 'set' ;
23312211var clear = 'clear' ;
23322212var 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 ;
23342214patchTimer ( _global , set , clear , 'Timeout' ) ;
23352215patchTimer ( _global , set , clear , 'Interval' ) ;
23362216patchTimer ( _global , set , clear , 'Immediate' ) ;
0 commit comments