@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
22 lines (21 loc) • 751 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNonInlineParent = void 0;
const isNullOrUndefined_js_1 = require("../type-predicates/isNullOrUndefined.js");
const isDisplayInline_js_1 = require("./isDisplayInline.js");
/**
* Gets the first parent of an element that isn't `display: inline`. Returns null if no matching element
*/
function getNonInlineParent(element) {
const parent = element.parentElement;
if ((0, isNullOrUndefined_js_1.isNullOrUndefined)(parent)) {
return null;
}
else if ((0, isDisplayInline_js_1.isDisplayInline)(parent)) {
return getNonInlineParent(parent);
}
else {
return parent;
}
}
exports.getNonInlineParent = getNonInlineParent;