Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created November 15, 2020 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/12dd835dd168013c956bef8e98c12f5b to your computer and use it in GitHub Desktop.
Save YonatanKra/12dd835dd168013c956bef8e98c12f5b to your computer and use it in GitHub Desktop.
list performance test
suite('performance issue', () => {
test(
'removing a list should not call layout more than once', async () => {
let count = 0;
const originalLayout = List.prototype.layout;
List.prototype.layout = function(update) {
originalLayout.call(this, update);
count++;
};
const itemsTemplates = new Array(100).fill(0).map(() => listItem());
fixt = await fixture(listTemplate({items: itemsTemplates}));
element = fixt.root.querySelector('mwc-list')!;
count = 0;
fixt.remove();
await element.updateComplete;
fixt = null;
assert.equal(
count,
1,
'list.layout ran more than once while it shouldn\'t have');
List.prototype.layout = originalLayout;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment