* Given a fragment, validate that it can only be provided with fragment props * @param {ReactElement} fragment
(fragment)
| 1922 | |
| 1923 | |
| 1924 | function validateFragmentProps(fragment) { |
| 1925 | { |
| 1926 | setCurrentlyValidatingElement(fragment); |
| 1927 | var keys = Object.keys(fragment.props); |
| 1928 | |
| 1929 | for (var i = 0; i < keys.length; i++) { |
| 1930 | var key = keys[i]; |
| 1931 | |
| 1932 | if (key !== 'children' && key !== 'key') { |
| 1933 | error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); |
| 1934 | |
| 1935 | break; |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | if (fragment.ref !== null) { |
| 1940 | error('Invalid attribute `ref` supplied to `React.Fragment`.'); |
| 1941 | } |
| 1942 | |
| 1943 | setCurrentlyValidatingElement(null); |
| 1944 | } |
| 1945 | } |
| 1946 | function createElementWithValidation(type, props, children) { |
| 1947 | var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to |
| 1948 | // succeed and there will likely be errors in render. |
no test coverage detected