JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 98
  • Score
    100M100P100Q70150F
  • License ISC

Detect references to undefined CSS classes

Package Exports

  • checkcss

Readme

checkcss

Logic for detecting when DOM elements reference undefined CSS classes.

Note: The scan() method uses the MutationObserver API to monitor DOM changes. While this should be pretty efficient, it's probably not something you want to be running in production.

Installation

npm install checkcss
# or
yarn add checkcss

Usage

import { CheckCSS } from 'checkcss';

// Create CheckCSS instance
const checkcss = new CheckCSS();

// OPTIONAL: Set hook to filter classnames.
// Return false for classnames that should be ignored.
checkcss.onClassnameDetected = function (classname, element) {
  return /^license-|^maintainer-/.test();
};

// OPTIONAL: Set hook for custom logging (replaces default log method)
checkcss.onUndefinedClassname = function (classname) {
  // Custom logging goes here
};

// Scan current DOM for undefined classes
checkcss.scan();

// Monitor DOM as it changes
checkcss.watch();