minor code review

This commit is contained in:
gorhill 2015-12-07 11:06:06 -05:00
parent fd1ccebf41
commit 3b61f7d11d
2 changed files with 6 additions and 9 deletions

View File

@ -64,10 +64,6 @@ if ( injectedSelectors.length === 0 ) {
return;
}
// https://github.com/gorhill/uBlock/issues/1015
// Remove runtime prefix used to augment the specificity of our CSS rules.
var reSpecificityBooster = /^:root\s+/;
var matchedSelectors = [];
var selector;
@ -81,7 +77,9 @@ while ( i-- ) {
continue;
}
loggedSelectors[selector] = true;
matchedSelectors.push(selector.replace(reSpecificityBooster, ''));
// https://github.com/gorhill/uBlock/issues/1015
// Discard `:root ` prefix.
matchedSelectors.push(selector.slice(6));
}
vAPI.loggedSelectors = loggedSelectors;

View File

@ -693,9 +693,6 @@ var cosmeticFilterFromTarget = function(nid, coarseSelector) {
/******************************************************************************/
var cosmeticFilterMapper = (function() {
// https://github.com/gorhill/uBlock/issues/1015
var reSpecificityBooster = /^:root\s+/;
// https://github.com/gorhill/uBlock/issues/546
var matchesFnName;
if ( typeof document.body.matches === 'function' ) {
@ -717,7 +714,9 @@ var cosmeticFilterMapper = (function() {
var i = selectors.length;
var selector, nodes, j, node;
while ( i-- ) {
selector = selectors[i].replace(reSpecificityBooster, '');
// https://github.com/gorhill/uBlock/issues/1015
// Discard `:root ` prefix.
selector = selectors[i].slice(6);
if ( filterMap.has(rootNode) === false && rootNode[matchesFnName](selector) ) {
filterMap.set(rootNode, selector);
hideNode(node);