MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / createElement

Function createElement

code/composition/public/app.js:18935–19005  ·  view source on GitHub ↗

* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement

(type, config, children)

Source from the content-addressed store, hash-verified

18933 * See https://reactjs.org/docs/react-api.html#createelement
18934 */
18935function createElement(type, config, children) {
18936 var propName = void 0;
18937
18938 // Reserved names are extracted
18939 var props = {};
18940
18941 var key = null;
18942 var ref = null;
18943 var self = null;
18944 var source = null;
18945
18946 if (config != null) {
18947 if (hasValidRef(config)) {
18948 ref = config.ref;
18949 }
18950 if (hasValidKey(config)) {
18951 key = '' + config.key;
18952 }
18953
18954 self = config.__self === undefined ? null : config.__self;
18955 source = config.__source === undefined ? null : config.__source;
18956 // Remaining properties are added to a new props object
18957 for (propName in config) {
18958 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
18959 props[propName] = config[propName];
18960 }
18961 }
18962 }
18963
18964 // Children can be more than one argument, and those are transferred onto
18965 // the newly allocated props object.
18966 var childrenLength = arguments.length - 2;
18967 if (childrenLength === 1) {
18968 props.children = children;
18969 } else if (childrenLength > 1) {
18970 var childArray = Array(childrenLength);
18971 for (var i = 0; i < childrenLength; i++) {
18972 childArray[i] = arguments[i + 2];
18973 }
18974 {
18975 if (Object.freeze) {
18976 Object.freeze(childArray);
18977 }
18978 }
18979 props.children = childArray;
18980 }
18981
18982 // Resolve default props
18983 if (type && type.defaultProps) {
18984 var defaultProps = type.defaultProps;
18985 for (propName in defaultProps) {
18986 if (props[propName] === undefined) {
18987 props[propName] = defaultProps[propName];
18988 }
18989 }
18990 }
18991 {
18992 if (key || ref) {

Callers 1

app.jsFile · 0.70

Calls 5

hasValidRefFunction · 0.70
hasValidKeyFunction · 0.70
ReactElementFunction · 0.70

Tested by

no test coverage detected