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

Function createElement$1

code/controlled-uncontrolled/public/app.js:15524–15574  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

15522}
15523
15524function createElement$1(type, props, rootContainerElement, parentNamespace) {
15525 var isCustomComponentTag = void 0;
15526
15527 // We create tags in the namespace of their parent container, except HTML
15528 // tags get no namespace.
15529 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
15530 var domElement = void 0;
15531 var namespaceURI = parentNamespace;
15532 if (namespaceURI === HTML_NAMESPACE) {
15533 namespaceURI = getIntrinsicNamespace(type);
15534 }
15535 if (namespaceURI === HTML_NAMESPACE) {
15536 {
15537 isCustomComponentTag = isCustomComponent(type, props);
15538 // Should this check be gated by parent namespace? Not sure we want to
15539 // allow <SVG> or <mATH>.
15540 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
15541 }
15542
15543 if (type === 'script') {
15544 // Create the script via .innerHTML so its "parser-inserted" flag is
15545 // set to true and it does not execute
15546 var div = ownerDocument.createElement('div');
15547 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
15548 // This is guaranteed to yield a script element.
15549 var firstChild = div.firstChild;
15550 domElement = div.removeChild(firstChild);
15551 } else if (typeof props.is === 'string') {
15552 // $FlowIssue `createElement` should be updated for Web Components
15553 domElement = ownerDocument.createElement(type, { is: props.is });
15554 } else {
15555 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
15556 // See discussion in https://github.com/facebook/react/pull/6896
15557 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
15558 domElement = ownerDocument.createElement(type);
15559 }
15560 } else {
15561 domElement = ownerDocument.createElementNS(namespaceURI, type);
15562 }
15563
15564 {
15565 if (namespaceURI === HTML_NAMESPACE) {
15566 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
15567 warnedUnknownTags[type] = true;
15568 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);
15569 }
15570 }
15571 }
15572
15573 return domElement;
15574}
15575
15576function createTextNode$1(text, rootContainerElement) {
15577 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