Skip to content

Commit f2cf829

Browse files
committed
fix(canvas): update initial svg element
1 parent 1e4ea6a commit f2cf829

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/canvas/SVG/SVG.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Http, View, Style, CssProperty, AddChildFromBuilder, Frame, Property, path, knownFolders, CSSType, Screen, Application, Utils } from '@nativescript/core';
1+
import { Http, View, Style, CssProperty, AddChildFromBuilder, Frame, Property, path, knownFolders, CSSType, Application, Utils } from '@nativescript/core';
22

33
export const strokeProperty = new CssProperty<Style, any>({
44
name: 'stroke',
@@ -54,9 +54,10 @@ export const srcProperty = new Property<Svg, string>({
5454
name: 'src',
5555
});
5656

57-
declare const TNSSVG;
57+
declare const TNSSVG, org;
5858
import { SVGItem } from './SVGItem';
5959
import { DOMParser, XMLSerializer } from 'xmldom';
60+
const initialSVG = '<svg width="auto" height="auto" xmlns="http://www.w3.org/2000/svg"></svg>';
6061
@CSSType('Svg')
6162
export class Svg extends View {
6263
public static readyEvent = 'ready';
@@ -75,7 +76,7 @@ export class Svg extends View {
7576
this._svg = TNSSVG.alloc().initWithFrame(CGRectZero);
7677
this._svg.backgroundColor = UIColor.clearColor;
7778
}
78-
this._dom = new DOMParser().parseFromString('<svg width="auto" height="auto" xmlns="http://www.w3.org/2000/svg"></svg>');
79+
this._dom = new DOMParser().parseFromString(initialSVG);
7980
this._serializer = new XMLSerializer();
8081
}
8182

@@ -143,7 +144,7 @@ export class Svg extends View {
143144
domCopy.documentElement.setAttribute('height', `${this.getMeasuredHeight()}px`);
144145
}
145146
const serialized = this._serializer.serializeToString(domCopy);
146-
if (serialized !== '<svg xmlns="http://www.w3.org/2000/svg"></svg>') {
147+
if (serialized !== initialSVG) {
147148
this.src = serialized;
148149
}
149150
}

0 commit comments

Comments
 (0)