@vaadin/vaadin-virtual-list
Advanced tools
Comparing version 21.0.0-beta2 to 21.0.0-rc1
{ | ||
"name": "@vaadin/vaadin-virtual-list", | ||
"version": "21.0.0-beta2", | ||
"version": "21.0.0-rc1", | ||
"description": "Web Component for displaying a virtual/infinite list or items.", | ||
@@ -29,6 +29,6 @@ "main": "vaadin-virtual-list.js", | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/vaadin-element-mixin": "^21.0.0-beta2", | ||
"@vaadin/vaadin-lumo-styles": "^21.0.0-beta2", | ||
"@vaadin/vaadin-material-styles": "^21.0.0-beta2", | ||
"@vaadin/vaadin-themable-mixin": "^21.0.0-beta2" | ||
"@vaadin/vaadin-element-mixin": "^21.0.0-rc1", | ||
"@vaadin/vaadin-lumo-styles": "^21.0.0-rc1", | ||
"@vaadin/vaadin-material-styles": "^21.0.0-rc1", | ||
"@vaadin/vaadin-themable-mixin": "^21.0.0-rc1" | ||
}, | ||
@@ -38,2 +38,3 @@ "devDependencies": { | ||
"@vaadin/testing-helpers": "^0.2.1", | ||
"lit": "^2.0.0-rc.1", | ||
"sinon": "^9.2.4" | ||
@@ -44,3 +45,3 @@ }, | ||
}, | ||
"gitHead": "85ac717fc9f16941a1593a44d1aec90735a5db54" | ||
"gitHead": "50d1c1ce987f97069674ea2e2002eade479bbf09" | ||
} |
@@ -10,2 +10,3 @@ # <vaadin-virtual-list> | ||
[![npm version](https://badgen.net/npm/v/@vaadin/vaadin-virtual-list)](https://www.npmjs.com/package/@vaadin/vaadin-virtual-list) | ||
[![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC) | ||
@@ -18,5 +19,5 @@ ```html | ||
list.items = items; // An array of data items | ||
list.renderer = (root, list, {item, index}) => { | ||
root.textContent = `#${index}: ${item.name}` | ||
} | ||
list.renderer = (root, list, { item, index }) => { | ||
root.textContent = `#${index}: ${item.name}`; | ||
}; | ||
</script> | ||
@@ -61,12 +62,6 @@ ``` | ||
## Big Thanks | ||
Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com). | ||
## Contributing | ||
To contribute to the component, please read [the guideline](https://github.com/vaadin/vaadin-core/blob/master/CONTRIBUTING.md) first. | ||
Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components. | ||
## License | ||
@@ -73,0 +68,0 @@ |
@@ -65,3 +65,3 @@ /** | ||
static get version() { | ||
return '21.0.0-beta2'; | ||
return '21.0.0-rc1'; | ||
} | ||
@@ -131,2 +131,7 @@ | ||
__updateElement(el, index) { | ||
if (el.__renderer !== this.renderer) { | ||
el.__renderer = this.renderer; | ||
this.__clearRenderTargetContent(el); | ||
} | ||
if (this.renderer) { | ||
@@ -137,5 +142,22 @@ this.renderer(el, this, { item: this.items[index], index }); | ||
/** | ||
* Clears the content of a render target. | ||
* @private | ||
*/ | ||
__clearRenderTargetContent(element) { | ||
element.innerHTML = ''; | ||
// Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into. | ||
// When clearing the rendered content, this part needs to be manually disposed of. | ||
// Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward. | ||
delete element._$litPart$; | ||
} | ||
/** @private */ | ||
__itemsOrRendererChanged(items = [], renderer, virtualizer) { | ||
if (renderer && virtualizer) { | ||
// If the renderer is removed but there are elements created by | ||
// a previous renderer, we need to request an update from the virtualizer | ||
// to get the already existing elements properly cleared. | ||
const hasRenderedItems = this.childElementCount > 0; | ||
if ((renderer || hasRenderedItems) && virtualizer) { | ||
if (items.length === virtualizer.size) { | ||
@@ -142,0 +164,0 @@ virtualizer.update(); |
81047
1951
4
69