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

Function ctor

test/unit/core/dom/layout/test-intersection.js:8–26  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

6describes.fakeWin('DOM - layout - intersection observer', {}, (env) => {
7 function getInObConstructorStub() {
8 const ctor = (cb) => {
9 if (ctor.callback) {
10 throw new Error('Only a single InOb instance allowed per Window.');
11 }
12 const observedEls = new Set();
13 ctor.callback = (entries) => {
14 if (entries.some((x) => !observedEls.has(x.target))) {
15 throw new Error(
16 'Attempted to fire intersection for unobserved element.'
17 );
18 }
19 cb(entries);
20 };
21 return {
22 observe: (e) => observedEls.add(e),
23 unobserve: (e) => observedEls.delete(e),
24 disconnect: () => observedEls.clear(),
25 };
26 };
27 return ctor;
28 }
29

Callers

nothing calls this directly

Calls 5

clearMethod · 0.65
cbFunction · 0.50
hasMethod · 0.45
addMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected