[[!meta title="LibDOM/The MutationEvent generation"]] [[!meta author="Struggleyb"]] [[!meta date="2009-08-09T10:20:48Z"]] [[!toc]] Events with Methods Generate them --------------------------------- DOMSubtreeModified: DOMNodeRemovedFromDocument: Node.replaceChild Node.removeChild Element.removeAttribute Element.setAttributeNode Element.removeAttributeNode Element.removeAttributeNS Element.setAttributeNodeNS DOMNodeInsertedIntoDocument: Node.insertBefore Node.replaceChild Node.appendChild Element.setAttribute Element.setAttributeNode Element.setAttributeNS Element.setAttributeNodeNS DOMNodeInserted: Node.insertBefore Node.replaceChild Node.appendChild Element.setAttribute Element.setAttributeNode Element.setAttributeNS Element.setAttributeNodeNS DOMNodeRemoved: Node.replaceChild Node.removeChild Element.removeAttribute Element.setAttributeNode Element.removeAttributeNode Element.removeAttributeNS Element.setAttributeNodeNS DOMAttrModified: Element.setAttribute Element.removeAttribute Element.setAttributeNode Element.removeAttributeNode Element.setAttributeNS Element.removeAttributeNS Element.setAttributeNodeNS DOMCharacterDataModified: Node.nodeValue CharacterData.data CharacterData.appendData CharacterData.deleteData CharacterData.insertData CharacterData.replaceData ProcessingInstruction.data #### Some Event Generation Order consideration As above, some changes of DOM caused by certain API can emit multiple Events. In some situation, the DOM spec define the order of the events. For example, when an Attr is removed from an element, the implementation should send the following events as the following order: DOMNodeRemoved DOMAttrModified DOMSubtreeModified But in other situation, the events order are not specified. For example, when an Attr is added to an element, the implement should may send: DOMNodeInserted DOMAttrModified DOMSubtreeModified or DOMAttrModified DOMNodeInserted DOMSubtreeModified The point here is, the DOMAttrModified and DOMNodeInserted can be dispatched in any order, but the DOMSubtreeModified event should always the last event after bunch of events.