Created
April 17, 2019 14:10
-
-
Save tomhodgins/2faf4683f866921839b53f2b0662b26b to your computer and use it in GitHub Desktop.
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
// includes anywhere (does this now) | |
function selector(string, list) { | |
list = list || all(); | |
if (list.cssRules) { | |
list = [list]; | |
} | |
return list.map(function(stylesheet) { | |
return filter( | |
stylesheet, | |
function(rule) { | |
return rule.selectorText && rule.selectorText.indexOf(string) !== -1; | |
} | |
); | |
}).filter(hasRules); | |
} | |
// strictly matches (doesnt do this now) | |
function selector(string, list) { | |
list = list || all(); | |
if (list.cssRules) { | |
list = [list]; | |
} | |
return list.map(function(stylesheet) { | |
return filter( | |
stylesheet, | |
function(rule) { | |
return rule.selectorText === string; | |
} | |
); | |
}).filter(hasRules); | |
} | |
// both (should it be like this?) | |
function selector(string, list, option) { | |
list = list || all(); | |
option = option || false | |
if (list.cssRules) { | |
list = [list]; | |
} | |
return list.map(function(stylesheet) { | |
return filter( | |
stylesheet, | |
function(rule) { | |
if (option) { | |
return rule.selectorText === string | |
} else { | |
return rule.selectorText && rule.selectorText.indexOf(string) !== -1 | |
} | |
} | |
); | |
}).filter(hasRules); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment