Skip to content

Commit

Permalink
fix(emotion): pass options through (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
agriffis authored and gregberge committed Mar 15, 2021
1 parent 1194100 commit 781704c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/emotion/src/styled.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ describe('#styled', () => {
const { container } = render(<Dummy />)
expect(container.firstChild).toHaveStyle('color: red; margin: 4px;')
})

it('passes options through', () => {
// https://emotion.sh/docs/styled#customizing-prop-forwarding
const Dummy = styled('div', {
shouldForwardProp: (prop) => prop !== 'color',
})``
const { container } = render(<Dummy color="lemonchiffon" />)
expect(container.firstChild).not.toHaveAttribute('color', 'lemonchiffon')
})
})

describe('#styled.xxx', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/emotion/src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type BoxStyledTags = {
interface CreateXStyled extends CreateStyled, BoxStyledTags {}

// @ts-ignore
export const styled: CreateXStyled = (component: any) => {
return getCreateStyle(emStyled(component))
export const styled: CreateXStyled = (component: any, options: any) => {
return getCreateStyle(emStyled(component, options))
}

styled.box = styled(x.div)
Expand Down

0 comments on commit 781704c

Please sign in to comment.