Re: [csswg-drafts] [css-scoping] Handling global name-defining constructs in shadow trees

> Apple's WebKit team's feedback for the proposal will be that: [...snipped...]

No, recursive search *does not work*.

If the outer page has a @font-face declaring a "foo" family, and sets `body { font-family: foo; }`, then a component declares its *own* "foo" @font-face but doesn't immediately use it, inheritance will still carry the `font-family: foo` declaration into the shadow.

With recursive search, as this declaration crosses the shadow boundary, it will suddenly start referencing the *inner* "foo" @font-face, which is completely unexpected. It means that shadows aren't encapsulated from the outer page; if they declare a font-family that happens to have the same name as one the outer page uses, it'll suddenly break the display of the component.  The same applies to every other inheritable reference; it means an inherited `fill: url(#foo)` will break if the shadow happens to have an element with the same ID, etc.

With my proposal (all referencing things are implicitly a (scope, reference) pair), all of this works as expected. The outer page's `font-family` declaration inherits correctly, maintaining its reference to the outer @font-face, regardless of what has been declared inside the shadow. If you ask for the computed style on one of the shadow elements, it'll serialize as `font-family: scoped(foo, 1)` instead, but the underlying value (the scope/name pair) is unchanged.

> Also see the compatibility analysis in #1995 (comment)

Chrome's behavior is definitely broken in that example; the two styles should act identically, either both seeing the shadow's @keyframes or neither seeing it (depending on how the resolution rules work out).

Compat's thornier than that tho, isn't it? In Chrome, @font-face simple doesn't work in shadows at all, and all `font-family` declarations implicitly reference the global definition. I can't easily test Safari at the moment, so I'm not sure what y'all do. My point, tho, is that compat is a complete mess around this subject right now, and *whatever* we do to make things consistent and reasonable will cause some amount of problems for some number of people.

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

Received on Friday, 16 November 2018 18:43:05 UTC