Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: src/symbol.js

Issue 461453002: Implement well-known symbol `Symbol.toStringTag` Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/collection.js ('k') | src/v8natives.js » ('j') | src/v8natives.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/symbol.js
diff --git a/src/symbol.js b/src/symbol.js
index 9f2e563704a0e678f7001b839213941e050b13ea..78216767e1427e95ae3a3d1aed8f17783fea291e 100644
--- a/src/symbol.js
+++ b/src/symbol.js
@@ -103,8 +103,8 @@ function SetUpSymbol() {
// "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable,
// "isRegExp", symbolIsRegExp,
- "iterator", symbolIterator
- // "toStringTag", symbolToStringTag,
+ "iterator", symbolIterator,
+ "toStringTag", symbolToStringTag
// "unscopables", symbolUnscopables // added in unscopables.js
));
InstallFunctions($Symbol, DONT_ENUM, $Array(
@@ -121,6 +121,22 @@ function SetUpSymbol() {
SetUpSymbol();
+function addToStringTagProperty(obj, tag){
+ %AddNamedProperty(obj, symbolToStringTag, tag, DONT_ENUM | READ_ONLY);
+}
+
+function setUpToStringTags(){
+ addToStringTagProperty(global.Math, "Math");
+ addToStringTagProperty(global.JSON, "JSON");
+ addToStringTagProperty($Symbol.prototype, "Symbol");
+ addToStringTagProperty(global.Promise.prototype, "Promise");
+ addToStringTagProperty(global.WeakMap.prototype, "WeakMap");
+ addToStringTagProperty(global.WeakSet.prototype, "WeakSet");
+ addToStringTagProperty(global.ArrayBuffer.prototype, "ArrayBuffer");
+ addToStringTagProperty(global.DataView.prototype, "DataView");
+}
+
+setUpToStringTags();
function ExtendObject() {
%CheckIsBootstrapping();
« no previous file with comments | « src/collection.js ('k') | src/v8natives.js » ('j') | src/v8natives.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698