@antv/g 5.0.13 → 5.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/dist/index.umd.min.js +18 -2
  2. package/es/Canvas.d.ts +3 -0
  3. package/es/Canvas.js +9 -9
  4. package/es/camera/Camera.d.ts +3 -2
  5. package/es/camera/Camera.js +16 -8
  6. package/es/canvas-module.js +11 -17
  7. package/es/components/Transform.d.ts +0 -1
  8. package/es/components/Transform.js +0 -1
  9. package/es/display-objects/Circle.d.ts +4 -2
  10. package/es/display-objects/Circle.js +8 -3
  11. package/es/display-objects/CustomElement.d.ts +3 -2
  12. package/es/display-objects/CustomElement.js +9 -6
  13. package/es/display-objects/DisplayObject.d.ts +4 -3
  14. package/es/display-objects/DisplayObject.js +80 -49
  15. package/es/display-objects/Ellipse.d.ts +6 -3
  16. package/es/display-objects/Ellipse.js +8 -3
  17. package/es/display-objects/Group.d.ts +18 -2
  18. package/es/display-objects/Group.js +14 -9
  19. package/es/display-objects/HTML.d.ts +6 -1
  20. package/es/display-objects/HTML.js +10 -5
  21. package/es/display-objects/Image.d.ts +12 -7
  22. package/es/display-objects/Image.js +10 -3
  23. package/es/display-objects/Line.d.ts +1 -1
  24. package/es/display-objects/Line.js +12 -4
  25. package/es/display-objects/Path.d.ts +3 -2
  26. package/es/display-objects/Path.js +10 -5
  27. package/es/display-objects/Polygon.d.ts +1 -1
  28. package/es/display-objects/Polygon.js +9 -3
  29. package/es/display-objects/Polyline.d.ts +1 -1
  30. package/es/display-objects/Polyline.js +10 -5
  31. package/es/display-objects/Rect.d.ts +8 -5
  32. package/es/display-objects/Rect.js +9 -4
  33. package/es/display-objects/Text.d.ts +9 -6
  34. package/es/display-objects/Text.js +15 -10
  35. package/es/dom/Animation.js +1 -1
  36. package/es/dom/AnimationTimeline.js +1 -2
  37. package/es/dom/CustomElementRegistry.js +12 -12
  38. package/es/dom/Document.d.ts +1 -0
  39. package/es/dom/Document.js +21 -1
  40. package/es/dom/Element.d.ts +14 -9
  41. package/es/dom/Element.js +41 -14
  42. package/es/dom/EventTarget.d.ts +2 -2
  43. package/es/dom/EventTarget.js +4 -3
  44. package/es/dom/KeyframeList.js +1 -1
  45. package/es/dom/MutationEvent.d.ts +15 -0
  46. package/es/dom/MutationEvent.js +29 -0
  47. package/es/dom/MutationObserver.d.ts +36 -0
  48. package/es/dom/MutationObserver.js +413 -0
  49. package/es/dom/MutationRecord.d.ts +14 -0
  50. package/es/dom/MutationRecord.js +31 -0
  51. package/es/dom/Node.d.ts +35 -3
  52. package/es/dom/Node.js +184 -17
  53. package/es/dom/index.d.ts +3 -0
  54. package/es/dom/index.js +3 -0
  55. package/es/dom/interfaces.d.ts +36 -8
  56. package/es/dom/interfaces.js +23 -5
  57. package/es/global-module.d.ts +4 -1
  58. package/es/global-module.js +38 -80
  59. package/es/index.d.ts +1 -0
  60. package/es/index.js +1 -0
  61. package/es/plugins/CullingPlugin.d.ts +0 -2
  62. package/es/plugins/CullingPlugin.js +3 -24
  63. package/es/plugins/DirtyCheckPlugin.js +2 -2
  64. package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
  65. package/es/plugins/FrustumCullingStrategy.js +40 -33
  66. package/es/plugins/PrepareRendererPlugin.js +21 -5
  67. package/es/property-handlers/aabb.js +22 -24
  68. package/es/property-handlers/anchor.js +2 -1
  69. package/es/property-handlers/color.js +5 -2
  70. package/es/property-handlers/dimension.d.ts +15 -2
  71. package/es/property-handlers/dimension.js +77 -8
  72. package/es/property-handlers/index.d.ts +3 -0
  73. package/es/property-handlers/index.js +4 -1
  74. package/es/property-handlers/inherit.d.ts +6 -0
  75. package/es/property-handlers/inherit.js +25 -0
  76. package/es/property-handlers/interfaces.d.ts +2 -2
  77. package/es/property-handlers/lineDash.d.ts +6 -1
  78. package/es/property-handlers/lineDash.js +23 -4
  79. package/es/property-handlers/offsetDistance.js +2 -2
  80. package/es/property-handlers/path.d.ts +1 -1
  81. package/es/property-handlers/text.d.ts +2 -0
  82. package/es/property-handlers/text.js +3 -0
  83. package/es/property-handlers/textTransform.d.ts +6 -0
  84. package/es/property-handlers/textTransform.js +19 -0
  85. package/es/services/EventService.js +3 -5
  86. package/es/services/RenderingContext.d.ts +5 -8
  87. package/es/services/RenderingContext.js +6 -7
  88. package/es/services/RenderingService.js +2 -8
  89. package/es/services/SceneGraphSelector.d.ts +3 -2
  90. package/es/services/SceneGraphSelector.js +8 -4
  91. package/es/services/SceneGraphService.d.ts +7 -14
  92. package/es/services/SceneGraphService.js +14 -82
  93. package/es/services/aabb/CircleUpdater.d.ts +2 -2
  94. package/es/services/aabb/CircleUpdater.js +21 -11
  95. package/es/services/aabb/EllipseUpdater.d.ts +2 -2
  96. package/es/services/aabb/EllipseUpdater.js +28 -13
  97. package/es/services/aabb/LineUpdater.js +2 -2
  98. package/es/services/aabb/PathUpdater.js +2 -2
  99. package/es/services/aabb/PolylineUpdater.js +3 -3
  100. package/es/services/aabb/RectUpdater.d.ts +2 -2
  101. package/es/services/aabb/RectUpdater.js +33 -17
  102. package/es/services/aabb/TextUpdater.js +19 -10
  103. package/es/services/aabb/interfaces.d.ts +1 -1
  104. package/es/services/aabb/interfaces.js +1 -1
  105. package/es/services/text/index.js +19 -21
  106. package/es/shapes/AABB.d.ts +1 -0
  107. package/es/shapes/AABB.js +8 -0
  108. package/es/types.d.ts +48 -27
  109. package/es/types.js +50 -31
  110. package/es/utils/custom-easing.js +1 -1
  111. package/es/utils/event.js +5 -3
  112. package/es/utils/index.d.ts +1 -0
  113. package/es/utils/index.js +2 -1
  114. package/es/utils/interpolation.d.ts +1 -0
  115. package/es/utils/interpolation.js +41 -8
  116. package/es/utils/path.d.ts +1 -1
  117. package/es/utils/path.js +16 -16
  118. package/es/utils/raf.d.ts +1 -1
  119. package/es/utils/raf.js +0 -2
  120. package/es/utils/string.d.ts +1 -0
  121. package/es/utils/string.js +9 -0
  122. package/es/utils/text.js +3 -3
  123. package/lib/Canvas.d.ts +3 -0
  124. package/lib/Canvas.js +7 -7
  125. package/lib/camera/Camera.d.ts +3 -2
  126. package/lib/camera/Camera.js +20 -10
  127. package/lib/canvas-module.js +10 -15
  128. package/lib/components/Transform.d.ts +0 -1
  129. package/lib/components/Transform.js +0 -1
  130. package/lib/display-objects/Circle.d.ts +4 -2
  131. package/lib/display-objects/Circle.js +7 -2
  132. package/lib/display-objects/CustomElement.d.ts +3 -2
  133. package/lib/display-objects/CustomElement.js +9 -6
  134. package/lib/display-objects/DisplayObject.d.ts +4 -3
  135. package/lib/display-objects/DisplayObject.js +79 -46
  136. package/lib/display-objects/Ellipse.d.ts +6 -3
  137. package/lib/display-objects/Ellipse.js +7 -2
  138. package/lib/display-objects/Group.d.ts +18 -2
  139. package/lib/display-objects/Group.js +13 -9
  140. package/lib/display-objects/HTML.d.ts +6 -1
  141. package/lib/display-objects/HTML.js +9 -5
  142. package/lib/display-objects/Image.d.ts +12 -7
  143. package/lib/display-objects/Image.js +9 -2
  144. package/lib/display-objects/Line.d.ts +1 -1
  145. package/lib/display-objects/Line.js +11 -3
  146. package/lib/display-objects/Path.d.ts +3 -2
  147. package/lib/display-objects/Path.js +9 -4
  148. package/lib/display-objects/Polygon.d.ts +1 -1
  149. package/lib/display-objects/Polygon.js +8 -2
  150. package/lib/display-objects/Polyline.d.ts +1 -1
  151. package/lib/display-objects/Polyline.js +9 -4
  152. package/lib/display-objects/Rect.d.ts +8 -5
  153. package/lib/display-objects/Rect.js +8 -3
  154. package/lib/display-objects/Text.d.ts +9 -6
  155. package/lib/display-objects/Text.js +14 -9
  156. package/lib/dom/Animation.js +1 -1
  157. package/lib/dom/AnimationTimeline.js +1 -2
  158. package/lib/dom/CustomElementRegistry.js +11 -11
  159. package/lib/dom/Document.d.ts +1 -0
  160. package/lib/dom/Document.js +22 -1
  161. package/lib/dom/Element.d.ts +14 -9
  162. package/lib/dom/Element.js +43 -14
  163. package/lib/dom/EventTarget.d.ts +2 -2
  164. package/lib/dom/EventTarget.js +4 -3
  165. package/lib/dom/KeyframeList.js +1 -1
  166. package/lib/dom/MutationEvent.d.ts +15 -0
  167. package/lib/dom/MutationEvent.js +37 -0
  168. package/lib/dom/MutationObserver.d.ts +36 -0
  169. package/lib/dom/MutationObserver.js +424 -0
  170. package/lib/dom/MutationRecord.d.ts +14 -0
  171. package/lib/dom/MutationRecord.js +38 -0
  172. package/lib/dom/Node.d.ts +35 -3
  173. package/lib/dom/Node.js +185 -16
  174. package/lib/dom/index.d.ts +3 -0
  175. package/lib/dom/index.js +39 -0
  176. package/lib/dom/interfaces.d.ts +36 -8
  177. package/lib/dom/interfaces.js +23 -5
  178. package/lib/global-module.d.ts +4 -1
  179. package/lib/global-module.js +44 -76
  180. package/lib/index.d.ts +1 -0
  181. package/lib/index.js +3 -1
  182. package/lib/plugins/CullingPlugin.d.ts +0 -2
  183. package/lib/plugins/CullingPlugin.js +2 -23
  184. package/lib/plugins/DirtyCheckPlugin.js +1 -1
  185. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
  186. package/lib/plugins/FrustumCullingStrategy.js +41 -33
  187. package/lib/plugins/PrepareRendererPlugin.js +24 -4
  188. package/lib/property-handlers/aabb.js +21 -23
  189. package/lib/property-handlers/anchor.js +3 -1
  190. package/lib/property-handlers/color.js +6 -3
  191. package/lib/property-handlers/dimension.d.ts +15 -2
  192. package/lib/property-handlers/dimension.js +80 -7
  193. package/lib/property-handlers/index.d.ts +3 -0
  194. package/lib/property-handlers/index.js +39 -0
  195. package/lib/property-handlers/inherit.d.ts +6 -0
  196. package/lib/property-handlers/inherit.js +34 -0
  197. package/lib/property-handlers/interfaces.d.ts +2 -2
  198. package/lib/property-handlers/lineDash.d.ts +6 -1
  199. package/lib/property-handlers/lineDash.js +25 -4
  200. package/lib/property-handlers/offsetDistance.js +1 -1
  201. package/lib/property-handlers/path.d.ts +1 -1
  202. package/lib/property-handlers/text.d.ts +2 -0
  203. package/lib/property-handlers/text.js +10 -0
  204. package/lib/property-handlers/textTransform.d.ts +6 -0
  205. package/lib/property-handlers/textTransform.js +27 -0
  206. package/lib/services/EventService.js +3 -5
  207. package/lib/services/RenderingContext.d.ts +5 -8
  208. package/lib/services/RenderingContext.js +8 -9
  209. package/lib/services/RenderingService.js +1 -7
  210. package/lib/services/SceneGraphSelector.d.ts +3 -2
  211. package/lib/services/SceneGraphSelector.js +10 -3
  212. package/lib/services/SceneGraphService.d.ts +7 -14
  213. package/lib/services/SceneGraphService.js +15 -82
  214. package/lib/services/aabb/CircleUpdater.d.ts +2 -2
  215. package/lib/services/aabb/CircleUpdater.js +20 -10
  216. package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
  217. package/lib/services/aabb/EllipseUpdater.js +27 -12
  218. package/lib/services/aabb/LineUpdater.js +1 -1
  219. package/lib/services/aabb/PathUpdater.js +1 -1
  220. package/lib/services/aabb/PolylineUpdater.js +2 -2
  221. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  222. package/lib/services/aabb/RectUpdater.js +32 -16
  223. package/lib/services/aabb/TextUpdater.js +18 -9
  224. package/lib/services/aabb/interfaces.d.ts +1 -1
  225. package/lib/services/aabb/interfaces.js +1 -1
  226. package/lib/services/text/index.js +19 -21
  227. package/lib/shapes/AABB.d.ts +1 -0
  228. package/lib/shapes/AABB.js +8 -0
  229. package/lib/types.d.ts +48 -27
  230. package/lib/types.js +56 -35
  231. package/lib/utils/custom-easing.js +1 -1
  232. package/lib/utils/event.js +5 -3
  233. package/lib/utils/index.d.ts +1 -0
  234. package/lib/utils/index.js +13 -0
  235. package/lib/utils/interpolation.d.ts +1 -0
  236. package/lib/utils/interpolation.js +43 -7
  237. package/lib/utils/path.d.ts +1 -1
  238. package/lib/utils/path.js +15 -15
  239. package/lib/utils/raf.d.ts +1 -1
  240. package/lib/utils/raf.js +0 -2
  241. package/lib/utils/string.d.ts +1 -0
  242. package/lib/utils/string.js +16 -0
  243. package/lib/utils/text.js +3 -3
  244. package/package.json +6 -4
