0
所以SDK有这个函数检查窗口是否加载,代码如下。检查window dom是否被解析
我的问题是如果一个innerHTML或appendChild或更改html发生什么?这是否带回了loadContext?我想知道如果窗口中的DOM完全解析,或正在解析,这是可能的这种方法?
编辑:其实这是代码,看是否加载文档:
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;
,但确实的readyState进入互动被解析innerHTML的时候?我想知道什么时候页面完全呈现。
啊,你认为dom分析器需要多少时间才能渲染像appendChild和innerHTML更新这样的东西?没有绘制完整的事件? – Noitidart
@Noitidart:渲染发生异步,只有DOM变化是同步的。 'innerHTML'可能需要一段时间,这取决于HTML代码的复杂程度。另一方面'appendChild'非常快 - 这里不涉及解析。有['MozAfterPaint'事件](https://developer.mozilla.org/en-US/docs/Web/Reference/Events/MozAfterPaint),但你不知道哪一个是“最终”的绘画事件。 –
Ahhh非常感谢那个MozAfterPaint,我知道我记得那样的东西,但找不到它。好的,谢谢Wlad! – Noitidart