@samitouri / QOS-React / commits / 40f6d3eaca

Performance: setTextContent should attempt to set TextNode nodeValue where possible (#7005)

Dominic Gannaway committed Jun 10, 2016 at 17:57 UTC 40f6d3eacad563c67bea0aa1c2220de6239ece43
1 file changed +8
src/renderers/dom/client/utils/setTextContent.js
+8
@@ -26,6 +26,14 @@ var setInnerHTML = require('setInnerHTML');
26 * @internal
27 */
28 var setTextContent = function(node, text) {
29 + if (text) {
30 + var firstChild = node.firstChild;
31 +
32 + if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) {
33 + firstChild.nodeValue = text;
34 + return;
35 + }
36 + }
37 node.textContent = text;
38 };
39