Closed emilio closed 3 years ago
Similar issue with step 2.2:
If the intersection root is not the implicit root, and target is not in the same document as the intersection root, skip further processing for target.
<!doctype html>
<style>
div {
width: 100px;
height: 100px;
background: blue;
margin: 10px
}
</style>
<div id="root"></div>
<script>
let doc = document.implementation.createHTMLDocument("");
let target = doc.createElement("div");
doc.body.appendChild(target);
new IntersectionObserver(
function() {
console.log(arguments);
},
{ root: document.querySelector("#root") }
).observe(target);
</script>
My preference would be to make the blink/webkit behavior official. I think it's useful to send the "not intersecting" notification when a target is removed from the containing block chain.
@emilio What do you think?
Yes, I tend to agree. I aligned Gecko with WebKit/Blink in https://bugzilla.mozilla.org/show_bug.cgi?id=1670327.
This test-case:
In Gecko it doesn't queue any entry. I believe this is correct per https://w3c.github.io/IntersectionObserver/#update-intersection-observations-algo:
I don't think that matches Blink or WebKit though, which just report a non-intersecting entry. I think it's also a bug in the spec, because per that reasoning
display: none
elements etc wouldn't get reported even if they're dom descendants of the root.cc @szager-chromium