MCPcopy Index your code
hub / github.com/microsoft/SandDance / createElement

Function createElement

docs/external/js/react.development.js:813–893  ·  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

811 */
812
813 function createElement(type, config, children) {
814 var propName; // Reserved names are extracted
815
816 var props = {};
817 var key = null;
818 var ref = null;
819 var self = null;
820 var source = null;
821
822 if (config != null) {
823 if (hasValidRef(config)) {
824 ref = config.ref;
825
826 {
827 warnIfStringRefCannotBeAutoConverted(config);
828 }
829 }
830
831 if (hasValidKey(config)) {
832 key = '' + config.key;
833 }
834
835 self = config.__self === undefined ? null : config.__self;
836 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
837
838 for (propName in config) {
839 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
840 props[propName] = config[propName];
841 }
842 }
843 } // Children can be more than one argument, and those are transferred onto
844 // the newly allocated props object.
845
846
847 var childrenLength = arguments.length - 2;
848
849 if (childrenLength === 1) {
850 props.children = children;
851 } else if (childrenLength > 1) {
852 var childArray = Array(childrenLength);
853
854 for (var i = 0; i < childrenLength; i++) {
855 childArray[i] = arguments[i + 2];
856 }
857
858 {
859 if (Object.freeze) {
860 Object.freeze(childArray);
861 }
862 }
863
864 props.children = childArray;
865 } // Resolve default props
866
867
868 if (type && type.defaultProps) {
869 var defaultProps = type.defaultProps;
870

Callers 1

constructorMethod · 0.90

Calls 6

hasValidRefFunction · 0.85
hasValidKeyFunction · 0.85
ReactElementFunction · 0.85

Tested by

no test coverage detected