2018-09-01 22:35:20 +02:00
|
|
|
For example, suppose you want to write a selector that matches the outer
|
|
|
|
selector *and* an element selector. You could write a mixin like this one that
|
|
|
|
uses the [`selector-unify()` function][] to combine `&` with a user's selector.
|
|
|
|
|
|
|
|
[`selector-unify()` function]: ../functions/selectors#selector-unify
|
|
|
|
|
|
|
|
<% example do %>
|
2018-10-23 22:42:40 +02:00
|
|
|
@mixin unify-parent($child) {
|
|
|
|
@at-root #{selector-unify(&, $child)} {
|
|
|
|
@content;
|
|
|
|
}
|
2018-09-01 22:35:20 +02:00
|
|
|
}
|
|
|
|
|
2018-10-23 22:42:40 +02:00
|
|
|
.wrapper .field {
|
|
|
|
@include unify-parent("input") {
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
@include unify-parent("select") {
|
|
|
|
/* ... */
|
|
|
|
}
|
2018-09-01 22:35:20 +02:00
|
|
|
}
|
2018-10-23 22:42:40 +02:00
|
|
|
===
|
|
|
|
@mixin unify-parent($child)
|
|
|
|
@at-root #{selector-unify(&, $child)}
|
|
|
|
@content
|
2018-09-01 22:35:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-23 22:42:40 +02:00
|
|
|
.wrapper .field
|
|
|
|
@include unify-parent("input")
|
|
|
|
/* ...
|
2018-09-01 22:35:20 +02:00
|
|
|
|
2018-10-23 22:42:40 +02:00
|
|
|
@include unify-parent("select")
|
|
|
|
/* ...
|
2018-09-01 22:35:20 +02:00
|
|
|
<% end %>
|