Skip to content

Commit b107125

Browse files
committed
🎨 Improved role attribute handling
1 parent 9083da8 commit b107125

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

dist/vue-a11y-dialog.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/A11yDialog.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@click="role === 'alertdialog' ? undefined : close" />
88

99
<component :is="dialogElement"
10-
:role="role"
10+
:role="roleAttribute"
1111
:class="classNames.element"
1212
:aria-labelledby="titleId">
1313
<div role="document" :class="classNames.document">
@@ -35,10 +35,6 @@
3535
<script>
3636
import A11yDialog from 'a11y-dialog'
3737
38-
function roleValidator (value) {
39-
return ['dialog', 'alertdialog'].includes(value)
40-
}
41-
4238
export default {
4339
name: 'VueA11yDialog',
4440
@@ -49,7 +45,7 @@
4945
titleId: { type: String },
5046
closeButtonLabel: { type: String, default: 'Close this dialog window' },
5147
disableNative: { type: Boolean, default: false },
52-
role: { type: String, default: 'dialog', validator: roleValidator }
48+
role: { type: String, default: 'dialog' }
5349
},
5450
5551
computed: {
@@ -58,6 +54,13 @@
5854
},
5955
dialogElement () {
6056
return this.disableNative ? 'div' : 'dialog'
57+
},
58+
roleAttribute () {
59+
if (['dialog', 'alertdialog'].includes(this.role)) {
60+
return this.role
61+
} else {
62+
return 'dialog'
63+
}
6164
}
6265
},
6366

0 commit comments

Comments
 (0)