We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
So, sometimes we can have a source map which built with other custom maps. Sometimes some of the them may be an empty.
Data:
$map1: ( x: (), y: (2: 2) ); $map2: ( x: (1: 1), y: (3: 3) ); // Result ( x: (), y: (2: 2, 3: 3) ) // Expected ( x: (1: 1), y: (2: 2, 3: 3) );
Solution:
// Add small helper function @function convert-empty-list-to-map($source) { @if ( type-of($source) == list and length($source) == 0 ) { @return map-remove((x:x), x); } @return $source; }; // Updated function @function recursive-map-merge($source1, $source2 ) { @if ( type-of($source1) == map or ( type-of($source1) == list and length($source1) == 0) ) and ( type-of($source2) == map or ( type-of($source2) == list and length($source2) == 0) ) { // Check both maps and convert to [map] when empty $map1: convert-empty-list-to-map($source1); $map2: convert-empty-list-to-map($source2); $result: $map1; @each $key, $value in $map2 { // Check both childs and convert to map when empty $map1-child: convert-empty-list-to-map(map-get($map1, $key)); $map2-child: convert-empty-list-to-map($value); @if ( type-of($map1-child) == map and type-of($map2-child) == map ) { $result: map-merge($result, ($key: recursive-map-merge($map1-child, $map2-child))); } @else { $result: map-merge($result, ($key: $value)); } } @return $result; } @else { @warn "recursive-map-merge() expects it\'s parameters to be map types!"; @return null; } }
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to my attention! I'd identify this as a bug. Do you mind opening a pull request with your proposed change?
Sorry, something went wrong.
No branches or pull requests
So, sometimes we can have a source map which built with other custom maps. Sometimes some of the them may be an empty.
Data:
Solution:
The text was updated successfully, but these errors were encountered: