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

Function createElement$1

code/communication/public/app.js:16235–16285  ·  view source on GitHub ↗
(type, props, rootContainerElement, parentNamespace)

Source from the content-addressed store, hash-verified

16233}
16234
16235function createElement$1(type, props, rootContainerElement, parentNamespace) {
16236 var isCustomComponentTag = void 0;
16237
16238 // We create tags in the namespace of their parent container, except HTML
16239 // tags get no namespace.
16240 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
16241 var domElement = void 0;
16242 var namespaceURI = parentNamespace;
16243 if (namespaceURI === HTML_NAMESPACE) {
16244 namespaceURI = getIntrinsicNamespace(type);
16245 }
16246 if (namespaceURI === HTML_NAMESPACE) {
16247 {
16248 isCustomComponentTag = isCustomComponent(type, props);
16249 // Should this check be gated by parent namespace? Not sure we want to
16250 // allow <SVG> or <mATH>.
16251 warning(isCustomComponentTag || type === type.toLowerCase(), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type);
16252 }
16253
16254 if (type === 'script') {
16255 // Create the script via .innerHTML so its "parser-inserted" flag is
16256 // set to true and it does not execute
16257 var div = ownerDocument.createElement('div');
16258 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
16259 // This is guaranteed to yield a script element.
16260 var firstChild = div.firstChild;
16261 domElement = div.removeChild(firstChild);
16262 } else if (typeof props.is === 'string') {
16263 // $FlowIssue `createElement` should be updated for Web Components
16264 domElement = ownerDocument.createElement(type, { is: props.is });
16265 } else {
16266 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
16267 // See discussion in https://github.com/facebook/react/pull/6896
16268 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
16269 domElement = ownerDocument.createElement(type);
16270 }
16271 } else {
16272 domElement = ownerDocument.createElementNS(namespaceURI, type);
16273 }
16274
16275 {
16276 if (namespaceURI === HTML_NAMESPACE) {
16277 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
16278 warnedUnknownTags[type] = true;
16279 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);
16280 }
16281 }
16282 }
16283
16284 return domElement;
16285}
16286
16287function createTextNode$1(text, rootContainerElement) {
16288 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