Re: [csswg-drafts] Proposal: CSS @sheet (#11509)

@KurtCattiSchmidt

> I can see lots of value in the SVG `<use>` behavior that you suggested, but we might not be able to adjust the existing behavior of CSS Modules without breaking existing usage. But perhaps we can make it work with some slight modifications to the syntax to handle both cases.

> I'll think about this and may propose some new updates. At the very least, there should be a table that indicates reference vs copy of stylesheets for each method of sharing stylesheets, as that will clarify a lot of the current discussion.

Yes, a table would be clarifying. 

And it would be a no-go to break existing behavior or usage of the specific case of CSS Modules (`import styles from './styles.css' with {type: "css"}`) or modules in general (`import {foo} from './bar.js'`). No change needed or suggested there.

But these existing module usages (like link rel) to date only allow specifiers (i.e. references) [to network resources](https://html.spec.whatwg.org/multipage/webappapis.html#module-specifier-resolution) (i.e. files): [relative, absolute, and bare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#module_specifier_resolution).

They do not currently allow or even contemplate references to DOM elements (loosely a term for [inline module scripts](https://github.com/whatwg/html/issues/7415) or in-document element references).

So no existing usage would necessarily be broken by [adding a new specifier/reference type for in-document references](https://github.com/whatwg/html/issues/10673#issuecomment-2460519693) to complement [#11019 fragment references](https://github.com/whatwg/html/issues/11019)  `<link rel="stylesheet" href="#inline_styles">`.

But it could help unblock and complete the assessment of this situation (and also open the door to a lot of new possibilities of other data types and bundling replacements).

I think this could be an indirect implication of @noamr [mention of allowing](https://github.com/w3c/csswg-drafts/issues/11509#issuecomment-2650179181) `import {something} from "#bundle";`, which of course now just produces:

```bash
Uncaught TypeError: Failed to resolve module specifier "#bundle". 
Relative references must start with either "/", "./", or "../".
```
It would be helpful to know if there is some past consideration that points away from this reasoning.

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 12 February 2025 23:50:05 UTC