mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
This was already defeating the XSS issue that Symbols was meant to protect against. So you were already supposed to use a polyfill for security. We rely on real Symbol.for in Flight for Server Components so those require real symbols anyway. We also don't really support IE without additional polyfills anyway.
51 lines
2.0 KiB
JavaScript
51 lines
2.0 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
// ATTENTION
|
|
// When adding new symbols to this file,
|
|
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
|
|
// The Symbol used to tag the ReactElement-like types.
|
|
export const REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
export const REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
export const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
export const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
export const REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
export const REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
export const REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
export const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
export const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
export const REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
|
export const REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
export const REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
export const REACT_SCOPE_TYPE = Symbol.for('react.scope');
|
|
export const REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for(
|
|
'react.debug_trace_mode',
|
|
);
|
|
export const REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
|
export const REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden');
|
|
export const REACT_CACHE_TYPE = Symbol.for('react.cache');
|
|
export const REACT_TRACING_MARKER_TYPE = Symbol.for('react.tracing_marker');
|
|
|
|
const MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
const FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
|
|
export function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<*> {
|
|
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
return null;
|
|
}
|
|
const maybeIterator =
|
|
(MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
|
|
maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
if (typeof maybeIterator === 'function') {
|
|
return maybeIterator;
|
|
}
|
|
return null;
|
|
}
|