Skip to content

Add a migrator for plain-CSS if() #283

@nex3

Description

@nex3

See sass/sass#3886. The proposal as currently written involves removing Sass's if() function and syntax and adding a sass() condition to the plain-CSS if() syntax instead. A migrator for this would encompass two changes:

  1. Converting direct calls to the Sass if() function into calls to the plain-CSS if(). For example,

    if(
      map.has-key($tokens, $token),
      map.get($tokens, $token),
      $fallback
    )

    would become

    if(
      sass(map.has-key($tokens, $token)): map.get($tokens, $token);
      else: $fallback;
    )

    For the special case where the else branch returns null, it can be omitted entirely.

  2. Converting references to if as a first-class function to references to a new custom function. For example,

    $if: meta.get-function("if");

    would become:

    @function -if($condition, $if-true, $if-false) {
      @return if(sass($condition): $if-true; else: $if-false);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions