@antv/g 5.0.16 → 5.0.19

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 (58) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.d.ts +4 -1
  3. package/es/Canvas.js +5 -3
  4. package/es/display-objects/DisplayObject.d.ts +5 -0
  5. package/es/display-objects/DisplayObject.js +20 -0
  6. package/es/display-objects/Text.d.ts +23 -0
  7. package/es/display-objects/Text.js +56 -1
  8. package/es/dom/Animation.js +1 -1
  9. package/es/dom/Document.d.ts +1 -1
  10. package/es/dom/Document.js +2 -2
  11. package/es/dom/Element.d.ts +28 -0
  12. package/es/dom/Element.js +74 -1
  13. package/es/dom/FederatedEvent.d.ts +4 -1
  14. package/es/dom/interfaces.d.ts +3 -0
  15. package/es/plugins/EventPlugin.d.ts +1 -0
  16. package/es/plugins/EventPlugin.js +15 -5
  17. package/es/plugins/FrustumCullingStrategy.js +3 -2
  18. package/es/property-handlers/color.js +3 -1
  19. package/es/services/EventService.js +8 -2
  20. package/es/services/RenderingService.d.ts +12 -2
  21. package/es/services/RenderingService.js +21 -4
  22. package/es/services/SceneGraphService.js +8 -10
  23. package/es/services/aabb/TextUpdater.js +12 -0
  24. package/es/shapes/AABB.js +5 -0
  25. package/es/types.d.ts +6 -0
  26. package/es/utils/animation.js +1 -1
  27. package/es/utils/event.js +6 -5
  28. package/es/utils/index.d.ts +2 -0
  29. package/es/utils/index.js +3 -1
  30. package/lib/Canvas.d.ts +4 -1
  31. package/lib/Canvas.js +5 -3
  32. package/lib/display-objects/DisplayObject.d.ts +5 -0
  33. package/lib/display-objects/DisplayObject.js +21 -0
  34. package/lib/display-objects/Text.d.ts +23 -0
  35. package/lib/display-objects/Text.js +56 -1
  36. package/lib/dom/Animation.js +1 -1
  37. package/lib/dom/Document.d.ts +1 -1
  38. package/lib/dom/Document.js +3 -3
  39. package/lib/dom/Element.d.ts +28 -0
  40. package/lib/dom/Element.js +74 -1
  41. package/lib/dom/FederatedEvent.d.ts +4 -1
  42. package/lib/dom/interfaces.d.ts +3 -0
  43. package/lib/plugins/EventPlugin.d.ts +1 -0
  44. package/lib/plugins/EventPlugin.js +13 -5
  45. package/lib/plugins/FrustumCullingStrategy.js +2 -1
  46. package/lib/property-handlers/color.js +3 -1
  47. package/lib/services/EventService.js +8 -2
  48. package/lib/services/RenderingService.d.ts +12 -2
  49. package/lib/services/RenderingService.js +21 -4
  50. package/lib/services/SceneGraphService.js +8 -14
  51. package/lib/services/aabb/TextUpdater.js +12 -0
  52. package/lib/shapes/AABB.js +5 -0
  53. package/lib/types.d.ts +6 -0
  54. package/lib/utils/animation.js +1 -1
  55. package/lib/utils/event.js +6 -5
  56. package/lib/utils/index.d.ts +2 -0
  57. package/lib/utils/index.js +26 -0
  58. package/package.json +3 -3
