-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept objects as
className
in jsx-created components (they are str…
…ingified) to match React behavior (#1548)
- Loading branch information
Showing
6 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "releases": [{ "name": "@emotion/core", "type": "patch" }], "dependents": [] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Accept objects as `className` in jsx-created components (they are stringified) to match React behavior |
21 changes: 21 additions & 0 deletions
21
packages/core/__tests__/__snapshots__/legacy-class-name.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`object className 1`] = ` | ||
.emotion-0 { | ||
color: hotpink; | ||
} | ||
<div | ||
className="legacy__class emotion-0" | ||
/> | ||
`; | ||
|
||
exports[`string className 1`] = ` | ||
.emotion-0 { | ||
color: hotpink; | ||
} | ||
<div | ||
className="legacy__class emotion-0" | ||
/> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// @flow | ||
/** @jsx jsx */ | ||
import 'test-utils/next-env' | ||
import { jsx, css } from '@emotion/core' | ||
import renderer from 'react-test-renderer' | ||
|
||
test('string className', () => { | ||
const tree = renderer | ||
.create( | ||
<div | ||
className="legacy__class" | ||
css={css` | ||
color: hotpink; | ||
`} | ||
/> | ||
) | ||
.toJSON() | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('object className', () => { | ||
const tree = renderer | ||
.create( | ||
<div | ||
className={{ toString: () => 'legacy__class' }} | ||
css={css` | ||
color: hotpink; | ||
`} | ||
/> | ||
) | ||
.toJSON() | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters