Fix placeholder sizing for cookie-consent elements

Expand the dimensional property allowlist with padding, box-sizing,
and positioning properties (position, top, right, bottom, left,
inset) so placeholders match the size of absolutely or sticky
positioned elements. Fall back to getComputedStyle for height when
no explicit value is found from inline styles or HTML attributes.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-30 16:59:13 +04:00
parent bd6abccb2d
commit 15ff6131e1

View File

@@ -146,6 +146,18 @@ function createPlaceholder(
"margin-right",
"margin-bottom",
"margin-left",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left",
"box-sizing",
"position",
"top",
"right",
"bottom",
"left",
"inset",
];
if (htmlEl.style) {
for (const prop of DIMENSIONAL_PROPS) {
@@ -154,6 +166,15 @@ function createPlaceholder(
}
}
const hasExplicitHeight =
placeholder.style.height || placeholder.style.minHeight;
if (!hasExplicitHeight) {
const computed = window.getComputedStyle(htmlEl);
if (computed.height && computed.height !== "auto" && computed.height !== "0px") {
placeholder.style.height = computed.height;
}
}
let phText: string;
if (texts?.placeholder_text) {
const parts = texts.placeholder_text.split("{{category}}");