1a30f6f1def59e4c705e6c575ec16f0e3615d0b154ad3c6a93fdeeeab706d4d700633e7019ef787267274e41cba237b0c6b87e5121f5477bc2bc2bc1d59ff6 474 B

1234567891011121314151617181920
  1. import arrayFrom from './array-from';
  2. /**
  3. * @param {NodeList} nodes
  4. * @param {Function} [matcher]
  5. * @return {Attr[]}
  6. */
  7. export default function selectAttributes(nodes, matcher) {
  8. const attrs = arrayFrom(nodes).reduce((acc, node) => {
  9. if (!node.attributes) {
  10. return acc;
  11. }
  12. const arrayfied = arrayFrom(node.attributes);
  13. const matched = matcher ? arrayfied.filter(matcher) : arrayfied;
  14. return acc.concat(matched);
  15. }, []);
  16. return attrs;
  17. }