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

Nested @ rules produce unexpected results #103

Open
chrisdeeming opened this issue Mar 8, 2024 · 1 comment
Open

Nested @ rules produce unexpected results #103

chrisdeeming opened this issue Mar 8, 2024 · 1 comment

Comments

@chrisdeeming
Copy link

Consider the following input:

html::after
{
	content: 'full';
	display: none;

	@media (max-width: 1200px)
	{ 
		content: 'wide';
	}
	@media (max-width: 800px)
	{ 
		content: 'medium';
	}
	@media (max-width: 400px)
	{ 
		content: 'narrow';
	}
}

Most pre-processors would process this as:

html::after {
  content: 'full';
  display: none;
}
@media (max-width: 1200px) {
  html::after {
    content: 'wide';
  }
}
@media (max-width: 800px) {
  html::after {
    content: 'medium';
  }
}
@media (max-width: 400px) {
  html::after {
    content: 'narrow';
  }
}

Unfortunately this is the result from Crush:

html:after {
    content: 'full';
    display: none;
    @media (max-width: 1200px){content: 'wide';
    }@media (max-width: 800px){content: 'medium';
    }@media (max-width: 400px){content: 'narrow';
    }

This is invalid in a couple of ways:

  1. Native CSS doesn't support this kind of nesting
  2. The output is completely malformed
@peteduel
Copy link

The preprocessor doesn't get this right as the closing brace is lost.

Though new native nesting does support this syntax if you try this is the latest firefox, for example:

html {
    letter-spacing: 1px;
    @media (min-width: 400px) {letter-spacing: 2px;}
    @media (min-width: 800px) {letter-spacing: 3px;}
    @media (min-width: 1200px) {letter-spacing: 4px;}
}

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

No branches or pull requests

2 participants