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

[Bug] Applying on all pages when using @preprocessor stylus #1819

Open
zenstorage opened this issue Sep 12, 2024 · 5 comments
Open

[Bug] Applying on all pages when using @preprocessor stylus #1819

zenstorage opened this issue Sep 12, 2024 · 5 comments
Labels

Comments

@zenstorage
Copy link

Bug Report

Bug Description

When using the Stylus preprocessor with nested Media Queries, the styles are applied to all pages.

Screenshots

image

example.net:
image

example.com:
image

CSS Code

/* ==UserStyle==
@name           example.com
@namespace      github.com/openstyles/stylus
@version        1.0.0
@description    A new userstyle
@author         Me
@preprocessor   stylus
==/UserStyle== */

@-moz-document domain("example.com") {
        /* Only in example.com */
	h1 {
		border: 3px solid yellow;
	}
	
	@media (min-width: 600px) {
		/* Only in example.com */
		p {
			border: 3px solid blueviolet;
		}
		@media (min-height: 600px) {
			/* Styles above are applied to all pages */
			* {
				border: 3px solid red;
			}
		}
	}
}

System Information

  • OS: Windows
  • Browser: Firefox 130
  • Stylus Version: 1.5.51

Additional Context

@tophf
Copy link
Member

tophf commented Sep 12, 2024

It's a bug in stylus-lang @preprocessor. Its development is apparently abandoned and it has so many bugs that I wonder if we should remove it altogether...

@tophf tophf added the external label Sep 12, 2024
@tophf tophf changed the title [Bug] Applying on all pages [Bug] Applying on all pages when using @preprocessor stylus Sep 12, 2024
@zenstorage
Copy link
Author

Good to know, unfortunately it is abandoned, it has the most functions to use

@tophf
Copy link
Member

tophf commented Sep 12, 2024

Try workarounds in this list and if none helps, try reporting the problem in https://github.com/stylus/stylus/issues/

@zenstorage
Copy link
Author

Thanks, I will try

@pabli24
Copy link
Contributor

pabli24 commented Sep 12, 2024

For some reason this

@-moz-document domain("example.com") {
	@media (min-width: 10px) {
		p {
			color: #000
		}
		@media (min-height: 20px) {
			p {
				color: #fff
			}
		}
	}
}

compiles to

@-moz-document domain("example.com") {
@media (min-width: 10px) {
    p {
      color: #000;
    }
}
}
@media (min-width: 10px) and (min-height: 20px) {
  p {
    color: #fff;
  }
}

The easiest solution would be to not nest @media

@-moz-document domain("example.com") {
	@media (min-width: 10px) {
	    p {
	      color: #000
	    }
	}
	@media (min-width: 10px) and (min-height: 20px) {
	  p {
	    color: #fff
	  }
	}
}

I also noticed that more nesting "fixes" it :D

@document domain("example.com") {
	& {
		@media (min-width: 10px) {
			p {
				color: #000
			}
			@media (min-height: 20px) {
				p {
					color: #fff
				}
			}
		}
	}
}

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

No branches or pull requests

3 participants