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

This commit is contained in:
Dominic Gannaway authored and Ben Alpert committed 2016-06-10 09:57:31 -07:00
1 parent 46cd6a0b62
commit 40f6d3eaca
1 file changed
+8
@@ -26,6 +26,14 @@ var setInnerHTML = require('setInnerHTML');
* @internal
*/
var setTextContent = function(node, text) {
if (text) {
var firstChild = node.firstChild;
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) {
firstChild.nodeValue = text;
return;
}
}
node.textContent = text;
};