Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validateDeclValue = (node: Declaration, context: Context): ReportData | null => {
const unsupported = getUnsupportedDetails({ property: node.prop, value: node.value }, context.browsers);
if (unsupported) {
const formatFeature = (value: string) => {
return `${node.prop}: ${value}`;
};
return { feature: formatFeature(node.value), formatFeature, isValue: true, node, unsupported };
}
return null;
};
const validateElement = (node: HTMLElement, context: Context) => {
const element = node.nodeName.toLowerCase();
if (context.ignore.has(element)) {
return;
}
const unsupported = getUnsupportedDetails({ element }, context.browsers);
if (unsupported) {
context.report({ feature: element, unsupported });
} else {
for (let i = 0; i < node.attributes.length; i++) {
validateAttribute(element, node.attributes[i], context);
}
}
};
const validateAttributeValue = (element: string, attr: HTMLAttribute, context: Context) => {
if (context.ignore.has(`${element}[${attr.name}=${attr.value}]`)) {
return;
}
const unsupported = getUnsupportedDetails({ attribute: attr.name, element, value: attr.value }, context.browsers);
if (unsupported) {
context.report({ feature: `${element}[${attr.name}=${attr.value}]`, unsupported });
}
};