Skip to content
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

Replace REACT_ELEMENT_TYPE magicnum with Infinity. #5830

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/isomorphic/classic/element/ReactElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var canDefineProperty = require('canDefineProperty');
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE =
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
0xeac7;
Infinity;

var RESERVED_PROPS = {
key: true,
Expand Down
6 changes: 4 additions & 2 deletions src/isomorphic/classic/element/__tests__/ReactElement-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('ReactElement', function() {
});

it('uses the fallback value when in an environment without Symbol', function() {
expect(<div />.$$typeof).toBe(0xeac7);
expect(<div />.$$typeof).toBe(Infinity);
});

it('returns a complete element according to spec', function() {
Expand Down Expand Up @@ -207,7 +207,9 @@ describe('ReactElement', function() {
expect(React.isValidElement({ type: 'div', props: {} })).toEqual(false);

var jsonElement = JSON.stringify(React.createElement('div'));
expect(React.isValidElement(JSON.parse(jsonElement))).toBe(true);
// Should be false, even with Symbol not present, due to Infinity value
// which cannot be serialized into/from JSON.
expect(React.isValidElement(JSON.parse(jsonElement))).toBe(false);
});

it('allows the use of PropTypes validators in statics', function() {
Expand Down