 
       if tokenText.length > MaxTokenLength
         while startIndex < endIndex
-          text = @sliceText(tokenText, startIndex, startIndex + MaxTokenLength)
-          scopeNode.appendChild(@domElementPool.buildElement("span", null, text))
+          textNode = @domElementPool.buildText(
+            @sliceText(tokenText, startIndex, startIndex + MaxTokenLength)
+          )
+          textSpan = @domElementPool.buildElement("span")
+
+          textSpan.appendChild(textNode)
+          scopeNode.appendChild(textSpan)
           startIndex += MaxTokenLength
       else
-        scopeNode.insertAdjacentText("beforeend", @sliceText(tokenText, startIndex, endIndex))
+        scopeNode.appendChild(
+          @domElementPool.buildText(@sliceText(tokenText, startIndex, endIndex))
+        )
 
       scopeNode.appendChild(trailingWhitespaceNode) if trailingWhitespaceNode?
 

    if endOfLineInvisibles?
      for invisible in endOfLineInvisibles
        hasInvisibles = true
        lineNode.appendChild(
          @domElementPool.buildElement("span", "invisible-character", invisible)
        )

    hasInvisibles



  appendTokenNodes: (tokenText, isHardTab, firstNonWhitespaceIndex, firstTrailingWhitespaceIndex, hasIndentGuide, hasInvisibleCharacters, scopeNode) ->
    if isHardTab
      hardTabNode = @domElementPool.buildElement("span", "hard-tab")
      hardTabNode.classList.add("leading-whitespace") if firstNonWhitespaceIndex?
      hardTabNode.classList.add("trailing-whitespace") if firstTrailingWhitespaceIndex?
      hardTabNode.classList.add("indent-guide") if hasIndentGuide
      hardTabNode.classList.add("invisible-character") if hasInvisibleCharacters
      hardTabNode.appendChild(@domElementPool.buildText(tokenText))

      scopeNode.appendChild(hardTabNode)
    else
