Skip to content

Commit

Permalink
Only call isCustomComponent once
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Dail committed Apr 9, 2017
1 parent 468ac42 commit c8665e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ describe('ReactDOMComponent', () => {

expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'The tag <mycustomcomponent> is unrecognized in this browser'
'The tag <mycustomcomponent> is unrecognized in this browser',
);
}
});
Expand Down
40 changes: 19 additions & 21 deletions src/renderers/dom/stack/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ ReactDOMComponent.Mixin = {

assertValidProps(this, props);

if (__DEV__) {
var isCustomComponentTag = isCustomComponent(this._tag, props);
}
// We create tags in the namespace of their parent container, except HTML
// tags get no namespace.
var namespaceURI;
Expand All @@ -505,8 +508,7 @@ ReactDOMComponent.Mixin = {
if (namespaceURI === DOMNamespaces.html) {
if (__DEV__) {
warning(
isCustomComponent(this._tag, props) ||
this._tag === this._currentElement.type,
isCustomComponentTag || this._tag === this._currentElement.type,
'<%s /> is using uppercase HTML. Always use lowercase HTML tags ' +
'in React.',
this._currentElement.type,
Expand Down Expand Up @@ -562,32 +564,28 @@ ReactDOMComponent.Mixin = {
} else {
el = ownerDocument.createElementNS(namespaceURI, type);
}
var isCustomComponentTag = isCustomComponent(this._tag, props);
if (__DEV__ && isCustomComponentTag && !didWarnShadyDOM && el.shadyRoot) {
var owner = this._currentElement._owner;
var name = (owner && owner.getName()) || 'A component';
warning(
false,
'%s is using shady DOM. Using shady DOM with React can ' +
'cause things to break subtly.',
name,
);
didWarnShadyDOM = true;
}

if (__DEV__) {
if (isCustomComponentTag && !didWarnShadyDOM && el.shadyRoot) {
var owner = this._currentElement._owner;
var name = (owner && owner.getName()) || 'A component';
warning(
false,
'%s is using shady DOM. Using shady DOM with React can ' +
'cause things to break subtly.',
name,
);
didWarnShadyDOM = true;
}
if (this._namespaceURI === DOMNamespaces.html) {
warning(
!(el instanceof window.HTMLUnknownElement) ||
isCustomComponent(this._tag, props),
isCustomComponentTag || !(el instanceof window.HTMLUnknownElement),
'The tag <%s> is unrecognized in this browser. ' +
'If you meant to render a React component, start its name with ' +
'an uppercase letter.',
this._tag
'If you meant to render a React component, start its name with ' +
'an uppercase letter.',
this._tag,
);
}
}

ReactDOMComponentTree.precacheNode(this, el);
this._flags |= Flags.hasCachedChildNodes;
if (!this._hostParent) {
Expand Down

0 comments on commit c8665e8

Please sign in to comment.