UNPKG

@ulu/frontend

Version:

A framework-agnostic frontend toolkit providing a modular, tree-shakable library of accessible components and utilities. Designed for seamless integration, it features a highly configurable SCSS system for any environment and vanilla JavaScript modules op

34 lines (33 loc) 836 B
import { separateCssUnit as u } from "@ulu/utils/string.js"; const o = /^\d+$/; function h(a) { const c = a.querySelectorAll("iframe"); if (c.length === 1 && a.textContent.trim() === "") { const n = c[0], l = n.getAttribute("width"), t = n.getAttribute("height"), e = !!(l && t && o.test(l) && o.test(t)); let s = null; if (!e) { const i = n.style.height || t; if (i) if (o.test(i)) s = `${i}px`; else try { const r = u(i); r && r.unit && r.unit !== "%" && (s = i); } catch (r) { } } return { iframe: n, isStaticSize: e, width: e ? l : null, height: e ? t : null, aspectRatio: e ? `${l} / ${t}` : null, fillHeight: s }; } return null; } export { h as getSoleIframeLayout };