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