Sass - map.remove() function throwing error

Viewed 46

Sass throws the following error when trying to compile the below code...what am I doing wrong?

Dart Sass failed with this error: Error: expected "{".
   ╷
13 │ map.remove($map-1, "1");
   │                       ^
   ╵
// Modules
@include "sass:map";

$map-1: (
    "1": (
        "color": red,
    ),
    "2": (
        "color": orange,
    ),
);

map.remove($map-1, "1");
1 Answers

Sass-modules are imported with @use, not included (@include), unlike mixins.

When "removing" a variable from a map, the original map does not get altered, therefor the altered map has to be redeclared. For example:

Dart Sass:

@use "sass:map";

$map: (
  'foo': bar,
  'faz': foobar,
);

$nMap: map.remove($map, 'faz');

@debug $map; //("foo": bar, "faz": foobar)
@debug $nMap; //("foo": bar)

Node Sass & Dart Sass (currently):

$map: (
  'foo': bar,
  'faz': foobar,
);

$nMap: map-remove($map, 'faz');

@debug $map; //("foo": bar, "faz": foobar)
@debug $nMap; //("foo": bar)
Related