MCPcopy
hub / github.com/ampproject/amphtml / waitForMutation

Function waitForMutation

test/unit/preact/test-base-element-mapping.js:50–67  ·  view source on GitHub ↗
(element, callback)

Source from the content-addressed store, hash-verified

48 });
49
50 function waitForMutation(element, callback) {
51 return new Promise((resolve) => {
52 const mo = new MutationObserver(() => {
53 resolve();
54 mo.disconnect();
55 });
56 mo.observe(element, {
57 attributes: true,
58 childList: true,
59 subtree: true,
60 characterData: true,
61 });
62 callback();
63 }).then(() => {
64 // Skip couple more animation frames.
65 return new Promise((resolve) => setTimeout(resolve, 32));
66 });
67 }
68
69 describe('R1', () => {
70 it('testElementR1', () => {

Callers 1

Calls 5

resolveFunction · 0.50
callbackFunction · 0.50
thenMethod · 0.45
disconnectMethod · 0.45
observeMethod · 0.45

Tested by

no test coverage detected