[Vuejs]-Create hooks for automated testing

2👍

If I’m understanding you correctly, you want to globally add `role=”$options.name” to the root element of every component?

If so, I think you can get away with a global mixin which does this on mounted lifecycle hook.

For example, something like this:

Vue.mixin({
  mounted () {
    if (this.$el.setAttribute && this.$options.name) {
      this.$el.setAttribute('role', this.$options.name)
    }
  },
})

Leave a comment