Skip to content
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

Merged
merged 10 commits into from
Nov 21, 2017
Merged

Add SVG attributes #465

merged 10 commits into from
Nov 21, 2017

Conversation

sleepycat
Copy link
Contributor

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 and circle. Omissions are onClick and friends and fr an attribute on radialGradient 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:

  • Documentation
  • Tests
  • Code complete

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.

sleepycat and others added 7 commits November 10, 2017 14:12
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/'
Copy link
Member

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.

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkh44 tkh44 merged commit 7d2b697 into emotion-js:master Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[react-emotion] Not support svg props
3 participants