Clear dataset elements for pooled objects

This commit is contained in:
Antonio Scandurra 2015-09-15 12:23:53 +02:00
parent ad83a03440
commit f8868ffcf2

View File

@ -9,12 +9,14 @@ class DOMElementPool
for tagName, freeElements of @freeElementsByTagName
freeElements.length = 0
build: (tagName, className, textContent) ->
build: (tagName, className, textContent = "") ->
element = @freeElementsByTagName[tagName]?.pop()
element ?= document.createElement(tagName)
element.className = className
element.textContent = textContent
delete element.dataset[dataId] for dataId of element.dataset
element.removeAttribute("class")
element.removeAttribute("style")
element.className = className if className?
element.textContent = textContent
@freedElements.delete(element)