offsetParent property

Element? get offsetParent
inherited

Implementation

Element? get offsetParent {
  // Returns null in the following cases.
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
  if (renderStyle.display == CSSDisplay.none
    || renderStyle.position == CSSPositionType.fixed
    || this is BodyElement
    || this == ownerDocument.documentElement) {
    return null;
  }

  Element? parent = parentElement;

  while (parent != null) {
    bool isNonStatic = parent.renderStyle.position != CSSPositionType.static;
    if (parent is BodyElement || isNonStatic) {
      break;
    }
    parent = parent.parentElement;
  }
  return parent;
}