Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/components/dropdown/dropdown-item-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const props = {
type: String,
default: 'active'
},
buttonClass: {
type: [String, Array, Object],
default: null
},
disabled: {
type: Boolean,
default: false
Expand Down Expand Up @@ -48,10 +52,13 @@ export const BDropdownItemButton = /*#__PURE__*/ Vue.extend({
'button',
{
staticClass: 'dropdown-item',
class: {
[this.activeClass]: this.active,
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
},
class: [
this.buttonClass,
{
[this.activeClass]: this.active,
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
}
],
attrs: {
...this.$attrs,
role: 'menuitem',
Expand Down
15 changes: 15 additions & 0 deletions src/components/dropdown/dropdown-item-button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,19 @@ describe('dropdown-item-button', () => {

wrapper.destroy()
})

it('has buttonClass when prop is passed a value', () => {
const wrapper = mount(BDropdownItemButton, {
propsData: {
buttonClass: 'button-class'
}
})
expect(wrapper.is('li')).toBe(true)

const button = wrapper.find('button')
expect(button.classes()).toContain('button-class')
expect(button.classes()).toContain('dropdown-item')

wrapper.destroy()
})
})
13 changes: 10 additions & 3 deletions src/components/dropdown/dropdown-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const BDropdownItem = /*#__PURE__*/ Vue.extend({
},
props: {
...props,
linkClass: {
type: [String, Array, Object],
default: null
},
variant: {
type: String,
default: null
Expand All @@ -43,9 +47,12 @@ export const BDropdownItem = /*#__PURE__*/ Vue.extend({
{
props: this.$props,
staticClass: 'dropdown-item',
class: {
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
},
class: [
this.linkClass,
{
[`text-${this.variant}`]: this.variant && !(this.active || this.disabled)
}
],
attrs: { ...this.$attrs, role: 'menuitem' },
on: { click: this.onClick },
ref: 'item'
Expand Down
15 changes: 15 additions & 0 deletions src/components/dropdown/dropdown-item.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ describe('dropdown-item', () => {
wrapper.destroy()
})

it('has linkClass when prop is passed a value', () => {
const wrapper = mount(BDropdownItem, {
propsData: {
linkClass: 'link-class'
}
})
expect(wrapper.is('li')).toBe(true)

const item = wrapper.find('a')
expect(item.classes()).toContain('link-class')
expect(item.classes()).toContain('dropdown-item')

wrapper.destroy()
})

describe('router-link support', () => {
it('works', async () => {
const localVue = new CreateLocalVue()
Expand Down
14 changes: 14 additions & 0 deletions src/components/dropdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@
"aliases": [
"BDdItem"
],
"props": [
{
"prop": "linkClass",
"version": "2.9.0",
"description": "Class or classes to apply to the inner link element"
}
],
"events": [
{
"event": "click",
Expand All @@ -219,6 +226,13 @@
"BDdItemButton",
"BDdItemBtn"
],
"props": [
{
"prop": "buttonClass",
"version": "2.9.0",
"description": "Class or classes to apply to the inner button element"
}
],
"events": [
{
"event": "click",
Expand Down