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'
5
5
6
6
function getCreateStyle ( baseCreateStyle ) {
7
7
const createStyle = ( ...args ) => baseCreateStyle ( [ css ( ...args ) ] )
8
+ createStyle . attrs = attrs => {
9
+ const nextCreateStyle = baseCreateStyle . attrs ( attrs )
10
+ return getCreateStyle ( nextCreateStyle )
11
+ }
8
12
createStyle . withConfig = config => {
9
13
const nextCreateStyle = baseCreateStyle . withConfig ( config )
10
14
return getCreateStyle ( nextCreateStyle )
Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ describe('#styled', () => {
65
65
expect ( container . firstChild ) . toHaveStyleRule ( 'margin-top' , '2px' )
66
66
expect ( container . firstChild ) . toHaveStyleRule ( 'padding' , '4px' )
67
67
} )
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
+ } )
68
76
} )
69
77
70
78
describe ( '#styled.xxx' , ( ) => {
You can’t perform that action at this time.
0 commit comments