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

Function createElement$1

code/new-context-api/public/app.js:15561–15611  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

15559}
15560
15561function createElement$1(type, props, rootContainerElement, parentNamespace) {
15562 var isCustomComponentTag = void 0;
15563
15564 // We create tags in the namespace of their parent container, except HTML
15565 // tags get no namespace.
15566 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
15567 var domElement = void 0;
15568 var namespaceURI = parentNamespace;
15569 if (namespaceURI === HTML_NAMESPACE) {
15570 namespaceURI = getIntrinsicNamespace(type);
15571 }
15572 if (namespaceURI === HTML_NAMESPACE) {
15573 {
15574 isCustomComponentTag = isCustomComponent(type, props);
15575 // Should this check be gated by parent namespace? Not sure we want to
15576 // allow <SVG> or <mATH>.
15577 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
15578 }
15579
15580 if (type === 'script') {
15581 // Create the script via .innerHTML so its "parser-inserted" flag is
15582 // set to true and it does not execute
15583 var div = ownerDocument.createElement('div');
15584 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
15585 // This is guaranteed to yield a script element.
15586 var firstChild = div.firstChild;
15587 domElement = div.removeChild(firstChild);
15588 } else if (typeof props.is === 'string') {
15589 // $FlowIssue `createElement` should be updated for Web Components
15590 domElement = ownerDocument.createElement(type, { is: props.is });
15591 } else {
15592 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
15593 // See discussion in https://github.com/facebook/react/pull/6896
15594 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
15595 domElement = ownerDocument.createElement(type);
15596 }
15597 } else {
15598 domElement = ownerDocument.createElementNS(namespaceURI, type);
15599 }
15600
15601 {
15602 if (namespaceURI === HTML_NAMESPACE) {
15603 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
15604 warnedUnknownTags[type] = true;
15605 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);
15606 }
15607 }
15608 }
15609
15610 return domElement;
15611}
15612
15613function createTextNode$1(text, rootContainerElement) {
15614 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