File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
packages/styled-components/src Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ import { Box } from './Box'
55
66function getCreateStyle ( baseCreateStyle ) {
77 const createStyle = ( ...args ) => baseCreateStyle ( [ css ( ...args ) ] )
8+ createStyle . attrs = attrs => {
9+ const nextCreateStyle = baseCreateStyle . attrs ( attrs )
10+ return getCreateStyle ( nextCreateStyle )
11+ }
812 createStyle . withConfig = config => {
913 const nextCreateStyle = baseCreateStyle . withConfig ( config )
1014 return getCreateStyle ( nextCreateStyle )
Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ describe('#styled', () => {
6565 expect ( container . firstChild ) . toHaveStyleRule ( 'margin-top' , '2px' )
6666 expect ( container . firstChild ) . toHaveStyleRule ( 'padding' , '4px' )
6767 } )
68+ it ( 'works with "attrs"' , ( ) => {
69+ const Dummy = styled . div . attrs ( { 'aria-label' : 'label' } ) `
70+ margin: 2;
71+ `
72+ const { container } = render ( < Dummy /> )
73+ expect ( container . firstChild . getAttribute ( 'aria-label' ) ) . toBe ( 'label' )
74+ expect ( container . firstChild ) . toHaveStyleRule ( 'margin' , '8px' )
75+ } )
6876} )
6977
7078describe ( '#styled.xxx' , ( ) => {
You can’t perform that action at this time.
0 commit comments