From c68ff1487a2847e3e89b60df0b7adb26691e5b67 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 16 Apr 2016 13:21:48 -0400 Subject: [PATCH] element picker: more sensible implementation ctrl-clicking a filter candidate --- src/js/scriptlets/element-picker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/js/scriptlets/element-picker.js b/src/js/scriptlets/element-picker.js index d0da4c52d..4e270ff14 100644 --- a/src/js/scriptlets/element-picker.js +++ b/src/js/scriptlets/element-picker.js @@ -853,10 +853,19 @@ var candidateFromFilterChoice = function(filterChoice) { } // For net filters there no such thing as a path - if ( filter.lastIndexOf('##', 0) !== 0 || filterChoice.modifier ) { + if ( filter.lastIndexOf('##', 0) !== 0 ) { return filter; } + // At this point, we have a cosmetic filter + + // Modifier means "target broadly". Hence: + // - Do not compute exact path. + // - Discard narrowing directives. + if ( filterChoice.modifier ) { + return filter.replace(/:nth-of-type\(\d+\)/, ''); + } + // Return path: the target element, then all siblings prepended var selector = []; for ( ; slot < filters.length; slot++ ) {