'In Sass, how to reference two parent classes with ampersand to compound with an element?

Using the method found here, it works, but not for two parent classes.

For instance:

.one, .two {
  @at-root a#{&} {
    color: blue;
  }
}

Produces:

a.one, .two {
  color: blue;
}

Rather than the intended:

a.one, a.two {
  color: blue;
}

Is there any way to get the intended result using a similar method?



Solution 1:[1]

This is now possible in pure CSS with the :is() matching pseudo-class:

.one, .two {
  &:is(a) {
    color: blue;
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zessx