-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is width="100%" height="100%" not considered as default attributes on <svg> ? #1262
Comments
This should probably be fixed yeah, can add it to defaultProps of Svg |
BREAKING CHANGE: default size might change if width or height is missing
# [12.0.0](v11.0.1...v12.0.0) (2020-03-04) * fix!: #1262 default width and height on svg ([1d6798b](1d6798b)), closes [#1262](#1262) * fix!: #1247 Animated view translation inside Svg tag ([0288d95](0288d95)), closes [#1247](#1247) [#1258](#1258) ### Bug Fixes * **ios:** handle gradient and pattern transform when null ([715e9b8](715e9b8)) * **ios:** pod install error ([675df92](675df92)) * **web:** [#1274](#1274) Unable to build using babel-plugin-react-native-web ([80b5064](80b5064)) * removed missing unnecessary React headers import error caused by non-framework style import ([f795029](f795029)) ### Performance Improvements * optimize extraction of fill, stroke, responder, matrix & display ([279c3fc](279c3fc)) * optimize handling of font properties in G elements ([0fa4177](0fa4177)) * optimize handling of inherited styles ([363c1b4](363c1b4)) * optimize svg root prop handling, simplify element development ([f0cd11d](f0cd11d)) ### BREAKING CHANGES * default size might change if width or height is missing * Behavior of native elements is reverted to pre v10
@zoontek Can you try the latest commit from the develop branch? |
🎉 This issue has been resolved in version 12.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@msand It still does not work correctly. <Svg viewBox="0 0 200 200" style={{ backgroundColor: "red", aspectRatio: 1, width: "50%" }}>
<G fill="#FFF">
<Path d="M120.95 79.05V67.62h11.43v11.42h-11.43z" />
{/* … */}
</G>
</Svg> Will result in: The SVG is wider than 50%. |
Too bad this change was made, by default The real issue was with the EDIT: I confirm, |
Perhaps the default size should only be applied if both width and height are missing? Wasn't even aware of the single dimension + aspectRatio support. Thanks for bringing this up |
It would be easier to understand to keep default React Native behavior (no size). SVGO has a |
Well, this is more about aligning with the svg spec, which does specify an initial value of auto, which in the context of an svg element is treated as 100% |
And in the 1.1 spec: https://www.w3.org/TR/SVG11/struct.html#SVGElementWidthAttribute
|
I understand, but |
## [12.0.2](v12.0.1...v12.0.2) (2020-03-05) ### Bug Fixes * [#1262](#1262) support single dimension + aspectRatio syntax ([b2f7605](b2f7605))
🎉 This issue has been resolved in version 12.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@msand Version 12.0.2 works! Thanks |
Bug
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
andheight
on the tag that has100%
(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:
Library version: 11.0.1
Steps To Reproduce
import MySVG from '../../mySVGFile.svg'
and use it as is in any component :
<MySVG />
width="100%"
andheight="100%"
Describe what you expected to happen:
The text was updated successfully, but these errors were encountered: