Skip to content

Commit

Permalink
refactor(selector.nest()): remove null and empty list ().
Browse files Browse the repository at this point in the history
  • Loading branch information
sciborrudnicki committed Oct 5, 2023
1 parent 9fb0fca commit 942e6b3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion selector/_selector.nest.function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@use 'sass:selector';

// Functions.
@use '../list/remove/remove.value.function';
@use 'selector.replace-parent.function' as *;

// Status: DONE
Expand All @@ -11,8 +12,15 @@
// @arbitrary `$selectors...` Selectors also with parent selectors.
// @returns The return value are selectors built of `$selectors`.
@function nest($selectors...) {
$selectors: remove.value($selectors, null, ());
@return replace-parent(
selector.nest(list.set-nth($selectors, 1, replace-parent(list.nth($selectors, 1), selector))...),
selector.nest(
list.set-nth(
$selectors,
1,
replace-parent(list.nth($selectors, 1), selector)
)...
),
placeholder
);
}
Expand All @@ -35,3 +43,7 @@

// @debug nest(card, ('&-header', '&-body', '&-footer')); // card-header, card-body, card-footer
// @debug nest('&card', ('&-header', '&-body', '&-footer')); // &card-header, &card-body, &card-footer

// remove null, ()
// @debug nest('&card', ('&-header', '&-body', '&-footer'), null); // &card-header, &card-body, &card-footer
// @debug nest('&card', (), ('&-header', '&-body', '&-footer'), null); // &card-header, &card-body, &card-footer

0 comments on commit 942e6b3

Please sign in to comment.