fix(core): update
This commit is contained in:
parent
64a3f57813
commit
e077bf5b25
@ -5,23 +5,20 @@ export class ElementInstrumenter {
|
||||
connectedElements = new plugins.lik.ObjectMap<LitElement>();
|
||||
|
||||
public instrumentElement(elementArg: LitElement) {
|
||||
const originalConnectedCallback = elementArg.connectedCallback;
|
||||
const originalDisconnectedCallback = elementArg.disconnectedCallback;
|
||||
const addToConnectedElementsFunc = (eventArg: CustomEvent) => {
|
||||
this.connectedElements.add(elementArg);
|
||||
};
|
||||
const removeFromConnectedElementsFunc = eventArg => {
|
||||
this.connectedElements.remove(elementArg);
|
||||
elementArg.removeEventListener('domtools-connected', addToConnectedElementsFunc);
|
||||
elementArg.removeEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
|
||||
};
|
||||
elementArg.addEventListener('domtools-connected', addToConnectedElementsFunc);
|
||||
elementArg.addEventListener('domtools-disconnected', removeFromConnectedElementsFunc);
|
||||
|
||||
if (!elementArg.parentElement) {
|
||||
elementArg.connectedCallback = () => {
|
||||
this.connectedElements.add(elementArg);
|
||||
originalConnectedCallback.apply(elementArg);
|
||||
};
|
||||
} else {
|
||||
this.connectedElements.add(elementArg);
|
||||
}
|
||||
|
||||
elementArg.disconnectedCallback = () => {
|
||||
this.connectedElements.remove(elementArg);
|
||||
originalDisconnectedCallback.apply(elementArg);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public async forEachelement(eachFuncArg: (elementArg: LitElement) => Promise<void>) {
|
||||
|
Loading…
Reference in New Issue
Block a user