Skip to content

Commit 61f2002

Browse files
committed
Validate skip-to list component to prop
1 parent a905292 commit 61f2002

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/skip-to-list.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ export default {
3737
3838
props: {
3939
to: {
40-
type: Array
41-
/* TODO: add validator */
40+
validator: function (val) {
41+
return Array.isArray(val) &&
42+
val.every(({anchor, label}) => (
43+
typeof anchor === 'string' &&
44+
anchor.startsWith('#') &&
45+
typeof String(label) === 'string'
46+
))
47+
}
4248
}
4349
},
4450

0 commit comments

Comments
 (0)