W3C home > Mailing lists > Public > public-css-archive@w3.org > August 2020

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

From: Rune Lillesveen via GitHub <sysbot+gh@w3.org>
Date: Fri, 14 Aug 2020 13:32:40 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-674076666-1597411959-sysbot+gh@w3.org>
The current draft says in css-scoping says:

"Tree-scoped references implicitly capture a node tree root along with their specified value: unless otherwise specified, the root of the element hosting the stylesheet that the property or descriptor is defined in."

What about constructed stylesheets?

If I have a constructed sheet with

```
  div { font-family: myfont }
```

and add it as an adopted sheet in both shadow trees below, I think that I would expect myfont to match the @font-face rule in the corresponding shadow tree. That is, the myfont reference will capture a different node tree root for each case.

```
<host-1>
  <:shadow>
    <style>@font-face { font-family: myfont; src: url(a.ttf) }</style>
    <div></div>
  </:shadow>
</host-1>
<host-2>
  <:shadow>
    <style>@font-face { font-family: myfont; src: url(b.ttf) }</style>
    <div></div>
  </:shadow>
</host2>
```

That brings the question of when the root node is captured along with the specified value.

If I query CSSStyleRule.styleMap or Element.attributeStyleMap for a parsed font-family, will that typed OM object have the scope for that sheet/element?

If we always have a scope with CSSScopedKeyword, it means that if I have two sheets in different scopes, simply retrieving a font-family name from CSSStyleRule.styleMap in on sheet and setting it directly on a CSSStyleRule.styleMap of another sheet will make that declaration resolve font-family against @font-face rules in the scope the declaration value was copied from.

An alternative is to let CSSScopedKeyword.scope be initially null on values exposed from style attributes and stylesheets, making them scope-agnostic when copying them between sheets and attributes. Then, capture the root node at computed style time (with root node being the root node for the DocumentOrShadowRoot of adoptedStyleSheets for constructed sheets). computedStyleMap will always have non-null scope references and if copied into attributeStyleMap, it will have a reference to make the value round-trip.


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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 14 August 2020 13:32:42 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:13 UTC