Skip to content

Using Object.is implementation when compare values inside React.PropTypes.oneOf #6132

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

chicoxyzzy
Copy link
Contributor

implementation of #6131

return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint emits warnings here

  99:12  warning  Comparing to itself is potentially pointless  no-self-compare
  99:23  warning  Comparing to itself is potentially pointless  no-self-compare

✖ 2 problems (0 errors, 2 warnings)

what should I do here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just disable that warning for the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done and rebased

* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, just going to do this for now.

@chicoxyzzy chicoxyzzy force-pushed the use_object_is_in_oneof_validate_method branch from 8229a5e to 03925f4 Compare February 29, 2016 15:47
@facebook-github-bot
Copy link

@chicoxyzzy updated the pull request.

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
/*eslint-disable no-self-compare*/
function is(x, y) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a weird place to define a polyfill. Seems like we should do something more analogous to https://github.com/facebook/react/blob/master/src/shared/stubs/Object.assign.js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional and requested by me due to conversations had with @sebmarkbage a couple months ago, don't worry about it. We can deal with figuring out the polyfill story later.

@zpao
Copy link
Member

zpao commented Feb 29, 2016

Thanks!

zpao added a commit that referenced this pull request Feb 29, 2016
…ate_method

Using Object.is implementation when compare values inside React.PropTypes.oneOf
@zpao zpao merged commit 730e5ac into facebook:master Feb 29, 2016
@chicoxyzzy chicoxyzzy deleted the use_object_is_in_oneof_validate_method branch March 1, 2016 00:17
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants