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

Wrong compiling for :is, :has, :where #2750

Open
cyfung1031 opened this issue Jan 11, 2023 · 7 comments
Open

Wrong compiling for :is, :has, :where #2750

cyfung1031 opened this issue Jan 11, 2023 · 7 comments

Comments

@cyfung1031
Copy link

cyfung1031 commented Jan 11, 2023

:is(section.is-styling, aside.is-styling, footer.is-styling) {
  a {
    color: red;
  }
}

is wrongly composed as

:is(section.is-styling a, aside.is-styling a, footer.is-styling) a{
  color: red;
}

Screen Shot 2023-01-11 at 16 50 35

@cyfung1031
Copy link
Author

https://stylus-lang.com/try.html

Same result in official playground.
Screen Shot 2023-01-11 at 18 19 54

@cyfung1031
Copy link
Author

Currently I am doing this way to ensure the correct compiling output.

buildL4(type, args...) {
    st1 = join('', ':', type, '(', join('\, ', args), ')')
    selector(st1)
}

Screen Shot 2023-01-11 at 18 57 02

Screen Shot 2023-01-11 at 18 57 07

@EmmanuelBeziat
Copy link

This is still an issue today, even with simpler examples:

.menu-item:is(:hover, :focus)
    color red

Should render:

.menu-item:is(:hover, :focus) { color: red; }

But render this instead:

.menu-item:is(:hover, .menu-item :focus) { color: red; }

@kyohei-23
Copy link

This problem also appears to occur when :not is used

From this I can infer that the problem is apparently occurring in pseudo-classes that accept a list of selectors in general.

image

@iChenLei
Copy link
Member

iChenLei commented Sep 2, 2023

Hello, everyone. I don't have enough bandwidth to fix it, so you can use @css as a workaround.

kyohei-23 added a commit to kyohei-23/stylus that referenced this issue Sep 2, 2023
@cyfung1031
Copy link
Author

cyfung1031 commented Sep 2, 2023

Hello, everyone. I don't have enough bandwidth to fix it, so you can use @css as a workaround.

can use this function to avoid the problem, but I just want it to be fixed officially.

buildL4(type, args...) {
    st1 = join('', ':', type, '(', join('\, ', args), ')')
    selector(st1)
}

{buildL4('is', 'section.is-styling', 'aside.is-styling', 'footer.is-styling')} {
  a {
    color: red;
  }
}


.is-styling{buildL4('is', 'section', 'aside', 'footer')} {
  b {
    color: blue;
  }
}

It is proven working since I created this issue.

@idangoldman
Copy link

@iChenLei, can you please point me in the direction where the codebase might break on this issue? I want to try and fix it.

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

5 participants