From 22a240fd39b893982cc397ea8b8bcb78eb31158f Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Sat, 24 Oct 2015 12:19:30 -0700 Subject: [PATCH] Avoid lastProps[key] lookup in initial render This makes both Firefox and IE 15-20% faster in initial render (!!). On my PE benchmark, createElement is now on par with HTML in Firefox and faster in IE11 (before, it was slower). --- src/renderers/dom/shared/ReactDOMComponent.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index e8833226ed..967573f34b 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -665,7 +665,7 @@ ReactDOMComponent.Mixin = { DOMPropertyOperations.setAttributeForID(el, this._rootNodeID); // Populate node cache ReactMount.getID(el); - this._updateDOMProperties({}, props, transaction); + this._updateDOMProperties(null, props, transaction); var lazyTree = DOMLazyTree(el); this._createInitialChildren(transaction, props, context, lazyTree); mountImage = lazyTree; @@ -964,9 +964,9 @@ ReactDOMComponent.Mixin = { } for (propKey in nextProps) { var nextProp = nextProps[propKey]; - var lastProp = propKey === STYLE ? - this._previousStyleCopy : - lastProps[propKey]; + var lastProp = + propKey === STYLE ? this._previousStyleCopy : + lastProps != null ? lastProps[propKey] : undefined; if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {