Comparing version 1.0.2 to 1.1.0
16
index.js
const seen = new Set(); | ||
let defined; | ||
let ignoreRE; | ||
export function ignoreCSS(re) { | ||
ignoreRE = re; | ||
} | ||
function checkClassNames(node, includeChildren = false) { | ||
if (node?.classList) { | ||
for (const cl of node.classList) { | ||
// Ignore if matches the ignore regex | ||
if (ignoreRE.test(cl)) continue; | ||
// Ignore defined and already-seen classes | ||
@@ -25,2 +33,10 @@ if (defined.has(cl) || seen.has(cl)) continue; | ||
for (const rule of rules) { | ||
if (!rule) continue; | ||
let cssRules; | ||
try { | ||
cssRules = rule.cssRules; | ||
} catch (err) { | ||
console.log(`Unable to access ${rule.href}`); | ||
continue; | ||
} | ||
if (rule?.cssRules) { // Rules can contain sub-rules (e.g. @media, @print) | ||
@@ -27,0 +43,0 @@ ingestRules(rule.cssRules); |
{ | ||
"name": "checkcss", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Utility method for warning when elements have a `class` attribute that refers to an undefined CSS class", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3610
78