Skip to content

Commit

Permalink
add Reflect[@@toStringTag]
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Nov 4, 2020
1 parent 7fad6ac commit 3fd6d0b
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##### Unreleased
- `String#replaceAll` moved to the stable ES, [per June TC39 meeting](https://github.com/tc39/notes/blob/master/meetings/2020-06/june-2.md#stringprototypereplaceall-for-stage-4)
- `Promise.any` and `AggregateError` moved to the stable ES, [per July TC39 meeting](https://github.com/tc39/notes/blob/master/meetings/2020-07/july-21.md#promiseany--aggregateerror-for-stage-4)
- Added `Reflect[@@toStringTag]`, [per July TC39 meeting](https://github.com/tc39/ecma262/pull/2057)
- Following the changes in [the `upsert` proposal](https://github.com/tc39/proposal-upsert), `{ Map, WeakMap }#emplace` replace `{ Map, WeakMap }#upsert`, these obsolete methods will be removed in the next major release
- [By the current spec](https://tc39.es/ecma262/#sec-aggregate-error-constructor), `AggregateError#errors` is own data property
- Added correct iteration closing in the iteration helpers according to the current version of [the proposal](https://tc39.es/proposal-iterator-helpers)
Expand Down
5 changes: 5 additions & 0 deletions packages/core-js-compat/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ const data = {
firefox: '42',
safari: '10.0',
},
'es.reflect.to-string-tag': {
chrome: '86',
firefox: '82',
safari: '14.0',
},
'es.regexp.constructor': {
chrome: '51',
firefox: '49',
Expand Down
1 change: 1 addition & 0 deletions packages/core-js-compat/src/modules-by-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
3.7: [
'es.aggregate-error',
'es.promise.any',
'es.reflect.to-string-tag',
'es.string.replace-all',
'esnext.map.emplace',
'esnext.weak-map.emplace',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
1 change: 1 addition & 0 deletions packages/core-js/es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ require('../modules/es.reflect.own-keys');
require('../modules/es.reflect.prevent-extensions');
require('../modules/es.reflect.set');
require('../modules/es.reflect.set-prototype-of');
require('../modules/es.reflect.to-string-tag');
var path = require('../internals/path');

module.exports = path;
1 change: 1 addition & 0 deletions packages/core-js/es/reflect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require('../../modules/es.reflect.own-keys');
require('../../modules/es.reflect.prevent-extensions');
require('../../modules/es.reflect.set');
require('../../modules/es.reflect.set-prototype-of');
require('../../modules/es.reflect.to-string-tag');
var path = require('../../internals/path');

module.exports = path.Reflect;
3 changes: 3 additions & 0 deletions packages/core-js/es/reflect/to-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('../../modules/es.reflect.to-string-tag');

module.exports = 'Reflect';
3 changes: 3 additions & 0 deletions packages/core-js/features/reflect/to-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('../../modules/es.reflect.to-string-tag');

module.exports = 'Reflect';
9 changes: 9 additions & 0 deletions packages/core-js/modules/es.reflect.to-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var $ = require('../internals/export');
var global = require('../internals/global');
var setToStringTag = require('../internals/set-to-string-tag');

$({ global: true }, { Reflect: {} });

// Reflect[@@toStringTag] property
// https://tc39.es/ecma262/#sec-reflect-@@tostringtag
setToStringTag(global.Reflect, 'Reflect', true);
3 changes: 3 additions & 0 deletions packages/core-js/stable/reflect/to-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('../../modules/es.reflect.to-string-tag');

module.exports = 'Reflect';
3 changes: 3 additions & 0 deletions tests/commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(load('features/reflect/prevent-extensions')({}));
ok(load('features/reflect/set')({}, 'a', 42));
load('features/reflect/set-prototype-of')(O = {}, []);
ok(load('features/reflect/to-string-tag') === 'Reflect');
ok(O instanceof Array);
ok(typeof load('features/reflect/define-metadata') === 'function');
ok(typeof load('features/reflect/delete-metadata') === 'function');
Expand Down Expand Up @@ -560,6 +561,7 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(load('stable/reflect/prevent-extensions')({}));
ok(load('stable/reflect/set')({}, 'a', 42));
load('stable/reflect/set-prototype-of')(O = {}, []);
ok(load('stable/reflect/to-string-tag') === 'Reflect');
ok(O instanceof Array);
ok('has' in load('stable/reflect'));
ok(load('stable/string/from-code-point')(97) === 'a');
Expand Down Expand Up @@ -832,6 +834,7 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(load('es/reflect/prevent-extensions')({}));
ok(load('es/reflect/set')({}, 'a', 42));
load('es/reflect/set-prototype-of')(O = {}, []);
ok(load('es/reflect/to-string-tag') === 'Reflect');
ok(O instanceof Array);
ok('has' in load('es/reflect'));
ok(load('es/string/from-code-point')(97) === 'a');
Expand Down
3 changes: 3 additions & 0 deletions tests/compat/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ GLOBAL.tests = {
'es.reflect.set-prototype-of': function () {
return Reflect.setPrototypeOf;
},
'es.reflect.to-string-tag': function () {
return Reflect[Symbol.toStringTag];
},
'es.regexp.constructor': function () {
var re1 = /a/g;
var re2 = /a/g;
Expand Down
3 changes: 3 additions & 0 deletions tests/tests/es.math.to-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
QUnit.test('Math[@@toStringTag]', assert => {
assert.strictEqual(Math[Symbol.toStringTag], 'Math', 'Math[@@toStringTag] is `Math`');
});
3 changes: 3 additions & 0 deletions tests/tests/es.reflect.to-string-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
QUnit.test('Reflect[@@toStringTag]', assert => {
assert.strictEqual(Reflect[Symbol.toStringTag], 'Reflect', 'Reflect[@@toStringTag] is `Reflect`');
});
2 changes: 2 additions & 0 deletions tests/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import './es.math.log2';
import './es.math.sign';
import './es.math.sinh';
import './es.math.tanh';
import './es.math.to-string-tag';
import './es.math.trunc';
import './es.number.constructor';
import './es.number.epsilon';
Expand Down Expand Up @@ -111,6 +112,7 @@ import './es.reflect.own-keys';
import './es.reflect.prevent-extensions';
import './es.reflect.set-prototype-of';
import './es.reflect.set';
import './es.reflect.to-string-tag';
import './es.regexp.constructor';
import './es.regexp.exec';
import './es.regexp.flags';
Expand Down

0 comments on commit 3fd6d0b

Please sign in to comment.