Raynos / dom-delegator

Decorate elements with delegated events
MIT License
58 stars 16 forks source link

Shadow DOM event retargeting #21

Open rtsao opened 9 years ago

rtsao commented 9 years ago

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.

Raynos commented 9 years ago

I don't understand enough about shadow Dom. It sounds like it does isolation and might not be compatible.

Alternatively we can just support it

lixiaoyan commented 9 years ago

+1 for shadow dom support.