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

Unified Diff: lib/content/elemHideEmulation.js

Issue 29714606: Issue 6505 - Make selector parameter in makeSelector optional (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 5, 2018, 7:57 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/content/elemHideEmulation.js
===================================================================
--- a/lib/content/elemHideEmulation.js
+++ b/lib/content/elemHideEmulation.js
@@ -31,17 +31,17 @@
{
let {children} = node.parentNode;
for (let i = 0; i < children.length; i++)
if (children[i] == node)
return i + 1;
return 0;
}
-function makeSelector(node, selector)
+function makeSelector(node, selector = "")
{
if (node == null)
return null;
if (!node.parentElement)
{
let newSelector = ":root";
if (selector)
newSelector += " > " + selector;
@@ -262,17 +262,17 @@
return this._innerSelectors.some(
selector => selector.maybeDependsOnAttributes
);
},
*getSelectors(prefix, subtree, styles)
{
for (let element of this.getElements(prefix, subtree, styles))
- yield [makeSelector(element, ""), element];
+ yield [makeSelector(element), element];
},
/**
* Generator function returning selected elements.
* @param {string} prefix the prefix for the selector.
* @param {Node} subtree the subtree we work on.
* @param {StringifiedStyle[]} styles the stringified style objects.
*/
@@ -306,17 +306,17 @@
ContainsSelector.prototype = {
requiresHiding: true,
dependsOnCharacterData: true,
*getSelectors(prefix, subtree, styles)
{
for (let element of this.getElements(prefix, subtree, styles))
- yield [makeSelector(element, ""), subtree];
+ yield [makeSelector(element), subtree];
},
*getElements(prefix, subtree, styles)
{
let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ?
prefix + "*" : prefix;
let elements = scopedQuerySelectorAll(subtree, actualPrefix);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld