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: Support -adb-properties inside :has(). Created March 22, 2017, 1:45 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/content/elemHideEmulation.js ('k') | test/browser/elemHideEmulation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 980
981 // We don't allow ElemHide filters which have any empty domains. 981 // We don't allow ElemHide filters which have any empty domains.
982 // Note: The ElemHide.prototype.domainSeparator is duplicated here, if that 982 // Note: The ElemHide.prototype.domainSeparator is duplicated here, if that
983 // changes this must be changed too. 983 // changes this must be changed too.
984 if (domain && /(^|,)~?(,|$)/.test(domain)) 984 if (domain && /(^|,)~?(,|$)/.test(domain))
985 return new InvalidFilter(text, "filter_invalid_domain"); 985 return new InvalidFilter(text, "filter_invalid_domain");
986 986
987 if (isException) 987 if (isException)
988 return new ElemHideException(text, domain, selector); 988 return new ElemHideException(text, domain, selector);
989 989
990 if (selector.indexOf("[-abp-properties") != -1) 990 if ((selector.indexOf("[-abp-properties") != -1) ||
991 (selector.indexOf(":has(") != -1))
991 { 992 {
992 // Element hiding emulation filters are inefficient so we need to make sure 993 // Element hiding emulation filters are inefficient so we need to make sure
993 // that they're only applied if they specify active domains 994 // that they're only applied if they specify active domains
994 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) 995 if (!/,[^~][^,.]*\.[^,]/.test("," + domain))
995 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); 996 return new InvalidFilter(text, "filter_elemhideemulation_nodomain");
996 997
997 return new ElemHideEmulationFilter(text, domain, selector); 998 return new ElemHideEmulationFilter(text, domain, selector);
998 } 999 }
999 1000
1000 return new ElemHideFilter(text, domain, selector); 1001 return new ElemHideFilter(text, domain, selector);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 * Class for element hiding emulation filters 1041 * Class for element hiding emulation filters
1041 * @param {string} text see Filter() 1042 * @param {string} text see Filter()
1042 * @param {string} domains see ElemHideBase() 1043 * @param {string} domains see ElemHideBase()
1043 * @param {string} selector see ElemHideBase() 1044 * @param {string} selector see ElemHideBase()
1044 * @constructor 1045 * @constructor
1045 * @augments ElemHideBase 1046 * @augments ElemHideBase
1046 */ 1047 */
1047 function ElemHideEmulationFilter(text, domains, selector) 1048 function ElemHideEmulationFilter(text, domains, selector)
1048 { 1049 {
1049 ElemHideBase.call(this, text, domains, selector); 1050 ElemHideBase.call(this, text, domains, selector);
1051 this.cssPropFilter = (selector.indexOf("[-abp-properties") != -1);
1052 this.pseudoClassHas = (selector.indexOf(":has(") != -1);
1050 } 1053 }
1051 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1054 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1052 1055
1053 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1056 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1054 type: "elemhideemulation" 1057 type: "elemhideemulation",
1058 cssPropFilter: false,
1059 pseudoClassHas: false
1055 }); 1060 });
OLDNEW
« no previous file with comments | « chrome/content/elemHideEmulation.js ('k') | test/browser/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld