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

Function createElement$1

code/third-party/public/app.js:15433–15483  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

15431}
15432
15433function createElement$1(type, props, rootContainerElement, parentNamespace) {
15434 var isCustomComponentTag = void 0;
15435
15436 // We create tags in the namespace of their parent container, except HTML
15437 // tags get no namespace.
15438 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
15439 var domElement = void 0;
15440 var namespaceURI = parentNamespace;
15441 if (namespaceURI === HTML_NAMESPACE) {
15442 namespaceURI = getIntrinsicNamespace(type);
15443 }
15444 if (namespaceURI === HTML_NAMESPACE) {
15445 {
15446 isCustomComponentTag = isCustomComponent(type, props);
15447 // Should this check be gated by parent namespace? Not sure we want to
15448 // allow <SVG> or <mATH>.
15449 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
15450 }
15451
15452 if (type === 'script') {
15453 // Create the script via .innerHTML so its "parser-inserted" flag is
15454 // set to true and it does not execute
15455 var div = ownerDocument.createElement('div');
15456 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
15457 // This is guaranteed to yield a script element.
15458 var firstChild = div.firstChild;
15459 domElement = div.removeChild(firstChild);
15460 } else if (typeof props.is === 'string') {
15461 // $FlowIssue `createElement` should be updated for Web Components
15462 domElement = ownerDocument.createElement(type, { is: props.is });
15463 } else {
15464 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
15465 // See discussion in https://github.com/facebook/react/pull/6896
15466 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
15467 domElement = ownerDocument.createElement(type);
15468 }
15469 } else {
15470 domElement = ownerDocument.createElementNS(namespaceURI, type);
15471 }
15472
15473 {
15474 if (namespaceURI === HTML_NAMESPACE) {
15475 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
15476 warnedUnknownTags[type] = true;
15477 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);
15478 }
15479 }
15480 }
15481
15482 return domElement;
15483}
15484
15485function createTextNode$1(text, rootContainerElement) {
15486 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