@@ -2,6 +2,7 @@ import { __extends } from "tslib";
2
2
  import { Node } from './Node';
3
3
  import { AnimationTimeline } from './AnimationTimeline';
4
4
  import { Group } from '../display-objects/Group';
5
+ import { TextAlign } from '../types';
5
6
  /**
6
7
  * the entry of DOM tree
7
8
  * Document -> Node -> EventTarget
@@ -28,7 +29,15 @@ function (_super) {
28
29
  _this.timeline = new AnimationTimeline(); // like <html> in DOM tree
29
30
 
30
31
  _this.documentElement = new Group({
31
- id: 'g-root'
32
+ id: 'g-root',
33
+ style: {
34
+ textAlign: TextAlign.START,
35
+ fontSize: '16px',
36
+ fontFamily: 'sans-serif' // fontStyle: 'normal',
37
+ // fontWeight: 'normal',
38
+ // fontVariant: 'normal',
39
+
40
+ }
32
41
  });
33
42
  _this.documentElement.ownerDocument = _this;
34
43
  _this.documentElement.parentNode = _this;
@@ -69,8 +78,19 @@ function (_super) {
69
78
  */
70
79
 
71
80
  Document.prototype.createElement = function (tagName, options) {
81
+ // d3 will use <tspan>
72
82
  var clazz = this.defaultView.customElements.get(tagName);
83
+
84
+ if (!clazz) {
85
+ console.warn('Unsupported tagName: ', tagName);
86
+ clazz = Group;
87
+ }
88
+
73
89
  return new clazz(options);
90
+ };
91
+
92
+ Document.prototype.createElementNS = function (namespaceURI, tagName, options) {
93
+ return this.createElement(tagName, options);
74
94
  }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
95
 
76
96
 
@@ -3,7 +3,7 @@ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../componen
3
3
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { Node } from './Node';
5
5
  import type { AABB, Rectangle } from '../shapes';
6
- import type { IEventTarget, IElement, INode } from './interfaces';
6
+ import type { IEventTarget, IElement, INode, ICSSStyleDeclaration } from './interfaces';
7
7
  /**
8
8
  * Has following capabilities:
9
9
  * * Node insert/remove, eg. appendChild, removeChild, remove...
@@ -28,12 +28,17 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
28
28
  * used in `getElementsByClassName`
29
29
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
30
30
  */
31
- className: string;
31
+ get className(): string;
32
+ set className(className: string);
32
33
  /**
33
34
  * used in `getElementsByName`
34
35
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByName
35
36
  */
36
37
  name: string;
38
+ /**
39
+ * https://developer.mozilla.org/zh-CN/docs/Web/API/Element/namespaceURI
40
+ */
41
+ namespaceURI: string;
37
42
  /**
38
43
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
39
44
  */
@@ -103,16 +108,16 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
103
108
  */
104
109
  destroyed: boolean;
105
110
  destroy(): void;
106
- getGeometryBounds(): AABB | null;
107
- getRenderBounds(): AABB | null;
111
+ getGeometryBounds(): AABB;
112
+ getRenderBounds(): AABB;
108
113
  /**
109
114
  * get bounds in world space, account for children
110
115
  */
111
- getBounds(): AABB | null;
116
+ getBounds(): AABB;
112
117
  /**
113
118
  * get bounds in local space, account for children
114
119
  */
115
- getLocalBounds(): AABB | null;
120
+ getLocalBounds(): AABB;
116
121
  /**
117
122
  * account for context's bounds in client space,
118
123
  * but not accounting for children
@@ -127,16 +132,16 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
127
132
  * compatible with `style`
128
133
  * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
129
134
  */
130
- style: StyleProps;
135
+ style: StyleProps & ICSSStyleDeclaration<StyleProps>;
131
136
  parsedStyle: ParsedStyleProps;
132
137
  /**
133
138
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
134
139
  */
135
- attributes: StyleProps;
140
+ readonly attributes: StyleProps;
136
141
  /**
137
142
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
138
143
  */
139
- getAttribute(attributeName: keyof StyleProps): StyleProps[keyof StyleProps];
144
+ getAttribute(name: keyof StyleProps): any;
140
145
  /**
141
146
  * should use removeAttribute() instead of setting the attribute value to null either directly or using setAttribute(). Many attributes will not behave as expected if you set them to null.
142
147
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
package/es/dom/Element.js CHANGED
@@ -5,6 +5,8 @@ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../componen
5
5
  import { Node } from './Node';
6
6
  import { ElementEvent } from './interfaces';
7
7
  import { globalContainer } from '../global-module';
8
+ import { formatAttribute } from '../utils';
9
+ import { MutationEvent } from '..';
8
10
  var entityCounter = 0;
9
11
  /**
10
12
  * Has following capabilities:
@@ -28,6 +30,11 @@ function (_super) {
28
30
  _this.transformable = new Transform();
29
31
  _this.sortable = new Sortable();
30
32
  _this.geometry = new Geometry();
33
+ /**
34
+ * https://developer.mozilla.org/zh-CN/docs/Web/API/Element/namespaceURI
35
+ */
36
+
37
+ _this.namespaceURI = 'g';
31
38
  _this.scrollLeft = 0;
32
39
  _this.scrollTop = 0;
33
40
  /**
@@ -54,6 +61,20 @@ function (_super) {
54
61
  return !!target.getAttribute;
55
62
  };
56
63
 
64
+ Object.defineProperty(Element.prototype, "className", {
65
+ /**
66
+ * used in `getElementsByClassName`
67
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
68
+ */
69
+ get: function get() {
70
+ return this.getAttribute('class') || '';
71
+ },
72
+ set: function set(className) {
73
+ this.setAttribute('class', className);
74
+ },
75
+ enumerable: false,
76
+ configurable: true
77
+ });
57
78
  Object.defineProperty(Element.prototype, "classList", {
58
79
  /**
59
80
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
@@ -139,10 +160,12 @@ function (_super) {
139
160
  this.sceneGraphService.attach(child, this, index);
140
161
  this.emit(ElementEvent.CHILD_INSERTED, {
141
162
  child: child
142
- });
143
- child.emit(ElementEvent.INSERTED, {
144
- parent: this
145
- });
163
+ }); // child.emit(ElementEvent.INSERTED, {
164
+ // parent: this,
165
+ // index,
166
+ // });
167
+
168
+ child.dispatchEvent(new MutationEvent(ElementEvent.INSERTED, this, '', '', '', 0, '', ''));
146
169
  return child;
147
170
  };
148
171
 
@@ -165,14 +188,15 @@ function (_super) {
165
188
  };
166
189
 
167
190
  Element.prototype.removeChild = function (child, destroy) {
191
+ // should emit on itself before detach
192
+ // child.emit(ElementEvent.REMOVED, {
193
+ // parent: this,
194
+ // });
168
195
  if (destroy === void 0) {
169
196
  destroy = true;
170
- } // should emit on itself before detach
171
-
197
+ }
172
198
 
173
- child.emit(ElementEvent.REMOVED, {
174
- parent: this
175
- }); // emit destroy event
199
+ child.dispatchEvent(new MutationEvent(ElementEvent.REMOVED, this, '', '', '', 0, '', '')); // emit destroy event
176
200
 
177
201
  if (destroy) {
178
202
  child.emit(ElementEvent.DESTROY, {});
@@ -216,15 +240,15 @@ function (_super) {
216
240
  };
217
241
 
218
242
  Element.prototype.getElementById = function (id) {
219
- return this.sceneGraphService.querySelector("#" + id, this);
243
+ return this.sceneGraphService.querySelector("#".concat(id), this);
220
244
  };
221
245
 
222
246
  Element.prototype.getElementsByName = function (name) {
223
- return this.sceneGraphService.querySelectorAll("[name=\"" + name + "\"]", this);
247
+ return this.sceneGraphService.querySelectorAll("[name=\"".concat(name, "\"]"), this);
224
248
  };
225
249
 
226
250
  Element.prototype.getElementsByClassName = function (className) {
227
- return this.sceneGraphService.querySelectorAll("." + className, this);
251
+ return this.sceneGraphService.querySelectorAll(".".concat(className), this);
228
252
  };
229
253
 
230
254
  Element.prototype.getElementsByTagName = function (tagName) {
@@ -460,10 +484,13 @@ function (_super) {
460
484
  */
461
485
 
462
486
 
463
- Element.prototype.getAttribute = function (attributeName) {
487
+ Element.prototype.getAttribute = function (name) {
488
+ var _a = __read(formatAttribute(name, ''), 1),
489
+ attributeName = _a[0];
490
+
464
491
  var value = this.attributes[attributeName]; // if the given attribute does not exist, the value returned will either be null or ""
465
492
 
466
- return isNil(value) ? undefined : value;
493
+ return isNil(value) ? null : value;
467
494
  };
468
495
  /**
469
496
  * should use removeAttribute() instead of setting the attribute value to null either directly or using setAttribute(). Many attributes will not behave as expected if you set them to null.
@@ -20,14 +20,14 @@ export declare class EventTarget implements IEventTarget {
20
20
  * support `capture` & `once` in options
21
21
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
22
22
  */
23
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
23
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
24
24
  /**
25
25
  * @deprecated
26
26
  * @alias removeEventListener
27
27
  */
28
28
  off(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
29
29
  removeAllEventListeners(): void;
30
- removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
30
+ removeEventListener(type: string, listener?: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
31
31
  /**
32
32
  * @deprecated
33
33
  * @alias dispatchEvent
@@ -54,7 +54,7 @@ function () {
54
54
  useDelegatedName = true;
55
55
  }
56
56
 
57
- type = capture ? type + "capture" : type;
57
+ type = capture ? "".concat(type, "capture") : type;
58
58
  listener = isFunction(listener) ? listener : listener.handleEvent; // compatible with G 3.0
59
59
 
60
60
  if (useDelegatedName) {
@@ -71,7 +71,8 @@ function () {
71
71
 
72
72
  if (((_a = args[0].target) === null || _a === void 0 ? void 0 : _a.name) !== delegatedName) {
73
73
  return;
74
- }
74
+ } // @ts-ignore
75
+
75
76
 
76
77
  originListener_1.apply(void 0, __spreadArray([], __read(args), false));
77
78
  };
@@ -109,7 +110,7 @@ function () {
109
110
  EventTarget.prototype.removeEventListener = function (type, listener, options) {
110
111
  var capture = isBoolean(options) && options || isObject(options) && options.capture;
111
112
  var context = isFunction(listener) ? undefined : listener;
112
- type = capture ? type + "capture" : type;
113
+ type = capture ? "".concat(type, "capture") : type;
113
114
  listener = isFunction(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
114
115
  this.emitter.off(type, listener, context);
115
116
  return this;
@@ -95,7 +95,7 @@ export function normalizeKeyframes(effectInput, timing) {
95
95
  // TODO: Support add & accumulate in KeyframeEffect.composite
96
96
  // @see https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/composite
97
97
  if (['replace', 'add', 'accumulate', 'auto'].indexOf(memberValue) === -1) {
98
- throw new Error(memberValue + " compositing is not supported");
98
+ throw new Error("".concat(memberValue, " compositing is not supported"));
99
99
  }
100
100
  } else if (member === 'easing') {// TODO: Validate animation-timing-function
101
101
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function
@@ -0,0 +1,15 @@
1
+ import type { ElementEvent, IElement } from '..';
2
+ import { FederatedEvent } from './FederatedEvent';
3
+ export declare class MutationEvent extends FederatedEvent {
4
+ relatedNode: IElement;
5
+ prevValue: any;
6
+ newValue: any;
7
+ attrName: string;
8
+ attrChange: number;
9
+ prevParsedValue: any;
10
+ newParsedValue: any;
11
+ static readonly ADDITION: number;
12
+ static readonly MODIFICATION: number;
13
+ static readonly REMOVAL: number;
14
+ constructor(typeArg: ElementEvent, relatedNode: IElement, prevValue: any, newValue: any, attrName: string, attrChange: number, prevParsedValue: any, newParsedValue: any);
15
+ }
@@ -0,0 +1,29 @@
1
+ import { __extends } from "tslib";
2
+ import { FederatedEvent } from './FederatedEvent';
3
+
4
+ var MutationEvent =
5
+ /** @class */
6
+ function (_super) {
7
+ __extends(MutationEvent, _super);
8
+
9
+ function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
10
+ var _this = _super.call(this, null) || this;
11
+
12
+ _this.relatedNode = relatedNode;
13
+ _this.prevValue = prevValue;
14
+ _this.newValue = newValue;
15
+ _this.attrName = attrName;
16
+ _this.attrChange = attrChange;
17
+ _this.prevParsedValue = prevParsedValue;
18
+ _this.newParsedValue = newParsedValue;
19
+ _this.type = typeArg;
20
+ return _this;
21
+ }
22
+
23
+ MutationEvent.ADDITION = 2;
24
+ MutationEvent.MODIFICATION = 1;
25
+ MutationEvent.REMOVAL = 3;
26
+ return MutationEvent;
27
+ }(FederatedEvent);
28
+
29
+ export { MutationEvent };
@@ -0,0 +1,36 @@
1
+ import 'setimmediate';
2
+ import type { IElement, DisplayObject } from '..';
3
+ import { MutationEvent } from './MutationEvent';
4
+ import { MutationRecord } from './MutationRecord';
5
+ export declare class Registration {
6
+ observer: MutationObserver;
7
+ target: IElement;
8
+ options?: MutationObserverInit;
9
+ private transientObservedNodes;
10
+ constructor(observer: MutationObserver, target: IElement, options?: MutationObserverInit);
11
+ enqueue(record: MutationRecord): void;
12
+ addListeners(): void;
13
+ private addListeners_;
14
+ removeListeners(): void;
15
+ removeListeners_(node: IElement): void;
16
+ /**
17
+ * Adds a transient observer on node. The transient observer gets removed
18
+ * next time we deliver the change records.
19
+ */
20
+ removeTransientObservers(): void;
21
+ handleEvent(e: MutationEvent): void;
22
+ }
23
+ /**
24
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
25
+ * @see https://github.com/googlearchive/MutationObservers/blob/master/MutationObserver.js
26
+ */
27
+ export declare class MutationObserver {
28
+ callback: MutationCallback;
29
+ nodes: IElement[];
30
+ records: MutationRecord[];
31
+ uid: number;
32
+ constructor(callback: MutationCallback);
33
+ observe(target: DisplayObject, options?: MutationObserverInit): void;
34
+ disconnect(): void;
35
+ takeRecords(): MutationRecord[];
36
+ }