Skip to content

Commit 781704c

Browse files
agriffisgregberge
authored andcommitted
fix(emotion): pass options through (#202)
1 parent 1194100 commit 781704c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/emotion/src/styled.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ describe('#styled', () => {
142142
const { container } = render(<Dummy />)
143143
expect(container.firstChild).toHaveStyle('color: red; margin: 4px;')
144144
})
145+
146+
it('passes options through', () => {
147+
// https://emotion.sh/docs/styled#customizing-prop-forwarding
148+
const Dummy = styled('div', {
149+
shouldForwardProp: (prop) => prop !== 'color',
150+
})``
151+
const { container } = render(<Dummy color="lemonchiffon" />)
152+
expect(container.firstChild).not.toHaveAttribute('color', 'lemonchiffon')
153+
})
145154
})
146155

147156
describe('#styled.xxx', () => {

packages/emotion/src/styled.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ type BoxStyledTags = {
3333
interface CreateXStyled extends CreateStyled, BoxStyledTags {}
3434

3535
// @ts-ignore
36-
export const styled: CreateXStyled = (component: any) => {
37-
return getCreateStyle(emStyled(component))
36+
export const styled: CreateXStyled = (component: any, options: any) => {
37+
return getCreateStyle(emStyled(component, options))
3838
}
3939

4040
styled.box = styled(x.div)

0 commit comments

Comments
 (0)