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

Side by Side Diff: lib/filterClasses.js

Issue 29788574: Noissue - Remove ElemHideBase.selectorDomains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created May 24, 2018, 3 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 | « no previous file | no next file » | 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 * restricted to 989 * restricted to
990 * @param {string} selector CSS selector for the HTML elements that should be 990 * @param {string} selector CSS selector for the HTML elements that should be
991 * hidden 991 * hidden
992 * @constructor 992 * @constructor
993 * @augments ActiveFilter 993 * @augments ActiveFilter
994 */ 994 */
995 function ElemHideBase(text, domains, selector) 995 function ElemHideBase(text, domains, selector)
996 { 996 {
997 ActiveFilter.call(this, text, domains || null); 997 ActiveFilter.call(this, text, domains || null);
998 998
999 if (domains)
1000 {
1001 this.selectorDomains = domains.replace(/,~[^,]+/g, "")
1002 .replace(/^~[^,]+,?/, "").toLowerCase();
1003 }
1004
1005 // Braces are being escaped to prevent CSS rule injection. 999 // Braces are being escaped to prevent CSS rule injection.
1006 this.selector = selector.replace("{", "\\7B ").replace("}", "\\7D "); 1000 this.selector = selector.replace("{", "\\7B ").replace("}", "\\7D ");
1007 } 1001 }
1008 exports.ElemHideBase = ElemHideBase; 1002 exports.ElemHideBase = ElemHideBase;
1009 1003
1010 ElemHideBase.prototype = extend(ActiveFilter, { 1004 ElemHideBase.prototype = extend(ActiveFilter, {
1011 /** 1005 /**
1012 * @see ActiveFilter.domainSeparator 1006 * @see ActiveFilter.domainSeparator
1013 */ 1007 */
1014 domainSeparator: ",", 1008 domainSeparator: ",",
1015 1009
1016 /** 1010 /**
1017 * @see ActiveFilter.ignoreTrailingDot 1011 * @see ActiveFilter.ignoreTrailingDot
1018 */ 1012 */
1019 ignoreTrailingDot: false, 1013 ignoreTrailingDot: false,
1020 1014
1021 /** 1015 /**
1022 * Host names or domains the filter should be restricted to (can be null for
1023 * no restriction)
1024 * @type {?string}
1025 */
1026 selectorDomains: null,
1027 /**
1028 * CSS selector for the HTML elements that should be hidden 1016 * CSS selector for the HTML elements that should be hidden
1029 * @type {string} 1017 * @type {string}
1030 */ 1018 */
1031 selector: null 1019 selector: null,
1020
1021 /**
1022 * Host names or domains the filter should be restricted to (can be null for
1023 * no restriction)
1024 * @type {?Array.<string>}
1025 */
1026 get selectorDomains()
1027 {
1028 let {domains} = this;
1029 if (!domains)
1030 return null;
1031
1032 return [...domains].filter(([domain, isIncluded]) => isIncluded)
1033 .map(([domain]) => domain.toLowerCase());
1034 }
1032 }); 1035 });
1033 1036
1034 /** 1037 /**
1035 * Creates an element hiding filter from a pre-parsed text representation 1038 * Creates an element hiding filter from a pre-parsed text representation
1036 * 1039 *
1037 * @param {string} text same as in Filter() 1040 * @param {string} text same as in Filter()
1038 * @param {string} [domains] 1041 * @param {string} [domains]
1039 * domains part of the text representation 1042 * domains part of the text representation
1040 * @param {string} [type] 1043 * @param {string} [type]
1041 * rule type, either empty or @ (exception) or ? (emulation rule) 1044 * rule type, either empty or @ (exception) or ? (emulation rule)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 */ 1116 */
1114 function ElemHideEmulationFilter(text, domains, selector) 1117 function ElemHideEmulationFilter(text, domains, selector)
1115 { 1118 {
1116 ElemHideBase.call(this, text, domains, selector); 1119 ElemHideBase.call(this, text, domains, selector);
1117 } 1120 }
1118 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1121 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1119 1122
1120 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1123 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1121 type: "elemhideemulation" 1124 type: "elemhideemulation"
1122 }); 1125 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld