diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-25 11:58:32 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-25 11:58:32 +0800 |
| commit | 0cc4a179cfed5c2be516186dd134c6d208b7f2a9 (patch) | |
| tree | 47eb657e7f3a84e95e55b6560d63ac07cbe3878f /snippets/javascript_mutationoberserver | |
| parent | 544734673b2235fc9d011f740118fb56f21bf0ff (diff) | |
Update
Diffstat (limited to 'snippets/javascript_mutationoberserver')
| -rw-r--r-- | snippets/javascript_mutationoberserver | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/snippets/javascript_mutationoberserver b/snippets/javascript_mutationoberserver index 48f17af..9962aac 100644 --- a/snippets/javascript_mutationoberserver +++ b/snippets/javascript_mutationoberserver | |||
| @@ -1,12 +1,14 @@ | |||
| 1 | new window.MutationObserver((ms) => { | 1 | new window.MutationObserver((mutations) => { |
| 2 | for (const m of ms) { | 2 | for (const mutation of mutations) { |
| 3 | console.log(m) | 3 | console.log(mutation) |
| 4 | console.log('m', m.target.innerHTML) | 4 | console.log('mutation', mutation.target.innerHTML) |
| 5 | console.log('m', m.target.classList) | 5 | console.log('mutation', mutation.target.classList) |
| 6 | } | 6 | } |
| 7 | }).observe(item, { | 7 | }).observe(item, { |
| 8 | attributes: true, | 8 | attributes: true, |
| 9 | attributeFilter: ['class'], | 9 | attributeFilter: ['class'], |
| 10 | attributeOldValue: true, | 10 | attributeOldValue: true, |
| 11 | characterDataOldValue: true | 11 | characterDataOldValue: true, |
| 12 | }) | 12 | childList: true, |
| 13 | subtree: true, | ||
| 14 | }) | ||