getDataAttr.ts 294 B

12345678
  1. export default function getDataAttr(props: Record<string, any>) {
  2. return Object.keys(props).reduce((prev, key) => {
  3. if (key.substr(0, 5) === 'aria-' || key.substr(0, 5) === 'data-' || key === 'role') {
  4. prev[key] = props[key];
  5. }
  6. return prev;
  7. }, {});
  8. }