This repository was archived by the owner on Feb 26, 2024. It is now read-only.
feat(patch): fix #499, let promise instance toString active like native#734
Merged
mhevery merged 1 commit intoangular:masterfrom Apr 21, 2017
Merged
feat(patch): fix #499, let promise instance toString active like native#734mhevery merged 1 commit intoangular:masterfrom
mhevery merged 1 commit intoangular:masterfrom
Conversation
mhevery
approved these changes
Apr 21, 2017
sod
reviewed
Oct 9, 2017
| export function patchObjectToString() { | ||
| const originalObjectToString = Object.prototype.toString; | ||
| Object.prototype.toString = function() { | ||
| if (this instanceof Promise) { |
There was a problem hiding this comment.
Isn't the reason why Promise shims are in use because Promise is not available in all common browsers today? So wouldn't this line throw
ReferenceError: Can't find variable: Promise
for projects & browsers that haven't window.Promise (neither native nor shim)?
Collaborator
Author
There was a problem hiding this comment.
zone.js has provided Promise shim, so it will be ok even some browser or other environment doesn't provide native Promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #499, let
active as native to output
instead of current
in ES6, we can use Symbol.toStringTag, in ES5, I didn't find a better way to do this.