Skip to content

Commit d7cd5e7

Browse files
committed
chore(svg): clean up
1 parent 37f6f2f commit d7cd5e7

File tree

1 file changed

+60
-64
lines changed

1 file changed

+60
-64
lines changed

packages/canvas/SVG/SVG.ts

Lines changed: 60 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,86 @@
1-
import {View, AddChildFromBuilder, Style, CssProperty} from '@nativescript/core';
2-
import {Canvas} from '../Canvas';
3-
import {DOMParser} from 'xmldom-qsa';
1+
import { View, Style, CssProperty, AddChildFromBuilder } from '@nativescript/core';
2+
import { Canvas } from '../Canvas';
43

54
export const strokeProperty = new CssProperty<Style, any>({
6-
name: 'stroke',
7-
cssName: 'stroke',
8-
defaultValue: undefined
5+
name: 'stroke',
6+
cssName: 'stroke',
7+
defaultValue: undefined,
98
});
109

1110
export const strokeWidthProperty = new CssProperty<Style, number>({
12-
name: 'strokeWidth',
13-
cssName: 'stroke-width',
14-
defaultValue: 1,
11+
name: 'strokeWidth',
12+
cssName: 'stroke-width',
13+
defaultValue: 1,
1514
});
1615

1716
export const fillProperty = new CssProperty<Style, any>({
18-
name: 'fill',
19-
cssName: 'fill',
20-
defaultValue: undefined
17+
name: 'fill',
18+
cssName: 'fill',
19+
defaultValue: undefined,
2120
});
2221

2322
export const fillOpacityProperty = new CssProperty<Style, any>({
24-
name: 'fillOpacity',
25-
cssName: 'fill-opacity',
26-
defaultValue: undefined
23+
name: 'fillOpacity',
24+
cssName: 'fill-opacity',
25+
defaultValue: undefined,
2726
});
2827

2928
export const stopColorProperty = new CssProperty<Style, any>({
30-
name: 'stopColor',
31-
cssName: 'stop-color',
32-
defaultValue: undefined
29+
name: 'stopColor',
30+
cssName: 'stop-color',
31+
defaultValue: undefined,
3332
});
3433

3534
export class SVG extends View implements AddChildFromBuilder {
36-
_canvas: any;
37-
_views: any[];
38-
_children: Map<string, View>;
39-
_parser: DOMParser;
35+
_canvas: any;
36+
_views: any[];
37+
_children: Map<string, View>;
4038

41-
constructor() {
42-
super();
43-
this._canvas = new Canvas();
44-
this._views = [];
45-
this._parser = new DOMParser();
46-
this._children = new Map<string, View>();
47-
}
39+
constructor() {
40+
super();
41+
this._canvas = new Canvas();
42+
this._views = [];
43+
this._children = new Map<string, View>();
44+
}
4845

49-
createNativeView(): Object {
50-
this.on('layoutChanged', args => {
51-
this._views.forEach(view => {
52-
if (typeof view.handleValues === 'function') {
53-
view.handleValues();
54-
}
55-
});
56-
});
57-
if (this._canvas.ios) {
58-
return this._canvas.ios;
59-
}
60-
return this._canvas.android;
61-
}
46+
createNativeView(): Object {
47+
this.on('layoutChanged', (args) => {
48+
this._views.forEach((view) => {
49+
if (typeof view.handleValues === 'function') {
50+
view.handleValues();
51+
}
52+
});
53+
});
54+
if (this._canvas.ios) {
55+
return this._canvas.ios;
56+
}
57+
return this._canvas.android;
58+
}
6259

63-
_addChildFromBuilder(name: string, value: any): void {
64-
value._canvas = this._canvas;
65-
value.parent = this;
66-
this._views.push(value);
67-
this._children.set(value.id || value._domId, value);
68-
}
60+
_addChildFromBuilder(name: string, value: any): void {
61+
value._canvas = this._canvas;
62+
value.parent = this;
63+
this._views.push(value);
64+
this._children.set(value.id || value._domId, value);
65+
}
6966

67+
_getViewById(name: string) {
68+
if (typeof name === 'string') {
69+
if (name.indexOf('url') > -1) {
70+
name = name.replace('url', '').replace('(', '').replace(')', '');
71+
}
7072

71-
_getViewById(name: string) {
72-
if (typeof name === 'string') {
73-
if (name.indexOf('url') > -1) {
74-
name = name.replace('url', '').replace('(', '').replace(')', '');
75-
}
73+
if (name.indexOf('#')) {
74+
name = name.replace('#', '');
75+
}
7676

77-
if (name.indexOf('#')) {
78-
name = name.replace('#', '');
79-
}
80-
81-
if (name.startsWith("'")) {
82-
name = name.replace("'", '').replace("'", '');
83-
}
84-
return (this as any)._children.get(name);
85-
}
86-
return null;
87-
}
77+
if (name.startsWith("'")) {
78+
name = name.replace("'", '').replace("'", '');
79+
}
80+
return (this as any)._children.get(name);
81+
}
82+
return null;
83+
}
8884
}
8985

9086
stopColorProperty.register(Style);

0 commit comments

Comments
 (0)