S
S
Sergey2019-02-12 11:20:28
Sass
Sergey, 2019-02-12 11:20:28

What is this admixture for?

I found the following mixin in the Bootstrap sources:

// Ascending
// Used to evaluate Sass maps like our grid breakpoints.
@mixin _assert-ascending($map, $map-name) {
  $prev-key: null;
  $prev-num: null;
  @each $key, $num in $map {
    @if $prev-num == null or unit($num) == "%" {
      // Do nothing
    } @else if not comparable($prev-num, $num) {
      @warn "Potentially invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} whose unit makes it incomparable to #{$prev-num}, the value of the previous key '#{$prev-key}' !";
    } @else if $prev-num >= $num {
      @warn "Invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} which isn't greater than #{$prev-num}, the value of the previous key '#{$prev-key}' !";
    }
    $prev-key: $key;
    $prev-num: $num;
  }
}

Can you explain what this admixture is for? As I understand it, this is something related to sorting keys in sass maps.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2019-02-12
@Flying

This code checks that the elements in $mapare arranged in ascending order of values

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question