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

Function createElement

code/one-direction-data-flow/public/app.js:18670–18740  ·  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

18668 * See https://reactjs.org/docs/react-api.html#createelement
18669 */
18670function createElement(type, config, children) {
18671 var propName = void 0;
18672
18673 // Reserved names are extracted
18674 var props = {};
18675
18676 var key = null;
18677 var ref = null;
18678 var self = null;
18679 var source = null;
18680
18681 if (config != null) {
18682 if (hasValidRef(config)) {
18683 ref = config.ref;
18684 }
18685 if (hasValidKey(config)) {
18686 key = '' + config.key;
18687 }
18688
18689 self = config.__self === undefined ? null : config.__self;
18690 source = config.__source === undefined ? null : config.__source;
18691 // Remaining properties are added to a new props object
18692 for (propName in config) {
18693 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
18694 props[propName] = config[propName];
18695 }
18696 }
18697 }
18698
18699 // Children can be more than one argument, and those are transferred onto
18700 // the newly allocated props object.
18701 var childrenLength = arguments.length - 2;
18702 if (childrenLength === 1) {
18703 props.children = children;
18704 } else if (childrenLength > 1) {
18705 var childArray = Array(childrenLength);
18706 for (var i = 0; i < childrenLength; i++) {
18707 childArray[i] = arguments[i + 2];
18708 }
18709 {
18710 if (Object.freeze) {
18711 Object.freeze(childArray);
18712 }
18713 }
18714 props.children = childArray;
18715 }
18716
18717 // Resolve default props
18718 if (type && type.defaultProps) {
18719 var defaultProps = type.defaultProps;
18720 for (propName in defaultProps) {
18721 if (props[propName] === undefined) {
18722 props[propName] = defaultProps[propName];
18723 }
18724 }
18725 }
18726 {
18727 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