Fixed readyStateCompleteListeners never flushing when initialized after DOM ready - #15571
Fixed readyStateCompleteListeners never flushing when initialized after DOM ready#15571KamilDev wants to merge 1 commit into
Conversation
|
Unfortunately this will have negative effect on websites that load slowly (or when the internet connection is slow), as it postpones certain mechanisms until the state is complete (all style sheets and images finished loading). Particularly, this check is used to remove the fallback style, which is inserted to prevent white flashes. Is your SVG dynamically generated? Dark Reader is supposed to watch for DOM and inline style changes, but maybe there's a bug. Also this SVG analysis is not perfect, maybe switching it off completely will work better for you. E.g. by supplying a "fix" argument like |
|
Nothing gets postponed, because the change removes no case from the guard, it only adds one. The line decides whether the listener gets registered, nothing else: if (!isReadyStateComplete()) { // was !isDOMReady()
const onReadyStateChange = () => { /* unchanged */ };
document.addEventListener('readystatechange', onReadyStateChange);
}and it's negated, so the narrower predicate registers in more cases, not fewer: export let isDOMReady: () => boolean = () => {
return document.readyState === 'complete' || document.readyState === 'interactive';
};
export function isReadyStateComplete(): boolean {
return document.readyState === 'complete';
}
That added case is init at The SVG is static markup. |
Fixes #15570
The readystatechange listener in dom.ts was only registered when the module initialized before readyState "interactive". When the API is enabled from a deferred page script, initialization happens at "interactive", so
readyStateCompleteListeners(deferred SVG fill overrides, image loads) never ran. Register the listener while readyState is not yet "complete" instead. The handler already deals with both flush stages, and nothing changes for the extension, which initializes at document_start.