Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Loirooriol opened this issue Sep 12, 2017 · 6 comments
Closed

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

Loirooriol opened this issue Sep 12, 2017 · 6 comments

Comments

@Loirooriol
Copy link
Collaborator

@Loirooriol Loirooriol commented Sep 12, 2017

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.

@SelenIT
Copy link
Collaborator

@SelenIT SelenIT commented Sep 12, 2017

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.

@fantasai
Copy link
Collaborator

@fantasai fantasai commented Sep 14, 2017

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.

@SelenIT
Copy link
Collaborator

@SelenIT SelenIT commented Sep 14, 2017

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?

@Loirooriol
Copy link
Collaborator Author

@Loirooriol Loirooriol commented Sep 14, 2017

@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?

@fantasai
Copy link
Collaborator

@fantasai fantasai commented Mar 21, 2018

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

@fantasai
Copy link
Collaborator

@fantasai fantasai commented Mar 21, 2018

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants