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

Add CSS module script/CSS modules #5944

Closed
Schweinepriester opened this issue Jun 12, 2021 · 3 comments · Fixed by #7023
Closed

Add CSS module script/CSS modules #5944

Schweinepriester opened this issue Jun 12, 2021 · 3 comments · Fixed by #7023

Comments

@atjn
Copy link
Contributor

atjn commented Jun 16, 2021

Related: #5928

@e111077
Copy link

e111077 commented Jun 24, 2022

I accidentally made a duplicate issue but here's more relevant info:

Stage 3: https://github.com/tc39/proposal-import-assertions
web.dev explainer: https://web.dev/css-module-scripts/

// styles.css
div {
  color: red;
}
// index.js
import styles from './styles.css' assert { type: "css" };
document.adoptedStyleSheets = [styles];
const success = getComputedStyle(document.querySelector('div')).color === 'rgb(255, 0, 0)'
// index.html
<script type="module" src="./index.js"></script>
<div>YOLO</div>

@o-t-w
Copy link
Contributor

o-t-w commented Mar 24, 2024

Chrome 123 added support for import attributes. Chrome already supported CSS module scripts but used a now deprecated syntax. Now that CSS module scripts work with the up-to-date syntax it seems like a good time to add this data to caniuse. All browsers have indicated that they will support this feature eventually.

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

Successfully merging a pull request may close this issue.

5 participants