Skip to content

Instantly share code, notes, and snippets.

View petermihailov's full-sized avatar
👋

Peter Mihailov petermihailov

👋
View GitHub Profile
@petermihailov
petermihailov / checkForUndefinedCSSClasses.js
Created February 15, 2023 16:33 — forked from broofa/checkForUndefinedCSSClasses.js
ES module for detecting undefined CSS classes (uses mutation observer to monitor DOM changes). `console.warn()`s undefined classes.
/**
* Sets up a DOM MutationObserver that watches for elements using undefined CSS
* class names. Performance should be pretty good, but it's probably best to
* avoid using this in production.
*
* Usage:
*
* import cssCheck from './checkForUndefinedCSSClasses.js'
*
* // Call before DOM renders (e.g. in <HEAD> or prior to React.render())