         indentGuide = @domElementPool.buildElement("span", "indent-guide")
         for j in [0...tabLength]
           if invisible = endOfLineInvisibles?[invisibleIndex++]
-            indentGuide.appendChild(
-              @domElementPool.buildElement("span", "invisible-character", invisible)
-            )
+            invisibleSpan = @domElementPool.buildElement("span", "invisible-character")
+            invisibleSpan.appendChild(@domElementPool.buildText(invisible))
+            indentGuide.appendChild(invisibleSpan)
           else
-            indentGuide.insertAdjacentText("beforeend", " ")
+            indentGuide.appendChild(@domElementPool.buildText(" "))
         lineNode.appendChild(indentGuide)
 
       while invisibleIndex < endOfLineInvisibles?.length
         invisible = endOfLineInvisibles[invisibleIndex++]
-        lineNode.appendChild(
-          @domElementPool.buildElement("span", "invisible-character", invisible)
-        )
+        invisibleSpan = @domElementPool.buildElement("span", "invisible-character")
+        invisibleSpan.appendChild(@domElementPool.buildText(invisible))
+        lineNode.appendChild(invisibleSpan)
     else
       unless @appendEndOfLineNodes(id, lineNode)
-        lineNode.textContent = "\u00a0"
+        lineNode.appendChild(@domElementPool.buildText("\u00a0"))
 
   setLineInnerNodes: (id, lineNode) ->
     lineState = @newTileState.lines[id]

      trailingWhitespaceNode = null

      if firstNonWhitespaceIndex?
        leadingWhitespaceNode = @domElementPool.buildElement(
          "span",
          "leading-whitespace",
          tokenText.substring(0, firstNonWhitespaceIndex)
        )
        leadingWhitespaceNode.classList.add("indent-guide") if hasIndentGuide
        leadingWhitespaceNode.classList.add("invisible-character") if hasInvisibleCharacters

        startIndex = firstNonWhitespaceIndex

      if firstTrailingWhitespaceIndex?
        tokenIsOnlyWhitespace = firstTrailingWhitespaceIndex is 0

        trailingWhitespaceNode = @domElementPool.buildElement(
          "span",
          "trailing-whitespace",
          tokenText.substring(firstTrailingWhitespaceIndex)
        )
        trailingWhitespaceNode.classList.add("indent-guide") if hasIndentGuide and not firstNonWhitespaceIndex? and tokenIsOnlyWhitespace
        trailingWhitespaceNode.classList.add("invisible-character") if hasInvisibleCharacters

        endIndex = firstTrailingWhitespaceIndex



      if tokenText.length > MaxTokenLength
        while startIndex < endIndex
          textNode = @domElementPool.buildText(
            @sliceText(tokenText, startIndex, startIndex + MaxTokenLength)
          )
          textSpan = @domElementPool.buildElement("span")

          textSpan.appendChild(textNode)
          scopeNode.appendChild(textSpan)
          startIndex += MaxTokenLength
      else
        scopeNode.appendChild(
          @domElementPool.buildText(@sliceText(tokenText, startIndex, endIndex))
        )

      scopeNode.appendChild(trailingWhitespaceNode) if trailingWhitespaceNode?

