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

Unified Diff: lib/content/elemHideEmulation.js

Issue 29517687: Issue 5079, 5516 - Use webpack for browser tests, modules for content scripts (Closed)
Patch Set: Addressed Wladimir's and Hubert's initial feedback Created Aug. 17, 2017, 12:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/common.js ('k') | package.json » ('j') | test_runner.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/content/elemHideEmulation.js
diff --git a/chrome/content/elemHideEmulation.js b/lib/content/elemHideEmulation.js
similarity index 93%
rename from chrome/content/elemHideEmulation.js
rename to lib/content/elemHideEmulation.js
index 447a479a6fc9e835291506c7a3127b809d17a4de..9c0539480cab195dcee47a84f6a10fd1093d2b05 100644
--- a/chrome/content/elemHideEmulation.js
+++ b/lib/content/elemHideEmulation.js
@@ -15,51 +15,13 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-/* globals filterToRegExp */
-
"use strict";
+const {filterToRegExp, splitSelector} = require("common");
+
const MIN_INVOCATION_INTERVAL = 3000;
const abpSelectorRegexp = /:-abp-([\w-]+)\(/i;
-function splitSelector(selector)
-{
- if (selector.indexOf(",") == -1)
- return [selector];
-
- let selectors = [];
- let start = 0;
- let level = 0;
- let sep = "";
-
- for (let i = 0; i < selector.length; i++)
- {
- let chr = selector[i];
-
- if (chr == "\\") // ignore escaped characters
- i++;
- else if (chr == sep) // don't split within quoted text
- sep = ""; // e.g. [attr=","]
- else if (sep == "")
- {
- if (chr == '"' || chr == "'")
- sep = chr;
- else if (chr == "(") // don't split between parentheses
- level++; // e.g. :matches(div,span)
- else if (chr == ")")
- level = Math.max(0, level - 1);
- else if (chr == "," && level == 0)
- {
- selectors.push(selector.substring(start, i));
- start = i + 1;
- }
- }
- }
-
- selectors.push(selector.substring(start));
- return selectors;
-}
-
/** Return position of node from parent.
* @param {Node} node the node to find the position of.
* @return {number} One-based index like for :nth-child(), or 0 on error.
@@ -512,3 +474,5 @@ ElemHideEmulation.prototype = {
});
}
};
+
+exports.ElemHideEmulation = ElemHideEmulation;
« no previous file with comments | « lib/common.js ('k') | package.json » ('j') | test_runner.js » ('J')

Powered by Google App Engine
This is Rietveld