-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: Add notes for using @@toStringTag #2201
Conversation
@yosuke-furukawa would you mind changing this to inform about this, but also center it around deprecation notices? That would be great, it's something I never got around to doing. :) Prior discussion: #1301 |
@Fishrock123 +1. We would be better to deprecate |
@yosuke-furukawa I wouldn't delay a deprecation notice in the docs for v3 (It was supposed to be in v2 so..) Besides, we'll probably need to wait a good while before we deprecate this with a run-time warning. |
@Fishrock123 @yosuke-furukawa ... is there reason to keep this one open? Is it still needed? If so, it needs to be updated. |
@@ -194,6 +194,21 @@ Returns `true` if the given "object" is a `RegExp`. `false` otherwise. | |||
util.isRegExp({}) | |||
// false | |||
|
|||
note: This function uses `Object.prototype.toString.call` and check the returned value is `[object RegExp]`. However, `Symbol.toStringTag` can change the returned value directly. `Symbol.toStringTag` is enabled under `--harmony-tostring`. |
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.
"Note:" (capitalize) and please wrap lines at 80 columns. I'd write 'enabled with' instead of 'enabled under'.
LGTM when rebased and comments addressed. I think this is a valuable addition to the documentation. |
@yosuke-furukawa ... could I ask you to please rebase, update and address @bnoordhuis' comments. Thank you! |
This is mostly resolved. The |
util.isError() is the only remaining util.is*() method that depends on Object.prototype.toString() behavior. This commit notes the limitations of isError() related to @@toStringTag. Refs: nodejs#2201 PR-URL: nodejs#5414 Reviewed-By: Sakthipriyan Vairamani <[email protected]>
util.isError() is the only remaining util.is*() method that depends on Object.prototype.toString() behavior. This commit notes the limitations of isError() related to @@toStringTag. Refs: #2201 PR-URL: #5414 Reviewed-By: Sakthipriyan Vairamani <[email protected]>
util.isError() is the only remaining util.is*() method that depends on Object.prototype.toString() behavior. This commit notes the limitations of isError() related to @@toStringTag. Refs: #2201 PR-URL: #5414 Reviewed-By: Sakthipriyan Vairamani <[email protected]>
I checked
util.is*
functions. the following functions may be broken using ES2015 features.those functions use
Object.prototype.toString.call
to check the type.But
@@toStringTag
can chage the returned value.@@toStringTag
is enabled under--harmony
on io.js v2.For example,
This PR is to add a notice in these util function.