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

Function createElement$1

code/composition/public/app.js:16338–16388  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

16336}
16337
16338function createElement$1(type, props, rootContainerElement, parentNamespace) {
16339 var isCustomComponentTag = void 0;
16340
16341 // We create tags in the namespace of their parent container, except HTML
16342 // tags get no namespace.
16343 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
16344 var domElement = void 0;
16345 var namespaceURI = parentNamespace;
16346 if (namespaceURI === HTML_NAMESPACE) {
16347 namespaceURI = getIntrinsicNamespace(type);
16348 }
16349 if (namespaceURI === HTML_NAMESPACE) {
16350 {
16351 isCustomComponentTag = isCustomComponent(type, props);
16352 // Should this check be gated by parent namespace? Not sure we want to
16353 // allow <SVG> or <mATH>.
16354 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
16355 }
16356
16357 if (type === 'script') {
16358 // Create the script via .innerHTML so its "parser-inserted" flag is
16359 // set to true and it does not execute
16360 var div = ownerDocument.createElement('div');
16361 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
16362 // This is guaranteed to yield a script element.
16363 var firstChild = div.firstChild;
16364 domElement = div.removeChild(firstChild);
16365 } else if (typeof props.is === 'string') {
16366 // $FlowIssue `createElement` should be updated for Web Components
16367 domElement = ownerDocument.createElement(type, { is: props.is });
16368 } else {
16369 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
16370 // See discussion in https://github.com/facebook/react/pull/6896
16371 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
16372 domElement = ownerDocument.createElement(type);
16373 }
16374 } else {
16375 domElement = ownerDocument.createElementNS(namespaceURI, type);
16376 }
16377
16378 {
16379 if (namespaceURI === HTML_NAMESPACE) {
16380 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
16381 warnedUnknownTags[type] = true;
16382 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);
16383 }
16384 }
16385 }
16386
16387 return domElement;
16388}
16389
16390function createTextNode$1(text, rootContainerElement) {
16391 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