commit 29949b500a8800e7a800f23371cfab72182b8c96 parent 8f2674001067fbcd260896039ffec94e78e8cbaf Author: Ben Alpert <spicyjalapeno@gmail.com> Date: Fri, 5 Jul 2013 21:24:39 -0700 Make clearNode screaming-fast-er Reviewers: xymostech Reviewed By: xymostech Differential Revision: http://phabricator.benalpert.com/D35 Diffstat:
| M | MJLite.js | | | 7 | ++++--- |
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/MJLite.js b/MJLite.js @@ -87,9 +87,10 @@ var MJLite = (function() { }; var clearNode = function(node) { - var children = node.childNodes; - for (var i = children.length - 1; i >= 0; i--) { - node.removeChild(children[i]); + if ("textContent" in node) { + node.textContent = ""; + } else { + node.innerText = ""; } };