diff --git a/src/TabBarTabsNode.js b/src/TabBarTabsNode.js index e7cb58e9..b24cfc92 100644 --- a/src/TabBarTabsNode.js +++ b/src/TabBarTabsNode.js @@ -52,6 +52,7 @@ export default class TabBarTabsNode extends React.Component { key={key} style={ style } {...ref} + {...(typeof child.props.tab === 'string' ? {'data-tab': child.props.tab}: {})} > {child.props.tab} diff --git a/tests/__snapshots__/index.spec.js.snap b/tests/__snapshots__/index.spec.js.snap index 81425c4b..be2a5ebb 100644 --- a/tests/__snapshots__/index.spec.js.snap +++ b/tests/__snapshots__/index.spec.js.snap @@ -42,6 +42,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = ` aria-disabled="false" aria-selected="false" class=" rc-tabs-tab" + data-tab="tab 1" role="tab" > tab 1 @@ -50,6 +51,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = ` aria-disabled="false" aria-selected="true" class="rc-tabs-tab-active rc-tabs-tab" + data-tab="tab 2" role="tab" > tab 2 @@ -58,6 +60,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = ` aria-disabled="false" aria-selected="false" class=" rc-tabs-tab" + data-tab="tab 3" role="tab" > tab 3 diff --git a/tests/index.spec.js b/tests/index.spec.js index 7e37ba15..c2be07be 100755 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -268,4 +268,21 @@ describe('rc-tabs', () => { done(); }, 1000); }); + + it('string type tab should have [data-tab] attribute', () => { + const wrapper = mount( + } + renderTabContent={() => } + > + first + second + third + tab 4} key="4">fourth + + ); + + expect(wrapper.find('[data-tab]').length).toBe(3); + }) });