filterStyles: code cosmetics and a bug fix
This commit is contained in:
		
							parent
							
								
									e69b6482b7
								
							
						
					
					
						commit
						d843b4e23f
					
				| 
						 | 
				
			
			@ -160,15 +160,16 @@ function filterStyles({
 | 
			
		|||
  ) {
 | 
			
		||||
    return cachedStyles.list;
 | 
			
		||||
  }
 | 
			
		||||
  const blankHash = asHash && {
 | 
			
		||||
    disableAll: prefs.get('disableAll'),
 | 
			
		||||
    exposeIframes: prefs.get('exposeIframes'),
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  if (matchUrl && !URLS.supported(matchUrl)) {
 | 
			
		||||
    return asHash ? {} : [];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const blankHash = asHash && {
 | 
			
		||||
    disableAll: prefs.get('disableAll'),
 | 
			
		||||
    exposeIframes: prefs.get('exposeIframes'),
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // add \t after url to prevent collisions (not sure it can actually happen though)
 | 
			
		||||
  const cacheKey = ' ' + enabled + url + '\t' + id + matchUrl + '\t' + asHash + strictRegexp;
 | 
			
		||||
  const cached = cachedStyles.filters.get(cacheKey);
 | 
			
		||||
| 
						 | 
				
			
			@ -216,8 +217,8 @@ function filterStylesInternal({
 | 
			
		|||
  const styles = id === null
 | 
			
		||||
    ? cachedStyles.list
 | 
			
		||||
    : [cachedStyles.byId.get(id)];
 | 
			
		||||
  const filtered = asHash ? {} : [];
 | 
			
		||||
  if (!styles) {
 | 
			
		||||
  const filtered = asHash ? blankHash : [];
 | 
			
		||||
  if (!styles[0]) {
 | 
			
		||||
    // may happen when users [accidentally] reopen an old URL
 | 
			
		||||
    // of edit.html with a non-existent style id parameter
 | 
			
		||||
    return filtered;
 | 
			
		||||
| 
						 | 
				
			
			@ -259,9 +260,7 @@ function filterStylesInternal({
 | 
			
		|||
    cleanupCachedFilters();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return asHash
 | 
			
		||||
    ? Object.assign(blankHash, filtered)
 | 
			
		||||
    : filtered;
 | 
			
		||||
  return filtered;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user