| Index: lib/filterClasses.js |
| diff --git a/lib/filterClasses.js b/lib/filterClasses.js |
| index 417e4d8df3cc13fdd4daa0d6ac14489ad73b92cb..21db77c85832ec19368cadb5dabcbfe1b1800425 100644 |
| --- a/lib/filterClasses.js |
| +++ b/lib/filterClasses.js |
| @@ -359,7 +359,7 @@ ActiveFilter.prototype = extend(Filter, { |
| /** |
| * Map containing domains that this filter should match on/not match |
| * on or null if the filter should match on all domains |
| - * @type {Object} |
| + * @type {?Map.<string,boolean>} |
| */ |
| get domains() |
| { |
| @@ -383,11 +383,9 @@ ActiveFilter.prototype = extend(Filter, { |
| if (list.length == 1 && list[0][0] != "~") |
| { |
| // Fast track for the common one-domain scenario |
| - domains = Object.create(null); |
| - domains[""] = false; |
| if (this.ignoreTrailingDot) |
| list[0] = list[0].replace(/\.+$/, ""); |
| - domains[list[0]] = true; |
| + domains = new Map([["", false], [list[0], true]]); |
| } |
| else |
| { |
| @@ -413,12 +411,12 @@ ActiveFilter.prototype = extend(Filter, { |
| } |
| if (!domains) |
| - domains = Object.create(null); |
| + domains = new Map(); |
| - domains[domain] = include; |
| + domains.set(domain, include); |
| } |
| if (domains) |
| - domains[""] = !hasIncludes; |
| + domains.set("", !hasIncludes); |
| } |
| this.domainSource = null; |
| @@ -458,7 +456,7 @@ ActiveFilter.prototype = extend(Filter, { |
| // If the document has no host name, match only if the filter |
| // isn't restricted to specific domains |
| if (!docDomain) |
| - return this.domains[""]; |
| + return this.domains.get(""); |
| if (this.ignoreTrailingDot) |
| docDomain = docDomain.replace(/\.+$/, ""); |
| @@ -466,15 +464,16 @@ ActiveFilter.prototype = extend(Filter, { |
| while (true) |
| { |
| - if (docDomain in this.domains) |
| - return this.domains[docDomain]; |
| + let isDomainIncluded = this.domains.get(docDomain); |
| + if (typeof isDomainIncluded != "undefined") |
| + return isDomainIncluded; |
| let nextDot = docDomain.indexOf("."); |
| if (nextDot < 0) |
| break; |
| docDomain = docDomain.substr(nextDot + 1); |
| } |
| - return this.domains[""]; |
| + return this.domains.get(""); |
| }, |
| /** |
| @@ -484,16 +483,16 @@ ActiveFilter.prototype = extend(Filter, { |
| */ |
| isActiveOnlyOnDomain(docDomain) |
| { |
| - if (!docDomain || !this.domains || this.domains[""]) |
| + if (!docDomain || !this.domains || this.domains.get("")) |
| return false; |
| if (this.ignoreTrailingDot) |
| docDomain = docDomain.replace(/\.+$/, ""); |
| docDomain = docDomain.toUpperCase(); |
| - for (let domain in this.domains) |
| + for (let [domain, isIncluded] of this.domains) |
| { |
| - if (this.domains[domain] && domain != docDomain) |
| + if (isIncluded && domain != docDomain) |
| { |
| if (domain.length <= docDomain.length) |
| return false; |
| @@ -513,7 +512,7 @@ ActiveFilter.prototype = extend(Filter, { |
| isGeneric() |
| { |
| return !(this.sitekeys && this.sitekeys.length) && |
| - (!this.domains || this.domains[""]); |
| + (!this.domains || this.domains.get("")); |
| }, |
| /** |