Is width="100%" height="100%" not considered as default attributes on <svg> ?
See original GitHub issueBug
We’re using this library along with react-native-transformer to load our .svg files directly as react components. We recently added a compression step with SVGO library to reduce our .svgs files. By default, this library removes default attributes. One of them is the width
and height
on the <svg> tag that has 100%
(it looks like it should be 100% by default according to MDN. Unfortunately, by removing those two attributes, our svgs are not displayed anymore.
Is this something expected?
I don’t know if that can help but I also found out that the result svg in react native debugger was :
and by forcing the width and height to 100%:
our svgs were displayed again.
Environment info
React native info output:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 428.48 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 26, 27, 28, 29
Build Tools: 28.0.2, 28.0.3, 29.0.0, 29.0.2
System Images: android-26 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
Library version: 11.0.1
Steps To Reproduce
- Import an Svg file with that has the width and height attribute on the svg tag with 100% value
import MySVG from '../../mySVGFile.svg'
and use it as is in any component :<MySVG />
- Remove the
width="100%"
andheight="100%"
Describe what you expected to happen:
- I would expect the svg to be still displayed as per the default spec of svgs
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
@msand Version 12.0.2 works! Thanks
🎉 This issue has been resolved in version 12.0.2 🎉
The release is available on:
Your semantic-release bot 📦🚀