jquery/jquery — pull request #1976 by nazar-pc (2014-12-26 07:19:35+00:00)
Title: Offset: `$.fn.offset()` on element inside shadowRoot

`$.fn.offset()` didn't worked on `html>...>shadowRoot>...>target_element`, while `target_element.getBoundingClientRect` worked fine with correct result.
The reason was that check for disconnected node made by checking whether `document` contains `target_element` fails, which is correct, element inside shadowDOM, not in main DOM.

That is why I've added recursive traversal from element to its parent until it reaches `document` or until `parent_element.parentNode` is `falsy` (for disconnected nodes it will be `null`, if pass some badly composed object - it may be `undefined`, so, just `falsy`, in this case we just return).
If we encounter `DocumentFragment` (`shadowRoot`), we take `parent_element.host` property instead of `parent_element.parentNode` in order to get parent element of that `shadowRoot`.
Also it was necessary to add explicit check for `target_element.getBoundingClientRect` property.

This is modern, Web Components-aware version of ea507b3e998126ae1f94f4fd1618994d645c9cc8