Keep a backward compatible DOM structure for atom-text-editor contents

This commit is contained in:
Antonio Scandurra
2016-10-06 13:30:58 +02:00
parent e94ea55d90
commit 91df848b8a
5 changed files with 34 additions and 27 deletions

View File

@@ -6,6 +6,7 @@ module.exports = class OffScreenBlockDecorationsComponent {
this.oldState = {offScreenBlockDecorations: {}, width: 0}
this.domNode = document.createElement('div')
this.domNode.style.visibility = 'hidden'
this.domNode.style.position = 'absolute'
this.blockDecorationNodesById = {}
}

View File

@@ -62,11 +62,7 @@ class TextEditorComponent
@domElementPool = new DOMElementPool
@domNode = document.createElement('div')
@domNode.classList.add('editor-contents')
# TODO: Remove these backwards compatible classes once everyone has
# transitioned to non-shadow DOM selectors.
@domNode.classList.add('editor-contents--private')
@domNode.classList.add('editor--private')
@overlayManager = new OverlayManager(@presenter, @domNode, @views)

View File

@@ -30,7 +30,18 @@ class TextEditorElement extends HTMLElement
@setAttribute('tabindex', -1)
initializeContent: (attributes) ->
@rootElement = this
Object.defineProperty(this, 'shadowRoot', {
get: =>
Grim.deprecate("""
The contents of `atom-text-editor` elements are no longer encapsulated
within a shadow DOM boundary. Please, stop using `shadowRoot` and access
the editor contents directly instead.
""")
this
})
@rootElement = document.createElement('div')
@rootElement.classList.add('editor--private')
@appendChild(@rootElement)
attachedCallback: ->
@buildModel() unless @getModel()?
@@ -106,7 +117,7 @@ class TextEditorElement extends HTMLElement
workspace: @workspace
assert: @assert
)
@appendChild(@component.getDomNode())
@rootElement.appendChild(@component.getDomNode())
inputNode = @component.hiddenInputComponent.getDomNode()
inputNode.addEventListener 'focus', @focused.bind(this)
inputNode.addEventListener 'blur', => @dispatchEvent(new FocusEvent('blur', bubbles: false))