@lwrjs/client-modules 0.10.0-alpha.14 → 0.10.0-alpha.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.
@@ -0,0 +1,22 @@
1
+ // Polyfill the Declarative ShadowDOM spec - call this function AFTER the DOM has been parsed and BEFORE hydrateComponent() is invoked
2
+ // See https://github.com/salesforce/lwc-rfcs/blob/master/text/0129-declarative-shadow-dom-polyfill.md#single-loop-script-shadow-root-attachment-reference
3
+
4
+ function applyShadowRoots(node) {
5
+ // if this browser DOES NOT support Declarative ShadowDOM
6
+ node.querySelectorAll('template[shadowroot]').forEach(template => {
7
+ const mode = template.getAttribute('shadowroot') || 'open';
8
+ const shadowRoot = template.parentNode?.attachShadow({
9
+ mode
10
+ });
11
+ shadowRoot.appendChild(template.content);
12
+ template.remove();
13
+ applyShadowRoots(shadowRoot);
14
+ });
15
+ }
16
+ export function polyfillDeclarativeShadowDom(node = document) {
17
+ // eslint-disable-next-line no-prototype-builtins
18
+ if (!HTMLTemplateElement.prototype.hasOwnProperty('shadowRoot')) {
19
+ // if this browser DOES NOT support Declarative ShadowDOM
20
+ applyShadowRoots(node);
21
+ }
22
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.10.0-alpha.14",
7
+ "version": "0.10.0-alpha.16",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@locker/sandbox": "0.19.5",
37
- "@lwrjs/shared-utils": "0.10.0-alpha.14"
37
+ "@lwrjs/shared-utils": "0.10.0-alpha.16"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.10.0-alpha.14",
40
+ "@lwrjs/types": "0.10.0-alpha.16",
41
41
  "@rollup/plugin-node-resolve": "^15.0.2",
42
42
  "@rollup/plugin-sucrase": "^5.0.1",
43
43
  "@rollup/plugin-terser": "^0.4.3",
@@ -52,6 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "expose": [
55
+ "lwr/declarativeShadow",
55
56
  "lwr/environment",
56
57
  "lwr/hmr",
57
58
  "lwr/preInit",
@@ -69,5 +70,5 @@
69
70
  "volta": {
70
71
  "extends": "../../../package.json"
71
72
  },
72
- "gitHead": "f80dc1c18719b77c183f339027313be11d69f9dc"
73
+ "gitHead": "c5a13d471330c0f738d0c783fd1b69f456c544bd"
73
74
  }