From fabb9d5f03e66ca1044da76d2aaa5202920c9888 Mon Sep 17 00:00:00 2001 From: Simona <36978416+SimonaliaChen@users.noreply.github.com> Date: Tue, 8 Dec 2020 21:01:16 +0800 Subject: [PATCH] fix(popper): attr style fallthrough failed (#897) --- packages/popper/__tests__/popper.spec.ts | 14 ++++++++++++++ packages/popper/src/index.vue | 2 ++ packages/popper/src/use-popper/defaults.ts | 1 + 3 files changed, 17 insertions(+) diff --git a/packages/popper/__tests__/popper.spec.ts b/packages/popper/__tests__/popper.spec.ts index cdf55318b3..99ffe3a9ee 100644 --- a/packages/popper/__tests__/popper.spec.ts +++ b/packages/popper/__tests__/popper.spec.ts @@ -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') + }) }) }) diff --git a/packages/popper/src/index.vue b/packages/popper/src/index.vue index 9b33242542..5732b3ed54 100644 --- a/packages/popper/src/index.vue +++ b/packages/popper/src/index.vue @@ -53,6 +53,7 @@ export default defineComponent({ $slots, appendToBody, class: kls, + style, effect, hide, onPopperMouseEnter, @@ -103,6 +104,7 @@ export default defineComponent({ const triggerProps = { ariaDescribedby: popperId, class: kls, + style, ref: 'triggerRef', ...this.events, } diff --git a/packages/popper/src/use-popper/defaults.ts b/packages/popper/src/use-popper/defaults.ts index 65cf5be065..b32becfbec 100644 --- a/packages/popper/src/use-popper/defaults.ts +++ b/packages/popper/src/use-popper/defaults.ts @@ -62,6 +62,7 @@ export default { type: String, default: '', }, + style: Object, closeDelay: { type: Number, default: 200,