Closed philkunz closed 3 years ago
Either it's a race condition (you are instrumenting, after CustomElements have been defined and added) or it is an issue with prototypes. You are not showing the rest of your code (how and when do you instrument). At first glance, if you do instrumentation like that, I am betting, you are overwriting instance methods where you should override prototype methods.
An easier way would be class-based expression mixins (aka High Order Components) and I think this is the preferred way in LitElement itself for composition; they have a lot of advantages (working instanceof
...); you'd collect the connected instances either in a closure or in a global.
I solved it by writing an extension class for lit-element that would use connectedCallback und disconnectedCallback to emit events for connected and disconnected. This will then allow the instrumented to subscribe to those events and unsubscribe upon dom disconnection.
I have the above class. However hooking into the callbacks that way does not work. Any obvious reason why?