ignore empty code only in global (non-targeted) sections
This commit is contained in:
		
							parent
							
								
									7c89f7b21d
								
							
						
					
					
						commit
						cb89be8682
					
				|  | @ -1,5 +1,5 @@ | |||
| /* eslint no-eq-null: 0, eqeqeq: [2, "smart"] */ | ||||
| /* global createCache db calcStyleDigest db tryRegExp styleCodeEmpty | ||||
| /* global createCache db calcStyleDigest db tryRegExp styleCodeEmpty styleSectionGlobal | ||||
|   getStyleWithNoCode msg sync uuidv4 */ | ||||
| /* exported styleManager */ | ||||
| 'use strict'; | ||||
|  | @ -445,7 +445,7 @@ const styleManager = (() => { | |||
|         excluded = true; | ||||
|       } | ||||
|       for (const section of data.sections) { | ||||
|         if (styleCodeEmpty(section.code)) { | ||||
|         if (styleSectionGlobal(section) && styleCodeEmpty(section.code)) { | ||||
|           continue; | ||||
|         } | ||||
|         const match = urlMatchSection(query, section); | ||||
|  | @ -612,15 +612,7 @@ const styleManager = (() => { | |||
|       return 'sloppy'; | ||||
|     } | ||||
|     // TODO: check for invalid regexps?
 | ||||
|     if ( | ||||
|       (!section.regexps || !section.regexps.length) && | ||||
|       (!section.urlPrefixes || !section.urlPrefixes.length) && | ||||
|       (!section.urls || !section.urls.length) && | ||||
|       (!section.domains || !section.domains.length) | ||||
|     ) { | ||||
|       return true; | ||||
|     } | ||||
|     return false; | ||||
|     return styleSectionGlobal(section); | ||||
|   } | ||||
| 
 | ||||
|   function createCompiler(compile) { | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| /* exported styleSectionsEqual styleCodeEmpty calcStyleDigest styleJSONseemsValid */ | ||||
| /* exported styleSectionsEqual styleCodeEmpty styleSectionGlobal calcStyleDigest styleJSONseemsValid */ | ||||
| 'use strict'; | ||||
| 
 | ||||
| function styleCodeEmpty(code) { | ||||
|  | @ -14,6 +14,14 @@ function styleCodeEmpty(code) { | |||
|   return false; | ||||
| } | ||||
| 
 | ||||
| /** Checks if section is global i.e. has no targets at all */ | ||||
| function styleSectionGlobal(section) { | ||||
|   return (!section.regexps || !section.regexps.length) && | ||||
|          (!section.urlPrefixes || !section.urlPrefixes.length) && | ||||
|          (!section.urls || !section.urls.length) && | ||||
|          (!section.domains || !section.domains.length); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * @param {Style} a - first style object | ||||
|  * @param {Style} b - second style object | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user