Use a DocumentFragment to insert all lines at once

This commit is contained in:
Nathan Sobo 2012-03-12 18:51:43 -06:00
parent a7c5ea08be
commit 0a38793450

View File

@ -202,14 +202,13 @@ class Editor extends View
elementsToReplace = @lineCache[startRow...endRow]
@lineCache[startRow...endRow] = lineElements?.toArray() or []
lines = @lines[0]
if lineElements
fragment = document.createDocumentFragment()
lineElements.each -> fragment.appendChild(this)
if elementToInsertBefore
lineElements.each ->
lines.insertBefore(this, elementToInsertBefore)
@lines[0].insertBefore(fragment, elementToInsertBefore)
else
lineElements.each ->
lines.appendChild(this)
@lines[0].appendChild(fragment)
$(elementsToReplace).remove()