aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/exclusions.coffee
diff options
context:
space:
mode:
authorStephen Blott2014-12-30 10:58:46 +0000
committerStephen Blott2014-12-30 11:56:28 +0000
commitb5c0b8da794407bc72f9f43da40422ed23e3899e (patch)
treeae9eebca8b4a6ae8665a568d0a2d4c37303efbd0 /background_scripts/exclusions.coffee
parentf7f0f8ec7500a4b2f6d39b7ca1e68cf59795d5d4 (diff)
downloadvimium-b5c0b8da794407bc72f9f43da40422ed23e3899e.tar.bz2
Exclusions; use querySelector to find sub-elements.
As @philc pointed out in #1366, this is less brittle.
Diffstat (limited to 'background_scripts/exclusions.coffee')
-rw-r--r--background_scripts/exclusions.coffee8
1 files changed, 5 insertions, 3 deletions
diff --git a/background_scripts/exclusions.coffee b/background_scripts/exclusions.coffee
index 62647bd8..55ced3ef 100644
--- a/background_scripts/exclusions.coffee
+++ b/background_scripts/exclusions.coffee
@@ -23,15 +23,17 @@ root.Exclusions = Exclusions =
rules: Settings.get("exclusionRules")
- # Merge the matching rules for URL, or null. If rules are provided, match against those.
+ # Merge the matching rules for URL, or null. In the normal case, we use the configured @rules; hence, this
+ # is the default. However, when called from the page popup, we are testing what effect candidate new rules
+ # would have on the current tab. In this case, the candidate rules are provided by the caller.
getRule: (url, rules=@rules) ->
matches = (rule for rule in rules when rule.pattern and 0 <= url.search(RegexpCache.get(rule.pattern)))
# An absolute exclusion rule (with no passKeys) takes priority.
for rule in matches
return rule unless rule.passKeys
- if matches.length
+ if 0 < matches.length
pattern: (rule.pattern for rule in matches).join " | " # Not used; for debugging only.
- passKeys: Utils.uniqueCharacters (rule.passKeys for rule in matches).join ""
+ passKeys: Utils.distinctCharacters (rule.passKeys for rule in matches).join ""
else
null