From 20db02efe9d55e13f14f077b999e90f8315bc4e8 Mon Sep 17 00:00:00 2001 From: Ryan2128 <33176053+Ryan2128@users.noreply.github.com> Date: Tue, 1 Dec 2020 19:57:36 +0800 Subject: [PATCH] fix(card): fix the bug that `bodyStyle` can not accept Object and Array (#754) * fix(card): fix the bug that `bodyStyle` can not accept Object and Array * test(card): add 'bodyStyle' test case --- packages/card/__tests__/card.spec.ts | 26 ++++++++++++++++++++++++++ packages/card/src/index.vue | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/card/__tests__/card.spec.ts b/packages/card/__tests__/card.spec.ts index 9efae6e1f6..03789682a6 100644 --- a/packages/card/__tests__/card.spec.ts +++ b/packages/card/__tests__/card.spec.ts @@ -55,6 +55,32 @@ describe('Card.vue', () => { expect(wrapper.find('.el-card__body').attributes('style')).toBe(style) }) + test('body style with object', () => { + const style = { 'font-size': '14px' } + const wrapper = mount(Card, { + props: { + slots: { + default: AXIOM, + }, + bodyStyle: style, + }, + }) + expect(wrapper.find('.el-card__body').attributes('style')).toBe('font-size: 14px;') + }) + + test('body style with array', () => { + const style = [{ 'font-size': '14px' }, { color: 'blue' }] + const wrapper = mount(Card, { + props: { + slots: { + default: AXIOM, + }, + bodyStyle: style, + }, + }) + expect(wrapper.find('.el-card__body').attributes('style').replace(/[ ]/g, '')).toBe('font-size:14px;color:blue;') + }) + test('shadow', () => { const shadow = 'test-shadow' const wrapper = mount(Card, { diff --git a/packages/card/src/index.vue b/packages/card/src/index.vue index f4f0673356..3ce2c8674c 100644 --- a/packages/card/src/index.vue +++ b/packages/card/src/index.vue @@ -20,7 +20,7 @@ export default defineComponent({ default: '', }, bodyStyle: { - type: String, + type: [String, Object, Array], default: '', }, shadow: {