Use custom document to create test elements

This commit is contained in:
Kevin Sawicki
2015-02-09 09:35:38 -08:00
parent 784cd96bd0
commit ac1cc87037

View File

@@ -109,17 +109,20 @@ class MenuManager
# Simulate an atom-text-editor element attached to a atom-workspace element attached
# to a body element that has the same classes as the current body element.
unless @testEditor?
testBody = document.createElement('body')
# Use new document so that custom elements don't actually get created
testDocument = document.implementation.createDocument(document.namespaceURI, 'html')
testBody = testDocument.createElement('body')
testBody.classList.add(@classesForElement(document.body)...)
testWorkspace = document.createElement('atom-workspace')
testWorkspace = testDocument.createElement('atom-workspace')
workspaceClasses = @classesForElement(document.body.querySelector('atom-workspace'))
workspaceClasses = ['workspace'] if workspaceClasses.length is 0
testWorkspace.classList.add(workspaceClasses...)
testBody.appendChild(testWorkspace)
@testEditor = document.createElement('atom-text-editor')
@testEditor = testDocument.createElement('atom-text-editor')
@testEditor.classList.add('editor')
testWorkspace.appendChild(@testEditor)