Skip to content

Commit

Permalink
fix(popper): attr style fallthrough failed (element-plus#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonaliaChen authored Dec 8, 2020
1 parent 158c4f9 commit fabb9d5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/popper/__tests__/popper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,19 @@ describe('Popper.vue', () => {
await trigger.trigger(CLICK_EVENT)
expect(popper.vm.visibility).toBe(false)
})

test('should pass style and class to trigger', async () => {
const CLASS = 'fake'
const STYLE = 'width: 100px'
const wrapper = _mount({
appendToBody: false,
class: CLASS,
style: STYLE,
})

const trigger = wrapper.find(`.${TEST_TRIGGER}`)
expect(trigger.classes(CLASS)).toBe(true)
expect((trigger.element as HTMLDivElement).style.width).toBe('100px')
})
})
})
2 changes: 2 additions & 0 deletions packages/popper/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default defineComponent({
$slots,
appendToBody,
class: kls,
style,
effect,
hide,
onPopperMouseEnter,
Expand Down Expand Up @@ -103,6 +104,7 @@ export default defineComponent({
const triggerProps = {
ariaDescribedby: popperId,
class: kls,
style,
ref: 'triggerRef',
...this.events,
}
Expand Down
1 change: 1 addition & 0 deletions packages/popper/src/use-popper/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default {
type: String,
default: '',
},
style: Object,
closeDelay: {
type: Number,
default: 200,
Expand Down

0 comments on commit fabb9d5

Please sign in to comment.