Reputation: 37318
So SDK has this function that checks if window is loading, the code for that is below.
My question is what if an innerHTML or appendChild or something to change html happens? Does that bring back loadContext? I want to know if the DOM in a window is fully done parsing, or in progress of parsing, is this possible with this method?
edit: actually this is the code to see if document is loaded:
const isInteractive = window =>
window.document.readyState === "interactive" ||
isDocumentLoaded(window) ||
// XUL documents stays '"uninitialized"' until it's `readyState` becomes
// `"complete"`.
isXULDocumentWindow(window) && window.document.readyState === "interactive";
exports.isInteractive = isInteractive;
const isXULDocumentWindow = ({document}) =>
document.documentElement &&
document.documentElement.namespaceURI === XUL_NS;
/**
* Check if the given window is completely loaded.
* i.e. if its "load" event has already been fired and all possible DOM content
* is done loading (the whole DOM document, images content, ...)
* @params {nsIDOMWindow} window
*/
function isDocumentLoaded(window) {
return window.document.readyState == "complete";
}
exports.isDocumentLoaded = isDocumentLoaded;
but does readyState go to interactive when innerHTML is being parsed? i want to know when page is fully rendered.
Upvotes: 0
Views: 123
Reputation: 57681
Dynamic HTML changes don't affect the document.readyState
property, it is a one-way street. The value is "loading"
while the document is being parsed, "interactive"
once parsing is done and only things like images need to load (DOMContentLoaded
event fired) and "complete"
once everything is done (load
event fired). It no longer changes after that.
Upvotes: 1