-
-
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
Add SVG attributes #465
Add SVG attributes #465
Conversation
SVG attributes like "d" would not be passed to components, making SVG elements not render correctly (or at all). This commit adds SVG attributes as described on MDN (https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute) to the whitelist that are passed down to wrapped components. closes emotion-js#357
@@ -1,6 +1,6 @@ | |||
import React from 'react' | |||
import renderer from 'react-test-renderer' | |||
import styled, { css, flush } from 'react-emotion' | |||
import styled, { css, flush } from '../src/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this was changed? We alias all the packages to their src
and import them by name so we can runs tests on the dist files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like some snapshots are failing, could you update them?
What: This PR adds SVG attributes listed on MDN's SVG Attribute Reference page to the attribute whitelist so they are successfully passed to SVG elements like
path
andcircle
. Omissions are onClick and friends andfr
an attribute onradialGradient
elements which React seems to not seem to view as a legitimate attribute (it warns that it must be removed).Why: Currently key attributes required for the element to be rendered/visible are stripped off resulting in
path
elements not displaying on screen.How:
Checklist:
I'm happy to add documentation for this, but essentially this removes surprising behaviour and makes SVG work just like the rest of the documented API. As such, documenting the absence of this would probably provide more value than documenting it's presence.
It there are improvements in the tests or code that can should be made, please let me know. This is currently blocking me from adopting Emotion in one of my projects that uses a bunch of SVG so I'm keen to get merge-worthy.
Additionally, this closes #357
One other note: One of the commits here updates some of the existing snapshots. While I am a fan of Jest snapshotting failures aren't super instructive. Basically scale and fontSize attributes showed up in a few tests. I thought I would flag that so it get's a careful look and the implications could be thought about by people who are deeper into this than I am.