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

[css-properties-values-api] [css-cascade] Interaction of @scope and @property #9077

Closed
bramus opened this issue Jul 17, 2023 · 3 comments
Closed

Comments

@bramus
Copy link
Contributor

bramus commented Jul 17, 2023

With @scope defined in css-cascade-6, should authors be able to register custom properties with @property inside the scope, without those properties loitering the global space?

@scope (.card) {
  /* Should --color be local to the scope or not? */
  @property --color {
    …
  }
}

If it should be scoped, should that happen automatically or should it be opt-in by means of an extra descriptor during registration?

@bramus
Copy link
Contributor Author

bramus commented Jul 18, 2023

Spec currently reads this (source):

Global name-defining at-rules such as @keyframes or @font-face or @layer that are defined inside @scope are valid, but are not scoped or otherwise affected by the enclosing @scope rule.

Probably makes sense to keep this behavior, and make it an opt-int should we want to.

Use-case would be an author shipping a component with scoped styles, knowing that the custom properties they use don’t clash with the global namespace. Right now they need to work around this by prefixing their custom props, hoping nobody else uses that prefix.

@andruud
Copy link
Member

andruud commented Aug 11, 2023

With @scope defined in css-cascade-6, should authors be able to register custom properties with @Property inside the scope, without those properties loitering the global space?

No, we couldn't even do it for ShadowDOM (which is more strict and encapsulating): https://drafts.css-houdini.org/css-properties-values-api-1/#shadow-dom

@bramus
Copy link
Contributor Author

bramus commented Aug 11, 2023

Thanks for the clarification, @andruud. Closing.

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

No branches or pull requests

2 participants