Skip to content

Commit

Permalink
Throw error when rule type is not supported
Browse files Browse the repository at this point in the history
fixes #82
  • Loading branch information
fb55 committed Mar 9, 2018
1 parent da7318e commit 56dbbe6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ function isTraversal(t){
function compileRules(rules, options, context){
return rules.reduce(function(func, rule){
if(func === falseFunc) return func;

if(!(rule.type in Rules)){
throw new Error(
"Rule type " + rule.type + " is not supported by css-select"
);
}

return Rules[rule.type](func, rule, options, context);
}, (options && options.rootFunc) || trueFunc);
}
Expand Down

0 comments on commit 56dbbe6

Please sign in to comment.