UNPKG

647 BJavaScriptView Raw
1import React from 'react';
2import classNames from 'classnames';
3export function withNativeProps(props, element) {
4 const p = Object.assign({}, element.props);
5 if (props.className) {
6 p.className = classNames(element.props.className, props.className);
7 }
8 if (props.style) {
9 p.style = Object.assign(Object.assign({}, p.style), props.style);
10 }
11 if (props.tabIndex !== undefined) {
12 p.tabIndex = props.tabIndex;
13 }
14 for (const key in props) {
15 if (!props.hasOwnProperty(key)) continue;
16 if (key.startsWith('data-') || key.startsWith('aria-')) {
17 p[key] = props[key];
18 }
19 }
20 return React.cloneElement(element, p);
21}
\No newline at end of file