-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dispose of Lit parts after changing a renderer (#2325)
- Loading branch information
1 parent
76fab2f
commit 54042b7
Showing
8 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { fixtureSync } from '@vaadin/testing-helpers'; | ||
import { html, render } from 'lit'; | ||
import '../vaadin-combo-box.js'; | ||
|
||
describe('lit', () => { | ||
describe('renderer', () => { | ||
let comboBox; | ||
|
||
function getFirstItem() { | ||
return comboBox.$.overlay._selector.querySelector('vaadin-combo-box-item'); | ||
} | ||
|
||
beforeEach(() => { | ||
comboBox = fixtureSync(`<vaadin-combo-box></vaadin-combo-box>`); | ||
|
||
const size = 100; | ||
|
||
comboBox.items = new Array(size).fill().map((e, i) => { | ||
return { value: `value-${i}` }; | ||
}); | ||
|
||
comboBox.renderer = (root, _, { index }) => { | ||
render(html`value-${index}`, root); | ||
}; | ||
}); | ||
|
||
it('should render the content', () => { | ||
comboBox.opened = true; | ||
expect(getFirstItem().$.content.textContent).to.equal('value-0'); | ||
}); | ||
|
||
it('should render new content after assigning a new renderer', () => { | ||
comboBox.opened = true; | ||
comboBox.renderer = (root, _, { index }) => { | ||
render(html`new-${index}`, root); | ||
}; | ||
expect(getFirstItem().$.content.textContent).to.equal('new-0'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { fixtureSync } from '@vaadin/testing-helpers'; | ||
import { html, render } from 'lit'; | ||
import '../vaadin-virtual-list.js'; | ||
|
||
describe('lit', () => { | ||
describe('renderer', () => { | ||
let list; | ||
|
||
beforeEach(() => { | ||
list = fixtureSync(`<vaadin-virtual-list></vaadin-virtual-list>`); | ||
|
||
const size = 100; | ||
|
||
list.items = new Array(size).fill().map((e, i) => { | ||
return { value: `value-${i}` }; | ||
}); | ||
|
||
list.renderer = (root, _, { index }) => { | ||
render(html`value-${index}`, root); | ||
}; | ||
}); | ||
|
||
it('should render the content', () => { | ||
expect(list.children[0].textContent.trim()).to.equal('value-0'); | ||
}); | ||
|
||
it('should render new content after assigning a new renderer', () => { | ||
list.renderer = (root, _, { index }) => { | ||
render(html`new-${index}`, root); | ||
}; | ||
|
||
expect(list.children[0].textContent.trim()).to.equal('new-0'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters