-
-
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.
Fixed an issue with extracting labels from obj literal properties and…
… added support for extracting from object methods (#2340) * Fixed an issue with extracting labels from obj literal properties and added support for extracting from object methods * Stick to only extracting from string literals Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
- Loading branch information
Showing
14 changed files
with
529 additions
and
194 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,5 @@ | ||
--- | ||
'@emotion/babel-plugin': patch | ||
--- | ||
|
||
Fixed a crash when extracting labels from object properties with string literal keys in certain situations. |
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,5 @@ | ||
--- | ||
'@emotion/babel-plugin': minor | ||
--- | ||
|
||
Added support for label extraction from object methods. |
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
217 changes: 142 additions & 75 deletions
217
packages/babel-plugin/__tests__/__snapshots__/styled.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
packages/babel-plugin/__tests__/css-macro/__fixtures__/label-obj-method.js
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,13 @@ | ||
import { css } from '@emotion/react/macro' | ||
|
||
const obj = { | ||
FooBar() { | ||
return ( | ||
<div | ||
css={css` | ||
background-color: hotpink; | ||
`} | ||
/> | ||
) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/babel-plugin/__tests__/css-macro/__fixtures__/label-obj-property-literal.js
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,11 @@ | ||
import { css } from '@emotion/react/macro' | ||
|
||
const obj = { | ||
'red component': ( | ||
<div | ||
css={css` | ||
background-color: hotpink; | ||
`} | ||
/> | ||
) | ||
} |
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
6 changes: 6 additions & 0 deletions
6
packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-assignment-expression.js
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,6 @@ | ||
/** @jsx jsx */ | ||
import styled from '@emotion/styled/macro' | ||
import { jsx } from '@emotion/react' | ||
|
||
let Comp | ||
Comp = styled.div`` |
12 changes: 12 additions & 0 deletions
12
packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-class-fields.js
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,12 @@ | ||
/** @jsx jsx */ | ||
import styled from '@emotion/styled/macro' | ||
import { jsx } from '@emotion/react' | ||
|
||
class Thing { | ||
static SomeComponent = styled.div` | ||
color: hotpink; | ||
` | ||
BadIdeaComponent = styled.div` | ||
background: hotpink; | ||
` | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-member-expression.js
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,7 @@ | ||
/** @jsx jsx */ | ||
import styled from '@emotion/styled/macro' | ||
import { jsx } from '@emotion/react' | ||
|
||
const Timeline = styled.ul`` | ||
Timeline.Item = styled.li`` | ||
Timeline.Item.Anchor = styled.a`` |
9 changes: 9 additions & 0 deletions
9
packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-sanitize.js
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,9 @@ | ||
/** @jsx jsx */ | ||
/* eslint-disable react/jsx-pascal-case */ | ||
import styled from '@emotion/styled/macro' | ||
import { jsx } from '@emotion/react' | ||
|
||
const MiniCalWrap$ = styled.div` | ||
color: red; | ||
` | ||
const Test = () => <MiniCalWrap$ /> |
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
Oops, something went wrong.