🐎 Save an allocation while removing nodes

This commit is contained in:
Antonio Scandurra 2015-09-14 17:44:57 +02:00
parent 6b2e7a6765
commit 536a5f4395
2 changed files with 5 additions and 4 deletions

View File

@ -35,7 +35,7 @@ describe "DomElementsPool", ->
domElementsPool.freeElementAndDescendants(div)
expect(domElementsPool.build("div")).toBe(div)
expect(domElementsPool.build("span")).toBe(span3)
expect(domElementsPool.build("span")).toBe(span4)
expect(domElementsPool.build("span")).toBe(span1)
expect(domElementsPool.build("span")).toBe(span2)
expect(domElementsPool.build("span")).toBe(span1)
expect(domElementsPool.build("span")).toBe(span4)
expect(domElementsPool.build("span")).toBe(span3)

View File

@ -21,5 +21,6 @@ class DomElementsPool
freeElementAndDescendants: (element) ->
@free(element)
for child in toArray(element.children)
for index in [element.children.length - 1..0] by -1
child = element.children[index]
@freeElementAndDescendants(child)