diff --git a/js/31-classes-ids.js b/js/31-classes-ids.js new file mode 100644 index 0000000..4844fb2 --- /dev/null +++ b/js/31-classes-ids.js @@ -0,0 +1,25 @@ +export default function compute() { + +let ret = { + class: {}, + id: {}, + attribute: {} +}; + +walkSelectors(ast, selector => { + let sast = parsel.parse(selector, {list: false}); + + parsel.walk(sast, node => { + if (node.type === "id" || node.type === "class" || node.type === "attribute") { + incrementByKey(ret[node.type], node.name); + } + }, {subtree: true}); +}); + +for (let type in ret) { + ret[type] = sortObject(ret[type]); +} + +return ret; + +}