Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4985,7 +4985,17 @@ protected function libMapMerge($args)
$map1 = $this->assertMap($args[0]);
$map2 = $this->assertMap($args[1]);

return [Type::T_MAP, array_merge($map1[1], $map2[1]), array_merge($map1[2], $map2[2])];
foreach ($map2[1] as $i2 => $key2) {
foreach ($map1[1] as $i1 => $key1) {
if ($this->compileStringContent($this->coerceString($key1)) === $this->compileStringContent($this->coerceString($key2))) {
$map1[2][$i1] = $map2[2][$i2];
continue 2;
}
}
$map1[1][] = $map2[1][$i2];
$map1[2][] = $map2[2][$i2];
}
return $map1;
}

protected static $libKeywords = ['args'];
Expand Down
5 changes: 3 additions & 2 deletions tests/inputs/map.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ div {
bar: nth(nth($map, 1), 1);
}

$color: ("black" : #000000);
$color: ("black" : #000000, "grey" : #777777);
$color2: ("grey" : #888888, "white" : #ffffff);

@each $color_name, $color_value in $color {
@each $color_name, $color_value in map_merge( $color, $color2 ) {
.#{$color_name} {
background-color: $color_value !important;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/outputs/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ div {
bar: color; }
.black {
background-color: #000 !important; }
.grey {
background-color: #888 !important; }
.white {
background-color: #fff !important; }

div {
a: 1;
Expand Down
10 changes: 8 additions & 2 deletions tests/outputs_numbered/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ div {
div {
foo: color black;
bar: color; }
/* line 31, inputs/map.scss */
/* line 32, inputs/map.scss */
.black {
background-color: #000 !important; }
/* line 52, inputs/map.scss */
/* line 32, inputs/map.scss */
.grey {
background-color: #888 !important; }
/* line 32, inputs/map.scss */
.white {
background-color: #fff !important; }
/* line 53, inputs/map.scss */
div {
a: 1;
b: 2;
Expand Down