nbhi 0.6.7 → 0.6.8

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **HTML includes and reactive rendering, all without any build tools**
4
4
 
5
- No-build HTML includes (NBHI) is a simple **3.9KB** 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 and attributes in your html pages. No build tools required, no `package.json` needed.
5
+ No-build HTML includes (NBHI) is a simple **4.3KB** 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 and attributes in your html pages. No build tools required, no `package.json` needed.
6
6
 
7
7
  # Why?
8
8
 
@@ -15,7 +15,7 @@ NBHI minimizes abstractions, just standard HTML, CSS and Javascript. Migrating f
15
15
  # Benefits
16
16
 
17
17
  - No-build web applications (you can still make it a dependency via npm install) 👍
18
- - Lightweight: **~3.9KB** (minified and bundled) 👍
18
+ - Lightweight: **~4.3KB** (minified and bundled) 👍
19
19
  - No dependencies 👍
20
20
  - Benefit from standard web component encapsulation 👍
21
21
  - Lazy load page content, when about to enter the viewport 👍
@@ -67,7 +67,7 @@ index.html
67
67
  <my-component>Overwritten text</my-component>
68
68
 
69
69
  <script type="module">
70
- import initialize from '/NBHI.js';
70
+ import initialize from '/nbhi.js';
71
71
  await initialize(); // await if external templates
72
72
  </script>
73
73
  </body>
@@ -108,7 +108,7 @@ index.html
108
108
  <my-component>Overwrite</my-component>
109
109
 
110
110
  <script type="module">
111
- import initialize from '/NBHI.js';
111
+ import initialize from '/nbhi.js';
112
112
  initialize(); // No await needed for internal templates
113
113
  </script>
114
114
  </body>
@@ -99,7 +99,11 @@ function updateAttributes({ name, value, attributeMapping, root }) {
99
99
  const { type, tagNames = [] } = attributeMapping[name] ?? [];
100
100
 
101
101
  if (type === 'userDefined') {
102
- process(root.querySelector(`[${ name }]`));
102
+ if (root.hasAttribute && root.hasAttribute(name)) {
103
+ process(root);
104
+ } else {
105
+ process(root.querySelector(`[${ name }]`));
106
+ }
103
107
  } else {
104
108
  tagNames.forEach(tagName => {
105
109
  root.querySelectorAll(tagName).forEach(process);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nbhi",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
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",