[go: nahoru, domu]

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

Import condition #7658

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Import condition #7658

wants to merge 7 commits into from

Conversation

mirisuzanne
Copy link
@mirisuzanne mirisuzanne commented Feb 24, 2022

Draft fix for #7540

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chrome: …
    • Firefox: …
    • Safari: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …

(See WHATWG Working Mode: Changes for more details.)


💥 Error: Wattsi server error 💥

PR Preview failed to build. (Last tried on Jul 18, 2023, 10:57 PM UTC).

More

PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.

🔗 Related URL

Parsing MDN data...
Parsing...
Generating HTML variant...
Error: Multiple definitions for term "matches the environment" Parent of first says: "A string matches the environment of the user if it is the empty string, a string   consisting of only ASCII whitespace, or is a media query list that matches the user's   environment according to the definitions given in Media Queries. [MQ]", parent of second says: "A string matches the environment of the user if it is the empty string, a string   consisting of only ASCII whitespace, or is an import condition that matches the user's   environment according to the definitions given in CSS Cascade and Inheritance. "
Error: missing <dfn> for topic "valid import condition or media query list" explicitly from <span> element containing "Valid import condition or media query list"; previous heading contents are "Attributes"
Error count: 2
Saving index-html
Splitting...
Saving index.html
Saving introduction.html
Saving infrastructure.html
Saving common-microsyntaxes.html
Saving urls-and-fetching.html
Saving common-dom-interfaces.html
Saving structured-data.html
Saving dom.html
Saving semantics.html
Saving sections.html
Saving grouping-content.html
Saving text-level-semantics.html
Saving links.html
Saving edits.html
Saving embedded-content.html
Saving images.html
Saving iframe-embed-object.html
Saving media.html
Saving image-maps.html
Saving embedded-content-other.html
Saving tables.html
Saving forms.html
Saving input.html
Saving form-elements.html
Saving form-control-infrastructure.html
Saving interactive-elements.html
Saving scripting.html
Saving canvas.html
Saving custom-elements.html
Saving semantics-other.html
Saving microdata.html
Saving interaction.html
Saving dnd.html
Saving browsers.html
Saving window-object.html
Saving origin.html
Saving history.html
Saving browsing-the-web.html
Saving webappapis.html
Saving dynamic-markup-insertion.html
Saving timers-and-user-prompts.html
Saving system-state.html
Saving imagebitmap-and-animations.html
Saving comms.html
Saving server-sent-events.html
Saving web-messaging.html
Saving workers.html
Saving worklets.html
Saving webstorage.html
Saving syntax.html
Saving parsing.html
Saving named-characters.html
Saving xhtml.html
Saving rendering.html
Saving obsolete.html
Saving iana.html
Saving indices.html
Saving references.html
Saving acknowledgements.html
Generating DEV variant...
Error: Multiple definitions for term "matches the environment" Parent of first says: "A string matches the environment of the user if it is the empty string, a string   consisting of only ASCII whitespace, or is a media query list that matches the user's   environment according to the definitions given in Media Queries. [MQ]", parent of second says: "A string matches the environment of the user if it is the empty string, a string   consisting of only ASCII whitespace, or is an import condition that matches the user's   environment according to the definitions given in CSS Cascade and Inheritance. "
Error count: 1
Splitting...
Saving index.html
Saving introduction.html
Saving infrastructure.html
Saving common-microsyntaxes.html
Saving urls-and-fetching.html
Saving common-dom-interfaces.html
Saving structured-data.html
Saving dom.html
Saving semantics.html
Saving sections.html
Saving grouping-content.html
Saving text-level-semantics.html
Saving links.html
Saving edits.html
Saving embedded-content.html
Saving images.html
Saving iframe-embed-object.html
Saving media.html
Saving image-maps.html
Saving embedded-content-other.html
Saving tables.html
Saving forms.html
Saving input.html
Saving form-elements.html
Saving form-control-infrastructure.html
Saving interactive-elements.html
Saving scripting.html
Saving canvas.html
Saving custom-elements.html
Saving semantics-other.html
Saving microdata.html
Saving interaction.html
Saving dnd.html
Saving browsers.html
Saving window-object.html
Saving origin.html
Saving history.html
Saving browsing-the-web.html
Saving webappapis.html
Saving dynamic-markup-insertion.html
Saving timers-and-user-prompts.html
Saving system-state.html
Saving imagebitmap-and-animations.html
Saving comms.html
Saving server-sent-events.html
Saving web-messaging.html
Saving workers.html
Saving worklets.html
Saving webstorage.html
Saving syntax.html
Saving named-characters.html
Saving xhtml.html
Saving obsolete.html
Saving indices.html
Saving references.html
Saving acknowledgements.html
Generating SNAP variant...
Error: Multiple definitions for term "matches the environment" Parent of first says: "A string matches the environment of the user if it is the empty string, a string   consisting of only ASCII whitespace, or is a media query list that matches the user's   environment according to the definitions given in Media Queries. [MQ]", parent of second says: "A string matches the environment of the user if it is the empty string, a string   consisting of only ASCII whitespace, or is an import condition that matches the user's   environment according to the definitions given in CSS Cascade and Inheritance. "
Error: missing <dfn> for topic "valid import condition or media query list" explicitly from <span> element containing "Valid import condition or media query list"; previous heading contents are "Attributes"
Error count: 2
Saving index-snap



