Skip to content

Commit 7a063cc

Browse files
committed
style(core): name the image layout exception instead of commenting it
1 parent e4ce71d commit 7a063cc

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎packages/core/src/runtime/init.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,7 @@ export function initSandboxRuntimeModular(): void {
10271027
el.style.position = "absolute";
10281028
}
10291029
if (tag !== "audio") {
1030-
// An <img> measures 0px until its file loads; its size comes from the file, never a 100% fill.
1031-
const fillsWhenEmpty = tag !== "img";
1030+
const sizedByItsFile = tag === "img";
10321031
const forcedWidth = parseDimensionPx(el.getAttribute("data-width"));
10331032
const forcedHeight = parseDimensionPx(el.getAttribute("data-height"));
10341033
const hasMeaningfulComputedWidth = computed.width !== "0px" && computed.width !== "auto";
@@ -1037,14 +1036,14 @@ export function initSandboxRuntimeModular(): void {
10371036
if (!el.style.width && !hasMeaningfulComputedWidth) {
10381037
el.style.width = forcedWidth;
10391038
}
1040-
} else if (fillsWhenEmpty && !el.style.width && computed.width === "0px") {
1039+
} else if (!sizedByItsFile && !el.style.width && computed.width === "0px") {
10411040
el.style.width = "100%";
10421041
}
10431042
if (forcedHeight) {
10441043
if (!el.style.height && !hasMeaningfulComputedHeight) {
10451044
el.style.height = forcedHeight;
10461045
}
1047-
} else if (fillsWhenEmpty && !el.style.height && computed.height === "0px") {
1046+
} else if (!sizedByItsFile && !el.style.height && computed.height === "0px") {
10481047
el.style.height = "100%";
10491048
}
10501049
}

0 commit comments

Comments
 (0)