@vaadin/vaadin-themable-mixin 25.0.0-alpha16 → 25.0.0-alpha17
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 +6 -5
- package/src/lumo-modules.js +31 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/vaadin-themable-mixin",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha17",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
|
+
"@vaadin/component-base": "25.0.0-alpha17",
|
|
36
37
|
"lit": "^3.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
41
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
41
|
+
"@vaadin/chai-plugins": "25.0.0-alpha17",
|
|
42
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha17",
|
|
42
43
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
43
|
-
"sinon": "^
|
|
44
|
+
"sinon": "^21.0.0"
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "8264c71309907be99368b09414f0f8d7f591e0b9"
|
|
46
47
|
}
|
package/src/lumo-modules.js
CHANGED
|
@@ -3,9 +3,33 @@
|
|
|
3
3
|
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { issueWarning } from '@vaadin/component-base/src/warnings.js';
|
|
7
|
+
|
|
6
8
|
/** @type {WeakMap<CSSStyleSheet, Record<string, Map>>} */
|
|
7
9
|
const cache = new WeakMap();
|
|
8
10
|
|
|
11
|
+
function getRuleMediaText(rule) {
|
|
12
|
+
try {
|
|
13
|
+
return rule.media.mediaText;
|
|
14
|
+
} catch {
|
|
15
|
+
issueWarning(
|
|
16
|
+
'[LumoInjector] Browser denied to access property "mediaText" for some CSS rules, so they were skipped.',
|
|
17
|
+
);
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getStyleSheetRules(styleSheet) {
|
|
23
|
+
try {
|
|
24
|
+
return styleSheet.cssRules;
|
|
25
|
+
} catch {
|
|
26
|
+
issueWarning(
|
|
27
|
+
'[LumoInjector] Browser denied to access property "cssRules" for some CSS stylesheets, so they were skipped.',
|
|
28
|
+
);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
9
33
|
function parseStyleSheet(
|
|
10
34
|
styleSheet,
|
|
11
35
|
result = {
|
|
@@ -13,20 +37,11 @@ function parseStyleSheet(
|
|
|
13
37
|
modules: new Map(),
|
|
14
38
|
},
|
|
15
39
|
) {
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
cssRules = styleSheet.cssRules;
|
|
19
|
-
} catch {
|
|
20
|
-
// External stylesheets may not be accessible due to CORS security restrictions.
|
|
21
|
-
cssRules = [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for (const rule of cssRules) {
|
|
25
|
-
const { media } = rule;
|
|
26
|
-
|
|
40
|
+
for (const rule of getStyleSheetRules(styleSheet)) {
|
|
27
41
|
if (rule instanceof CSSImportRule) {
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
const mediaText = getRuleMediaText(rule);
|
|
43
|
+
if (mediaText.startsWith('lumo_')) {
|
|
44
|
+
result.modules.set(mediaText, [...rule.styleSheet.cssRules]);
|
|
30
45
|
} else {
|
|
31
46
|
parseStyleSheet(rule.styleSheet, result);
|
|
32
47
|
}
|
|
@@ -35,8 +50,9 @@ function parseStyleSheet(
|
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
if (rule instanceof CSSMediaRule) {
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
const mediaText = getRuleMediaText(rule);
|
|
54
|
+
if (mediaText.startsWith('lumo_')) {
|
|
55
|
+
result.modules.set(mediaText, [...rule.cssRules]);
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
continue;
|