nbhi 0.6.12 → 0.6.14
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/javascript/update.js +6 -5
- package/package.json +2 -2
package/javascript/update.js
CHANGED
|
@@ -8,6 +8,7 @@ export default selector => {
|
|
|
8
8
|
let renderedChildren = new Map();
|
|
9
9
|
let idCount = 1;
|
|
10
10
|
let templateChild;
|
|
11
|
+
let templateParent;
|
|
11
12
|
|
|
12
13
|
return data => {
|
|
13
14
|
if (isDate(data)) {
|
|
@@ -98,11 +99,6 @@ export default selector => {
|
|
|
98
99
|
|
|
99
100
|
function updateList(records) {
|
|
100
101
|
const parent = getParent();
|
|
101
|
-
|
|
102
|
-
if (!templateChild) {
|
|
103
|
-
throw new Error(`Cannot update ${ selector }, cannot find child element`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
102
|
const newChildren = new Map();
|
|
107
103
|
|
|
108
104
|
records.forEach((record, index) => {
|
|
@@ -154,6 +150,9 @@ export default selector => {
|
|
|
154
150
|
};
|
|
155
151
|
|
|
156
152
|
function getParent() {
|
|
153
|
+
if (templateParent) {
|
|
154
|
+
return templateParent;
|
|
155
|
+
}
|
|
157
156
|
const topLevel = getTopLevel();
|
|
158
157
|
if (topLevel.localName === 'table') {
|
|
159
158
|
return process('tbody', 'tr');
|
|
@@ -165,6 +164,7 @@ export default selector => {
|
|
|
165
164
|
return process('select', 'option');
|
|
166
165
|
} else if (topLevel.querySelector('[child]')) {
|
|
167
166
|
const parent = getParent(topLevel.querySelector('[child]')).parentElement;
|
|
167
|
+
templateParent = parent;
|
|
168
168
|
setTemplateChild('[child]', parent);
|
|
169
169
|
if (parent.localName === 'slot' && parent.hasAttribute('name')) {
|
|
170
170
|
templateChild.slot = parent.getAttribute('name');
|
|
@@ -178,6 +178,7 @@ export default selector => {
|
|
|
178
178
|
function process(parentName, childName) {
|
|
179
179
|
const parent = getParent(parentName);
|
|
180
180
|
setTemplateChild(childName, parent);
|
|
181
|
+
templateParent = parent;
|
|
181
182
|
return parent;
|
|
182
183
|
}
|
|
183
184
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nbhi",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
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",
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|