Index: lib/content/elemHideEmulation.js |
=================================================================== |
--- a/lib/content/elemHideEmulation.js |
+++ b/lib/content/elemHideEmulation.js |
@@ -13,16 +13,17 @@ |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
"use strict"; |
const {textToRegExp, filterToRegExp, splitSelector} = require("../common"); |
+const {indexOf} = require("../coreUtils"); |
let MIN_INVOCATION_INTERVAL = 3000; |
const MAX_SYNCHRONOUS_PROCESSING_TIME = 50; |
const abpSelectorRegexp = /:-abp-([\w-]+)\(/i; |
function getCachedPropertyValue(object, name, defaultValueFunc = () => {}) |
{ |
let value = object[name]; |
@@ -32,21 +33,17 @@ |
} |
/** 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. |
*/ |
function positionInParent(node) |
{ |
- let {children} = node.parentNode; |
- for (let i = 0; i < children.length; i++) |
- if (children[i] == node) |
- return i + 1; |
- return 0; |
+ return indexOf(node.parentNode.children, node) + 1; |
} |
function makeSelector(node, selector) |
{ |
if (node == null) |
return null; |
if (!node.parentElement) |
{ |