Module Stylesheet <link> tags - #12339
Conversation
|
From an initial look this seems to be on the right track. I need to spend some time on the details though. |
This comment was marked as outdated.
This comment was marked as outdated.
Note that the current properties of So I think it might be nice to include it in the init dictionary but I could also see why it's not necessary. |
Agreed with @noamr's response here - since there's already an Think of |
emilio
left a comment
There was a problem hiding this comment.
Question, might be me misunderstanding CSS modules, but I'd figure I'd ask...
This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1629010}
This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1629010}
This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1629010}
…a=testonly Automatic update from web-platform-tests [CSS Modules] Update fetching strategy This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniec@microsoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1629010} -- wpt-commits: e564867fbfe3cc70cc8d43ddac392b7b848bc7e4 wpt-pr: 59805
…a=testonly Automatic update from web-platform-tests [CSS Modules] Update fetching strategy This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniecmicrosoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmimicrosoft.com> Cr-Commit-Position: refs/heads/main{#1629010} -- wpt-commits: e564867fbfe3cc70cc8d43ddac392b7b848bc7e4 wpt-pr: 59805 UltraBlame original commit: 04a038fe6e54a754c927f29afe85d3c66476f8a3
…a=testonly Automatic update from web-platform-tests [CSS Modules] Update fetching strategy This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniecmicrosoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmimicrosoft.com> Cr-Commit-Position: refs/heads/main{#1629010} -- wpt-commits: e564867fbfe3cc70cc8d43ddac392b7b848bc7e4 wpt-pr: 59805 UltraBlame original commit: 04a038fe6e54a754c927f29afe85d3c66476f8a3
…a=testonly Automatic update from web-platform-tests [CSS Modules] Update fetching strategy This change updates the fetch behavior to match whatwg/html#12339. Note that this modifies the code for existing import, import(), and modulepreload for consistency, but the existing behavior for these API's does *not* change in any circumstance. The only observable change is in the shadowrootadoptedstylesheets fetching behavior. By modifying the CSS module fetching to first create the CSSStyleSheet before fetching and calling replaceSync upon completion, we are able to remove the placeholder stylesheets that were being inserted for shadowrootadoptedstylesheets. This simplifies the logic considerably and will be more performant. Unlike the other API's for fetching a CSS Module Script, shadowrootadoptedstylesheets will leave behind an empty CSSStyleSheet in adoptedStyleSheets if the fetch fails. This simplifies the logic and seems like a reasonable trade off for a rare condition. Earlier versions of this CL removed it upon failure, but the implementation was considerably more complex and had other side effects. Change-Id: If00445458983f5062a1ca2d83ed0253cc171d1ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7709812 Reviewed-by: Dan Clark <daniecmicrosoft.com> Commit-Queue: Kurt Catti-Schmidt <kschmimicrosoft.com> Cr-Commit-Position: refs/heads/main{#1629010} -- wpt-commits: e564867fbfe3cc70cc8d43ddac392b7b848bc7e4 wpt-pr: 59805 UltraBlame original commit: 04a038fe6e54a754c927f29afe85d3c66476f8a3
|
@KurtCattiSchmidt - While implementing #10327 in Chromium, I've noticed some failing tentative tests related to this PR that I believe would need to change, given the new behavior of failed module loads. shadowrootadoptedstylesheets-async-fetch-failure-shared.html and shadowrootadoptedstylesheets-modulepreload-failure.html both assume that a failed fetch is permanent, when that's no longer the case. I believe we'd need to change these tests, and any relevant spec language. |
3897188 to
46ba117
Compare
…rializable, and failed fetch behavior
acba836 to
cbaba09
Compare
noamr
left a comment
There was a problem hiding this comment.
Really nice work, see comments!
There was a problem hiding this comment.
I think we can make it so that specifiers used in href like this also have to be valid URLs as far as conformance goes.
It's mostly a single word or something which is a valid URL to begin with. Then this is just a URL with using module-specifier for relative resolution rather than ordinary URL resolution
There was a problem hiding this comment.
(this is an opinion btw, and the whole "href can be a specifier" notion should be discussed with a wider community)
| <code>link</code> element, then <dfn id="the-link-is-an-alternative-stylesheet">the link is an | ||
| alternative style sheet</dfn>; in this case, the <code data-x="attr-title">title</code> attribute | ||
| must be specified on the <code>link</code> element, with a non-empty value.</p> | ||
| <code>link</code> element and the element is not a <span>module stylesheet link</span>, then <dfn |
There was a problem hiding this comment.
This is another cardinality issue - on regular <link rel=stylesheet>, the title attribute on link goes straight to the StyleSheet.title value: https://drafts.csswg.org/cssom/#dom-stylesheet-title. alternate works for selecting which alternate stylesheet and has similar cardinality issues.
Unlike media and disabled, we can't handle it at the element level instead, since it needs to interact with the stylesheet and a browser UI setting.
I assumed these were unofficially deprecated, as Chrome doesn't support them. But it looks like Firefox still does support them, so I'm curious what their thoughts are on this. I think for now, removing this exception for link modules makes sense, as it won't impact interop.
|
This used to be the PR for adoptedStyleSheets, it seems like it's now for modules in |
emilio
left a comment
There was a problem hiding this comment.
Curious, so the current state of the PR defines <link import=""> rather than using type="module". Not objecting or anything, but why?
Would it be possible to share more of the processing model (specially the fetching etc, and the load event firing) with the current href version? I assume that's roughly how it would work, implementation-wise.
| <li><p>Set <var>el</var>'s <span data-x="link module CSS style sheet">module CSS style | ||
| sheet</span> to <var>sheet</var>, and <span | ||
| data-x="concept-event-fire">fire an event</span> named <code | ||
| data-x="event-load">load</code> at <var>el</var>.</p></li> |
There was a problem hiding this comment.
Link load events generally fire async, probably this should use a task.
This came up at WHATNOT, as wanting to keep By using |
|
To be clear, I don't think we ended up really reaching a conclusion about the design of this feature at WHATNOT. Perhaps we should first flesh out some of the alternatives in a design document. And I second @keithamus's request for closing this PR as that just makes reviewing unwieldy. |
|
@annevk - for context, there is a design document that we discussed at a two hour joint WHATWG-CSSWG meeting a few weeks ago. Minutes are here. Members of Mozilla, Webkit, and Blink were present and we jointly agreed that The suggestion to use Agreed that the history makes this confusing. I'll open a new PR. |
New PR is at #12860 |
|
I might be missing something but I don't see anyone from WebKit in the list of attendees there? But also, WHATWG only makes tentative decisions during meetings so it doesn't really matter. |
@rniwa was there (not that that makes the conclusions binding) |
Adds support for
<link type=module rel=stylesheet>.At least two implementers are interested (and none opposed):
[] Tests are written and can be reviewed and commented upon at:
Implementation bugs are filed:
Corresponding HTML AAM & ARIA in HTML issues & PRs: N/A
MDN issue is filed: Module Stylesheet <link> tags mdn/mdn#824
The top of this comment includes a clear commit message to use.
(See WHATWG Working Mode: Changes for more details.)
Addresses #10673
/indices.html ( diff )
/links.html ( diff )
/semantics.html ( diff )
/webappapis.html ( diff )