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

Function createElement$1

code/event-handlers/public/app.js:15530–15580  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

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