Skip to content

Commit

Permalink
Create 31-classes-ids.js
Browse files Browse the repository at this point in the history
Rel #31
  • Loading branch information
LeaVerou committed Sep 16, 2020
1 parent 0c7ae90 commit 1523d16
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions js/31-classes-ids.js
Original file line number Diff line number Diff line change
@@ -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;

}

0 comments on commit 1523d16

Please sign in to comment.