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

Function createElement$1

code/one-direction-data-flow/public/app.js:16073–16123  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

16071}
16072
16073function createElement$1(type, props, rootContainerElement, parentNamespace) {
16074 var isCustomComponentTag = void 0;
16075
16076 // We create tags in the namespace of their parent container, except HTML
16077 // tags get no namespace.
16078 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
16079 var domElement = void 0;
16080 var namespaceURI = parentNamespace;
16081 if (namespaceURI === HTML_NAMESPACE) {
16082 namespaceURI = getIntrinsicNamespace(type);
16083 }
16084 if (namespaceURI === HTML_NAMESPACE) {
16085 {
16086 isCustomComponentTag = isCustomComponent(type, props);
16087 // Should this check be gated by parent namespace? Not sure we want to
16088 // allow <SVG> or <mATH>.
16089 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
16090 }
16091
16092 if (type === 'script') {
16093 // Create the script via .innerHTML so its "parser-inserted" flag is
16094 // set to true and it does not execute
16095 var div = ownerDocument.createElement('div');
16096 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
16097 // This is guaranteed to yield a script element.
16098 var firstChild = div.firstChild;
16099 domElement = div.removeChild(firstChild);
16100 } else if (typeof props.is === 'string') {
16101 // $FlowIssue `createElement` should be updated for Web Components
16102 domElement = ownerDocument.createElement(type, { is: props.is });
16103 } else {
16104 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
16105 // See discussion in https://github.com/facebook/react/pull/6896
16106 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
16107 domElement = ownerDocument.createElement(type);
16108 }
16109 } else {
16110 domElement = ownerDocument.createElementNS(namespaceURI, type);
16111 }
16112
16113 {
16114 if (namespaceURI === HTML_NAMESPACE) {
16115 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
16116 warnedUnknownTags[type] = true;
16117 warning(false, 'The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type);
16118 }
16119 }
16120 }
16121
16122 return domElement;
16123}
16124
16125function createTextNode$1(text, rootContainerElement) {
16126 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);

Callers

nothing calls this directly

Calls 4

warningFunction · 0.85
getIntrinsicNamespaceFunction · 0.70
isCustomComponentFunction · 0.70

Tested by

no test coverage detected