Skip to content

Commit e4fccec

Browse files
committed
fix cell render props
1 parent 13b5a5c commit e4fccec

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Cell/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,13 @@ function Cell<RecordType extends DefaultRecordType>(
118118
childNode = <span className={`${cellPrefixCls}-content`}>{childNode}</span>;
119119
}
120120

121-
const { colSpan: cellColSpan, rowSpan: cellRowSpan, style: cellStyle, className: cellClassName } =
122-
cellProps || {};
121+
const {
122+
colSpan: cellColSpan,
123+
rowSpan: cellRowSpan,
124+
style: cellStyle,
125+
className: cellClassName,
126+
...restCellProps
127+
} = cellProps || {};
123128
const mergedColSpan = cellColSpan !== undefined ? cellColSpan : colSpan;
124129
const mergedRowSpan = cellRowSpan !== undefined ? cellRowSpan : rowSpan;
125130

@@ -160,6 +165,7 @@ function Cell<RecordType extends DefaultRecordType>(
160165

161166
const componentProps = {
162167
title,
168+
...restCellProps,
163169
...additionalProps,
164170
colSpan: mergedColSpan && mergedColSpan !== 1 ? mergedColSpan : null,
165171
rowSpan: mergedRowSpan && mergedRowSpan !== 1 ? mergedRowSpan : null,

tests/Table.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,15 @@ describe('Table.Basic', () => {
310310
expect(wrapper.render()).toMatchSnapshot();
311311
});
312312

313-
it('render with style & className', () => {
313+
it('render with style & className & data-*', () => {
314314
const columns = [
315315
{
316316
dataIndex: 'key',
317317
render: text => ({
318318
props: {
319319
style: { background: 'red' },
320320
className: 'customize-render',
321+
'data-light': 'bamboo',
321322
},
322323
children: text,
323324
}),
@@ -328,6 +329,7 @@ describe('Table.Basic', () => {
328329
const props = wrapper.find('td').props();
329330
expect(props.style).toEqual(expect.objectContaining({ background: 'red' }));
330331
expect(props.className.includes('customize-render')).toBeTruthy();
332+
expect(props['data-light']).toEqual('bamboo');
331333
});
332334

333335
it('renders rowSpan correctly', () => {

0 commit comments

Comments
 (0)