This repository was archived by the owner on Dec 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44// Adapted from : https://github.com/microsoft/pxt/blob/master/pxtsim/svg.ts
55
6+ // tslint:disable-next-line: no-namespace
67namespace 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
You can’t perform that action at this time.
0 commit comments