Skip to content

Commit ae937ec

Browse files
committed
Use custom element on pane-element
document.registerElement is being deprecated which will make upgrading to later versions of electron imposible
1 parent e574623 commit ae937ec

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/pane-element.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ const path = require('path');
22
const { CompositeDisposable } = require('event-kit');
33

44
class PaneElement extends HTMLElement {
5-
createdCallback() {
5+
constructor() {
6+
super();
67
this.attached = false;
78
this.subscriptions = new CompositeDisposable();
89
this.inlineDisplayStyles = new WeakMap();
9-
this.initializeContent();
1010
this.subscribeToDOMEvents();
11+
this.itemViews = document.createElement('div');
1112
}
1213

13-
attachedCallback() {
14+
connectedCallback() {
15+
this.initializeContent();
1416
this.attached = true;
1517
if (this.model.isFocused()) {
1618
this.focus();
@@ -24,7 +26,6 @@ class PaneElement extends HTMLElement {
2426
initializeContent() {
2527
this.setAttribute('class', 'pane');
2628
this.setAttribute('tabindex', -1);
27-
this.itemViews = document.createElement('div');
2829
this.appendChild(this.itemViews);
2930
this.itemViews.setAttribute('class', 'item-views');
3031
}
@@ -148,6 +149,7 @@ class PaneElement extends HTMLElement {
148149
});
149150
}
150151
}
152+
151153
if (!this.itemViews.contains(itemView)) {
152154
this.itemViews.appendChild(itemView);
153155
}
@@ -213,6 +215,12 @@ class PaneElement extends HTMLElement {
213215
}
214216
}
215217

216-
module.exports = document.registerElement('atom-pane', {
217-
prototype: PaneElement.prototype
218-
});
218+
function createPaneElement() {
219+
return document.createElement('atom-pane');
220+
}
221+
222+
window.customElements.define('atom-pane', PaneElement);
223+
224+
module.exports = {
225+
createPaneElement
226+
};

src/pane.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const Grim = require('grim');
22
const { CompositeDisposable, Emitter } = require('event-kit');
33
const PaneAxis = require('./pane-axis');
44
const TextEditor = require('./text-editor');
5-
const PaneElement = require('./pane-element');
5+
const { createPaneElement } = require('./pane-element');
66

77
let nextInstanceId = 1;
88

@@ -98,7 +98,7 @@ module.exports = class Pane {
9898

9999
getElement() {
100100
if (!this.element) {
101-
this.element = new PaneElement().initialize(this, {
101+
this.element = createPaneElement().initialize(this, {
102102
views: this.viewRegistry,
103103
applicationDelegate: this.applicationDelegate
104104
});

0 commit comments

Comments
 (0)