Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/filterClasses.js

Issue 29383960: Issue 3143 - Filter elements with :-abp-has() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Validate the syntax, remove unused flags Created April 10, 2017, 1:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 981
982 // We don't allow ElemHide filters which have any empty domains. 982 // We don't allow ElemHide filters which have any empty domains.
983 // Note: The ElemHide.prototype.domainSeparator is duplicated here, if that 983 // Note: The ElemHide.prototype.domainSeparator is duplicated here, if that
984 // changes this must be changed too. 984 // changes this must be changed too.
985 if (domain && /(^|,)~?(,|$)/.test(domain)) 985 if (domain && /(^|,)~?(,|$)/.test(domain))
986 return new InvalidFilter(text, "filter_invalid_domain"); 986 return new InvalidFilter(text, "filter_invalid_domain");
987 987
988 if (isException) 988 if (isException)
989 return new ElemHideException(text, domain, selector); 989 return new ElemHideException(text, domain, selector);
990 990
991 if (selector.indexOf("[-abp-properties=") != -1) 991 if ((selector.indexOf("[-abp-properties=") != -1) ||
992 (selector.indexOf("[-abp-selector=") != -1))
992 { 993 {
993 // Element hiding emulation filters are inefficient so we need to make sure 994 // Element hiding emulation filters are inefficient so we need to make sure
994 // that they're only applied if they specify active domains 995 // that they're only applied if they specify active domains
995 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) 996 if (!/,[^~][^,.]*\.[^,]/.test("," + domain))
996 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); 997 return new InvalidFilter(text, "filter_elemhideemulation_nodomain");
997 998
998 return new ElemHideEmulationFilter(text, domain, selector); 999 return new ElemHideEmulationFilter(text, domain, selector);
999 } 1000 }
1000 1001
1001 return new ElemHideFilter(text, domain, selector); 1002 return new ElemHideFilter(text, domain, selector);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 */ 1048 */
1048 function ElemHideEmulationFilter(text, domains, selector) 1049 function ElemHideEmulationFilter(text, domains, selector)
1049 { 1050 {
1050 ElemHideBase.call(this, text, domains, selector); 1051 ElemHideBase.call(this, text, domains, selector);
1051 } 1052 }
1052 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1053 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1053 1054
1054 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1055 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1055 type: "elemhideemulation" 1056 type: "elemhideemulation"
1056 }); 1057 });
OLDNEW

Powered by Google App Engine
This is Rietveld