Sass @if rule fails when expression is $my-variable == null

20 Views Asked by At

I am facing a strange behavior of Sass, when the expression of an @if-rule compares a variable with null.

$foo: null;

@debug $foo, $foo == null, $foo != null;

@if $foo == null {
    @debug "$foo is null";
}

@if $foo != null {
    @debug "$foo is not null";
}

Output:

DEBUG: null, true, false
DEBUG: $foo is not null

When $foo is null why the second @if-rule will be executed and not the first?

I am using the Dart Sass 1.57.1

1

There are 1 best solutions below

0
Karsten On

I just found out, that there was an hidden character in the @if-rule which causes it to be ignored.