@samitouri / QOS-React / commits / 3b708728b0

Declare type var higher up in mountComponent() in ReactDOMComponent for reuse (#7944)

Kevin Huang committed Oct 12, 2016 at 02:12 UTC 3b708728b011fdab90c1bcb27d40837de1393cac
1 file changed +5 -6
src/renderers/dom/shared/ReactDOMComponent.js
+5 -6
@@ -607,6 +607,7 @@ ReactDOMComponent.Mixin = {
607 }
608
609 var mountImage;
610 + var type = this._currentElement.type;
611 if (transaction.useCreateElement) {
612 var ownerDocument = hostContainerInfo._ownerDocument;
613 var el;
@@ -615,21 +616,20 @@ ReactDOMComponent.Mixin = {
616 // Create the script via .innerHTML so its "parser-inserted" flag is
617 // set to true and it does not execute
618 var div = ownerDocument.createElement('div');
618 - var type = this._currentElement.type;
619 div.innerHTML = `<${type}></${type}>`;
620 el = div.removeChild(div.firstChild);
621 } else if (props.is) {
622 - el = ownerDocument.createElement(this._currentElement.type, props.is);
622 + el = ownerDocument.createElement(type, props.is);
623 } else {
624 // Separate else branch instead of using `props.is || undefined` above becuase of a Firefox bug.
625 // See discussion in https://github.com/facebook/react/pull/6896
626 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
627 - el = ownerDocument.createElement(this._currentElement.type);
627 + el = ownerDocument.createElement(type);
628 }
629 } else {
630 el = ownerDocument.createElementNS(
631 namespaceURI,
632 - this._currentElement.type
632 + type
633 );
634 }
635 ReactDOMComponentTree.precacheNode(this, el);
@@ -647,8 +647,7 @@ ReactDOMComponent.Mixin = {
647 if (!tagContent && omittedCloseTags[this._tag]) {
648 mountImage = tagOpen + '/>';
649 } else {
650 - mountImage =
651 - tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
650 + mountImage = tagOpen + '>' + tagContent + '</' + type + '>';
651 }
652 }
653