-
Notifications
You must be signed in to change notification settings - Fork 407
add OriginalDelegate prop to Function::toString #993
Conversation
@gdh1995 , thank you for making the PR, could you add a test case in https://github.com/angular/zone.js/blob/master/test/common/toString.spec.ts to check |
@JiaLiPassion Thanks, I've added a new test. |
@@ -42,6 +42,8 @@ Zone.__load_patch('toString', (global: any, Zone: ZoneType) => { | |||
} | |||
return originalFunctionToString.apply(this, arguments); | |||
}; | |||
(newFunctionToString as any)[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current version, we attached originalFunctionToString
to Zone
, and if we attached it to Function.prototype
, we don't need to attached it to Zone
any more.
so please just change this line https://github.com/gdh1995/zone.js/blob/b98f284030a4296a0e476728829298515edc3b0d/lib/common/to-string.ts#L14
const originalFunctionToString = Function.prototype[ORIGINAL_DELEGATE_SYMBOL] =
Function.prototype.toString;
@gdh1995 , I just leave a comment, we don't need to keep |
Thanks. I've rebased those commits. |
lib/common/to-string.ts
Outdated
@@ -11,13 +11,12 @@ import {zoneSymbol} from './utils'; | |||
// look like native function | |||
Zone.__load_patch('toString', (global: any, Zone: ZoneType) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove Zone: ZoneType
here to reduce the bundle size.
@gdh1995 , thank you, please also remove the unused |
This makes `Function.prototype.toString.toString()` also returns `"function toString() { [native code] }"`, which should be a little safer. Squashed: store originalFunctionToString only in one place add a test to Function::toString
The commit has been rebased secondly. |
This PR complements PR #686 , making
Function.prototype.toString.toString()
also returns"function toString() { [native code] }"
, which should be a little safer.Update:
Function.prototype.toString.call(Function.prototype.toString)
will return[native code]
, too.