Skip to content

Commit 2c05f4f

Browse files
authored
refactor: remove no longer used logic from ThemableMixin (#10011)
1 parent 1ad9843 commit 2c05f4f

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

packages/vaadin-themable-mixin/vaadin-themable-mixin.d.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import type { Constructor } from '@open-wc/dedupe-mixin';
77
import type { CSSResult, CSSResultGroup } from 'lit';
88
import type { ThemePropertyMixinClass } from './vaadin-theme-property-mixin.js';
99

10-
/**
11-
* A mixin for `nav` elements, facilitating navigation and selection of childNodes.
12-
*/
1310
export declare function ThemableMixin<T extends Constructor<HTMLElement>>(
1411
base: T,
1512
): Constructor<ThemableMixinClass> & Constructor<ThemePropertyMixinClass> & T;
@@ -29,18 +26,6 @@ export declare interface ThemableMixinClass extends ThemePropertyMixinClass {}
2926
*/
3027
declare function registerStyles(themeFor: string | null, styles: CSSResultGroup, options?: object | null): void;
3128

32-
type Theme = {
33-
themeFor: string;
34-
styles: CSSResult[];
35-
moduleId?: string;
36-
include?: string[] | string;
37-
};
38-
39-
/**
40-
* For internal purposes only.
41-
*/
42-
declare const __themeRegistry: Theme[];
43-
4429
export { css, unsafeCSS } from 'lit';
4530

46-
export { registerStyles, __themeRegistry };
31+
export { registerStyles };

packages/vaadin-themable-mixin/vaadin-themable-mixin.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,6 @@ export function registerStyles(themeFor, styles, options = {}) {
234234
}
235235
}
236236

237-
/**
238-
* Returns all registered themes. By default the themeRegistry is returned as is.
239-
* In case the style-modules adapter is imported, the themes are obtained from there instead
240-
* @returns {Theme[]}
241-
*/
242-
function getAllThemes() {
243-
if (window.Vaadin && window.Vaadin.styleModules) {
244-
return window.Vaadin.styleModules.getAllThemes();
245-
}
246-
return themeRegistry;
247-
}
248-
249237
/**
250238
* Maps the moduleName to an include priority number which is used for
251239
* determining the order in which styles are applied.
@@ -271,7 +259,7 @@ function getIncludedStyles(theme) {
271259
const includedStyles = [];
272260
if (theme.include) {
273261
[].concat(theme.include).forEach((includeModuleId) => {
274-
const includedTheme = getAllThemes().find((s) => s.moduleId === includeModuleId);
262+
const includedTheme = themeRegistry.find((s) => s.moduleId === includeModuleId);
275263
if (includedTheme) {
276264
includedStyles.push(...getIncludedStyles(includedTheme), ...includedTheme.styles);
277265
} else {
@@ -291,7 +279,7 @@ function getIncludedStyles(theme) {
291279
function getThemes(tagName) {
292280
const defaultModuleName = `${tagName}-default-theme`;
293281

294-
const themes = getAllThemes()
282+
const themes = themeRegistry
295283
// Filter by matching themeFor properties
296284
.filter((theme) => theme.moduleId !== defaultModuleName && matchesThemeFor(theme.themeFor, tagName))
297285
.map((theme) => ({
@@ -308,7 +296,7 @@ function getThemes(tagName) {
308296
return themes;
309297
}
310298
// No theme modules found, return the default module if it exists
311-
return getAllThemes().filter((theme) => theme.moduleId === defaultModuleName);
299+
return themeRegistry.filter((theme) => theme.moduleId === defaultModuleName);
312300
}
313301

314302
/**
@@ -380,5 +368,3 @@ export const ThemableMixin = (superClass) =>
380368
return themeStyles.filter((style, index) => index === themeStyles.lastIndexOf(style));
381369
}
382370
};
383-
384-
export { themeRegistry as __themeRegistry };

0 commit comments

Comments
 (0)