Skip to content

Commit

Permalink
bug: remove element after dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Mar 10, 2025
1 parent 090f2d2 commit 4eff83e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand All @@ -84,7 +84,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -365,7 +365,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -495,7 +495,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -524,14 +524,14 @@ describe('gridview', () => {

gridview.dispose();

expect(container.childNodes.length).toBe(0);
expect(container.children.length).toBe(0);
});

test('#1/VERTICAL', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -596,7 +596,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -661,7 +661,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -744,7 +744,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -845,7 +845,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -946,7 +946,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1178,7 +1178,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1309,7 +1309,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1442,7 +1442,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1573,7 +1573,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1704,7 +1704,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1838,7 +1838,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1875,7 +1875,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1911,7 +1911,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: false,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -1956,7 +1956,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -2085,7 +2085,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -2218,7 +2218,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -2500,7 +2500,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.VERTICAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down Expand Up @@ -2864,7 +2864,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand All @@ -2881,7 +2881,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand All @@ -2899,7 +2899,7 @@ describe('gridview', () => {
const gridview = new GridviewComponent(container, {
proportionalLayout: true,
orientation: Orientation.HORIZONTAL,
createComponent: (options) => {
createComponent: (options) => {
switch (options.name) {
case 'default':
return new TestGridview(options.id, options.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('componentPaneview', () => {
paneview.dispose();

expect(container.parentElement).toBe(root);
expect(container.children.length).toBe(0);
});

test('vertical panels', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('componentSplitview', () => {
splitview.dispose();

expect(container.parentElement).toBe(root);
expect(container.children.length).toBe(0);
});

test('event leakage', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/dockview-core/src/paneview/paneviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent {
}
this._viewDisposables.clear();

this.element.remove();

this.paneview.dispose();
}
}
2 changes: 2 additions & 0 deletions packages/dockview-core/src/splitview/splitviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ export class SplitviewComponent
view.dispose();
}

this.element.remove();

super.dispose();
}
}

0 comments on commit 4eff83e

Please sign in to comment.