react / react/react-native

Set polyfill says it is [object Object] but should say [object Set]

Open
#19,594 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug JavaScript Priority: Low
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Environment

Any - you can reproduce the issue using only file

https://github.com/facebook/react-native/blob/master/Libraries/vendor/core/Set.js

and any Javascript encironment.

EDIT: Just for the bot, it is completely irrelevant:

Environment:
OS: Windows 10
Node: 10.3.0
Yarn: Not Found
npm: 6.1.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4720617

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

Description and Steps to Reproduce

Here is code that creates a simple Set object and then uses the spread operator to spread the Set's contents into a new array.

First, using an environment where the above file was executed/loaded (plus its own dependencies), and I also short-circuited the detection at the beginning that determines whether the polyfill is applied:

const s1 = new Set([1,2,3]);
console.log(Object.prototype.toString.call(s1));

Result:

[object Object]

Expected Behavior

Now for comparison a clean ES6+ environment without anything loaded, so we get a native Set implementation:

const s1 = new Set([1,2,3]);
console.log(Object.prototype.toString.call(s1));

Result:

[object Set]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Libraries/vendor/core/Set.js and reproduce the reported behavior in a JavaScript environment using the provided Object.prototype.toString.call example. Compare the polyfilled Set result with the native Set result; done means the polyfill reports [object Set] for a Set instance.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.