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

Function createElement$1

code/dependency-injection/public/app.js:16293–16343  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

16291}
16292
16293function createElement$1(type, props, rootContainerElement, parentNamespace) {
16294 var isCustomComponentTag = void 0;
16295
16296 // We create tags in the namespace of their parent container, except HTML
16297 // tags get no namespace.
16298 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
16299 var domElement = void 0;
16300 var namespaceURI = parentNamespace;
16301 if (namespaceURI === HTML_NAMESPACE) {
16302 namespaceURI = getIntrinsicNamespace(type);
16303 }
16304 if (namespaceURI === HTML_NAMESPACE) {
16305 {
16306 isCustomComponentTag = isCustomComponent(type, props);
16307 // Should this check be gated by parent namespace? Not sure we want to
16308 // allow <SVG> or <mATH>.
16309 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
16310 }
16311
16312 if (type === 'script') {
16313 // Create the script via .innerHTML so its "parser-inserted" flag is
16314 // set to true and it does not execute
16315 var div = ownerDocument.createElement('div');
16316 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
16317 // This is guaranteed to yield a script element.
16318 var firstChild = div.firstChild;
16319 domElement = div.removeChild(firstChild);
16320 } else if (typeof props.is === 'string') {
16321 // $FlowIssue `createElement` should be updated for Web Components
16322 domElement = ownerDocument.createElement(type, { is: props.is });
16323 } else {
16324 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
16325 // See discussion in https://github.com/facebook/react/pull/6896
16326 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
16327 domElement = ownerDocument.createElement(type);
16328 }
16329 } else {
16330 domElement = ownerDocument.createElementNS(namespaceURI, type);
16331 }
16332
16333 {
16334 if (namespaceURI === HTML_NAMESPACE) {
16335 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
16336 warnedUnknownTags[type] = true;
16337 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);
16338 }
16339 }
16340 }
16341
16342 return domElement;
16343}
16344
16345function createTextNode$1(text, rootContainerElement) {
16346 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