functions.scss 666 B

123456789101112131415161718192021
  1. // 合并 map
  2. @function map-deep-merge($parent-map, $child-map) {
  3. $result: $parent-map;
  4. @each $key, $child in $child-map {
  5. $parent-has-key: map-has-key($result, $key);
  6. $parent-value: map-get($result, $key);
  7. $parent-type: type-of($parent-value);
  8. $child-type: type-of($child);
  9. $parent-is-map: $parent-type == map;
  10. $child-is-map: $child-type == map;
  11. @if (not $parent-has-key) or ($parent-type != $child-type) or (not ($parent-is-map and $child-is-map)) {
  12. $result: map-merge($result, ($key: $child));
  13. } @else {
  14. $result: map-merge($result, ($key: map-deep-merge($parent-value, $child)));
  15. }
  16. }
  17. @return $result;
  18. }
  19. ;