File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
examples/todomvc/components Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,13 @@ export default class MainSection extends Component {
1515 todos : PropTypes . array . isRequired ,
1616 actions : PropTypes . object . isRequired
1717 } ;
18+ // Keep a counter that can be used to create an html `id` attribute.
19+ static mountCount = 0 ;
1820
1921 constructor ( props , context ) {
2022 super ( props , context ) ;
2123 this . state = { filter : SHOW_ALL } ;
24+ this . htmlFormInputId = `toggle-all-${ MainSection . mountCount ++ } ` ;
2225 }
2326
2427 handleClearMarked ( ) {
@@ -57,12 +60,17 @@ export default class MainSection extends Component {
5760
5861 renderToggleAll ( markedCount ) {
5962 const { todos, actions } = this . props ;
63+
6064 if ( todos . length > 0 ) {
6165 return (
62- < input className = 'toggle-all'
63- type = 'checkbox'
64- checked = { markedCount === todos . length }
65- onChange = { actions . markAll } />
66+ < div >
67+ < input id = { this . htmlFormInputId }
68+ className = 'toggle-all'
69+ type = 'checkbox'
70+ checked = { markedCount === todos . length }
71+ onChange = { actions . markAll } />
72+ < label htmlFor = { this . htmlFormInputId } > Mark all as complete</ label >
73+ </ div >
6674 ) ;
6775 }
6876 }
You can’t perform that action at this time.
0 commit comments