Skip to content

Commit 0336b80

Browse files
chipit24sdras
authored andcommitted
Update todo-list-example for a11y (#1630)
* Update todo-list-example for a11y * Implement review suggestions * Use explicit label instead of aria-label * Move v-model directive to top for improved readability
1 parent f247d17 commit 0336b80

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/v2/guide/list.md

+20-12
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,15 @@ Here's a complete example of a simple todo list:
489489

490490
``` html
491491
<div id="todo-list-example">
492-
<input
493-
v-model="newTodoText"
494-
v-on:keyup.enter="addNewTodo"
495-
placeholder="Add a todo"
496-
>
492+
<form v-on:submit.prevent="addNewTodo">
493+
<label for="new-todo">Add a todo</label>
494+
<input
495+
v-model="newTodoText"
496+
id="new-todo"
497+
placeholder="E.g. Feed the cat"
498+
>
499+
<button>Add</button>
500+
</form>
497501
<ul>
498502
<li
499503
is="todo-item"
@@ -513,7 +517,7 @@ Vue.component('todo-item', {
513517
template: '\
514518
<li>\
515519
{{ title }}\
516-
<button v-on:click="$emit(\'remove\')">X</button>\
520+
<button v-on:click="$emit(\'remove\')">Remove</button>\
517521
</li>\
518522
',
519523
props: ['title']
@@ -553,11 +557,15 @@ new Vue({
553557

554558
{% raw %}
555559
<div id="todo-list-example" class="demo">
556-
<input
557-
v-model="newTodoText"
558-
v-on:keyup.enter="addNewTodo"
559-
placeholder="Add a todo"
560-
>
560+
<form v-on:submit.prevent="addNewTodo">
561+
<label for="new-todo">Add a todo</label>
562+
<input
563+
v-model="newTodoText"
564+
id="new-todo"
565+
placeholder="E.g. Feed the cat"
566+
>
567+
<button>Add</button>
568+
</form>
561569
<ul>
562570
<li
563571
is="todo-item"
@@ -573,7 +581,7 @@ Vue.component('todo-item', {
573581
template: '\
574582
<li>\
575583
{{ title }}\
576-
<button v-on:click="$emit(\'remove\')">X</button>\
584+
<button v-on:click="$emit(\'remove\')">Remove</button>\
577585
</li>\
578586
',
579587
props: ['title']

0 commit comments

Comments
 (0)