ensure own style elements dominance over other style elements
This commit is contained in:
		
							parent
							
								
									f40dc29497
								
							
						
					
					
						commit
						6d4689e559
					
				|  | @ -386,7 +386,6 @@ | ||||||
|     let restorationCounter = 0; |     let restorationCounter = 0; | ||||||
|     let observing = false; |     let observing = false; | ||||||
|     let sorting = false; |     let sorting = false; | ||||||
|     let timer; |  | ||||||
|     // allow any types of elements between ours, except for the following:
 |     // allow any types of elements between ours, except for the following:
 | ||||||
|     const ORDERED_TAGS = ['head', 'body', 'frameset', 'style', 'link']; |     const ORDERED_TAGS = ['head', 'body', 'frameset', 'style', 'link']; | ||||||
| 
 | 
 | ||||||
|  | @ -431,8 +430,11 @@ | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     function sortStyleElements() { |     function sortStyleElements() { | ||||||
|       let prevExpected = document.body || document.head; |       let prevExpected = document.documentElement.lastElementChild; | ||||||
|       if (!prevExpected || sorting) { |       while (prevExpected && isSkippable(prevExpected, true)) { | ||||||
|  |         prevExpected = prevExpected.previousElementSibling; | ||||||
|  |       } | ||||||
|  |       if (!prevExpected) { | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|       for (const el of styleElements.values()) { |       for (const el of styleElements.values()) { | ||||||
|  | @ -443,7 +445,10 @@ | ||||||
|           const next = prevExpected.nextElementSibling; |           const next = prevExpected.nextElementSibling; | ||||||
|           if (next && isSkippable(next)) { |           if (next && isSkippable(next)) { | ||||||
|             prevExpected = next; |             prevExpected = next; | ||||||
|           } else if (moveAfter(el, prevExpected)) { |           } else if ( | ||||||
|  |               next === el || | ||||||
|  |               next === el.previousElementSibling || | ||||||
|  |               moveAfter(el, next || prevExpected)) { | ||||||
|             prevExpected = el; |             prevExpected = el; | ||||||
|             break; |             break; | ||||||
|           } else { |           } else { | ||||||
|  | @ -454,17 +459,16 @@ | ||||||
|       if (sorting) { |       if (sorting) { | ||||||
|         sorting = false; |         sorting = false; | ||||||
|         docRootObserver.takeRecords(); |         docRootObserver.takeRecords(); | ||||||
|         clearTimeout(timer); |         start(); | ||||||
|         timer = setTimeout(start); |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     function isMovable(el) { |     function isMovable(el) { | ||||||
|       return el.parentNode || !disabledElements.has(getStyleId(el)); |       return el.parentNode || !disabledElements.has(getStyleId(el)); | ||||||
|     } |     } | ||||||
|     function isSkippable(el) { |     function isSkippable(el, skipOwnStyles) { | ||||||
|       return !ORDERED_TAGS.includes(el.localName) || |       return !ORDERED_TAGS.includes(el.localName) || | ||||||
|         el.id.startsWith(ID_PREFIX) && |         el.id.startsWith(ID_PREFIX) && | ||||||
|         el.id.endsWith('-ghost') && |         (skipOwnStyles || el.id.endsWith('-ghost')) && | ||||||
|         el.localName === 'style' && |         el.localName === 'style' && | ||||||
|         el.className === 'stylus'; |         el.className === 'stylus'; | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user