If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.

@mirisuzanne
Copy link
Author

@domenic The build is now working, as the remaining mentions of media-condition were updated. At this point, I think CSSOM is the main remaining issue – and then I can start working on implementer interest/bugs/tests. I'll also see about getting a prototype implementation in place.

If I understand right, the CSSOM update will require changes in the CSSOM spec as well, so I'm looking into that. Happy for any other feedback you have here.

Copy link
Member
@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a few nits, plus one larger question about the scope of this change; those are noted inline.

But indeed, the biggest missing piece is updating CSSOM. I don't really know much about those specs but it looks like the following pieces are relevant and probably will need updates:

source Outdated Show resolved Hide resolved
source Outdated
@@ -13788,8 +13789,7 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
data-x="external resource link">external resource links</span>.</p>

<p>The <dfn element-attr for="link"><code data-x="attr-link-media">media</code></dfn> attribute
says which media the resource applies to. The value must be a <span>valid media query
list</span>.</p>
says which media the resource applies to. The value must be a <span>valid import condition</span>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update "says which media the resource applies to"? I'm personally not sure. The sentence here is supposed to be a statement of fact so it doesn't need to be super-accurate. But I feel like with the new value space maybe the current sentence becomes inaccurate?

source Outdated
@@ -14450,7 +14450,7 @@ interface <dfn interface>HTMLMetaElement</dfn> : <span>HTMLElement</span> {
name-value pair is the empty string.</p>

<p>The <dfn element-attr for="meta"><code data-x="attr-meta-media">media</code></dfn> attribute
says which media the metadata applies to. The value must be a <span>valid media query list</span>.
says which media the metadata applies to. The value must be a <span>valid import condition</span>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to double-check, do we have implementer buy-in for changing not only link and style, but also meta and source? I think it's best if we change them all, for consistency. But it is extra work, and some implementers might not be excited about doing that extra work so that you can do conditional meta theme colors.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layer syntax would only have meaning in the link & style elements - and is only needed on the former (the CSS syntax can be used directly inside style). Other import conditions, such as support queries, may be useful on all three. We could narrow the scope of this PR to only the essential change, and expand later if desired?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do implementers want to do here?

Even for the link element, media can be specified and is processed for preload in addition to stylesheet. Do we want to check the value of the as attribute for preloads and decide between media query list or import condition, or always treat as import condition for link?

For images, videos, and <meta name=theme-color>, I think it doesn't make much sense to support supports() since they don't import CSS stylesheets, but I don't feel strongly about it.

We also have the Link HTTP header which per spec seems to always process the media header attribute regardless of rel (https://html.spec.whatwg.org/multipage/semantics.html#process-link-headers step 5). Link supports preconnect and preload rels per spec (not stylesheet).

@zcorpan
Copy link
Member
zcorpan commented Sep 14, 2023

For <link rel=stylesheet media=...> the media attribute is used in the CSSOM "create a CSS stylesheet" steps and a MediaList object gets created from the attribute's value, where that vaule is parsed as a media query list.

Meanwhile, for @import, the CSSImportRule interface has a supportsText attribute for the <supports-condition> part.

I think CSSOM needs to change to allow creating stylesheets with supports conditions, and changing the HTML media attribute needs to update both the MediaList's mediaText and the StyleSheet's supportsText. I'll file an issue for CSSOM.

(Maybe also CSSStyleSheetInit (options for constructable stylesheets) should support supports, but that's not blocking this PR.)

Edit: filed w3c/csswg-drafts#9361

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

Successfully merging this pull request may close these issues.

None yet

3 participants