Support space-separated scopes in selector parser

This commit is contained in:
Kevin Sawicki
2013-04-17 17:28:49 -07:00
parent 3e5448b698
commit beeaa01d22
2 changed files with 25 additions and 1 deletions

View File

@@ -39,8 +39,26 @@ scope
}
}
path
= first:scope others:(_ scope)* {
return function(scopes) {
var scopeMatchers = [first];
for (var i = 0; i < others.length; i++)
scopeMatchers.push(others[i][1]);
var matcher = scopeMatchers.shift();
for (var i = 0; i < scopes.length; i++) {
if (matcher(scopes[i]))
matcher = scopeMatchers.shift();
if (!matcher)
return true;
}
return false;
}
}
expression
= scope
= path
/ "(" _ selector:selector _ ")" {
return selector;