@lwrjs/client-modules 0.11.11 → 0.11.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.
@@ -1,22 +1,28 @@
1
1
  // Polyfill the Declarative ShadowDOM spec - call this function AFTER the DOM has been parsed and BEFORE hydrateComponent() is invoked
2
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) {
3
+ // Note we handle both the old (Chrome-only) `shadowroot` attribute as well as the standard `shadowrootmode` attribute.
4
+ // As of this writing, Chrome supports both formats but Safari only supports the standard format.
5
+ function applyShadowRoots(node, attributeName) {
5
6
  // if this browser DOES NOT support Declarative ShadowDOM
6
- node.querySelectorAll('template[shadowroot]').forEach(template => {
7
- const mode = template.getAttribute('shadowroot') || 'open';
7
+ node.querySelectorAll(`template[${attributeName}]`).forEach(template => {
8
+ const mode = template.getAttribute(attributeName) || 'open';
8
9
  const shadowRoot = template.parentNode?.attachShadow({
9
10
  mode
10
11
  });
11
12
  shadowRoot.appendChild(template.content);
12
13
  template.remove();
13
- applyShadowRoots(shadowRoot);
14
+ applyShadowRoots(shadowRoot, attributeName);
14
15
  });
15
16
  }
16
17
  export function polyfillDeclarativeShadowDom(node = document) {
18
+ // eslint-disable-next-line no-prototype-builtins
19
+ if (!HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode')) {
20
+ // this browser does not support the standard format
21
+ applyShadowRoots(node, 'shadowrootmode');
22
+ }
17
23
  // eslint-disable-next-line no-prototype-builtins
18
24
  if (!HTMLTemplateElement.prototype.hasOwnProperty('shadowRoot')) {
19
- // if this browser DOES NOT support Declarative ShadowDOM
20
- applyShadowRoots(node);
25
+ // this browser does not support the non-standard format
26
+ applyShadowRoots(node, 'shadowroot');
21
27
  }
22
28
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.11.11",
7
+ "version": "0.11.13",
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.20.6",
37
- "@lwrjs/shared-utils": "0.11.11"
37
+ "@lwrjs/shared-utils": "0.11.13"
38
38
  },
39
39
  "devDependencies": {
40
- "@lwrjs/types": "0.11.11",
40
+ "@lwrjs/types": "0.11.13",
41
41
  "@rollup/plugin-node-resolve": "^15.2.3",
42
42
  "@rollup/plugin-sucrase": "^5.0.2",
43
43
  "@rollup/plugin-terser": "^0.4.4",
@@ -69,5 +69,5 @@
69
69
  "volta": {
70
70
  "extends": "../../../package.json"
71
71
  },
72
- "gitHead": "ebb34457d870c12a891f519145f4c2f08ad29f88"
72
+ "gitHead": "e91de40d8db1aa100c06a3075cfc4cde950dac5d"
73
73
  }