@@ -13,15 +13,52 @@ foreach ($file in $svgFiles) {
1313# Add a class="Stravaig" attribute to the <svg> element, if one does not already exist
1414# Save the file back to disk
1515 [xml ]$svgXml = Get-Content - Path $file.FullName
16- $svgElement = $svgXml.DocumentElement
1716
17+ # Add the class to the SVG element
18+ $svgElement = $svgXml.DocumentElement
1819 if (-not $svgElement.HasAttribute (" class" )) {
1920 $svgElement.SetAttribute (" class" , " Stravaig" )
20- $svgXml.Save ($file.FullName )
21- Write-Host " Updated file: $ ( $file.FullName ) "
22- } else {
23- Write-Host " File already has class attribute: $ ( $file.FullName ) "
21+ Write-Host " Added <svg ... class=`" Stravaig`" > attribute to: $ ( $file.FullName ) "
22+ }
23+
24+ # All circle elements should get the fill="currentColor" attribute
25+ $circleElements = $svgXml.GetElementsByTagName (" circle" )
26+ foreach ($circle in $circleElements ) {
27+ if (-not $circle.HasAttribute (" fill" )) {
28+ $circle.SetAttribute (" fill" , " currentColor" )
29+ Write-Host " Added <circle ... fill=`" currentColor`" > in: $ ( $file.FullName ) "
30+ }
31+ }
32+
33+ # All path elements with an opacity attribute should get fill="currentColor"
34+ $pathElements = $svgXml.GetElementsByTagName (" path" )
35+ foreach ($path in $pathElements ) {
36+ if ($path.HasAttribute (" opacity" ) -and -not $path.HasAttribute (" fill" )) {
37+ $path.SetAttribute (" fill" , " currentColor" )
38+ Write-Host " Added <path ... fill=`" currentColor`" > in: $ ( $file.FullName ) "
39+ }
2440 }
41+
42+ # All rect elements with an opacity attribute should get fill="currentColor"
43+ $pathElements = $svgXml.GetElementsByTagName (" rect" )
44+ foreach ($path in $pathElements ) {
45+ if ($path.HasAttribute (" opacity" ) -and -not $path.HasAttribute (" fill" )) {
46+ $path.SetAttribute (" fill" , " currentColor" )
47+ Write-Host " Added <rect ... fill=`" currentColor`" > in: $ ( $file.FullName ) "
48+ }
49+ }
50+
51+ # All polygon elements with an opacity attribute should get fill="currentColor"
52+ $pathElements = $svgXml.GetElementsByTagName (" polygon" )
53+ foreach ($path in $pathElements ) {
54+ if ($path.HasAttribute (" opacity" ) -and -not $path.HasAttribute (" fill" )) {
55+ $path.SetAttribute (" fill" , " currentColor" )
56+ Write-Host " Added <polygon ... fill=`" currentColor`" > in: $ ( $file.FullName ) "
57+ }
58+ }
59+
60+ $svgXml.Save ($file.FullName )
61+ Write-Host " Updated file: $ ( $file.FullName ) "
2562}
2663
2764Write-Host " Completed updating SVG files."
0 commit comments