Skip to content

[OUDS] Investigate and improve :has and :is usage #3661

Description

@MaxLardenois

We use the pseudo-classes :has and :is but we need to exploit them as much as possible.

Sometimes we have this kind of code

  &:has(input:hover),
  &:has(input:active),
  &:has(input:focus-visible) {
    background-color: transparent;
    outline: 0;
    box-shadow: none;
  }

Which could be simplified to

  &:has(input:is(hover, :active, :focus-visible)) {
    background-color: transparent;
    outline: 0;
    box-shadow: none;
  }

This would reduce the selectors size in output CSS.

Another improvement could be to merge enclosed selectors into a :is so that the enclosing selector is not repeated for example

.chip-interactive {
  svg,
  img,
  .icon {
    //...
  }
}

should be

.chip-interactive {
  :is(svg, img, .icon) {
    //...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Enhancement.

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions