1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.dom;
16
17 import java.util.ArrayList;
18
19 import org.htmlunit.corejs.javascript.ScriptableObject;
20 import org.htmlunit.javascript.HtmlUnitScriptable;
21 import org.htmlunit.javascript.configuration.JsxClass;
22 import org.htmlunit.javascript.configuration.JsxConstructor;
23 import org.htmlunit.javascript.configuration.JsxGetter;
24 import org.htmlunit.javascript.host.html.HTMLElement;
25
26
27
28
29
30
31
32 @JsxClass
33 public class MutationRecord extends HtmlUnitScriptable {
34
35 private String type_;
36 private ScriptableObject target_;
37 private String oldValue_;
38 private String attributeName_;
39
40 private NodeList addedNodes_;
41 private NodeList removedNodes_;
42 private Node previousSibling_;
43 private Node nextSibling_;
44
45
46
47
48 @JsxConstructor
49 public void jsConstructor() {
50
51 }
52
53
54
55
56
57 void setType(final String type) {
58 type_ = type;
59 }
60
61
62
63
64
65 @JsxGetter
66 public String getType() {
67 return type_;
68 }
69
70
71
72
73
74 void setTarget(final ScriptableObject target) {
75 target_ = target;
76 }
77
78
79
80
81
82 @JsxGetter
83 public ScriptableObject getTarget() {
84 return target_;
85 }
86
87
88
89
90
91 void setOldValue(final String oldValue) {
92 oldValue_ = oldValue;
93 }
94
95
96
97
98
99 @JsxGetter
100 public String getOldValue() {
101 return oldValue_;
102 }
103
104
105
106
107
108 void setAttributeName(final String attributeName) {
109 attributeName_ = attributeName;
110 }
111
112
113
114
115
116 @JsxGetter
117 public String getAttributeName() {
118 return attributeName_;
119 }
120
121
122
123
124
125 void setAddedNodes(final NodeList addedNodes) {
126 addedNodes_ = addedNodes;
127 }
128
129
130
131
132 @JsxGetter
133 public NodeList getAddedNodes() {
134 if (addedNodes_ == null && target_ instanceof HTMLElement) {
135 final NodeList addedNodes = new NodeList(((HTMLElement) target_).getDomNodeOrDie(), new ArrayList<>());
136 addedNodes.setParentScope(getParentScope());
137 addedNodes.setPrototype(getPrototype(addedNodes.getClass()));
138
139 addedNodes_ = addedNodes;
140 }
141 return addedNodes_;
142 }
143
144
145
146
147
148 void setRemovedNodes(final NodeList removedNodes) {
149 removedNodes_ = removedNodes;
150 }
151
152
153
154
155 @JsxGetter
156 public NodeList getRemovedNodes() {
157 if (removedNodes_ == null && target_ instanceof HTMLElement) {
158 final NodeList removedNodes = new NodeList(((HTMLElement) target_).getDomNodeOrDie(), new ArrayList<>());
159 removedNodes.setParentScope(getParentScope());
160 removedNodes.setPrototype(getPrototype(removedNodes.getClass()));
161
162 removedNodes_ = removedNodes;
163 }
164 return removedNodes_;
165 }
166
167
168
169
170
171 void setPreviousSibling(final Node previousSibling) {
172 previousSibling_ = previousSibling;
173 }
174
175
176
177
178 @JsxGetter
179 public Node getPreviousSibling() {
180 return previousSibling_;
181 }
182
183
184
185
186
187 void setNextSibling(final Node nextSibling) {
188 nextSibling_ = nextSibling;
189 }
190
191
192
193
194 @JsxGetter
195 public Node getNextSibling() {
196 return nextSibling_;
197 }
198 }