nbhi 0.6.14 → 0.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/javascript/update.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -272,6 +272,8 @@ index.html
|
|
|
272
272
|
|
|
273
273
|
Same logic for `<ol>`, `<ul>` and `<option>`
|
|
274
274
|
|
|
275
|
+
When a record has an `id` (string or number), its rendered element is reused for the next record with the same `id`, even when that is a new object (for example after reloading the data). The element stays in the DOM and is updated in place. Records without an `id` are matched by object identity.
|
|
276
|
+
|
|
275
277
|
## Lazy loading
|
|
276
278
|
|
|
277
279
|
```js
|
package/javascript/update.js
CHANGED
|
@@ -141,6 +141,10 @@ export default selector => {
|
|
|
141
141
|
|
|
142
142
|
function getId(record, index) {
|
|
143
143
|
if (record && typeof record === 'object') {
|
|
144
|
+
const recordId = record.id;
|
|
145
|
+
if (['string', 'number'].includes(typeof recordId) && !newChildren.has(`id:${ recordId }`)) {
|
|
146
|
+
return `id:${ recordId }`;
|
|
147
|
+
}
|
|
144
148
|
if (!idCache.has(record)) {
|
|
145
149
|
idCache.set(record, idCount++);
|
|
146
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nbhi",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"description": "No-Build HTML Includes (NBHI) is a simple library that allows you to include html files into other html files and turns them into [web components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components). Lazy initialization of content (when entering the viewport) and a one line call to update/hydrate content in your html pages. No build tools required, no `package.json` needed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|