-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Declarative CSS Modules - <script> vs <style> for defining modules #10710
Comments
IMHO, the most important point would be which interface proposes the most suited API? Unless it is planned that most of said API would be disabled anyway? At a glance it seems that indeed |
So "I just want my page style resets to apply to both the light DOM and to a shadow DOM."
|
When I try: <style id="disabledStyle" disabled>
body {
border: 2px dashed green;
}
</style>
<style id="moduleStyle" type="module">
body {
border: 2px dotted red;
}
</style>
<script id="scriptStyle" type="css-module">
body {
border: 2px solid yellow;
}
</script> Only Which says to me it might be the better choice for either a source for an inline module or a reference to a globally-id'd style element, because removing the disabled attribute would make it also apply in the light DOM, which would be a use case. |
What is the issue with the HTML Standard?
This topic is for discussion of #10673, which is a Stage 1 proposal.
Our original explainer (MSEdgeExplainers/ShadowDOM/explainer.md at main · MicrosoftEdge/MSEdgeExplainers) uses
<script>
tags to define Declarative CSS Modules, but consensus seems to be overwhelmingly in favor of using a<style>
tag instead.Specifically, this example:
Would change to this:
The
type="module"
attribute is necessary to prevent styles from applying to the main document by default (this was one of the reasons for using the<script>
tag initially).The HTML5 Specification explicitly only allows
<script>
tags to have atype
attribute of either:type
attributetype="text/css"
See https://html.spec.whatwg.org/#update-a-style-block - this will need to be amended to include a stage for Declarative CSS Modules.
Pros for the <script> approach
Pros for the <style> approach
The TPAC breakout session had quite a bit of discussion on this.
The MSEdgeExplainer's GitHub also had a public comment advocating for
<style>
over<script>
- MicrosoftEdge/MSEdgeExplainers#887 (comment)My preference is to proceed with updating the explainer to use
<style>
instead of<script>
unless there are any objections.The text was updated successfully, but these errors were encountered: