esvg 4.2.5 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/esvg/symbol.rb +9 -0
- data/lib/esvg/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3215d01408d6127b3827a4514024675e5e45f46c
|
4
|
+
data.tar.gz: 8b1a528f475f4cf98e2c674d8b25f57643906f41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915d328c730f351de449eab23ac219f8b2ec9aef6df69f05656a5fc020de9c9c62c9a6bcab5a2c68fb5bcecd893d54888a808c42191669e33811a4d74d17461b
|
7
|
+
data.tar.gz: 7a65f080943ddd4d367b02474ecc0087f8246faa452973e7f1a37fbc10eab47daec0dfc3de0a710a18df6ef8df3e207829b48284c978f20cb046912e512937b4
|
data/lib/esvg/symbol.rb
CHANGED
@@ -139,6 +139,7 @@ module Esvg
|
|
139
139
|
|
140
140
|
@optimized = @content
|
141
141
|
sub_def_ids
|
142
|
+
move_defs
|
142
143
|
|
143
144
|
if svgo?
|
144
145
|
response = Open3.capture3(%Q{#{Esvg.node_module('svgo')} --disable=removeUselessDefs -s '#{@optimized}' -o -})
|
@@ -283,5 +284,13 @@ module Esvg
|
|
283
284
|
end
|
284
285
|
end
|
285
286
|
end
|
287
|
+
|
288
|
+
# <defs> should be moved to the beginning of the SVG file for braod browser support. Ahem, Firefox ಠ_ಠ
|
289
|
+
def move_defs
|
290
|
+
if defs = @optimized.scan(/(\s*<defs>.+<\/defs>\s*)/m).flatten[0]
|
291
|
+
@optimized.sub!(defs, '')
|
292
|
+
@optimized.sub!(/(<svg.+?>)/, "\1#{defs}")
|
293
|
+
end
|
294
|
+
end
|
286
295
|
end
|
287
296
|
end
|
data/lib/esvg/version.rb
CHANGED