panzoom icon indicating copy to clipboard operation
panzoom copied to clipboard

feat: support attached shadow dom elements

Open breakthestatic opened this issue 2 years ago • 2 comments

PR Checklist

Please review the guidelines for contributing to this repository.

  • [X] I am requesting to pull a topic/feature/bugfix branch (right side). In other words, not main.
  • [X] I have run yarn test against my changes and tests pass.
  • [X] I have added tests to prove my fix is effective or my feature works. This can be done in the form of unit tests in test/unit/ or a new or altered demo in demo/.
  • [X] I have added or edited necessary types and generated documentation (yarn docs), or no docs changes are needed.

Description

Updates the isAttached helper to handle shadow dom elements. ~~If the passed element's root node is a ShadowRoot, it sets parent to the ShadowRoot's host and subsequently checks if the host is attached; otherwise it falls back to the pre-existing functionality.~~

With additional testing, I found that the prior change was not sufficient to handle multiple nested shadow dom elements. The logic has been updated to manually traverse through the dom (handling both regular & shadow nodes) to ensure that any nesting is properly accounted for.

Fixes: #536

breakthestatic avatar Apr 22 '22 20:04 breakthestatic

Hey @timmywil, I haven't really contributed to many open source projects before, so I apologize in advance if this is not the "right" way to do this - would you be able to take a look at this PR soon or provide a rough idea of when you'll be able to? I'm using the proposed fix in 2 other projects right now and would love to point to your repo instead of a local link or my fork. Let me know if there's anything else needed & thanks!

breakthestatic avatar May 09 '22 18:05 breakthestatic

Hey @timmywil, just wanted to ping again to see if you're able to review and merge or provide feedback. Thanks!

breakthestatic avatar Jun 27 '22 21:06 breakthestatic

@timmywil, can you please take a look at this and merge if acceptable (or provide guidance if you have any issues). I'd rather not permanently fork the project for this, but it's been quite a while with no movement.

breakthestatic avatar Nov 03 '22 21:11 breakthestatic

@timmywil any chance of this being merged? It all works for me. Thanks!

dbrnz avatar Jan 09 '23 22:01 dbrnz

Yes, this looks good. Sorry I haven't gotten to it sooner.

timmywil avatar Jan 09 '23 22:01 timmywil

Thanks!!

A great library -- it just works and works well, compared to some others out there...

dbrnz avatar Jan 09 '23 23:01 dbrnz

@timmywil Thanks for this great little library. Would it be possible to get a new release anytime soon to include this PR? As-is the latest release is not usable by web components (without turning off shadow DOM usage entirely), and it looks like this is the only major change since the last release -- so may be an easy / low risk release. Thank you again.

dermotduffy avatar Apr 17 '23 19:04 dermotduffy