@antv/g 5.0.15 → 5.0.18
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 +7 -1
- package/es/Canvas.js +9 -10
- 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 +9 -3
- package/es/display-objects/DisplayObject.js +97 -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 +32 -4
- package/es/display-objects/Text.js +70 -10
- package/es/dom/Animation.js +2 -2
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +2 -1
- package/es/dom/Document.js +22 -2
- package/es/dom/Element.d.ts +38 -5
- package/es/dom/Element.js +115 -16
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- package/es/dom/FederatedEvent.d.ts +4 -1
- 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 +39 -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/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +15 -5
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +41 -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 +11 -7
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.d.ts +12 -2
- package/es/services/RenderingService.js +23 -12
- 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 +17 -87
- 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 +31 -10
- package/es/services/text/index.js +19 -21
- package/es/shapes/AABB.js +5 -0
- package/es/types.d.ts +48 -24
- package/es/types.js +50 -31
- package/es/utils/animation.js +1 -1
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +7 -4
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +3 -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 +7 -1
- package/lib/Canvas.js +7 -8
- 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 +9 -3
- package/lib/display-objects/DisplayObject.js +97 -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 +32 -4
- package/lib/display-objects/Text.js +69 -9
- package/lib/dom/Animation.js +2 -2
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +2 -1
- package/lib/dom/Document.js +24 -3
- package/lib/dom/Element.d.ts +38 -5
- package/lib/dom/Element.js +117 -16
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- package/lib/dom/FederatedEvent.d.ts +4 -1
- 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 +39 -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/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +13 -5
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +42 -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 +11 -7
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.d.ts +12 -2
- package/lib/services/RenderingService.js +23 -11
- 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 +18 -91
- 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 +30 -9
- package/lib/services/text/index.js +19 -21
- package/lib/shapes/AABB.js +5 -0
- package/lib/types.d.ts +48 -24
- package/lib/types.js +56 -35
- package/lib/utils/animation.js +1 -1
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +7 -4
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +26 -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
package/es/dom/Document.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
2
|
import { Node } from './Node';
|
|
3
3
|
import { AnimationTimeline } from './AnimationTimeline';
|
|
4
|
-
import { Group } from '../display-objects
|
|
4
|
+
import { Group, Text } from '../display-objects';
|
|
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 = tagName === 'tspan' ? Text : 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
|
|
package/es/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
|
*/
|
|
@@ -41,6 +46,12 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
41
46
|
interactive: boolean;
|
|
42
47
|
scrollLeft: number;
|
|
43
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;
|
|
44
55
|
get tagName(): string;
|
|
45
56
|
get children(): IElement[];
|
|
46
57
|
get childElementCount(): number;
|
|
@@ -127,16 +138,28 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
127
138
|
* compatible with `style`
|
|
128
139
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
129
140
|
*/
|
|
130
|
-
style: StyleProps
|
|
141
|
+
style: StyleProps & ICSSStyleDeclaration<StyleProps>;
|
|
131
142
|
parsedStyle: ParsedStyleProps;
|
|
132
143
|
/**
|
|
133
144
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
|
|
134
145
|
*/
|
|
135
|
-
attributes: StyleProps;
|
|
146
|
+
readonly attributes: StyleProps;
|
|
147
|
+
/**
|
|
148
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
|
|
149
|
+
*/
|
|
150
|
+
getAttributeNames(): string[];
|
|
136
151
|
/**
|
|
137
152
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
|
|
138
153
|
*/
|
|
139
|
-
getAttribute(
|
|
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;
|
|
140
163
|
/**
|
|
141
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.
|
|
142
165
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
|
|
@@ -146,4 +169,14 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
146
169
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
|
|
147
170
|
*/
|
|
148
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;
|
|
149
182
|
}
|
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,8 +30,20 @@ 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;
|
|
40
|
+
/**
|
|
41
|
+
* We don't support border now
|
|
42
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
_this.clientTop = 0;
|
|
46
|
+
_this.clientLeft = 0;
|
|
33
47
|
/**
|
|
34
48
|
* is destroyed or not
|
|
35
49
|
*/
|
|
@@ -54,12 +68,28 @@ function (_super) {
|
|
|
54
68
|
return !!target.getAttribute;
|
|
55
69
|
};
|
|
56
70
|
|
|
71
|
+
Object.defineProperty(Element.prototype, "className", {
|
|
72
|
+
/**
|
|
73
|
+
* used in `getElementsByClassName`
|
|
74
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
|
|
75
|
+
*/
|
|
76
|
+
get: function get() {
|
|
77
|
+
return this.getAttribute('class') || '';
|
|
78
|
+
},
|
|
79
|
+
set: function set(className) {
|
|
80
|
+
this.setAttribute('class', className);
|
|
81
|
+
},
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true
|
|
84
|
+
});
|
|
57
85
|
Object.defineProperty(Element.prototype, "classList", {
|
|
58
86
|
/**
|
|
59
87
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
|
|
60
88
|
*/
|
|
61
89
|
get: function get() {
|
|
62
|
-
return this.className.split(' ')
|
|
90
|
+
return this.className.split(' ').filter(function (c) {
|
|
91
|
+
return c !== '';
|
|
92
|
+
});
|
|
63
93
|
},
|
|
64
94
|
enumerable: false,
|
|
65
95
|
configurable: true
|
|
@@ -139,11 +169,12 @@ function (_super) {
|
|
|
139
169
|
this.sceneGraphService.attach(child, this, index);
|
|
140
170
|
this.emit(ElementEvent.CHILD_INSERTED, {
|
|
141
171
|
child: child
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
172
|
+
}); // child.emit(ElementEvent.INSERTED, {
|
|
173
|
+
// parent: this,
|
|
174
|
+
// index,
|
|
175
|
+
// });
|
|
176
|
+
|
|
177
|
+
child.dispatchEvent(new MutationEvent(ElementEvent.INSERTED, this, '', '', '', 0, '', ''));
|
|
147
178
|
return child;
|
|
148
179
|
};
|
|
149
180
|
|
|
@@ -166,14 +197,15 @@ function (_super) {
|
|
|
166
197
|
};
|
|
167
198
|
|
|
168
199
|
Element.prototype.removeChild = function (child, destroy) {
|
|
200
|
+
// should emit on itself before detach
|
|
201
|
+
// child.emit(ElementEvent.REMOVED, {
|
|
202
|
+
// parent: this,
|
|
203
|
+
// });
|
|
169
204
|
if (destroy === void 0) {
|
|
170
205
|
destroy = true;
|
|
171
|
-
}
|
|
172
|
-
|
|
206
|
+
}
|
|
173
207
|
|
|
174
|
-
child.
|
|
175
|
-
parent: this
|
|
176
|
-
}); // emit destroy event
|
|
208
|
+
child.dispatchEvent(new MutationEvent(ElementEvent.REMOVED, this, '', '', '', 0, '', '')); // emit destroy event
|
|
177
209
|
|
|
178
210
|
if (destroy) {
|
|
179
211
|
child.emit(ElementEvent.DESTROY, {});
|
|
@@ -217,15 +249,15 @@ function (_super) {
|
|
|
217
249
|
};
|
|
218
250
|
|
|
219
251
|
Element.prototype.getElementById = function (id) {
|
|
220
|
-
return this.sceneGraphService.querySelector("#"
|
|
252
|
+
return this.sceneGraphService.querySelector("#".concat(id), this);
|
|
221
253
|
};
|
|
222
254
|
|
|
223
255
|
Element.prototype.getElementsByName = function (name) {
|
|
224
|
-
return this.sceneGraphService.querySelectorAll("[name=\""
|
|
256
|
+
return this.sceneGraphService.querySelectorAll("[name=\"".concat(name, "\"]"), this);
|
|
225
257
|
};
|
|
226
258
|
|
|
227
259
|
Element.prototype.getElementsByClassName = function (className) {
|
|
228
|
-
return this.sceneGraphService.querySelectorAll("."
|
|
260
|
+
return this.sceneGraphService.querySelectorAll(".".concat(className), this);
|
|
229
261
|
};
|
|
230
262
|
|
|
231
263
|
Element.prototype.getElementsByTagName = function (tagName) {
|
|
@@ -456,15 +488,42 @@ function (_super) {
|
|
|
456
488
|
Element.prototype.getClientRects = function () {
|
|
457
489
|
return [this.getBoundingClientRect()];
|
|
458
490
|
};
|
|
491
|
+
/**
|
|
492
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
|
|
493
|
+
*/
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
Element.prototype.getAttributeNames = function () {
|
|
497
|
+
return Object.keys(this.attributes);
|
|
498
|
+
};
|
|
459
499
|
/**
|
|
460
500
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
|
|
461
501
|
*/
|
|
462
502
|
|
|
463
503
|
|
|
464
|
-
Element.prototype.getAttribute = function (
|
|
504
|
+
Element.prototype.getAttribute = function (name) {
|
|
505
|
+
var _a = __read(formatAttribute(name, ''), 1),
|
|
506
|
+
attributeName = _a[0];
|
|
507
|
+
|
|
465
508
|
var value = this.attributes[attributeName]; // if the given attribute does not exist, the value returned will either be null or ""
|
|
466
509
|
|
|
467
|
-
return isNil(value) ?
|
|
510
|
+
return isNil(value) ? null : value;
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
|
|
514
|
+
*/
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
Element.prototype.hasAttribute = function (qualifiedName) {
|
|
518
|
+
return this.getAttributeNames().includes(qualifiedName);
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
|
|
522
|
+
*/
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
Element.prototype.hasAttributes = function () {
|
|
526
|
+
return !!this.getAttributeNames().length;
|
|
468
527
|
};
|
|
469
528
|
/**
|
|
470
529
|
* 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.
|
|
@@ -489,6 +548,46 @@ function (_super) {
|
|
|
489
548
|
this.attributes[attributeName] = value;
|
|
490
549
|
};
|
|
491
550
|
|
|
551
|
+
Element.prototype.getAttributeNS = function (namespace, localName) {
|
|
552
|
+
throw new Error('Method not implemented.');
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
Element.prototype.getAttributeNode = function (qualifiedName) {
|
|
556
|
+
throw new Error('Method not implemented.');
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
Element.prototype.getAttributeNodeNS = function (namespace, localName) {
|
|
560
|
+
throw new Error('Method not implemented.');
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
Element.prototype.hasAttributeNS = function (namespace, localName) {
|
|
564
|
+
throw new Error('Method not implemented.');
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
Element.prototype.removeAttributeNS = function (namespace, localName) {
|
|
568
|
+
throw new Error('Method not implemented.');
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
Element.prototype.removeAttributeNode = function (attr) {
|
|
572
|
+
throw new Error('Method not implemented.');
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
Element.prototype.setAttributeNS = function (namespace, qualifiedName, value) {
|
|
576
|
+
throw new Error('Method not implemented.');
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
Element.prototype.setAttributeNode = function (attr) {
|
|
580
|
+
throw new Error('Method not implemented.');
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
Element.prototype.setAttributeNodeNS = function (attr) {
|
|
584
|
+
throw new Error('Method not implemented.');
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
Element.prototype.toggleAttribute = function (qualifiedName, force) {
|
|
588
|
+
throw new Error('Method not implemented.');
|
|
589
|
+
};
|
|
590
|
+
|
|
492
591
|
return Element;
|
|
493
592
|
}(Node);
|
|
494
593
|
|
package/es/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/es/dom/EventTarget.js
CHANGED
|
@@ -54,7 +54,7 @@ function () {
|
|
|
54
54
|
useDelegatedName = true;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
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
|
|
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;
|
|
@@ -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;
|
package/es/dom/KeyframeList.js
CHANGED
|
@@ -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
|
|
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
|
+
}
|