MCPcopy Index your code
hub / github.com/prototypejs/prototype / getOffsetParent

Function getOffsetParent

src/prototype/dom/layout.js:1052–1076  ·  view source on GitHub ↗

* Element.getOffsetParent(@element) -> Element * * Returns `element`'s closest _positioned_ ancestor. If none is found, the * `body` element is returned.

(element)

Source from the content-addressed store, hash-verified

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 /**

Callers 1

absolutizeFunction · 0.85

Calls 6

$Function · 0.85
isDocumentFunction · 0.85
isDetachedFunction · 0.85
isBodyFunction · 0.85
isHtmlFunction · 0.85
selfOrBodyFunction · 0.85

Tested by

no test coverage detected