@@ -21,8 +21,20 @@ function () {
21
21
  function RenderingService() {
22
22
  this.inited = false;
23
23
  this.stats = {
24
+ /**
25
+ * total display objects in scenegraph
26
+ */
24
27
  total: 0,
25
- rendered: 0
28
+
29
+ /**
30
+ * number of display objects need to render in current frame
31
+ */
32
+ rendered: 0,
33
+
34
+ /**
35
+ * number of display objects displayed on screen
36
+ */
37
+ renderedOnscreen: 0
26
38
  };
27
39
  this.zIndexCounter = 0;
28
40
  this.hooks = {
@@ -81,7 +93,7 @@ function () {
81
93
  return this.stats;
82
94
  };
83
95
 
84
- RenderingService.prototype.render = function () {
96
+ RenderingService.prototype.render = function (canvasConfig) {
85
97
  this.stats.total = 0;
86
98
  this.stats.rendered = 0;
87
99
  this.zIndexCounter = 0;
@@ -90,13 +102,18 @@ function () {
90
102
  if (this.renderingContext.renderReasons.size && this.inited) {
91
103
  this.renderDisplayObject(this.renderingContext.root);
92
104
 
93
- if (this.renderingContext.dirty) {
105
+ if (this.renderingContext.dirty || canvasConfig.renderer.getConfig().enableDirtyRectangleRendering && this.stats.total === 1) {
106
+ if (!this.renderingContext.dirty) {
107
+ this.hooks.beginFrame.call();
108
+ }
109
+
110
+ this.stats.renderedOnscreen = this.stats.rendered;
94
111
  this.hooks.endFrame.call();
95
112
  this.renderingContext.dirty = false;
96
113
  }
97
114
 
98
115
  this.renderingContext.renderReasons.clear();
99
- } // console.log('render objects: ', this.stats.count);
116
+ } // console.log('stats', this.stats);
100
117
 
101
118
  };
102
119
 
@@ -342,16 +342,14 @@ function () {
342
342
 
343
343
  DefaultSceneGraphService.prototype.detach = function (child) {
344
344
  if (child.parentNode) {
345
- var transform = child.transformable;
346
-
347
- if (transform) {
348
- var worldTransform = this.getWorldTransform(child, transform);
349
- mat4.getScaling(transform.localScale, worldTransform);
350
- mat4.getTranslation(transform.localPosition, worldTransform);
351
- mat4.getRotation(transform.localRotation, worldTransform);
352
- transform.localDirtyFlag = true;
353
- } // parent needs re-sort
354
-
345
+ var transform = child.transformable; // if (transform) {
346
+ // const worldTransform = this.getWorldTransform(child, transform);
347
+ // mat4.getScaling(transform.localScale, worldTransform);
348
+ // mat4.getTranslation(transform.localPosition, worldTransform);
349
+ // mat4.getRotation(transform.localRotation, worldTransform);
350
+ // transform.localDirtyFlag = true;
351
+ // }
352
+ // parent needs re-sort
355
353
 
356
354
  var sortable = child.parentNode.sortable;
357
355
 
@@ -24,6 +24,18 @@ function () {
24
24
  dy = parsedStyle.dy;
25
25
  var metrics = this.textService.measureText(text, parsedStyle);
26
26
  parsedStyle.metrics = metrics;
27
+
28
+ if (!text) {
29
+ return {
30
+ width: 0,
31
+ height: 0,
32
+ x: 0,
33
+ y: 0,
34
+ offsetX: 0,
35
+ offsetY: 0
36
+ };
37
+ }
38
+
27
39
  var width = metrics.width,
28
40
  height = metrics.height,
29
41
  lineHeight = metrics.lineHeight,
package/es/shapes/AABB.js CHANGED
@@ -47,6 +47,11 @@ function () {
47
47
  return;
48
48
  }
49
49
 
50
+ if (AABB.isEmpty(this)) {
51
+ this.setMinMax(aabb.getMin(), aabb.getMax());
52
+ return;
53
+ }
54
+
50
55
  var tc = this.center;
51
56
  var tcx = tc[0];
52
57
  var tcy = tc[1];
package/es/types.d.ts CHANGED
@@ -208,6 +208,10 @@ export interface CanvasConfig {
208
208
  */
209
209
  requestAnimationFrame?: (callback: FrameRequestCallback) => number;
210
210
  cancelAnimationFrame?: (id: number) => void;
211
+ /**
212
+ * replace `new window.Image()`
213
+ */
214
+ createImage?: () => HTMLImageElement;
211
215
  /**
212
216
  * 画布宽度
213
217
  */
@@ -243,6 +247,8 @@ export declare type PathCommand = A | C | O | H | L | M | R | Q | S | T | V | U
243
247
  export declare type InteractivePointerEvent = PointerEvent | TouchEvent | MouseEvent | WheelEvent;
244
248
  export declare type Tuple4<T> = [T, T, T, T];
245
249
  export declare type Tuple4Number = Tuple4<number>;
250
+ export declare type Tuple3<T> = [T, T, T];
251
+ export declare type Tuple3Number = Tuple3<number>;
246
252
  export declare type ComninedValue<T> = T | [T] | [T, T] | [T, T, T] | Tuple4<T>;
247
253
  export declare type CombinedNumber = ComninedValue<number>;
248
254
  export declare type Length = number;
@@ -82,7 +82,7 @@ function calculatePhase(activeDuration, localTime, timing) {
82
82
  return PhaseNone;
83
83
  }
84
84
 
85
- var endTime = timing.delay + activeDuration + timing.endDelay;
85
+ var endTime = timing.endTime;
86
86
 
87
87
  if (localTime < Math.min(timing.delay, endTime)) {
88
88
  return PhaseBefore;
package/es/utils/event.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { isUndefined } from '@antv/util'; // use `self` instead of `window`, account for non-window contexts, such as in Web Workers
2
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/globalThis
2
3
  // @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
3
4
 
4
- export var supportsTouchEvents = !!self.TouchEvent;
5
- export var supportsPointerEvents = !!self.PointerEvent;
5
+ export var supportsTouchEvents = !!globalThis.TouchEvent;
6
+ export var supportsPointerEvents = !!globalThis.PointerEvent;
6
7
  export var MOUSE_POINTER_ID = 1;
7
8
  export var TOUCH_TO_POINTER = {
8
9
  touchstart: 'pointerdown',
@@ -15,7 +16,7 @@ export function isTouchEvent(event) {
15
16
  return supportsTouchEvents && event instanceof TouchEvent;
16
17
  }
17
18
  export function isMouseEvent(event) {
18
- return !self.MouseEvent || event instanceof MouseEvent && (!supportsPointerEvents || !(event instanceof self.PointerEvent));
19
+ return !globalThis.MouseEvent || event instanceof MouseEvent && (!supportsPointerEvents || !(event instanceof globalThis.PointerEvent));
19
20
  }
20
21
  /**
21
22
  * borrow from pixi/events
@@ -29,8 +30,8 @@ export function normalizeToPointerEvent(event) {
29
30
  var touch = event.changedTouches[i]; // use changedTouches instead of touches since touchend has no touches
30
31
  // @see https://stackoverflow.com/a/10079076
31
32
 
32
- if (isUndefined(touch.button)) touch.button = event.changedTouches.length ? 1 : 0;
33
- if (isUndefined(touch.buttons)) touch.buttons = event.changedTouches.length ? 1 : 0;
33
+ if (isUndefined(touch.button)) touch.button = event.touches.length ? 1 : 0;
34
+ if (isUndefined(touch.buttons)) touch.buttons = event.touches.length ? 1 : 0;
34
35
 
35
36
  if (isUndefined(touch.isPrimary)) {
36
37
  touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';
@@ -4,3 +4,5 @@ export * from './path';
4
4
  export * from './raf';
5
5
  export * from './text';
6
6
  export * from './string';
7
+ export * from './event';
8
+ export * from './canvas';
package/es/utils/index.js CHANGED
@@ -3,4 +3,6 @@ export * from './interpolation';
3
3
  export * from './path';
4
4
  export * from './raf';
5
5
  export * from './text';
6
- export * from './string';
6
+ export * from './string';
7
+ export * from './event';
8
+ export * from './canvas';
package/lib/Canvas.d.ts CHANGED
@@ -71,7 +71,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
71
71
  getRenderingContext(): RenderingContext;
72
72
  getStats(): {
73
73
  total: number;
74
- rendered: number;
74
+ rendered: number; /**
75
+ * window.document
76
+ */
77
+ renderedOnscreen: number;
75
78
  };
76
79
  /**
77
80
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
package/lib/Canvas.js CHANGED
@@ -79,7 +79,8 @@ function (_super) {
79
79
  renderer = config.renderer,
80
80
  background = config.background,
81
81
  requestAnimationFrame = config.requestAnimationFrame,
82
- cancelAnimationFrame = config.cancelAnimationFrame;
82
+ cancelAnimationFrame = config.cancelAnimationFrame,
83
+ createImage = config.createImage;
83
84
  (0, _canvas.cleanExistedCanvas)(container, _this);
84
85
  var canvasWidth = width;
85
86
  var canvasHeight = height;
@@ -105,7 +106,8 @@ function (_super) {
105
106
  renderer: renderer,
106
107
  devicePixelRatio: dpr,
107
108
  cursor: 'default',
108
- background: background // background: 'white',
109
+ background: background,
110
+ createImage: createImage // background: 'white',
109
111
 
110
112
  });
111
113
 
@@ -326,7 +328,7 @@ function (_super) {
326
328
 
327
329
  if (this.container.isBound(_RenderingService.RenderingService)) {
328
330
  var renderingService = this.container.get(_RenderingService.RenderingService);
329
- renderingService.render();
331
+ renderingService.render(this.getConfig());
330
332
  }
331
333
 
332
334
  this.emit(CanvasEvent.AFTER_RENDER, {});
@@ -48,6 +48,11 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
48
48
  * called when attributes get changed or initialized
49
49
  */
50
50
  private changeAttribute;
51
+ /**
52
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
53
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
54
+ */
55
+ getBBox(): DOMRect;
51
56
  setOrigin(position: vec3 | vec2 | number, y?: number, z?: number): this;
52
57
  getOrigin(): vec3;
53
58
  /**
@@ -29,6 +29,8 @@ var _services = require("../services");
29
29
 
30
30
  var _MutationEvent = require("../dom/MutationEvent");
31
31
 
32
+ var _shapes = require("../shapes");
33
+
32
34
  var DEFAULT_STYLE_PROPS = {
33
35
  anchor: [0, 0, 0],
34
36
  origin: [0, 0, 0],
@@ -302,6 +304,25 @@ function (_super) {
302
304
  // });
303
305
  }; // #region transformable
304
306
 
307
+ /**
308
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
309
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
310
+ */
311
+
312
+
313
+ DisplayObject.prototype.getBBox = function () {
314
+ var aabb = this.getBounds();
315
+
316
+ var _a = (0, _tslib.__read)(aabb.getMin(), 2),
317
+ left = _a[0],
318
+ top = _a[1];
319
+
320
+ var _b = (0, _tslib.__read)(aabb.getMax(), 2),
321
+ right = _b[0],
322
+ bottom = _b[1];
323
+
324
+ return new _shapes.Rectangle(left, top, right - left, bottom - top);
325
+ };
305
326
 
306
327
  DisplayObject.prototype.setOrigin = function (position, y, z) {
307
328
  if (y === void 0) {
@@ -62,7 +62,30 @@ export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
62
62
  dx?: ParsedElement;
63
63
  dy?: ParsedElement;
64
64
  }
65
+ /**
66
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
67
+ */
65
68
  export declare class Text extends DisplayObject<TextStyleProps, ParsedTextStyleProps> {
69
+ /**
70
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
71
+ */
72
+ LENGTHADJUST_SPACING: number;
73
+ LENGTHADJUST_SPACINGANDGLYPHS: number;
74
+ LENGTHADJUST_UNKNOWN: number;
66
75
  constructor({ style, ...rest }?: DisplayObjectConfig<TextStyleProps>);
76
+ lengthAdjust: SVGAnimatedEnumeration;
77
+ textLength: SVGAnimatedLength;
78
+ getCharNumAtPosition(point?: DOMPointInit): number;
79
+ /**
80
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
81
+ */
82
+ getComputedTextLength(): number;
83
+ getEndPositionOfChar(charnum: number): DOMPoint;
84
+ getExtentOfChar(charnum: number): DOMRect;
85
+ getNumberOfChars(): number;
86
+ getRotationOfChar(charnum: number): number;
87
+ getStartPositionOfChar(charnum: number): DOMPoint;
88
+ getSubStringLength(charnum: number, nchars: number): number;
89
+ selectSubString(charnum: number, nchars: number): void;
67
90
  getLineBoundingRects(): import("..").Rectangle[];
68
91
  }
@@ -11,6 +11,9 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
+ /**
15
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
16
+ */
14
17
  var Text =
15
18
  /** @class */
16
19
  function (_super) {
@@ -21,9 +24,11 @@ function (_super) {
21
24
  _a = {};
22
25
  }
23
26
 
27
+ var _this = this;
28
+
24
29
  var style = _a.style,
25
30
  rest = (0, _tslib.__rest)(_a, ["style"]);
26
- return _super.call(this, (0, _tslib.__assign)({
31
+ _this = _super.call(this, (0, _tslib.__assign)({
27
32
  type: _types.Shape.TEXT,
28
33
  style: (0, _tslib.__assign)({
29
34
  text: '',
@@ -56,8 +61,58 @@ function (_super) {
56
61
  dy: 0
57
62
  }, style)
58
63
  }, rest)) || this;
64
+ /**
65
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
66
+ */
67
+
68
+ _this.LENGTHADJUST_SPACING = 1;
69
+ _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
70
+ _this.LENGTHADJUST_UNKNOWN = 0;
71
+ return _this;
59
72
  }
60
73
 
74
+ Text.prototype.getCharNumAtPosition = function (point) {
75
+ throw new Error('Method not implemented.');
76
+ };
77
+ /**
78
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
79
+ */
80
+
81
+
82
+ Text.prototype.getComputedTextLength = function () {
83
+ var _a;
84
+
85
+ return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.maxLineWidth) || 0;
86
+ };
87
+
88
+ Text.prototype.getEndPositionOfChar = function (charnum) {
89
+ throw new Error('Method not implemented.');
90
+ };
91
+
92
+ Text.prototype.getExtentOfChar = function (charnum) {
93
+ throw new Error('Method not implemented.');
94
+ };
95
+
96
+ Text.prototype.getNumberOfChars = function () {
97
+ throw new Error('Method not implemented.');
98
+ };
99
+
100
+ Text.prototype.getRotationOfChar = function (charnum) {
101
+ throw new Error('Method not implemented.');
102
+ };
103
+
104
+ Text.prototype.getStartPositionOfChar = function (charnum) {
105
+ throw new Error('Method not implemented.');
106
+ };
107
+
108
+ Text.prototype.getSubStringLength = function (charnum, nchars) {
109
+ throw new Error('Method not implemented.');
110
+ };
111
+
112
+ Text.prototype.selectSubString = function (charnum, nchars) {
113
+ throw new Error('Method not implemented.');
114
+ };
115
+
61
116
  Text.prototype.getLineBoundingRects = function () {
62
117
  var _a;
63
118
 
@@ -240,7 +240,7 @@ function () {
240
240
  get: function get() {
241
241
  var _a;
242
242
 
243
- return Number((_a = this.effect) === null || _a === void 0 ? void 0 : _a.getComputedTiming().activeDuration);
243
+ return Number((_a = this.effect) === null || _a === void 0 ? void 0 : _a.getComputedTiming().endTime);
244
244
  },
245
245
  enumerable: false,
246
246
  configurable: true
@@ -1,6 +1,6 @@
1
1
  import { Node } from './Node';
2
2
  import { AnimationTimeline } from './AnimationTimeline';
3
- import { Group } from '../display-objects/Group';
3
+ import { Group } from '../display-objects';
4
4
  import type { DisplayObject } from '../display-objects/DisplayObject';
5
5
  import type { IDocument, IElement, INode, ICanvas, DisplayObjectConfig } from './interfaces';
6
6
  import type { BaseStyleProps } from '../types';
@@ -11,7 +11,7 @@ var _Node = require("./Node");
11
11
 
12
12
  var _AnimationTimeline = require("./AnimationTimeline");
13
13
 
14
- var _Group = require("../display-objects/Group");
14
+ var _displayObjects = require("../display-objects");
15
15
 
16
16
  var _types = require("../types");
17
17
 
@@ -39,7 +39,7 @@ function (_super) {
39
39
 
40
40
  _this.timeline = new _AnimationTimeline.AnimationTimeline(); // like <html> in DOM tree
41
41
 
42
- _this.documentElement = new _Group.Group({
42
+ _this.documentElement = new _displayObjects.Group({
43
43
  id: 'g-root',
44
44
  style: {
45
45
  textAlign: _types.TextAlign.START,
@@ -94,7 +94,7 @@ function (_super) {
94
94
 
95
95
  if (!clazz) {
96
96
  console.warn('Unsupported tagName: ', tagName);
97
- clazz = _Group.Group;
97
+ clazz = tagName === 'tspan' ? _displayObjects.Text : _displayObjects.Group;
98
98
  }
99
99
 
100
100
  return new clazz(options);
@@ -46,6 +46,12 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
46
46
  interactive: boolean;
47
47
  scrollLeft: number;
48
48
  scrollTop: number;
49
+ /**
50
+ * We don't support border now
51
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
52
+ */
53
+ clientTop: number;
54
+ clientLeft: number;
49
55
  get tagName(): string;
50
56
  get children(): IElement[];
51
57
  get childElementCount(): number;
@@ -138,10 +144,22 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
138
144
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
139
145
  */
140
146
  readonly attributes: StyleProps;
147
+ /**
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
149
+ */
150
+ getAttributeNames(): string[];
141
151
  /**
142
152
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
143
153
  */
144
154
  getAttribute(name: keyof StyleProps): any;
155
+ /**
156
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
157
+ */
158
+ hasAttribute(qualifiedName: string): boolean;
159
+ /**
160
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
161
+ */
162
+ hasAttributes(): boolean;
145
163
  /**
146
164
  * 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.
147
165
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
@@ -151,4 +169,14 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
151
169
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
152
170
  */
153
171
  setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
172
+ getAttributeNS(namespace: string, localName: string): string;
173
+ getAttributeNode(qualifiedName: string): Attr;
174
+ getAttributeNodeNS(namespace: string, localName: string): Attr;
175
+ hasAttributeNS(namespace: string, localName: string): boolean;
176
+ removeAttributeNS(namespace: string, localName: string): void;
177
+ removeAttributeNode(attr: Attr): Attr;
178
+ setAttributeNS(namespace: string, qualifiedName: string, value: string): void;
179
+ setAttributeNode(attr: Attr): Attr;
180
+ setAttributeNodeNS(attr: Attr): Attr;
181
+ toggleAttribute(qualifiedName: string, force?: boolean): boolean;
154
182
  }
@@ -53,6 +53,13 @@ function (_super) {
53
53
  _this.namespaceURI = 'g';
54
54
  _this.scrollLeft = 0;
55
55
  _this.scrollTop = 0;
56
+ /**
57
+ * We don't support border now
58
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
59
+ */
60
+
61
+ _this.clientTop = 0;
62
+ _this.clientLeft = 0;
56
63
  /**
57
64
  * is destroyed or not
58
65
  */
@@ -96,7 +103,9 @@ function (_super) {
96
103
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
97
104
  */
98
105
  get: function get() {
99
- return this.className.split(' ');
106
+ return this.className.split(' ').filter(function (c) {
107
+ return c !== '';
108
+ });
100
109
  },
101
110
  enumerable: false,
102
111
  configurable: true
@@ -495,6 +504,14 @@ function (_super) {
495
504
  Element.prototype.getClientRects = function () {
496
505
  return [this.getBoundingClientRect()];
497
506
  };
507
+ /**
508
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
509
+ */
510
+
511
+
512
+ Element.prototype.getAttributeNames = function () {
513
+ return Object.keys(this.attributes);
514
+ };
498
515
  /**
499
516
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
500
517
  */
@@ -508,6 +525,22 @@ function (_super) {
508
525
 
509
526
  return (0, _util.isNil)(value) ? null : value;
510
527
  };
528
+ /**
529
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
530
+ */
531
+
532
+
533
+ Element.prototype.hasAttribute = function (qualifiedName) {
534
+ return this.getAttributeNames().includes(qualifiedName);
535
+ };
536
+ /**
537
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
538
+ */
539
+
540
+
541
+ Element.prototype.hasAttributes = function () {
542
+ return !!this.getAttributeNames().length;
543
+ };
511
544
  /**
512
545
  * 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.
513
546
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
@@ -531,6 +564,46 @@ function (_super) {
531
564
  this.attributes[attributeName] = value;
532
565
  };
533
566
 
567
+ Element.prototype.getAttributeNS = function (namespace, localName) {
568
+ throw new Error('Method not implemented.');
569
+ };
570
+
571
+ Element.prototype.getAttributeNode = function (qualifiedName) {
572
+ throw new Error('Method not implemented.');
573
+ };
574
+
575
+ Element.prototype.getAttributeNodeNS = function (namespace, localName) {
576
+ throw new Error('Method not implemented.');
577
+ };
578
+
579
+ Element.prototype.hasAttributeNS = function (namespace, localName) {
580
+ throw new Error('Method not implemented.');
581
+ };
582
+
583
+ Element.prototype.removeAttributeNS = function (namespace, localName) {
584
+ throw new Error('Method not implemented.');
585
+ };
586
+
587
+ Element.prototype.removeAttributeNode = function (attr) {
588
+ throw new Error('Method not implemented.');
589
+ };
590
+
591
+ Element.prototype.setAttributeNS = function (namespace, qualifiedName, value) {
592
+ throw new Error('Method not implemented.');
593
+ };
594
+
595
+ Element.prototype.setAttributeNode = function (attr) {
596
+ throw new Error('Method not implemented.');
597
+ };
598
+
599
+ Element.prototype.setAttributeNodeNS = function (attr) {
600
+ throw new Error('Method not implemented.');
601
+ };
602
+
603
+ Element.prototype.toggleAttribute = function (qualifiedName, force) {
604
+ throw new Error('Method not implemented.');
605
+ };
606
+
534
607
  return Element;
535
608
  }(_Node.Node);
536
609
 
@@ -127,13 +127,16 @@ export declare class FederatedEvent<N extends Event = Event, T = any> {
127
127
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation
128
128
  */
129
129
  stopPropagation(): void;
130
+ /**
131
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view
132
+ */
133
+ view: any;
130
134
  /**
131
135
  * added for compatibility with DOM Event,
132
136
  * deprecated props and methods
133
137
  */
134
138
  initEvent(): void;
135
139
  initUIEvent(): void;
136
- view: WindowProxy;
137
140
  which: number;
138
141
  returnValue: boolean;
139
142
  srcElement: IEventTarget;
@@ -303,6 +303,8 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
303
303
  getElementsByTagName: <E extends IElement = IElement>(tagName: string) => E[];
304
304
  scrollLeft: number;
305
305
  scrollTop: number;
306
+ clientLeft: number;
307
+ clientTop: number;
306
308
  /**
307
309
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
308
310
  */
@@ -315,6 +317,7 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
315
317
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
316
318
  */
317
319
  removeAttribute: (attributeName: keyof StyleProps) => void;
320
+ hasAttribute: (qualifiedName: string) => boolean;
318
321
  }
319
322
  export interface IDocument extends INode, IParentNode {
320
323
  /**
@@ -11,6 +11,7 @@ export declare class EventPlugin implements RenderingPlugin {
11
11
  private canvasConfig;
12
12
  private contextService;
13
13
  private renderingService;
14
+ private renderingContext;
14
15
  private eventService;
15
16
  private autoPreventDefault;
16
17
  private rootPointerEvent;