mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Rename TYPE_SYMBOL to REACT_ELEMENT_TYPE
See D2454031 for context.
This commit is contained in:
@@ -17,7 +17,7 @@ var assign = require('Object.assign');
|
||||
|
||||
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var TYPE_SYMBOL =
|
||||
var REACT_ELEMENT_TYPE =
|
||||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
|
||||
0xeac7;
|
||||
|
||||
@@ -59,7 +59,7 @@ if (__DEV__) {
|
||||
var ReactElement = function(type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allow us to uniquely identify this as a React Element
|
||||
$$typeof: TYPE_SYMBOL,
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
|
||||
// Built-in properties that belong on the element
|
||||
type: type,
|
||||
@@ -289,7 +289,7 @@ ReactElement.isValidElement = function(object) {
|
||||
return (
|
||||
typeof object === 'object' &&
|
||||
object !== null &&
|
||||
object.$$typeof === TYPE_SYMBOL
|
||||
object.$$typeof === REACT_ELEMENT_TYPE
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -327,14 +327,14 @@ describe('ReactElement', function() {
|
||||
// Rudimentary polyfill
|
||||
// Once all jest engines support Symbols natively we can swap this to test
|
||||
// WITH native Symbols by default.
|
||||
var TYPE_SYMBOL = function() {}; // fake Symbol
|
||||
var REACT_ELEMENT_TYPE = function() {}; // fake Symbol
|
||||
var OTHER_SYMBOL = function() {}; // another fake Symbol
|
||||
global.Symbol = function(name) {
|
||||
return OTHER_SYMBOL;
|
||||
};
|
||||
global.Symbol.for = function(key) {
|
||||
if (key === 'react.element') {
|
||||
return TYPE_SYMBOL;
|
||||
return REACT_ELEMENT_TYPE;
|
||||
}
|
||||
return OTHER_SYMBOL;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user