skatejs / cloudydom

ShadowDOM v1 shim
12 stars 2 forks source link

Missing DocumentOrShadowRoot interface implementation #5

Open bedeoverend opened 7 years ago

bedeoverend commented 7 years ago

See https://github.com/webcomponents/shadydom/issues/113.

It seems only activeElement is implemented - it'd be great to have support for all methods / props in the interface. My use case is using Prosemirror which relies on the interface for managing selections. I'd be keen to have a crack at a PR, but don't have time right now.

cc/ @treshugart - looks like you guys had this exact problem with WebKit, did you ever get around it?

matthewp commented 7 years ago

I'm not too familiar with these APIs as I don't use them often. Happy to accept a PR of course!

bedeoverend commented 7 years ago

Fair enough - I'm not too familiar either, but I'll take a crack when I can. Interestingly, the first Shadow DOM polyfill looks to have just called document.getSelection() for shadowRoot.getSelection(), might be able to be applied for a few of the methods in this interface 😕

treshugart commented 7 years ago

Shadow DOM polyfill looks to have just called document.getSelection() for shadowRoot.getSelection(), might be able to be applied for a few of the methods in this interface 😕

I think that's probably fine. I know things like ShadowRoot.activeElement is filled by simply doing document.activeElement because there's no encapsulation.

bedeoverend commented 7 years ago

Yeah though I'm not sure if there'd be repercussions of returning the document selection if that selection isn't encapsulated by the shadow root

treshugart commented 7 years ago

Yeah, you'd probably have to test something like shadowRoot.contains(document.getSelection().anchorNode).