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

Incorrect compilation when extending %placeholder which has parent selectors inside #1862

Closed
ah-yu opened this issue Dec 29, 2022 · 2 comments
Assignees

Comments

@ah-yu
Copy link

ah-yu commented Dec 29, 2022

Hi sass team,

I am currently facing a problem in the process of migrating node-sass to sass. See the minimal reproducible example below.

// test.scss
%foo {
  &:hover {
    background-color: blue;
  }

  @media (min-width: 500px) {
    &,
    &:hover {
      background-color: red;
    }
  }
}

.bar {
  @extend %foo;
}

the compilation of sass

.bar:hover {
  background-color: blue;
}
@media (min-width: 500px) {
  /* .bar:hover is missing */
  .bar { 
    background-color: red;
  }
}

expected compilation(the output of node-sass)

.bar:hover {
  background-color: blue; 
}

@media (min-width: 500px) {
  .bar, .bar:hover {
    background-color: red; 
  } 
}
@connorskees
Copy link
Contributor

This is reproducible without @media or placeholder selectors:

a, a:hover {
    background-color: red;
}

// for comparison only. not necessary for reproduction
a:hover {
    background-color: blue;
}

b {
    @extend a;
}

will output

// missing b:hover
a, b,
a:hover {
  background-color: red;
}

// contains b:hover
a:hover, b:hover {
  background-color: blue;
}

Perhaps this is because b is being considered a super selector of b:hover and so b:hover is considered superfluous and is omitted?

image

ruby sass does emit the b:hover, which I would argue is the correct behavior.

@nex3 nex3 assigned nex3 and jathak and unassigned nex3 Jan 10, 2023
@jathak
Copy link
Member

jathak commented Jan 17, 2023

This is working as intended, as any element matching b:hover would inherently have to match b, and the second law of extend only requires the new selector's specificity to be greater or equal to the extender (b in this case), not the extendee.

@jathak jathak closed this as completed Jan 17, 2023
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

4 participants