ant-design/components/_util/getDataOrAriaProps.ts
CommanderRoot 7c34addf57
refactor: replace deprecated String.prototype.substr() (#34498)
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with functions which aren't.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-15 10:41:12 +08:00

12 lines
317 B
TypeScript

export default function getDataOrAriaProps(props: any) {
return Object.keys(props).reduce((prev: any, key: string) => {
if (
(key.startsWith('data-') || key.startsWith('aria-') || key === 'role') &&
!key.startsWith('data-__')
) {
prev[key] = props[key];
}
return prev;
}, {});
}