bootstrap-vue
Version:
BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.
31 lines (29 loc) • 557 B
JavaScript
/*
* SSR Safe Client Side ID attribute generation
*
*/
export default {
props: {
id: {
type: String,
default: null
}
},
methods: {
safeId (suffix = '') {
const id = this.id || this.localId_ || null
if (!id) {
return null
}
suffix = String(suffix).replace(/\s+/g, '_')
return suffix ? id + '_' + suffix : id
}
},
computed: {
localId_ () {
if (!this.$isServer && !this.id && typeof this._uid !== 'undefined') {
return '__BVID__' + this._uid
}
}
}
}