Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/core/middleware/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import icache from './icache';
import injector from './injector';
import Injector from '../Injector';
import Set from '../../shim/Set';
import { shallow } from '../diff';
import { shallow, auto } from '../diff';
import Registry from '../Registry';

export { Theme, Classes, ClassNames } from './../interfaces';
Expand Down Expand Up @@ -32,11 +32,17 @@ const factory = create({ invalidator, icache, diffProperty, injector, getRegistr
export const theme = factory(
({ middleware: { invalidator, icache, diffProperty, injector, getRegistry }, properties }) => {
let themeKeys = new Set();
diffProperty('theme', (current: ThemeProperties, next: ThemeProperties) => {
if (current.theme !== next.theme) {

diffProperty('theme', properties, (current, next) => {
const themeInjector = injector.get<Injector<Theme | undefined>>(INJECTED_THEME_KEY);
const diffResult = auto(current.theme, next.theme);
if (diffResult.changed) {
icache.clear();
invalidator();
}
if (!next.theme && themeInjector) {
return themeInjector.get();
}
});
diffProperty('classes', (current: ThemeProperties, next: ThemeProperties) => {
let result = false;
Expand Down Expand Up @@ -79,10 +85,6 @@ export const theme = factory(
themeKeys.add(key);
theme = classes as T;
let { theme: currentTheme, classes: currentClasses } = properties();
if (!currentTheme) {
const injectedTheme = injector.get<Injector<Theme>>(INJECTED_THEME_KEY);
currentTheme = injectedTheme ? injectedTheme.get() : undefined;
}
if (currentTheme && currentTheme[key]) {
theme = { ...theme, ...currentTheme[key] };
}
Expand Down
258 changes: 0 additions & 258 deletions tests/core/unit/middleware/theme.ts

This file was deleted.

Loading