그래서 SDK에 윈도우가로드되는지 확인하는이 함수가 있습니다. 그 코드는 아래에 있습니다.윈도우 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;
는하지만 innerHTML을 구문 분석 될 때 대화 형으로 이동 readyState가 무엇입니까? 페이지가 완전히 렌더링 된시기를 알고 싶습니다.
Ah drats, 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