@antv/g 5.0.15 → 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.
- package/dist/index.umd.min.js +18 -2
- package/es/Canvas.d.ts +3 -0
- package/es/Canvas.js +8 -9
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +16 -8
- package/es/canvas-module.js +4 -2
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +0 -1
- package/es/display-objects/Circle.d.ts +1 -1
- package/es/display-objects/Circle.js +8 -3
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +9 -6
- package/es/display-objects/DisplayObject.d.ts +4 -3
- package/es/display-objects/DisplayObject.js +77 -50
- package/es/display-objects/Ellipse.d.ts +1 -1
- package/es/display-objects/Ellipse.js +8 -3
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +11 -9
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/HTML.js +9 -4
- package/es/display-objects/Image.d.ts +5 -3
- package/es/display-objects/Image.js +8 -3
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +12 -4
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +10 -5
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +9 -3
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +10 -5
- package/es/display-objects/Rect.d.ts +1 -1
- package/es/display-objects/Rect.js +8 -3
- package/es/display-objects/Text.d.ts +9 -4
- package/es/display-objects/Text.js +14 -9
- package/es/dom/Animation.js +1 -1
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +1 -0
- package/es/dom/Document.js +21 -1
- package/es/dom/Element.d.ts +10 -5
- package/es/dom/Element.js +41 -15
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +29 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +413 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +31 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +184 -17
- package/es/dom/index.d.ts +3 -0
- package/es/dom/index.js +3 -0
- package/es/dom/interfaces.d.ts +36 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +1 -0
- package/es/global-module.js +11 -13
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/CullingPlugin.d.ts +0 -2
- package/es/plugins/CullingPlugin.js +3 -24
- package/es/plugins/DirtyCheckPlugin.js +2 -2
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +40 -33
- package/es/plugins/PrepareRendererPlugin.js +21 -5
- package/es/property-handlers/aabb.js +19 -20
- package/es/property-handlers/color.js +5 -2
- package/es/property-handlers/dimension.d.ts +15 -3
- package/es/property-handlers/dimension.js +50 -9
- package/es/property-handlers/index.d.ts +3 -0
- package/es/property-handlers/index.js +4 -1
- package/es/property-handlers/inherit.d.ts +6 -0
- package/es/property-handlers/inherit.js +25 -0
- package/es/property-handlers/interfaces.d.ts +2 -2
- package/es/property-handlers/lineDash.d.ts +6 -1
- package/es/property-handlers/lineDash.js +23 -4
- package/es/property-handlers/offsetDistance.js +2 -2
- package/es/property-handlers/text.d.ts +2 -0
- package/es/property-handlers/text.js +3 -0
- package/es/property-handlers/textTransform.d.ts +6 -0
- package/es/property-handlers/textTransform.js +19 -0
- package/es/services/EventService.js +3 -5
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.js +2 -8
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +8 -4
- package/es/services/SceneGraphService.d.ts +0 -7
- package/es/services/SceneGraphService.js +9 -77
- package/es/services/aabb/CircleUpdater.js +3 -3
- package/es/services/aabb/EllipseUpdater.js +2 -2
- package/es/services/aabb/LineUpdater.js +2 -2
- package/es/services/aabb/PathUpdater.js +2 -2
- package/es/services/aabb/PolylineUpdater.js +3 -3
- package/es/services/aabb/RectUpdater.js +4 -4
- package/es/services/aabb/TextUpdater.js +19 -10
- package/es/services/text/index.js +19 -21
- package/es/types.d.ts +48 -24
- package/es/types.js +50 -31
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +5 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.js +11 -11
- package/es/utils/raf.d.ts +1 -1
- package/es/utils/raf.js +0 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +9 -0
- package/es/utils/text.js +3 -3
- package/lib/Canvas.d.ts +3 -0
- package/lib/Canvas.js +6 -7
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +20 -10
- package/lib/canvas-module.js +3 -1
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +0 -1
- package/lib/display-objects/Circle.d.ts +1 -1
- package/lib/display-objects/Circle.js +7 -2
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +9 -6
- package/lib/display-objects/DisplayObject.d.ts +4 -3
- package/lib/display-objects/DisplayObject.js +76 -47
- package/lib/display-objects/Ellipse.d.ts +1 -1
- package/lib/display-objects/Ellipse.js +7 -2
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +10 -9
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/HTML.js +8 -4
- package/lib/display-objects/Image.d.ts +5 -3
- package/lib/display-objects/Image.js +7 -2
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +11 -3
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +9 -4
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +8 -2
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +9 -4
- package/lib/display-objects/Rect.d.ts +1 -1
- package/lib/display-objects/Rect.js +7 -2
- package/lib/display-objects/Text.d.ts +9 -4
- package/lib/display-objects/Text.js +13 -8
- package/lib/dom/Animation.js +1 -1
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +1 -0
- package/lib/dom/Document.js +22 -1
- package/lib/dom/Element.d.ts +10 -5
- package/lib/dom/Element.js +43 -15
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +37 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +424 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +38 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +185 -16
- package/lib/dom/index.d.ts +3 -0
- package/lib/dom/index.js +39 -0
- package/lib/dom/interfaces.d.ts +36 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +1 -0
- package/lib/global-module.js +12 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +2 -23
- package/lib/plugins/DirtyCheckPlugin.js +1 -1
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +41 -33
- package/lib/plugins/PrepareRendererPlugin.js +24 -4
- package/lib/property-handlers/aabb.js +18 -19
- package/lib/property-handlers/color.js +6 -3
- package/lib/property-handlers/dimension.d.ts +15 -3
- package/lib/property-handlers/dimension.js +50 -8
- package/lib/property-handlers/index.d.ts +3 -0
- package/lib/property-handlers/index.js +39 -0
- package/lib/property-handlers/inherit.d.ts +6 -0
- package/lib/property-handlers/inherit.js +34 -0
- package/lib/property-handlers/interfaces.d.ts +2 -2
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/text.d.ts +2 -0
- package/lib/property-handlers/text.js +10 -0
- package/lib/property-handlers/textTransform.d.ts +6 -0
- package/lib/property-handlers/textTransform.js +27 -0
- package/lib/services/EventService.js +3 -5
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.js +1 -7
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +10 -3
- package/lib/services/SceneGraphService.d.ts +0 -7
- package/lib/services/SceneGraphService.js +10 -77
- package/lib/services/aabb/CircleUpdater.js +2 -2
- package/lib/services/aabb/EllipseUpdater.js +1 -1
- package/lib/services/aabb/LineUpdater.js +1 -1
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/PolylineUpdater.js +2 -2
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/services/aabb/TextUpdater.js +18 -9
- package/lib/services/text/index.js +19 -21
- package/lib/types.d.ts +48 -24
- package/lib/types.js +56 -35
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +5 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/path.js +10 -10
- package/lib/utils/raf.d.ts +1 -1
- package/lib/utils/raf.js +0 -2
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +3 -3
- package/package.json +5 -3
|
@@ -17,18 +17,22 @@ function (_super) {
|
|
|
17
17
|
(0, _tslib.__extends)(Text, _super);
|
|
18
18
|
|
|
19
19
|
function Text(_a) {
|
|
20
|
+
if (_a === void 0) {
|
|
21
|
+
_a = {};
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
var style = _a.style,
|
|
21
25
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
22
26
|
return _super.call(this, (0, _tslib.__assign)({
|
|
23
|
-
type: _types.
|
|
27
|
+
type: _types.Shape.TEXT,
|
|
24
28
|
style: (0, _tslib.__assign)({
|
|
25
29
|
text: '',
|
|
26
|
-
fontSize:
|
|
27
|
-
fontFamily: '
|
|
30
|
+
fontSize: 'inherit',
|
|
31
|
+
fontFamily: 'inherit',
|
|
28
32
|
fontStyle: 'normal',
|
|
29
33
|
fontWeight: 'normal',
|
|
30
34
|
fontVariant: 'normal',
|
|
31
|
-
textAlign: '
|
|
35
|
+
textAlign: 'inherit',
|
|
32
36
|
textBaseline: 'alphabetic',
|
|
33
37
|
dropShadow: false,
|
|
34
38
|
// dropShadowAlpha: 1,
|
|
@@ -39,16 +43,17 @@ function (_super) {
|
|
|
39
43
|
fill: '#000',
|
|
40
44
|
letterSpacing: 0,
|
|
41
45
|
lineHeight: 0,
|
|
42
|
-
lineJoin: _types.
|
|
43
|
-
lineCap: _types.
|
|
46
|
+
lineJoin: _types.LineJoin.MITER,
|
|
47
|
+
lineCap: _types.LineCap.BUTT,
|
|
44
48
|
lineWidth: 0,
|
|
45
49
|
miterLimit: 10,
|
|
46
|
-
// padding: 0,
|
|
47
50
|
stroke: '#000',
|
|
48
51
|
whiteSpace: 'pre',
|
|
49
52
|
wordWrap: false,
|
|
50
53
|
wordWrapWidth: 0,
|
|
51
|
-
leading: 0
|
|
54
|
+
leading: 0,
|
|
55
|
+
dx: 0,
|
|
56
|
+
dy: 0
|
|
52
57
|
}, style)
|
|
53
58
|
}, rest)) || this;
|
|
54
59
|
}
|
package/lib/dom/Animation.js
CHANGED
|
@@ -31,7 +31,7 @@ function () {
|
|
|
31
31
|
this.effect = effect;
|
|
32
32
|
effect.animation = this;
|
|
33
33
|
this.timeline = timeline;
|
|
34
|
-
this.id = ""
|
|
34
|
+
this.id = "".concat(sequenceNumber++);
|
|
35
35
|
this._inEffect = !!this.effect.update(0);
|
|
36
36
|
this._holdTime = 0;
|
|
37
37
|
this._paused = false;
|
|
@@ -19,17 +19,17 @@ var CustomElementRegistry =
|
|
|
19
19
|
function () {
|
|
20
20
|
function CustomElementRegistry() {
|
|
21
21
|
this.registry = {};
|
|
22
|
-
this.define(_types.
|
|
23
|
-
this.define(_types.
|
|
24
|
-
this.define(_types.
|
|
25
|
-
this.define(_types.
|
|
26
|
-
this.define(_types.
|
|
27
|
-
this.define(_types.
|
|
28
|
-
this.define(_types.
|
|
29
|
-
this.define(_types.
|
|
30
|
-
this.define(_types.
|
|
31
|
-
this.define(_types.
|
|
32
|
-
this.define(_types.
|
|
22
|
+
this.define(_types.Shape.CIRCLE, _displayObjects.Circle);
|
|
23
|
+
this.define(_types.Shape.ELLIPSE, _displayObjects.Ellipse);
|
|
24
|
+
this.define(_types.Shape.RECT, _displayObjects.Rect);
|
|
25
|
+
this.define(_types.Shape.IMAGE, _displayObjects.Image);
|
|
26
|
+
this.define(_types.Shape.LINE, _displayObjects.Line);
|
|
27
|
+
this.define(_types.Shape.GROUP, _displayObjects.Group);
|
|
28
|
+
this.define(_types.Shape.PATH, _displayObjects.Path);
|
|
29
|
+
this.define(_types.Shape.POLYGON, _displayObjects.Polygon);
|
|
30
|
+
this.define(_types.Shape.POLYLINE, _displayObjects.Polyline);
|
|
31
|
+
this.define(_types.Shape.TEXT, _displayObjects.Text);
|
|
32
|
+
this.define(_types.Shape.HTML, _displayObjects.HTML);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
CustomElementRegistry.prototype.define = function (name, constructor) {
|
package/lib/dom/Document.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class Document extends Node implements IDocument {
|
|
|
34
34
|
* @example const circle = document.createElement('circle', { style: { r: 10 } });
|
|
35
35
|
*/
|
|
36
36
|
createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
|
|
37
|
+
createElementNS<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(namespaceURI: string, tagName: string, options: DisplayObjectConfig<StyleProps>): T;
|
|
37
38
|
cloneNode(deep?: boolean): this;
|
|
38
39
|
destroy(): void;
|
|
39
40
|
/**
|
package/lib/dom/Document.js
CHANGED
|
@@ -13,6 +13,8 @@ var _AnimationTimeline = require("./AnimationTimeline");
|
|
|
13
13
|
|
|
14
14
|
var _Group = require("../display-objects/Group");
|
|
15
15
|
|
|
16
|
+
var _types = require("../types");
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* the entry of DOM tree
|
|
18
20
|
* Document -> Node -> EventTarget
|
|
@@ -38,7 +40,15 @@ function (_super) {
|
|
|
38
40
|
_this.timeline = new _AnimationTimeline.AnimationTimeline(); // like <html> in DOM tree
|
|
39
41
|
|
|
40
42
|
_this.documentElement = new _Group.Group({
|
|
41
|
-
id: 'g-root'
|
|
43
|
+
id: 'g-root',
|
|
44
|
+
style: {
|
|
45
|
+
textAlign: _types.TextAlign.START,
|
|
46
|
+
fontSize: '16px',
|
|
47
|
+
fontFamily: 'sans-serif' // fontStyle: 'normal',
|
|
48
|
+
// fontWeight: 'normal',
|
|
49
|
+
// fontVariant: 'normal',
|
|
50
|
+
|
|
51
|
+
}
|
|
42
52
|
});
|
|
43
53
|
_this.documentElement.ownerDocument = _this;
|
|
44
54
|
_this.documentElement.parentNode = _this;
|
|
@@ -79,8 +89,19 @@ function (_super) {
|
|
|
79
89
|
*/
|
|
80
90
|
|
|
81
91
|
Document.prototype.createElement = function (tagName, options) {
|
|
92
|
+
// d3 will use <tspan>
|
|
82
93
|
var clazz = this.defaultView.customElements.get(tagName);
|
|
94
|
+
|
|
95
|
+
if (!clazz) {
|
|
96
|
+
console.warn('Unsupported tagName: ', tagName);
|
|
97
|
+
clazz = _Group.Group;
|
|
98
|
+
}
|
|
99
|
+
|
|
83
100
|
return new clazz(options);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Document.prototype.createElementNS = function (namespaceURI, tagName, options) {
|
|
104
|
+
return this.createElement(tagName, options);
|
|
84
105
|
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
106
|
|
|
86
107
|
|
package/lib/dom/Element.d.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -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(
|
|
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/lib/dom/Element.js
CHANGED
|
@@ -19,6 +19,10 @@ var _interfaces = require("./interfaces");
|
|
|
19
19
|
|
|
20
20
|
var _globalModule = require("../global-module");
|
|
21
21
|
|
|
22
|
+
var _utils = require("../utils");
|
|
23
|
+
|
|
24
|
+
var _ = require("..");
|
|
25
|
+
|
|
22
26
|
var entityCounter = 0;
|
|
23
27
|
/**
|
|
24
28
|
* Has following capabilities:
|
|
@@ -42,6 +46,11 @@ function (_super) {
|
|
|
42
46
|
_this.transformable = new _components.Transform();
|
|
43
47
|
_this.sortable = new _components.Sortable();
|
|
44
48
|
_this.geometry = new _components.Geometry();
|
|
49
|
+
/**
|
|
50
|
+
* https://developer.mozilla.org/zh-CN/docs/Web/API/Element/namespaceURI
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
_this.namespaceURI = 'g';
|
|
45
54
|
_this.scrollLeft = 0;
|
|
46
55
|
_this.scrollTop = 0;
|
|
47
56
|
/**
|
|
@@ -68,6 +77,20 @@ function (_super) {
|
|
|
68
77
|
return !!target.getAttribute;
|
|
69
78
|
};
|
|
70
79
|
|
|
80
|
+
Object.defineProperty(Element.prototype, "className", {
|
|
81
|
+
/**
|
|
82
|
+
* used in `getElementsByClassName`
|
|
83
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
|
|
84
|
+
*/
|
|
85
|
+
get: function get() {
|
|
86
|
+
return this.getAttribute('class') || '';
|
|
87
|
+
},
|
|
88
|
+
set: function set(className) {
|
|
89
|
+
this.setAttribute('class', className);
|
|
90
|
+
},
|
|
91
|
+
enumerable: false,
|
|
92
|
+
configurable: true
|
|
93
|
+
});
|
|
71
94
|
Object.defineProperty(Element.prototype, "classList", {
|
|
72
95
|
/**
|
|
73
96
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
|
|
@@ -153,11 +176,12 @@ function (_super) {
|
|
|
153
176
|
this.sceneGraphService.attach(child, this, index);
|
|
154
177
|
this.emit(_interfaces.ElementEvent.CHILD_INSERTED, {
|
|
155
178
|
child: child
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
179
|
+
}); // child.emit(ElementEvent.INSERTED, {
|
|
180
|
+
// parent: this,
|
|
181
|
+
// index,
|
|
182
|
+
// });
|
|
183
|
+
|
|
184
|
+
child.dispatchEvent(new _.MutationEvent(_interfaces.ElementEvent.INSERTED, this, '', '', '', 0, '', ''));
|
|
161
185
|
return child;
|
|
162
186
|
};
|
|
163
187
|
|
|
@@ -180,14 +204,15 @@ function (_super) {
|
|
|
180
204
|
};
|
|
181
205
|
|
|
182
206
|
Element.prototype.removeChild = function (child, destroy) {
|
|
207
|
+
// should emit on itself before detach
|
|
208
|
+
// child.emit(ElementEvent.REMOVED, {
|
|
209
|
+
// parent: this,
|
|
210
|
+
// });
|
|
183
211
|
if (destroy === void 0) {
|
|
184
212
|
destroy = true;
|
|
185
|
-
}
|
|
186
|
-
|
|
213
|
+
}
|
|
187
214
|
|
|
188
|
-
child.
|
|
189
|
-
parent: this
|
|
190
|
-
}); // emit destroy event
|
|
215
|
+
child.dispatchEvent(new _.MutationEvent(_interfaces.ElementEvent.REMOVED, this, '', '', '', 0, '', '')); // emit destroy event
|
|
191
216
|
|
|
192
217
|
if (destroy) {
|
|
193
218
|
child.emit(_interfaces.ElementEvent.DESTROY, {});
|
|
@@ -231,15 +256,15 @@ function (_super) {
|
|
|
231
256
|
};
|
|
232
257
|
|
|
233
258
|
Element.prototype.getElementById = function (id) {
|
|
234
|
-
return this.sceneGraphService.querySelector("#"
|
|
259
|
+
return this.sceneGraphService.querySelector("#".concat(id), this);
|
|
235
260
|
};
|
|
236
261
|
|
|
237
262
|
Element.prototype.getElementsByName = function (name) {
|
|
238
|
-
return this.sceneGraphService.querySelectorAll("[name=\""
|
|
263
|
+
return this.sceneGraphService.querySelectorAll("[name=\"".concat(name, "\"]"), this);
|
|
239
264
|
};
|
|
240
265
|
|
|
241
266
|
Element.prototype.getElementsByClassName = function (className) {
|
|
242
|
-
return this.sceneGraphService.querySelectorAll("."
|
|
267
|
+
return this.sceneGraphService.querySelectorAll(".".concat(className), this);
|
|
243
268
|
};
|
|
244
269
|
|
|
245
270
|
Element.prototype.getElementsByTagName = function (tagName) {
|
|
@@ -475,10 +500,13 @@ function (_super) {
|
|
|
475
500
|
*/
|
|
476
501
|
|
|
477
502
|
|
|
478
|
-
Element.prototype.getAttribute = function (
|
|
503
|
+
Element.prototype.getAttribute = function (name) {
|
|
504
|
+
var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(name, ''), 1),
|
|
505
|
+
attributeName = _a[0];
|
|
506
|
+
|
|
479
507
|
var value = this.attributes[attributeName]; // if the given attribute does not exist, the value returned will either be null or ""
|
|
480
508
|
|
|
481
|
-
return (0, _util.isNil)(value) ?
|
|
509
|
+
return (0, _util.isNil)(value) ? null : value;
|
|
482
510
|
};
|
|
483
511
|
/**
|
|
484
512
|
* 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.
|
package/lib/dom/EventTarget.d.ts
CHANGED
|
@@ -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
|
package/lib/dom/EventTarget.js
CHANGED
|
@@ -68,7 +68,7 @@ function () {
|
|
|
68
68
|
useDelegatedName = true;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
type = capture ? type
|
|
71
|
+
type = capture ? "".concat(type, "capture") : type;
|
|
72
72
|
listener = (0, _util.isFunction)(listener) ? listener : listener.handleEvent; // compatible with G 3.0
|
|
73
73
|
|
|
74
74
|
if (useDelegatedName) {
|
|
@@ -85,7 +85,8 @@ function () {
|
|
|
85
85
|
|
|
86
86
|
if (((_a = args[0].target) === null || _a === void 0 ? void 0 : _a.name) !== delegatedName) {
|
|
87
87
|
return;
|
|
88
|
-
}
|
|
88
|
+
} // @ts-ignore
|
|
89
|
+
|
|
89
90
|
|
|
90
91
|
originListener_1.apply(void 0, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(args), false));
|
|
91
92
|
};
|
|
@@ -123,7 +124,7 @@ function () {
|
|
|
123
124
|
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
124
125
|
var capture = (0, _util.isBoolean)(options) && options || (0, _util.isObject)(options) && options.capture;
|
|
125
126
|
var context = (0, _util.isFunction)(listener) ? undefined : listener;
|
|
126
|
-
type = capture ? type
|
|
127
|
+
type = capture ? "".concat(type, "capture") : type;
|
|
127
128
|
listener = (0, _util.isFunction)(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
|
|
128
129
|
this.emitter.off(type, listener, context);
|
|
129
130
|
return this;
|
package/lib/dom/KeyframeList.js
CHANGED
|
@@ -102,7 +102,7 @@ function normalizeKeyframes(effectInput, timing) {
|
|
|
102
102
|
// TODO: Support add & accumulate in KeyframeEffect.composite
|
|
103
103
|
// @see https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/composite
|
|
104
104
|
if (['replace', 'add', 'accumulate', 'auto'].indexOf(memberValue) === -1) {
|
|
105
|
-
throw new Error(memberValue
|
|
105
|
+
throw new Error("".concat(memberValue, " compositing is not supported"));
|
|
106
106
|
}
|
|
107
107
|
} else if (member === 'easing') {// TODO: Validate animation-timing-function
|
|
108
108
|
// @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,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MutationEvent = void 0;
|
|
7
|
+
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
10
|
+
var _FederatedEvent = require("./FederatedEvent");
|
|
11
|
+
|
|
12
|
+
var MutationEvent =
|
|
13
|
+
/** @class */
|
|
14
|
+
function (_super) {
|
|
15
|
+
(0, _tslib.__extends)(MutationEvent, _super);
|
|
16
|
+
|
|
17
|
+
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
18
|
+
var _this = _super.call(this, null) || this;
|
|
19
|
+
|
|
20
|
+
_this.relatedNode = relatedNode;
|
|
21
|
+
_this.prevValue = prevValue;
|
|
22
|
+
_this.newValue = newValue;
|
|
23
|
+
_this.attrName = attrName;
|
|
24
|
+
_this.attrChange = attrChange;
|
|
25
|
+
_this.prevParsedValue = prevParsedValue;
|
|
26
|
+
_this.newParsedValue = newParsedValue;
|
|
27
|
+
_this.type = typeArg;
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
MutationEvent.ADDITION = 2;
|
|
32
|
+
MutationEvent.MODIFICATION = 1;
|
|
33
|
+
MutationEvent.REMOVAL = 3;
|
|
34
|
+
return MutationEvent;
|
|
35
|
+
}(_FederatedEvent.FederatedEvent);
|
|
36
|
+
|
|
37
|
+
exports.MutationEvent = 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
|
+
}
|