-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ShadowDOM Support #115
Comments
Wow, thanks for this, would be very cool to support ShadowDOM 🤘 Haven't used ShadowDOM yet so unfortunately can only offer moral support. |
Thanks for working on ShadowDOM support! I'm currently rather of no help because of less free time for OSS and no detailed ShadowDOM knowledge either. What I can offer though is a discussion about an API to make it easy to hook into those parts that need customization.
|
That API seems like it will cover the bases, so that's definitely a good start. I've stuck on how to implement I investigated trying to fire an event at an x,y coordinate and then use the same I'll keep trying to think of tricks, but it may be better to just wait until ShadowDOM support is more widespread (which hopefully won't be too much longer). |
API additions released as of v2.3.0-rc.0 Let me know if the API's provided need tweaking. |
thanks @reppners we'll check! |
I've shadow dom support workin on my system. This is my workin Code:
|
this works for me on my site on safari on ios |
@z2oh can you check this out? lets bump this to the top of our (internal) priority list |
@jogibear9988 Nice! Looks very elegant. Please let me know if any utility functions may make sense for the polyfill to export so they can be reused in those custom implementations. The body of I'm trying to wrap my head around why you're transporting the |
at first I tried to use hand over the lastEvent to the elementFromPoint, but when I call composedPath() there, I get an empty array! seems I could only call it in the function with was raised from the event. |
i've tested yesterday only on a iPad (where it worked). today I tested a galaxy tab and iPhone, both do not work. I will look whats different here |
I've to correct myself. iPhone & galaxy tab work. I tested an old version |
@jogibear9988 Thanks for the explanation! The issue with your particular implementation is that If the whole application consists of custom elements it will work because But if only a few components are custom elements eventually not sharing a common root element than looping only through the elements that are part of Would this naive implementation for let el = document.elementFromPoint(x, y);
if (el) {
// walk down custom component shadowRoots'
while (el.shadowRoot) {
let customEl = el.shadowRoot.elementFromPoint(x, y);
// I'm a ShadowDom noob, can the element returned ever be the custom element itself?
if(customEl === null || customEl === el) {
break;
}
el = customEl;
}
return el;
} |
Custom-element support should be a first class citizen of this polyfill but until browser support is solid and the implementation is battle-tested it makes sense to provide the needed custom implementations in a separate module similar as to how the That being said I'm happy to accept PRs adding such a module to maintain and iterate on the implementation for custom-element support. Once browser support/the implementation has matured and is proven solid it can be added to the polyfill's default implementation. |
@reppners I can only say, my code works in my application (with uses webcomponents everywhere!) should I test your code, or what should I do? |
If it's no trouble for you to test it - I'd be happy to know if it works this way, too. Ultimately this repo needs a demo page that makes use of web components but I'm too short in time to work on this atm. |
@reppners seems to work... |
would you include this? |
@reppners any news to this? |
@timruffles could you merge this? |
I'm facing the same issue when using web components. @timruffles Would love to see this feature merged 😎 |
I used a little bit updates version of my polyfill in my project:
it works here: what does not work is drag drop from jquery-fancytree, see issue here: |
@timruffles can this fix be merged? |
Sorry I haven't been actively doing much frontend these days. I've not worked with the ShadowDOM APIs, for instance. If someone makes a PR that everyone here is happy with I'd be happy to merge it. |
@timruffles i've tested @jogibear9988 's PR and it fixed the issue for me |
@jogibear9988 @danziv @timruffles Took care of merging the PR and cutting a release as |
thanks @reppners! |
I have started working on adding ShadowDOM support to this shim (which we are using for our Polymer 2 application).
At first, nothing was working at all. ShadowDOM introduces event retargeting, so events that fire up through Shadow Roots have their target changed to be the parent of the highest shadow root. This introduces a problem for the
tryFindDraggableTarget
function:https://github.com/timruffles/ios-html5-drag-drop-shim/blob/0f2c6426d2618fadd1e9dfa4816fa0384b0291a0/src/index.ts#L188-L213
as
event.target
no longer refers to the actual target of the event. I rewrote this method (in JS) as follows:Success! I can now start drag operations successfully. Next up is dropping, which has proved to be more difficult. The code responsible for finding the drop target is here:
https://github.com/timruffles/ios-html5-drag-drop-shim/blob/0f2c6426d2618fadd1e9dfa4816fa0384b0291a0/src/index.ts#L722
document.elementFromPoint
suffers a similar problem as before and returns only the highest shadow root rather than the actual element at the location. I found some documentation for DocumentOrShadowRoot.elementFromPoint(), but support forDocumentOrShadowRoot
seems limited at best. This is where I got stuck. Does anyone have any ideas on how to move forward from here?The text was updated successfully, but these errors were encountered: