Skip to content

The combination of a global and a local selector should be a local selector #73

Closed
@jantimon

Description

@jantimon

html { a_value: some-value; } is not local - and therefore css-modules/postcss-modules-local-by-default marks them as not pure.

However if only local selectors are inside that non local selector, it is still fine as all declarations are wrapped by a local selector.
The following examples are pure:

html { 
  .foo { 
     a_value: some-value; 
  } 
}
html { 
 .foo { a_value: some-value; } 
 .bar { a_value: some-value; }
}

As soon as a non local declaration gets added it still be marked as non pure.
The following examples are NOT pure:

html { 
 .foo { a_value: some-value; } 
 button { a_value: some-value; } 
}
html { 
  .foo { 
     a_value: some-value; 
  } 
  color: red;
}
html { 
 .foo { a_value: some-value; } 
 button { 
   color: red;
   .bar { a_value: some-value; }
  } 
}

Especially the second case will be tricky to implement in the current code as by now only the selectors are analyzed to find out wether the code is pure or not.

In future we would have to iterate over every declaration and check for its surrounding selector wether it is pure or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions