selector_unify

selector_unify($selector1, $selector2)

Unifies two selectors into a single selector that matches only elements matched by both input selectors. Returns null if there is no such selector.

Like the selector unification done for @extend, this doesn’t guarantee that the output selector will match all elements matched by both input selectors. For example, if .a .b is unified with .x .y, .a .x .b.y, .x .a .b.y will be returned, but .a.x .b.y will not. This avoids exponential output size while matching all elements that are likely to exist in practice.

Examples:

selector-unify(".a", ".b") => .a.b
selector-unify(".a .b", ".x .y") => .a .x .b.y, .x .a .b.y
selector-unify(".a.b", ".b.c") => .a.b.c
selector-unify("#a", "#b") => null

Returns A list of lists of strings representing the result of the unification, or null if no unification exists. This is in the same format as a selector returned by &.

Parameters:

  • $selector1 (String, List) The first selector to be unified. This can be either a string, a list of strings, or a list of lists of strings as returned by &.
  • $selector2 (String, List) The second selector to be unified. This can be either a string, a list of strings, or a list of lists of strings as returned by &.

Returns:

  • (List, Null) A list of lists of strings representing the result of the unification, or null if no unification exists. This is in the same format as a selector returned by &.
doc_Sass
2016-11-11 13:09:24
Comments
Leave a Comment

Please login to continue.