add OriginalDelegate prop to Function::toString#993
add OriginalDelegate prop to Function::toString#993mhevery merged 1 commit intoangular:masterfrom gdh1995:hook-toString
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. |
| } | ||
| return originalFunctionToString.apply(this, arguments); | ||
| }; | ||
| (newFunctionToString as any)[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; |
There was a problem hiding this comment.
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. |
| @@ -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.
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.