summaryrefslogtreecommitdiff
path: root/libdom/the_mutationevent_generation.mdwn
blob: ae00db38d5508f91d7a389322f089184f0931a7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
[[!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.