File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -706,3 +706,31 @@ describe('warningPrefix', () => {
706706 } ) ;
707707 } ) ;
708708} ) ;
709+
710+ describe ( 'testing children' , ( ) => {
711+ var createElement = React . createElement ;
712+
713+ before ( ( ) => {
714+ a11y ( React , { exclude : [ 'REDUNDANT_ALT' ] } ) ;
715+ } ) ;
716+
717+ after ( ( ) => {
718+ React . createElement = createElement ;
719+ } ) ;
720+
721+ describe ( 'when children is passed down in props' , ( ) => {
722+ it ( 'calls each test with the children' , ( ) => {
723+ doNotExpectWarning ( assertions . render . NO_LABEL . msg , ( ) => {
724+ React . createElement ( 'a' , { href : 'google.com' , children : 'Google' } ) ;
725+ } ) ;
726+ } ) ;
727+ } ) ;
728+
729+ describe ( 'when children is passed down separately from props' , ( ) => {
730+ it ( 'calls each test with the children' , ( ) => {
731+ doNotExpectWarning ( assertions . render . NO_LABEL . msg , ( ) => {
732+ React . createElement ( 'a' , { href : 'google.com' } , 'Google' ) ;
733+ } ) ;
734+ } ) ;
735+ } ) ;
736+ } ) ;
Original file line number Diff line number Diff line change @@ -177,6 +177,11 @@ var reactA11y = (React, options) => {
177177 var props = _props || { } ;
178178 options = options || { } ;
179179
180+ if ( children . length === 0 ) {
181+ children = props . children ;
182+ delete props . children ;
183+ }
184+
180185 props . id = createId ( props ) ;
181186 var reactEl = _createElement . apply ( this , [ type , props ] . concat ( children ) ) ;
182187 var failureCB = handleFailure . bind ( undefined , options , reactEl ) ;
You can’t perform that action at this time.
0 commit comments