I've been playing around with using virtual-dom inside Shadow DOM and have run into an issue with dom-delegator. The problem is events in shadow DOM are retargeted to their light DOM host, and thus in findAndInvokeListeners, no listener is found because the target is the host rather than the actual node in the Shadow DOM.
I've worked around this by overriding the delegate constructor document option with the shadow root (after assigning documentElement on the root to itself):
var root = this.createShadowRoot();
root.documentElement = root;
var del = Delegator({document: root});
However, if I understand correctly, it seems the delegator is meant to be a global singleton. What I'm doing seems a bit hacky and I was wondering if there might be a better way to get dom-delegator to play nicely with Shadow DOM or if this is a crazy idea in the first place.
I've been playing around with using virtual-dom inside Shadow DOM and have run into an issue with dom-delegator. The problem is events in shadow DOM are retargeted to their light DOM host, and thus in
findAndInvokeListeners
, no listener is found because the target is the host rather than the actual node in the Shadow DOM.I've worked around this by overriding the delegate constructor document option with the shadow root (after assigning
documentElement
on the root to itself):However, if I understand correctly, it seems the delegator is meant to be a global singleton. What I'm doing seems a bit hacky and I was wondering if there might be a better way to get dom-delegator to play nicely with Shadow DOM or if this is a crazy idea in the first place.