On 7/1/11 3:06 PM, Olli Pettay wrote:
On 07/02/2011 12:59 AM, David Flanagan wrote:

But, and I think this is an interesting but, what happens if a node is
removed from the document, has its attributes or data or children
changed and is then re-inserted into the document? If the node has no
parent when it is changed, no mutation events will be generated, will
they?
Sure they are. If the node has listeners, they will get called.

I'm assuming the listeners are further up the tree.

To give a concrete example, to a mutation event listener (under Rafael's proposal, but maybe yours, too?) on the document, these two sequences of operations will be indistinguishable:

// Generates one event for removing the title text from the <head> and another for // inserting it into the <body>. (Assume document.head.firstChild.firstChild is the text node inside
// the <title> tag.
document.body.appendChild(document.head.firstChild.firstChild);

// Here we generate the same sequence of mutation events
var titletext = document.head.firstChild.firstChild.
titletext.parentNode.removeChild(titletext);  // Generates a remove event
titletext.data = "foobar"; // Generates a mutation event no one sees
document.body.appendChild(titletext);         // Generates an insert event

I claim that it is useful to be able to distinguish these two cases with some sort of move event. If moves are treated as remove/insert pairs, then listeners have to assume that arbitrary changes could have taken place between the two.

    David



Reply via email to