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

(cherry picked from commit 40f6d3eaca)
This commit is contained in:
Dominic Gannaway
2016-06-14 15:50:39 -07:00
committed by Paul O’Shannessy
parent 1e0f0a35cf
commit eab4ffa721
@@ -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;
};