Baseline Widely available
MutationObserver
ì¸í°íì´ì¤ë DOM í¸ë¦¬ì ë³ê²½ì ê°ì§íë 기ë¥ì ì ê³µí©ëë¤. DOM3 ì´ë²¤í¸ ëª
ì¸ì ì¼ë¶ìë Mutation Events를 ëì²´í©ëë¤.
MutationObserver()
DOM ë³ê²½ì´ ë°ìíë©´ ì½ë°±ì í¸ì¶íë ì MutationObserver
를 ìì±íê³ ë°íí©ëë¤.
disconnect()
observe()
를 í¸ì¶í기 ì ê¹ì§ MutationObserver
ì¸ì¤í´ì¤ê° ëì´ìì ì림ì ìì íì§ ìëë¡ ì¤ì í©ëë¤.
observe()
주ì´ì§ ì¤ì ê³¼ ì¼ì¹íë DOM ë³ê²½ì´ ë°ìíì ë MutationObserver
ì¸ì¤í´ì¤ê° ìì ì ì½ë°±ì¼ë¡ ì림ì ìì íëë¡ ì¤ì í©ëë¤.
takeRecords()
MutationObserver
ì ì림 í를 ë¹ì°ê³ , íìì ë기 ì¤ì´ë ì림ë¤ì MutationRecord
ë¤ë¡ 구ì±ë ìë¡ì´ Array
ë¡ ë°íí©ëë¤.
ë¤ì ìì ë ì´ ë¸ë¡ê·¸ ê¸ìì ê°ì ¸ì¨ ê²ì ëë¤.
// ë³ê²½ì ê°ì§í ë
¸ë ì í
const targetNode = document.getElementById("some-id");
// ê°ì§ ìµì
(ê°ì§í ë³ê²½)
const config = { attributes: true, childList: true, subtree: true };
// ë³ê²½ ê°ì§ ì ì¤íí ì½ë°± í¨ì
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type === "childList") {
console.log("ìì ë
¸ëê° ì¶ê°ëê±°ë ì ê±°ëìµëë¤.");
} else if (mutation.type === "attributes") {
console.log(`${mutation.attributeName} í¹ì±ì´ ë³ê²½ëìµëë¤.`);
}
}
};
// ì½ë°± í¨ìì ì°ê²°ë ê°ì§ê¸° ì¸ì¤í´ì¤ ìì±
const observer = new MutationObserver(callback);
// ì¤ì í ë³ê²½ì ê°ì§ ìì
observer.observe(targetNode, config);
// ì´í ê°ì§ ì¤ë¨ ê°ë¥
observer.disconnect();
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4