Skip to content

Commit

Permalink
Performance: setTextContent should attempt to set TextNode nodeValue …
Browse files Browse the repository at this point in the history
…where possible (#7005)
  • Loading branch information
trueadm authored and sophiebits committed Jun 10, 2016
1 parent 46cd6a0 commit 40f6d3e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/renderers/dom/client/utils/setTextContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit 40f6d3e

Please sign in to comment.