Skip to content

Commit de977ec

Browse files
committed
add sanity check mutation observer
1 parent c690d80 commit de977ec

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

demo/src/entry-client.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
// import { hydrate } from 'preact';
2-
// import { App } from './App';
1+
import { hydrate } from 'preact';
2+
import { App } from './App';
33

4-
// hydrate(<App />, document);
4+
const config = { attributes: true, childList: true, subtree: true };
5+
const mut = new MutationObserver((mutationList, observer) => {
6+
for (const mutation of mutationList) {
7+
if (mutation.type === 'childList') {
8+
console.log('A child node has been added or removed.', mutation);
9+
} else if (mutation.type === 'attributes') {
10+
console.log(
11+
`The ${mutation.attributeName} attribute was modified.`,
12+
mutation
13+
);
14+
}
15+
}
16+
});
17+
mut.observe(document, config);
18+
19+
hydrate(<App />, document);

0 commit comments

Comments
 (0)