Re: [csswg-drafts] [css-display] Should anonymous boxes always inherit through the box tree?

> We didn't have a case where you could have non-box-generating element with visible text children before display:contents. There is nothing to be inconsistent with; the case is new.

Of course the case is new. But before `display:contents`, "text nodes exists in the element tree, and inherit from their parent element" and "text exists in the box tree, and inherits from its parent box" were *indistinguishable*.  Both behaviors had exactly the same effect (none of the box-tree manipulations that existed prior to `display:contents` changed the parent box of text in a way that would change the inheritance results).

Thus, you could pretend that inheritance always worked thru the element tree, for all styling.  Now, we suddenly have a case that breaks the symmetry, and we have to decide whether we prefer "inheritance always goes thru the element tree" or "inheritance is thru the element tree for elements, and thru the box tree for text".  The former is simpler overall, but requires introducing some new concepts to CSS; the latter requires no new spec concepts, but introduces an asymmetry and results that at least some people find surprising.

Neither way is particularly difficult for implementations, as far as I can tell, and thus I strongly prefer the one that doesn't produce a behavior asymmetry.

> The argument in the original post is that it is surprising that an unstyled element is still being affected via inheritance. I was curious why people found it surprising.

No, you seem to be misunderstanding the example? It's pointing out the difference in the style of *text*; the span is used to *introduce* the styling difference, it's not the point of the example.

The argument in the example is that it would be surprising if the two `target` elements in the markup below ended up with different `color` values:

```html
<parent color:red>
  <child display:contents color:green>
    <target />
  </child>
</parent>
<parent color:red>
  <child display:contents color:green>
    <wrapper>
      <target />
    </wrapper>
  </child>
</parent>
```

In both examples, `target` should have a computed `color` of `green`: in the first example, `target` directly inherits it from `child`; in the second example, `target` inherits from `wrapper`, but `wrapper` just inherits it from `child`, so it should be green as well.

It's weird, then, that if you replace `<target />` with raw text, you'd get a different result - it would be red in the first example, and green in the second.  What's the justification for raw text acting differently here?  Why, if I add a meaningless wrapper element that doesn't interfere with inheritance at all (for scripting purposes, perhaps), do I get a dramatic difference in inherited value?

Our diff fixes the specs so that this all works consistently, whether it's an element or text.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1118#issuecomment-306563559 using your GitHub account

Received on Tuesday, 6 June 2017 17:45:06 UTC