From 3a5c413cab6024d48b86a5a9d370b04caf22c2d2 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 14 Jul 2014 02:14:13 -0400 Subject: [PATCH] make lighter cosmetic filters: use tagname only when no id, class --- js/element-picker.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/element-picker.js b/js/element-picker.js index 6b04878b9..251c15db5 100644 --- a/js/element-picker.js +++ b/js/element-picker.js @@ -258,7 +258,7 @@ var pickerRootDistance = function(elem) { /******************************************************************************/ var highlightElements = function(elems, force) { - // To make mouse mouce handler more efficient + // To make mouse move handler more efficient if ( !force && elems.length === targetElements.length ) { if ( elems.length === 0 || elems[0] === targetElements[0] ) { return; @@ -347,7 +347,7 @@ var cosmeticFilterFromElement = function(elem) { return; } var tagName = elem.tagName.toLowerCase(); - var prefix = '##' + tagName; + var prefix = ''; var suffix = []; var v; @@ -368,6 +368,10 @@ var cosmeticFilterFromElement = function(elem) { suffix.push('.', v.join('.')); } + if ( suffix.length === 0 ) { + prefix = tagName; + } + // Attributes (depends on tag name) var attributes = [], attr; switch ( tagName ) { @@ -401,7 +405,7 @@ var cosmeticFilterFromElement = function(elem) { } } - return prefix + suffix.join(''); + return '##' + prefix + suffix.join(''); }; /******************************************************************************/