DEV: Ignore SVG sprite symbols missing ids

DEV: Ignore SVG sprite symbols missing ids

diff --git a/lib/svg_sprite/svg_sprite.rb b/lib/svg_sprite/svg_sprite.rb
index efdb832..fd2d688 100644
--- a/lib/svg_sprite/svg_sprite.rb
+++ b/lib/svg_sprite/svg_sprite.rb
@@ -365,7 +365,7 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL
       svg_file = Nokogiri::XML(File.open(fname))
 
       svg_file.css('symbol').each do |sym|
-        icons << sym.attributes['id'].value
+        icons << sym.attributes['id'].value if sym.attributes['id'].present?
       end
     end
     icons
diff --git a/spec/fixtures/images/custom-theme-icon-sprite.svg b/spec/fixtures/images/custom-theme-icon-sprite.svg
index 23974ec..eb3f524 100644
--- a/spec/fixtures/images/custom-theme-icon-sprite.svg
+++ b/spec/fixtures/images/custom-theme-icon-sprite.svg
@@ -3,4 +3,7 @@
   <symbol id="my-custom-theme-icon" viewBox="0 0 496 512">
     <path d="M248 8C111.03 8 0 119.03 0 256s111.03 248 248 248 248-111.03 248-248S384.97 8 248 8zm0 376c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm0-128c-53.02 0-96 42.98-96 96s42.98 96 96 96c-106.04 0-192-85.96-192-192S141.96 64 248 64c53.02 0 96 42.98 96 96s-42.98 96-96 96zm0-128c-17.67 0-32 14.33-32 32s14.33 32 32 32 32-14.33 32-32-14.33-32-32-32z"></path>
   </symbol>
+  <symbol class="id-missing" viewBox="0 0 64 64">
+    <path d="M18.679,56.392c-0.441,0-0.885-0.097-1.298-0.295c-1.04-0.5-1.702-1.551-1.702-2.705V10.608    c0-1.155,0.663-2.207,1.704-2.706c1.04-0.5,2.276-0.356,3.176,0.368l26.641,21.429c0.708,0.57,1.121,1.431,1.12,2.34    c-0.001,0.91-0.414,1.77-1.124,2.338L20.556,55.733C20.013,56.168,19.349,56.392,18.679,56.392z M21.68,16.871v30.271    l18.849-15.11L21.68,16.871z"/>
+  </symbol>
 </svg>

GitHub sha: dafba629

1 Like