bulma icon indicating copy to clipboard operation
bulma copied to clipboard

null checks on !default variables are useless because they can't be null

Open FunctionDJ opened this issue 2 years ago • 0 comments

This is about Bulma.

Overview of the problem

This is about the Bulma CSS framework I'm using Bulma version [0.9.3] This is a Sass issue: I'm using version [x.x.x] --> I am sure this issue is not a duplicate? -->

Description

Consider this code from Bulma's SASS source: https://github.com/jgthms/bulma/blob/e5ee280b32c2bac94e363013777ff41d1a9ed2dc/sass/helpers/spacing.sass#L9-L31

$spacing-horizontal and $spacing-vertical have !default to make the customizable. From the SASS documentation:

To make this possible, Sass provides the !default flag. This assigns a value to a variable only if that variable isn’t defined or its value is null. Otherwise, the existing value will be used.

This means that both of these variables can never be null. If they get set to null outside, !default kicks in and overwrites that value. This means not only that the null checks are useless, but also that the generation of these classes can't be turned off, which was probably intended. I found this tweet which claims that an empty list / array works instead, but it creates an error when i try to compile it because at least in the current versions of SASS, an empty list is not equal to null: https://twitter.com/TweetsOfSumit/status/1346502700893155328?s=20&t=ZSeM19qMCyagy71ppkyNpw And even if that was true, it's not documented anywhere.

FunctionDJ avatar Apr 06 '22 13:04 FunctionDJ