Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add isStandardSelector and reduce scope of isStandardRule
- Loading branch information
Showing
15 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import test from "tape" | ||
import isStandardSelector from "../isStandardSelector" | ||
|
||
test("isStandardSelector", t => { | ||
t.ok(isStandardSelector("a"), "type") | ||
t.ok(isStandardSelector(".a"), "class") | ||
t.ok(isStandardSelector("[a=a]"), "attribute") | ||
t.ok(isStandardSelector("*"), "universal") | ||
t.ok(isStandardSelector("a:last-child"), "pseudo-class") | ||
t.ok(isStandardSelector("a:not(.b)"), "pseudo-class with function") | ||
t.ok(isStandardSelector("a::after"), "pseudo-element") | ||
t.ok(isStandardSelector("a.b"), "compound") | ||
t.ok(isStandardSelector("a > b"), "complex") | ||
t.ok(isStandardSelector("a, b"), "list") | ||
t.notOk(isStandardSelector("#{50% - $n}"), "SCSS interpolation (id)") | ||
t.notOk(isStandardSelector(".n-#{$n}"), "SCSS interpolation (class)") | ||
t.notOk(isStandardSelector(".n-@{n}"), "Less interpolation") | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Check whether a selector is standard | ||
* | ||
* @param {string} selector | ||
* @return {boolean} If `true`, the selector is standard | ||
*/ | ||
export default function (selector) { | ||
|
||
// SCSS or Less interpolation | ||
if (/#{.+?}|@{.+?}|\$\(.+?\)/.test(selector)) { return false } | ||
|
||
return true | ||
} |