Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return node => {
const type = getType(node);
const props = getProperties(node);
const children = getChildren(node);
if (node.id != 0) {
if (type === 'var') {
state.vars.push(node);
} else if (state[type]) {
state[type].push(node);
} else if (storeElements) {
state.elements.push(node);
}
if (
!children ||
(children.length === 1 && getType(children[0]) === 'textnode')
) {
return;
}
children.forEach(handleNode(false));
}
};
};
const pluck = (acc, val) => {
const variableType = getType(val);
const attrs = getProperties(val) || [];
if (!attrs.name || !attrs.value) return attrs;
const nameValue = attrs.name.value;
const valueType = attrs.value.type;
const valueValue = attrs.value.value;
switch (valueType) {
case 'value':
acc[nameValue] = valueValue;
break;
case 'variable':
if (context.hasOwnProperty(valueValue)) {
acc[nameValue] = context[valueValue];
} else {
return node => {
const type = getType(node);
const props = getProperties(node);
const children = getChildren(node);
if (node.id != 0) {
if (type === 'var') {
state.vars.push(node);
} else if (state[type]) {
state[type].push(node);
} else if (storeElements) {
state.elements.push(node);
}
if (
!children ||
(children.length === 1 && getType(children[0]) === 'textnode')
) {
return;
}
let filter = filterNodes(ast, node => {
if (node.type === 'textnode') {
return false;
}
return !ignoreTypes.has(getType(node).toLowerCase());
});
return filter;
const tNode = node => {
if (getType(node) === 'textnode') return node;
let name = getNodeName(node);
let attrs = getProperties(node);
if (!attrs) {
attrs = {};
}
const children = getChildren(node);
return {
component: name,
...attrConvert(attrs, node),
children: children.map(tNode)
};
};