panzoom
panzoom copied to clipboard
feat: support attached shadow dom elements
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 indemo/
. - [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
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!
Hey @timmywil, just wanted to ping again to see if you're able to review and merge or provide feedback. Thanks!
@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.
@timmywil any chance of this being merged? It all works for me. Thanks!
Yes, this looks good. Sorry I haven't gotten to it sooner.
Thanks!!
A great library -- it just works and works well, compared to some others out there...
@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.