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

Function createElement$1

code/higher-order-components/public/app.js:16194–16244  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

16192}
16193
16194function createElement$1(type, props, rootContainerElement, parentNamespace) {
16195 var isCustomComponentTag = void 0;
16196
16197 // We create tags in the namespace of their parent container, except HTML
16198 // tags get no namespace.
16199 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
16200 var domElement = void 0;
16201 var namespaceURI = parentNamespace;
16202 if (namespaceURI === HTML_NAMESPACE) {
16203 namespaceURI = getIntrinsicNamespace(type);
16204 }
16205 if (namespaceURI === HTML_NAMESPACE) {
16206 {
16207 isCustomComponentTag = isCustomComponent(type, props);
16208 // Should this check be gated by parent namespace? Not sure we want to
16209 // allow <SVG> or <mATH>.
16210 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
16211 }
16212
16213 if (type === 'script') {
16214 // Create the script via .innerHTML so its "parser-inserted" flag is
16215 // set to true and it does not execute
16216 var div = ownerDocument.createElement('div');
16217 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
16218 // This is guaranteed to yield a script element.
16219 var firstChild = div.firstChild;
16220 domElement = div.removeChild(firstChild);
16221 } else if (typeof props.is === 'string') {
16222 // $FlowIssue `createElement` should be updated for Web Components
16223 domElement = ownerDocument.createElement(type, { is: props.is });
16224 } else {
16225 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
16226 // See discussion in https://github.com/facebook/react/pull/6896
16227 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
16228 domElement = ownerDocument.createElement(type);
16229 }
16230 } else {
16231 domElement = ownerDocument.createElementNS(namespaceURI, type);
16232 }
16233
16234 {
16235 if (namespaceURI === HTML_NAMESPACE) {
16236 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
16237 warnedUnknownTags[type] = true;
16238 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);
16239 }
16240 }
16241 }
16242
16243 return domElement;
16244}
16245
16246function createTextNode$1(text, rootContainerElement) {
16247 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