UNPKG

nehan

Version:

Html layout engine for paged-media written in Typescript

42 lines 1.39 kB
import { CssCascade, Display, } from './public-api'; export class ContainingElement { static getAbsAncestor(element) { let parent = element.parent; while (parent) { const position = parent.computedStyle.getPropertyValue("position"); if (position !== "static") { break; } parent = parent.parent; } return parent || element.ownerDocument.body; } static getBlockAncestor(element) { let parent = element.parent; while (parent) { const display = Display.load(parent); if (display.isBlockLevel() || display.isFlowRoot()) { return parent; } parent = parent.parent; } return element.ownerDocument.body; } static get(element) { const position = CssCascade.getValue(element, "position"); if (element.tagName === "body") { return element; } if (!element.parent) { return element.ownerDocument.body; } if (position === "absolute" || position === "fixed") { return this.getAbsAncestor(element); } if (Display.load(element).isBlockLevel()) { return this.getBlockAncestor(element); } return element.parent; } } //# sourceMappingURL=containing-element.js.map