@ornery/web-components 4.0.0 → 4.0.1
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/package.json +1 -1
- package/src/setup-connect.js +24 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornery/web-components",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "WebComponents html loader and optional runtime mixins to enable creation of custom HTML elements using es6 template literal syntax in *.html files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/src/setup-connect.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
export default function setupConnect(nodeList, context) {
|
|
2
2
|
nodeList.connect = function (root) {
|
|
3
|
-
if (typeof HTMLElement
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
if (typeof HTMLElement === "undefined") {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (root) {
|
|
8
|
+
// Explicit root provided — clear and append nodes.
|
|
9
|
+
root.innerHTML = "";
|
|
10
|
+
nodeList.forEach((node) => root.appendChild(node));
|
|
11
|
+
return root;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// No root provided — derive from context.
|
|
15
|
+
if (context instanceof HTMLElement) {
|
|
16
|
+
if (
|
|
17
|
+
context.shadowRoot &&
|
|
18
|
+
context.shadowRoot.mode === "open"
|
|
19
|
+
) {
|
|
20
|
+
root = context.shadowRoot;
|
|
21
|
+
} else {
|
|
22
|
+
root = document.createElement("div");
|
|
18
23
|
}
|
|
24
|
+
root.innerHTML = "";
|
|
25
|
+
nodeList.forEach((node) => root.appendChild(node));
|
|
26
|
+
return root;
|
|
19
27
|
}
|
|
20
28
|
};
|
|
21
29
|
return nodeList;
|
|
22
|
-
}
|
|
30
|
+
}
|