Object.prototype.toString() is overridden and behaves incorrectly
See original GitHub issueAfter updating to version 0.9, the Object.prototype.toString.call( undefined )
returns [Object Window]
instead of [Object Undefined]
when the strict
mode isn’t turned on.
The root of this bug is caused by this line:
https://github.com/angular/zone.js/pull/734/files#diff-7cf54420c5bf443f7d3575ad72ac1de3R44
where this
refers to the Window
in non-strict mode.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:24 (8 by maintainers)
Top Results From Across the Web
Object.prototype.toString() is overridden and behaves incorrectly
After updating to version 0.9, the Object. prototype. toString. call( undefined ) returns [Object Window] instead of [Object Undefined] when the strict mode ......
Read more >Why does `Object.prototype.toString` always return `[object *]`?
This is a correction that was made in the ES5.1 spec. Prior to ES5, passing null or undefined to toString always caused the...
Read more >Object.prototype.toString() - JavaScript - MDN Web Docs
The toString() method returns a string representing the object. This method is meant to be overridden by derived objects for custom type ...
Read more >Chapter 17. Objects and Inheritance - Exploring JS
We override a method in Super.prototype by adding a method with the same name to Sub.prototype . methodB is an example and in...
Read more >The-Principles-of-Object-Oriented-JavaScript - Javascript - 19
The primitive wrapper types override valueOf() so that it returns a string ... of this problem involves adding enumerable proper- ties to Object.prototype....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When this fix will be released through npm ?
I found two workarounds:
1- Add the
.js
to the import in the pollyfills.ts in the Angular app:2- Disable the toString patching as specified in:
https://github.com/angular/zone.js/blob/master/MODULE.md
I added the following to the pollyfills.ts in the Angular app:
__Zone_disable_toString = true; // Zone will not patch Function.prototype.toString