element picker: more sensible implementation ctrl-clicking a filter candidate

This commit is contained in:
gorhill 2016-04-16 13:21:48 -04:00
parent e475e1ece8
commit c68ff1487a
1 changed files with 10 additions and 1 deletions

View File

@ -853,10 +853,19 @@ var candidateFromFilterChoice = function(filterChoice) {
} }
// For net filters there no such thing as a path // For net filters there no such thing as a path
if ( filter.lastIndexOf('##', 0) !== 0 || filterChoice.modifier ) { if ( filter.lastIndexOf('##', 0) !== 0 ) {
return filter; 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 // Return path: the target element, then all siblings prepended
var selector = []; var selector = [];
for ( ; slot < filters.length; slot++ ) { for ( ; slot < filters.length; slot++ ) {