Closed Bug 1720699 Opened 3 years ago Closed 3 years ago

Empty text nodes with white-space:pre use line-height space rather than no space

Categories

(Core :: Layout: Block and Inline, defect)

Firefox 90
defect

Tracking

()

RESOLVED DUPLICATE of bug 1680706

People

(Reporter: pfg, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:90.0) Gecko/20100101 Firefox/90.0

Steps to reproduce:

Create a div with white-space: pre or pre-wrap and add an empty text node to it. Or, run this script in an about:blank tab:

{
let sample = document.createElement("div");
sample.style.whiteSpace = "pre-wrap";
sample.style.backgroundColor = "red";
sample.appendChild(document.createTextNode(""));
document.body.appendChild(sample);
}

Actual results:

The div is visible and takes up space with the height equal to the line height even though it has no content

Expected results:

The div should not be visible or take up space since the text node is empty. Other browsers (Chrome, Safari) display it this way.

The Bugbug bot thinks this bug should belong to the 'Core::Layout' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Layout
Product: Firefox → Core

Thanks for the bug report! Here's an interactive testcase that demonstrates the bug.

STR: Load testcase, click button.

EXPECTED RESULTS: No red.
ACTUAL RESULTS: Red is visible. (The black-bordered box grows its height to be 1 line-height tall, showing its red background.)

Chromium, Safari, and EdgeHTML all produce EXPECTED RESULTS.
Firefox produces ACTUAL RESULTS.

Status: UNCONFIRMED → NEW
Component: Layout → Layout: Block and Inline
Ever confirmed: true

Looks like this is already tracked in bug 1680706.

Severity: -- → S3
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: