Skip to content

Commit

Permalink
Get registered variables (that are currently set)
Browse files Browse the repository at this point in the history
Rel #1
  • Loading branch information
LeaVerou committed Oct 29, 2020
1 parent dbef879 commit b7048fd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
35 changes: 35 additions & 0 deletions vars/registered.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export default function compute() {

function walkElements(node, callback) {
if (Array.isArray(node)) {
for (let n of node) {
walkElements(n, callback);
}
}
else {
callback(node);

if (node.children) {
walkElements(node.children, callback);
}
}
}

let ret = new Set();

walkElements(vars.computed, node => {
if (node.declarations) {
for (let property in node.declarations) {
let value;
let o = node.declarations[property];

if (property.startsWith("--") && o.type) {
ret.add(property);
}
}
}
});

return [...ret];

}
1 change: 0 additions & 1 deletion vars/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ let ret = {
walkElements(vars.computed, node => {
if (node.declarations) {
for (let property in node.declarations) {
let value;
let o = node.declarations[property];

if (property.startsWith("--")) {
Expand Down

0 comments on commit b7048fd

Please sign in to comment.