Created
May 19, 2018 14:54
-
-
Save devxom/451c6338165f4fc4f1974cb580596a26 to your computer and use it in GitHub Desktop.
Fastest way insert text. Source https://twitter.com/_developit/status/997520637743779840
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setText(node, text) { | |
let c = node.firstChild | |
if (c && !c.nextSibling && c.nodeType==3) | |
c.data = text | |
else | |
node.textContent = text | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment