* Element.getOffsetParent(@element) -> Element * * Returns `element`'s closest _positioned_ ancestor. If none is found, the * `body` element is returned.
(element)
| 1050 | * `body` element is returned. |
| 1051 | **/ |
| 1052 | function getOffsetParent(element) { |
| 1053 | element = $(element); |
| 1054 | |
| 1055 | // Ensure we never return the root HTML tag. |
| 1056 | function selfOrBody(element) { |
| 1057 | return isHtml(element) ? $(document.body) : $(element); |
| 1058 | } |
| 1059 | |
| 1060 | // For unusual cases like these, we standardize on returning the BODY |
| 1061 | // element as the offset parent. |
| 1062 | if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element)) |
| 1063 | return $(document.body); |
| 1064 | |
| 1065 | // IE reports offset parent incorrectly for inline elements. |
| 1066 | var isInline = (Element.getStyle(element, 'display') === 'inline'); |
| 1067 | if (!isInline && element.offsetParent) return selfOrBody(element.offsetParent); |
| 1068 | |
| 1069 | while ((element = element.parentNode) && element !== document.body) { |
| 1070 | if (Element.getStyle(element, 'position') !== 'static') { |
| 1071 | return selfOrBody(element); |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | return $(document.body); |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | /** |
no test coverage detected