Fix case of unreported `:style` filters in logger

As reported by https://github.com/uBlock-user,
adding the two following filters:

example.com##div:style(width: 1016px !important)
example.com##div:style(display: block !important)

The logger would report only one of the filter when
navigating to https://example.com/
This commit is contained in:
Raymond Hill 2019-09-22 07:51:20 -04:00
parent 8c47fa1a3e
commit 22b390eb00
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 12 additions and 5 deletions

View File

@ -130,13 +130,15 @@ const processDeclarativeStyle = function(out) {
declarativeStyleStr = safeGroupSelectors(declarativeStyleDict.keys());
}
if ( document.querySelector(declarativeStyleStr) === null ) { return; }
for ( const [ selector, style ] of declarativeStyleDict ) {
for ( const selector of declarativeStyleDict.keys() ) {
if ( safeQuerySelector(selector) === null ) { continue; }
const raw = `##${selector}:style(${style})`;
out.push(raw);
for ( const style of declarativeStyleDict.get(selector) ) {
const raw = `##${selector}:style(${style})`;
out.push(raw);
loggedSelectors.add(raw);
}
declarativeStyleDict.delete(selector);
declarativeStyleStr = undefined;
loggedSelectors.add(raw);
}
};
@ -227,8 +229,13 @@ const handlers = {
for ( const entry of (changes.declarative || []) ) {
for ( let selector of entry[0].split(',\n') ) {
if ( entry[1] !== 'display:none!important;' ) {
declarativeStyleDict.set(selector, entry[1]);
declarativeStyleStr = undefined;
const styles = declarativeStyleDict.get(selector);
if ( styles === undefined ) {
declarativeStyleDict.set(selector, [ entry[1] ]);
continue;
}
styles.push(entry[1]);
continue;
}
if ( loggedSelectors.has(selector) ) { continue; }