@blockquote-web-components/blockquote-base-style-helpers 1.0.2 → 1.0.4
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/index.js +1 -1
- package/package.json +2 -2
- package/src/setDocumentStyles.js +14 -10
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockquote-web-components/blockquote-base-style-helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Webcomponent blockquote-base-style-helpers following open-wc recommendations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit",
|
|
@@ -136,5 +136,5 @@
|
|
|
136
136
|
"access": "public"
|
|
137
137
|
},
|
|
138
138
|
"customElements": "custom-elements.json",
|
|
139
|
-
"gitHead": "
|
|
139
|
+
"gitHead": "06f7e7928e79f9bb965a22f38bb6b74cfa0337a2"
|
|
140
140
|
}
|
package/src/setDocumentStyles.js
CHANGED
|
@@ -2,24 +2,28 @@ import { supportsAdoptingStyleSheets /* adoptStyles */ } from 'lit';
|
|
|
2
2
|
import '@blockquote/polymer/lib/elements/custom-style.js';
|
|
3
3
|
|
|
4
4
|
export { supportsAdoptingStyleSheets /* adoptStyles */ } from 'lit';
|
|
5
|
+
|
|
5
6
|
export const supportCustomStyleInterface =
|
|
6
|
-
|
|
7
|
+
/* c8 ignore next */
|
|
8
|
+
window.ShadyCSS && window.ShadyCSS.CustomStyleInterface && !window.ShadyCSS.nativeShadow;
|
|
7
9
|
|
|
8
|
-
const renderDocumentRoot =
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const renderDocumentRoot =
|
|
11
|
+
/* c8 ignore next */
|
|
12
|
+
supportsAdoptingStyleSheets ? document : document.head;
|
|
11
13
|
|
|
12
|
-
export const
|
|
14
|
+
export const adoptStyles = (renderRoot, styles) => {
|
|
13
15
|
if (supportsAdoptingStyleSheets) {
|
|
16
|
+
// https://github.com/lit/lit/pull/3061
|
|
14
17
|
// eslint-disable-next-line no-param-reassign
|
|
15
|
-
renderRoot.adoptedStyleSheets =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
renderRoot.adoptedStyleSheets = [
|
|
19
|
+
...renderRoot.adoptedStyleSheets,
|
|
20
|
+
...styles.map(s => (s instanceof CSSStyleSheet ? s : s.styleSheet)),
|
|
21
|
+
];
|
|
18
22
|
} else {
|
|
19
23
|
styles.forEach(s => {
|
|
20
24
|
const style = document.createElement('style');
|
|
21
25
|
// eslint-disable-next-line dot-notation
|
|
22
|
-
const nonce = window['litNonce'];
|
|
26
|
+
const nonce = window['litNonce'];
|
|
23
27
|
if (nonce !== undefined) {
|
|
24
28
|
style.setAttribute('nonce', nonce);
|
|
25
29
|
}
|
|
@@ -41,5 +45,5 @@ const documentCustomStyle = s => {
|
|
|
41
45
|
export const setDocumentStyles = styles => {
|
|
42
46
|
supportCustomStyleInterface
|
|
43
47
|
? documentCustomStyle(styles)
|
|
44
|
-
:
|
|
48
|
+
: adoptStyles(renderDocumentRoot, [styles]);
|
|
45
49
|
};
|