UNPKG

929 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getAttributes = getAttributes;
7
8function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
9
10/**
11 * Returns the Attribute selectors of the element
12 * @param { DOM Element } element
13 * @param { Array } array of attributes to ignore
14 * @return { Array }
15 */
16function getAttributes(el) {
17 var attributesToIgnore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['id', 'class', 'length'];
18 var attributes = el.attributes;
19
20 var attrs = [].concat(_toConsumableArray(attributes));
21
22 return attrs.reduce(function (sum, next) {
23 if (!(attributesToIgnore.indexOf(next.nodeName) > -1)) {
24 sum.push('[' + next.nodeName + '="' + next.value + '"]');
25 }
26 return sum;
27 }, []);
28}
\No newline at end of file