Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Convert PaneContainerElement and PaneElement to JS #16827

Merged
merged 1 commit into from Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/pane-container-element.coffee

This file was deleted.

40 changes: 40 additions & 0 deletions src/pane-container-element.js
@@ -0,0 +1,40 @@
const {CompositeDisposable} = require('event-kit')

class PaneContainerElement extends HTMLElement {
createdCallback () {
this.subscriptions = new CompositeDisposable()
this.classList.add('panes')
}

initialize (model, {views}) {
this.model = model
this.views = views
if (this.views == null) {
throw new Error('Must pass a views parameter when initializing PaneContainerElements')
}
this.subscriptions.add(this.model.observeRoot(this.rootChanged.bind(this)))
return this
}

rootChanged (root) {
const focusedElement = this.hasFocus() ? document.activeElement : null
if (this.firstChild != null) {
this.firstChild.remove()
}
if (root != null) {
const view = this.views.getView(root)
this.appendChild(view)
if (focusedElement != null) {
focusedElement.focus()
}
}
}

hasFocus () {
return this === document.activeElement || this.contains(document.activeElement)
}
}

module.exports = document.registerElement('atom-pane-container', {
prototype: PaneContainerElement.prototype
})
139 changes: 0 additions & 139 deletions src/pane-element.coffee

This file was deleted.