fix(core): update
This commit is contained in:
@ -8,15 +8,19 @@ export class ElementInstrumenter {
|
||||
const originalConnectedCallback = elementArg.connectedCallback;
|
||||
const originalDisconnectedCallback = elementArg.disconnectedCallback;
|
||||
|
||||
elementArg.connectedCallback = () => {
|
||||
if (!elementArg.parentElement) {
|
||||
elementArg.connectedCallback = () => {
|
||||
this.connectedElements.add(elementArg);
|
||||
originalConnectedCallback.apply(elementArg);
|
||||
};
|
||||
} else {
|
||||
this.connectedElements.add(elementArg);
|
||||
originalConnectedCallback.apply(elementArg);
|
||||
};
|
||||
}
|
||||
|
||||
elementArg.disconnectedCallback = () => {
|
||||
this.connectedElements.remove(elementArg);
|
||||
originalDisconnectedCallback.apply(elementArg);
|
||||
};
|
||||
this.connectedElements.add(elementArg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,28 +1,35 @@
|
||||
import { LitElement } from 'lit-element';
|
||||
import { DomTools } from './domtools.classes.domtools';
|
||||
import * as plugins from './domtools.plugins';
|
||||
|
||||
export class ThemeManager {
|
||||
public domtoolsRef: DomTools;
|
||||
|
||||
goBrightBoolean = false;
|
||||
|
||||
constructor(domtoolsRefArg: DomTools) {
|
||||
this.domtoolsRef = domtoolsRefArg;
|
||||
this.domtoolsRef.elementInstrumenter.connectedElements.eventSubject.subscribe(async eventData => {
|
||||
await this.setThemeStatusForElement(eventData.payload, this.goBrightBoolean);
|
||||
});
|
||||
}
|
||||
|
||||
private async setThemeStatusForElement (elementArg: LitElement, goBrightBool: boolean) {
|
||||
const goBright = (elementArg as any).goBright;
|
||||
if (typeof goBright === 'boolean') {
|
||||
(elementArg as any).goBright = goBrightBool;
|
||||
}
|
||||
}
|
||||
|
||||
public goBright() {
|
||||
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
|
||||
const goBright = (elementArg as any).goBright;
|
||||
if (typeof goBright === 'boolean') {
|
||||
(elementArg as any).goBright = true;
|
||||
}
|
||||
await this.setThemeStatusForElement(elementArg, true);
|
||||
});
|
||||
}
|
||||
|
||||
public goDark() {
|
||||
this.domtoolsRef.elementInstrumenter.forEachelement(async elementArg => {
|
||||
const goBright = (elementArg as any).goBright;
|
||||
if (typeof goBright === 'boolean') {
|
||||
(elementArg as any).goBright = false;
|
||||
}
|
||||
await this.setThemeStatusForElement(elementArg, false);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user