Skip to content

Commit

Permalink
add support fot component's modal.attributes property
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewvasilchuk committed Nov 10, 2019
1 parent 8c5666b commit 73bf020
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions demo/components/ExampleComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default {
modal: {
classes: ['baz', 'poo', { javascript: true, jQuery: false }],
label: 'Foo bar',
attributes: {
'data-test': 'foo'
}
},
}
</script>
Expand Down
19 changes: 17 additions & 2 deletions src/components/VueAccessibleModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default {
component: null,
options: {},
lastFocusedElement: null,
localAttributes: null,
}
},
computed: {
Expand All @@ -59,8 +60,14 @@ export default {
return arr
},
attributes() {
const { options } = this
if (options) return options.attributes
const { options, localAttributes } = this
if (options) {
if (localAttributes) {
return Object.assign({}, localAttributes, options.attributes)
}
return options.attributes
}
return {}
},
props() {
Expand Down Expand Up @@ -157,6 +164,14 @@ export default {
if (focusableElements.length) {
focusableElements[0].focus()
}
const { modal } = this.$refs.component.$options
if (modal) {
if (modal.attributes) {
this.localAttributes = modal.attributes
}
}
},
},
}
Expand Down

0 comments on commit 73bf020

Please sign in to comment.