[Bug 22759] It is not clear what happens to the existing transient observers when MutationObserver.observe is called

https://www.w3.org/Bugs/Public/show_bug.cgi?id=22759

--- Comment #6 from Travis Leithead [MSFT] <travil@microsoft.com> ---
One more thing: what about the case where one mutation observer is observing
two or more nodes with different options? Current implementations are very
precise and only remove the transient registered observers belonging to a
single mutation observer object that also were created exclusively for the
options pertaining to a certain node. This is better illustrated by example:

<!doctype html>
<div id="div">
  <div id="gone">
    <div id="subgone"></div>
  </div>
</div>
<script>
onload = function() {
 var mutationObserver = new MutationObserver(function checkpoint(list) {
    alert(list.length);
 });
 mutationObserver.observe(document.body, 
                          { subtree: true, childList: true});
 mutationObserver.observe(document.body.firstElementChild, 
                          { subtree: true, attributes: true});
 // Cause a removal of "subgone" to create two transient observers, 
 // one for attibutes and one for childList
 var subgone =
document.getElementById("div").removeChild(document.getElementById("gone"));
 // Re-observe the attributes observer (same options--to reset 
 // it and its transients)
 mutationObserver.observe(document.body.firstElementChild, 
                          { subtree: true, attributes: true});
 // Did this clear both transient observers on "subgone" -- find out:
 // It certainly must have cleared the "attributes" transient observer
 // Did it also clear the childList observer?
 subgone.appendChild(document.createElement("span"));
 // Add an attribute: expected that it _doesn't_ get recorded.
 subgone.setAttribute("mytest", "test");
}
</script>

Latest Firefox/Chrome report only two records, not 3, so even on a single
mutation observer, not all of its transient observers are cleared out on
re-observe--just those related to the node on which the observe method is
called.

Just want to make sure this is super-clear in the spec :-)

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 24 July 2013 00:02:19 UTC