mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-04-01 09:56:43 +00:00
31 lines
812 B
HTML
31 lines
812 B
HTML
<!DOCTYPE html>
|
|
<script src="../testing.js"></script>
|
|
<div id="target" style="width: 100px; height: 100px;">Target Element</div>
|
|
|
|
<script id="disconnect">
|
|
const target = document.getElementById('target');
|
|
let callCount = 0;
|
|
|
|
const observer = new IntersectionObserver(() => {
|
|
callCount++;
|
|
});
|
|
|
|
observer.observe(target);
|
|
|
|
testing.onload(() => {
|
|
testing.expectEqual(1, callCount);
|
|
|
|
observer.disconnect();
|
|
|
|
// Create a new observer to trigger another check
|
|
// If disconnect worked, the old observer won't fire
|
|
const observer2 = new IntersectionObserver(() => {});
|
|
observer2.observe(target);
|
|
|
|
testing.onload(() => {
|
|
observer2.disconnect();
|
|
testing.expectEqual(1, callCount);
|
|
});
|
|
});
|
|
</script>
|