You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
SCSS
44 lines
1.0 KiB
SCSS
@function selectorToString ($selector) {
|
|
$selector: inspect($selector);
|
|
$selector: str-slice($selector, 2, -2);
|
|
@return $selector;
|
|
}
|
|
|
|
// 选择器是否包含修饰符连接符 --
|
|
@function containsModifier($selector) {
|
|
$selector: selectorToString($selector);
|
|
|
|
@if (str-index($selector, $modifier-separator)) {
|
|
@return true;
|
|
} @else {
|
|
@return false;
|
|
}
|
|
}
|
|
|
|
// 选择器是否包含状态前缀 .is
|
|
@function containWhenFlag($selector) {
|
|
$selector: selectorToString($selector);
|
|
|
|
@if (str-index($selector, '.' + $state-prefix)) {
|
|
@return true;
|
|
} @else {
|
|
@return false;
|
|
}
|
|
}
|
|
|
|
// 选择器是否包含伪类选择器
|
|
@function containPseudoClass($selector) {
|
|
$selector: selectorToString($selector);
|
|
|
|
@if (str-index($selector, ':')) {
|
|
@return true;
|
|
} @else {
|
|
@return false;
|
|
}
|
|
}
|
|
|
|
// 选择器是否包含 -- 或 .is 或伪类选择器
|
|
@function hitAllSpecialNestRule($selector) {
|
|
@return containsModifier($selector) or containWhenFlag($selector) or containPseudoClass($selector);
|
|
}
|