Skip to content

Commit cde092e

Browse files
authored
Merge pull request atom#22751 from atom/use-custom-element-on-pane-element
Use custom element on pane-element
2 parents e574623 + 7074840 commit cde092e

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

packages/about/spec/about-spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('About', () => {
4343
describe('when the Atom version number is clicked', () => {
4444
it('copies the version number to the clipboard', async () => {
4545
await atom.workspace.open('atom://about');
46+
jasmine.attachToDOM(workspaceElement);
4647

4748
let aboutElement = workspaceElement.querySelector('.about');
4849
let versionContainer = aboutElement.querySelector('.atom');
@@ -67,6 +68,7 @@ describe('About', () => {
6768
describe('when the Electron version number is clicked', () => {
6869
it('copies the version number to the clipboard', async () => {
6970
await atom.workspace.open('atom://about');
71+
jasmine.attachToDOM(workspaceElement);
7072

7173
let aboutElement = workspaceElement.querySelector('.about');
7274
let versionContainer = aboutElement.querySelector('.electron');
@@ -78,6 +80,7 @@ describe('About', () => {
7880
describe('when the Chrome version number is clicked', () => {
7981
it('copies the version number to the clipboard', async () => {
8082
await atom.workspace.open('atom://about');
83+
jasmine.attachToDOM(workspaceElement);
8184

8285
let aboutElement = workspaceElement.querySelector('.about');
8386
let versionContainer = aboutElement.querySelector('.chrome');
@@ -89,6 +92,7 @@ describe('About', () => {
8992
describe('when the Node version number is clicked', () => {
9093
it('copies the version number to the clipboard', async () => {
9194
await atom.workspace.open('atom://about');
95+
jasmine.attachToDOM(workspaceElement);
9296

9397
let aboutElement = workspaceElement.querySelector('.about');
9498
let versionContainer = aboutElement.querySelector('.node');

packages/about/spec/about-status-bar-spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('the status bar', () => {
2222

2323
await atom.packages.activatePackage('status-bar');
2424
await atom.workspace.open('sample.js');
25+
jasmine.attachToDOM(workspaceElement);
2526
});
2627

2728
afterEach(async () => {

packages/go-to-line/spec/go-to-line-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('GoToLine', () => {
7777
const rowsPerPage = editor.getRowsPerPage();
7878
const currentRow = editor.getCursorBufferPosition().row;
7979
expect(editor.getFirstVisibleScreenRow()).toBe(
80-
currentRow - Math.ceil(rowsPerPage / 2)
80+
Math.ceil(currentRow - rowsPerPage / 2)
8181
);
8282
expect(editor.getLastVisibleScreenRow()).toBe(
8383
currentRow + Math.floor(rowsPerPage / 2)

src/pane-element.js

Lines changed: 15 additions & 7 deletions
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

Lines changed: 2 additions & 2 deletions
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)