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

Make custom @at-root private API #14618

Merged
merged 2 commits into from
Oct 8, 2024
Merged

Conversation

RobinMalfait
Copy link
Member

This PR makes the internal @at-root API private. Before this PR you could use @at-root in your own CSS, which means that it was part of the public API. If you (accidentally) used it in variants, you could generate CSS that was completely broken.

This now introduces a new private AtRoot node (similar to the recently introduced Context node) and can only be constructed within the framework.

This is an internal that cannot be constructed from CSS land which means
that we can keep it private. This is a similar idea to the private
`Context` node.
@@ -22,7 +22,12 @@ export type Context = {
nodes: AstNode[]
}

export type AstNode = Rule | Declaration | Comment | Context
export type AtRoot = {
kind: 'at-root'
Copy link
Member Author

@RobinMalfait RobinMalfait Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever need more like this, we could have a more generic marker node where you attach an additional sub-kind or w/e. I think this is the best solution for now though.

@RobinMalfait RobinMalfait merged commit 68c32d1 into next Oct 8, 2024
1 check passed
@RobinMalfait RobinMalfait deleted the feat/make-at-root-private branch October 8, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants