Comparing version 2.0.4 to 2.0.5
@@ -22,7 +22,7 @@ import { isCSSStyleRule, isElement, isGroupingRule, isLinkElement, parseSelectorForClassnames, } from './util.js'; | ||
#seenStylesheets = new WeakMap(); | ||
// Hook for filtering classnames in DOM. Thi is called whenever a new | ||
// Hook for filtering classnames in DOM. This is called whenever a new | ||
// classname is detected in the DOM. Callback should return true to indicate | ||
// the class should be checked, false to ignore. | ||
onClassnameDetected; | ||
// Callback when undefined classname is detected (defaults to console.warn()) | ||
// Callback when undefined classname is detected (defaults to console.log()) | ||
onUndefinedClassname(classname) { | ||
@@ -78,8 +78,6 @@ console.log(`%ccheckcss%c: No CSS rule for %c.${classname}%c, referenced by: %o`, 'color: darkorange', '', 'font-weight: bold', '', this.#documentElement.querySelectorAll(`.${CSS.escape(classname)}`)); | ||
} | ||
if (!this.onUndefinedClassname) | ||
return; | ||
for (const [classname, status] of this.#classnames) { | ||
if (status == ClassnameStatus.DETECTED) { | ||
this.#classnames.set(classname, ClassnameStatus.EMITTED); | ||
this.onUndefinedClassname(classname); | ||
this.onUndefinedClassname?.(classname); | ||
} | ||
@@ -100,3 +98,8 @@ } | ||
continue; | ||
this.#classnames.set(n, ClassnameStatus.DETECTED); | ||
if (this.onClassnameDetected?.(n, el) === false) { | ||
this.#classnames.set(n, ClassnameStatus.IGNORED); | ||
} | ||
else { | ||
this.#classnames.set(n, ClassnameStatus.DETECTED); | ||
} | ||
} | ||
@@ -103,0 +106,0 @@ // Recurse into children(?) |
@@ -14,2 +14,3 @@ import { CheckCSS } from './CheckCSS.js'; | ||
export function ignoreCSS(re) { | ||
warn('ignoreRE is deprecated and will be removed in the next major release. Use CheckCSS#onClassnameDetected instead'); | ||
ignoreRE = re; | ||
@@ -21,2 +22,3 @@ } | ||
checkcss = new CheckCSS(document); | ||
// Legacy API support for ignoreRE. | ||
checkcss.onClassnameDetected = (classname, el) => { | ||
@@ -23,0 +25,0 @@ return ignoreRE?.test(classname) ?? true; |
{ | ||
"name": "checkcss", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Detect references to undefined CSS classes", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
21166
273