Files
education/frontend/node_modules/svg-baker-runtime/src/utils/select-attributes.js
T

21 lines
474 B
JavaScript

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;
}