From 82c9b9c78336dce758cd6cff4cc17216fd1c9248 Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Fri, 13 Nov 2009 14:21:14 -0500 Subject: [PATCH] Remove unnecessary function object creation and `Number#times` in `Element._getContentFromAnonymousElement`. --- CHANGELOG | 2 ++ src/dom/dom.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a194049..f1d99bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove unnecessary function object creation and `Number#times` in `Element._getContentFromAnonymousElement`. (kangax) + * Eliminate runtime forking and long method lookup in `Element.hasAttribute`. (kangax) * Remove redundant ternary. (kangax) diff --git a/src/dom/dom.js b/src/dom/dom.js index 7876327..6489c4f 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -1868,11 +1868,17 @@ Element._returnOffset = function(l, t) { }; Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; + var div = new Element('div'), + t = Element._insertionTranslations.tags[tagName]; if (t) { div.innerHTML = t[0] + html + t[1]; - t[2].times(function() { div = div.firstChild }); - } else div.innerHTML = html; + for (var i = t[2]; i--; ) { + div = div.firstChild; + } + } + else { + div.innerHTML = html; + } return $A(div.childNodes); };