From 4afc0764d2d38f3551c7baabb12f787c596a3fd8 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 2 Nov 2019 11:45:18 -0400 Subject: [PATCH] Fix logic mistake in last commit Related commit: - https://github.com/gorhill/uBlock/commit/6d935c89257d2778beb8cc6ebd79b9f6aa64f8e0 Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/756 --- src/js/scriptlets/dom-survey-elements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/scriptlets/dom-survey-elements.js b/src/js/scriptlets/dom-survey-elements.js index 3f36183c4..e9ad5f568 100644 --- a/src/js/scriptlets/dom-survey-elements.js +++ b/src/js/scriptlets/dom-survey-elements.js @@ -87,19 +87,19 @@ const matched = new Set(); if ( simpleStr !== '') { for ( const node of candidates ) { + if ( Date.now() > tMax ) { return -1; } if ( node.matches(simpleStr) === false ) { continue; } candidates.delete(node); matched.add(node); if ( matched.size === 99 ) { break; } - if ( Date.now() > tMax ) { return -1; } } } if ( matched.size < 99 && complexStr !== '') { for ( const node of candidates ) { + if ( Date.now() > tMax ) { return -1; } if ( node.closest(complexStr) !== node ) { continue; } matched.add(node); if ( matched.size === 99 ) { break; } - if ( Date.now() > tMax ) { return -1; } } } return matched.size;