mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Performance: setTextContent should attempt to set TextNode nodeValue where possible (#7005)
(cherry picked from commit 40f6d3eaca)
This commit is contained in:
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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user