Skip to content

[css-display] Do empty text nodes generate text runs? #1808

Closed

Description

@Loirooriol

Do text nodes with an empty string value generate a text run or not?

The difference will affect run-in layout:

If a run-in sequence is immediately followed by a block box [...]

And it's also observable in flow layout. According to CSS 2.2,

Line boxes that contain no text [...] must be treated as not existing [...]

I guess "text" refers to text runs. See https://jsfiddle.net/rs94bpay/

<div><div>Foo</div></div>
div {
  white-space: pre;
  border: 1px solid blue;
}
document.querySelector('div').prepend('');

Firefox does not discard the line because of the text node, Chrome and Edge do.

Activity

  1. SelenIT commented on Sep 12, 2017

    @SelenIT
    Collaborator

    The behavior of Firefox looks like a bug. The script doesn't add any white space characters that should be taken into account by white-space property. Interestingly, the same issue occurs for body > div::before { content: '' } instead of prepending empty string with the script.

  2. fantasai commented on Sep 14, 2017

    @fantasai
    Collaborator

    That's super weird, and it's definitely a bug. Different DOMs that output the same source code should not result in different CSS output, ever.

    @SelenIT ::before { content: '' } is a little different, it causes the ::before pseudo-element to exist, and empty inline boxes count as content that causes a line box to exist.

  3. SelenIT commented on Sep 14, 2017

    @SelenIT
    Collaborator

    empty inline boxes count as content that causes a line box to exist

    They do, but shouldn't they be treated as "not existing for any other [than positioning out-of-flow descendants] purpose" phantom line boxes?

  4. Loirooriol commented on Sep 14, 2017

    @Loirooriol
    ContributorAuthor

    @fantasai If I understand correctly, you mean that

    • An empty text node generates no text run.
    • A ::before or ::after with content: '' generates an empty text run.

    Is that correct?

  5. fantasai commented on Mar 21, 2018

    @fantasai
    Collaborator

    @Loirooriol A ::before or ::after with content: '' generates a box containing nothing.

  6. fantasai commented on Mar 21, 2018

    @fantasai
    Collaborator

    @SelenIT That depends on if they are assigned any other styles. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions