Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 5e9c90d

Browse files
committed
Reformat svg utils
1 parent 06f7555 commit 5e9c90d

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/view/components/cpx/Svg_utils.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33

44
// Adapted from : https://github.com/microsoft/pxt/blob/master/pxtsim/svg.ts
55

6+
// tslint:disable-next-line: no-namespace
67
namespace svg {
78
export function addClass(el: SVGElement, cls: string) {
8-
if (el.classList) { el.classList.add(cls); }
9-
else if (el.className.baseVal.indexOf(cls) < 0) {
9+
if (el.classList) {
10+
el.classList.add(cls);
11+
} else if (el.className.baseVal.indexOf(cls) < 0) {
1012
el.className.baseVal += " " + cls;
11-
}
13+
}
1214
}
1315

1416
export function removeClass(el: SVGElement, cls: string) {
15-
if (el.classList) { el.classList.remove(cls); }
16-
else {
17+
if (el.classList) {
18+
el.classList.remove(cls);
19+
} else {
1720
el.className.baseVal = el.className.baseVal
1821
.replace(cls, "")
1922
.replace(/\s{2,}/, " ");
@@ -24,7 +27,9 @@ namespace svg {
2427
for (const k in props) {
2528
if (k == "title") {
2629
svg.title(el, props[k]);
27-
} else { el.setAttributeNS(null, k, props[k]); }
30+
} else {
31+
el.setAttributeNS(null, k, props[k]);
32+
}
2833
}
2934
}
3035

@@ -33,7 +38,9 @@ namespace svg {
3338
"http://www.w3.org/2000/svg",
3439
name
3540
);
36-
if (props) { svg.hydrate(newElement, props); }
41+
if (props) {
42+
svg.hydrate(newElement, props);
43+
}
3744
return newElement;
3845
}
3946

0 commit comments

Comments
 (0)