nbhi 0.6.11 → 0.6.13
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 +12 -6
- 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)) {
|
|
@@ -73,15 +74,15 @@ export default selector => {
|
|
|
73
74
|
element.localName === 'li' ||
|
|
74
75
|
(element.hasAttribute('child') && !element.shadowRoot)) {
|
|
75
76
|
if (element.hasAttribute('data-slot') && element.dataset.slot === name) {
|
|
76
|
-
element.
|
|
77
|
+
element.innerHTML = value;
|
|
77
78
|
} else {
|
|
78
79
|
const match = element.querySelector(`[data-slot="${ name }"]`);
|
|
79
80
|
if (match) {
|
|
80
|
-
match.
|
|
81
|
+
match.innerHTML = value;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
} else if (!name && element.
|
|
84
|
-
element.
|
|
84
|
+
} else if (!name && element.innerHTML !== value) {
|
|
85
|
+
element.innerHTML = value;
|
|
85
86
|
} else {
|
|
86
87
|
let slot = element.querySelector(`[slot="${ name }"]`);
|
|
87
88
|
if (!slot) {
|
|
@@ -90,8 +91,8 @@ export default selector => {
|
|
|
90
91
|
element.append(slot);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
if (slot.
|
|
94
|
-
slot.
|
|
94
|
+
if (slot.innerHTML !== value) {
|
|
95
|
+
slot.innerHTML = value;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -154,6 +155,10 @@ export default selector => {
|
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
function getParent() {
|
|
158
|
+
if (templateParent) {
|
|
159
|
+
return templateParent;
|
|
160
|
+
}
|
|
161
|
+
|
|
157
162
|
const topLevel = getTopLevel();
|
|
158
163
|
if (topLevel.localName === 'table') {
|
|
159
164
|
return process('tbody', 'tr');
|
|
@@ -198,6 +203,7 @@ export default selector => {
|
|
|
198
203
|
console.log({ topLevel, parentName });
|
|
199
204
|
throw new Error('Cannot find parent');
|
|
200
205
|
}
|
|
206
|
+
templateParent = parent;
|
|
201
207
|
return parent;
|
|
202
208
|
}
|
|
203
209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nbhi",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.13",
|
|
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
|
+
}
|