Skip to content

Commit

Permalink
feat!: upgrade to lit-virtualizer
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop polymer iron-list
BREAKING CHANGE: drop updateSize and scrollTarget
  • Loading branch information
cristinecula committed Feb 28, 2024
1 parent 8d43767 commit 0ec6148
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 188 deletions.
95 changes: 34 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@
}
},
"dependencies": {
"@lit-labs/virtualizer": "^2.0.12",
"@neovici/cosmoz-utils": "^6.0.0",
"@pionjs/pion": "^2.0.0",
"@polymer/iron-list": "github:Neovici/iron-list",
"@polymer/polymer": "^3.3.1",
"lit-html": "^2.0.0 || ^3.0.0"
},
"devDependencies": {
Expand All @@ -72,6 +71,7 @@
"@polymer/paper-dropdown-menu": "^3.1.0",
"@polymer/paper-item": "^3.0.0",
"@polymer/paper-listbox": "^3.0.0",
"@polymer/polymer": "^3.5.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.0",
"husky": "^4.3.0",
Expand Down
29 changes: 11 additions & 18 deletions test/basic.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable max-lines */
import { spy as sinonSpy } from 'sinon';
import { assert, html, fixture, nextFrame } from '@open-wc/testing';
import { setupIgnoreWindowResizeObserverLoopErrors } from '@lit-labs/virtualizer/support/resize-observer-errors.js';

import '../cosmoz-grouped-list.js';

Expand All @@ -19,6 +20,8 @@ const renderItem = (item, index, { selected, expanded }) => html`
`;

suite('empty', () => {
setupIgnoreWindowResizeObserverLoopErrors(setup, teardown);

let element;
setup(async () => {
element = await fixture(basicHtmlFixture);
Expand Down Expand Up @@ -115,6 +118,8 @@ suite('empty', () => {
});

suite('flat data', () => {
setupIgnoreWindowResizeObserverLoopErrors(setup, teardown);

let element,
items;

Expand Down Expand Up @@ -181,6 +186,8 @@ suite('flat data', () => {
});

suite('empty-groups', () => {
setupIgnoreWindowResizeObserverLoopErrors(setup, teardown);

let element;
setup(async () => {
element = await fixture(basicHtmlFixture);
Expand Down Expand Up @@ -232,6 +239,8 @@ suite('empty-groups', () => {
});

suite('basic', () => {
setupIgnoreWindowResizeObserverLoopErrors(setup, teardown);

let element,
groups;

Expand Down Expand Up @@ -519,6 +528,8 @@ suite('basic', () => {
});

suite('compare items function', () => {
setupIgnoreWindowResizeObserverLoopErrors(setup, teardown);

let element;

setup(async () => {
Expand Down Expand Up @@ -563,21 +574,3 @@ suite('compare items function', () => {
);
});
});

suite('update item size', () => {
test('updates item size with index from composed path', async () => {
const el = await fixture(html`
<cosmoz-grouped-list
style="min-height: 300px"
.data= ${ [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }] }
.renderItem=${ item => html`<div class="item" data-id=${ item.id }>id: ${ item.idex }</div>` }
></cosmoz-grouped-list>
`);

await nextFrame();

const updateSpy = sinonSpy(el.querySelector('#list'), 'updateSizeForIndex');
el.querySelector(`[data-id="${ 2 }"]`).dispatchEvent(new CustomEvent('update-item-size', { bubbles: true }));
assert.isTrue(updateSpy.calledOnceWith(2));
});
});
Loading

0 comments on commit 0ec6148

Please sign in to comment.