Skip to content

Commit 222fb5e

Browse files
committed
fix: remove dom parser
1 parent 31a1050 commit 222fb5e

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

packages/canvas/SVG/SVG.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,62 +55,61 @@ export const srcProperty = new Property<Svg, string>({
5555
});
5656

5757
import { File } from '@nativescript/core';
58-
import { DOMParser } from 'xmldom';
5958
import { layout } from '@nativescript/core/utils';
6059
@CSSType('Svg')
6160
export class Svg extends View {
6261
public static readyEvent = 'ready';
6362
_svg: any;
6463
src: string;
65-
_domParser: DOMParser;
6664
constructor() {
6765
super();
68-
this._domParser = new DOMParser();
6966
if (global.isAndroid) {
7067
const activity = Application.android.foregroundActivity || Application.android.startActivity;
7168
this._svg = new (com as any).github.triniwiz.canvas.TNSSVG(activity);
7269
} else if (global.isIOS) {
73-
// this._svg = TNSSVG.new();
74-
// this._svg.backgroundColor = UIColor.clearColor;
70+
// this._svg = TNSSVG.new();
71+
// this._svg.backgroundColor = UIColor.clearColor;
7572
}
7673
}
7774

7875
[srcProperty.setNative](value: string) {
7976
if (typeof value === 'string') {
8077
if (value.indexOf('<svg') > -1) {
81-
if(global.isAndroid){
78+
if (global.isAndroid) {
8279
this._svg.setSrc(value);
83-
}else if(global.isIOS){
84-
setTimeout(()=>{
80+
} else if (global.isIOS) {
81+
setTimeout(() => {
8582
this._svg.src = value;
8683
}, 1000);
8784
}
8885
} else {
8986
if (value.startsWith('~')) {
90-
if(global.isAndroid){
87+
if (global.isAndroid) {
9188
this._svg.setSrcPath(path.join(knownFolders.currentApp().path, value.replace('~', '')));
92-
}else if(global.isIOS){
89+
} else if (global.isIOS) {
9390
this._svg.srcPath = path.join(knownFolders.currentApp().path, value.replace('~', ''));
9491
}
9592
} else if (value.startsWith('/')) {
96-
if(global.isAndroid){
93+
if (global.isAndroid) {
9794
this._svg.setSrcPath(value);
98-
}else if(global.isIOS){
95+
} else if (global.isIOS) {
9996
this._svg.srcPath = value;
10097
}
10198
} else if (value.startsWith('http')) {
102-
Http.getString(value).then((res) => {
103-
if(global.isAndroid){
104-
this._svg.setSrc(res);
105-
}else if(global.isIOS){
106-
setTimeout(()=>{
107-
console.log(!!res);
108-
this._svg.src = res;
109-
}, 1000);
110-
}
111-
}).catch(e=>{
112-
console.log(e);
113-
});
99+
Http.getString(value)
100+
.then((res) => {
101+
if (global.isAndroid) {
102+
this._svg.setSrc(res);
103+
} else if (global.isIOS) {
104+
setTimeout(() => {
105+
console.log(!!res);
106+
this._svg.src = res;
107+
}, 1000);
108+
}
109+
})
110+
.catch((e) => {
111+
console.log(e);
112+
});
114113
}
115114
}
116115
}

0 commit comments

Comments
 (0)