@@ -50,11 +50,13 @@ function scheduleUpdate() {
5050 * Returns a cleanup function that removes the overlay and deregisters it.
5151 *
5252 * @param {Element } el
53+ * @param {'error'|'warning' } [severity='error']
5354 * @returns {function } cleanup
5455 */
55- function createOverlay ( el ) {
56+ function createOverlay ( el , severity = 'error' ) {
5657 const overlay = document . createElement ( 'span' ) ;
5758 overlay . className = AUDIT_OVERLAY_CLASS ;
59+ if ( severity === 'warning' ) overlay . classList . add ( 'mageforge-audit-overlay--warning' ) ;
5860 document . body . appendChild ( overlay ) ;
5961
6062 function update ( ) {
@@ -122,16 +124,22 @@ export function clearHighlight(key) {
122124 * the first result, and updates the counter badge on the toolbar menu item.
123125 * Works for any element type – no special casing required in audit code.
124126 *
125- * @param {Element[] } elements - Elements to mark
126- * @param {string } key - Audit key (e.g. 'images-without-alt')
127- * @param {object } context - Alpine toolbar component instance
127+ * @param {Element[] } elements - Elements to mark
128+ * @param {string } key - Audit key (e.g. 'images-without-alt')
129+ * @param {object } context - Alpine toolbar component instance
130+ * @param {object } [options={}] - Options
131+ * @param {'error'|'warning' } [options.severity='error'] - Visual severity level
132+ * @param {boolean } [options.skipBadge=false] - Skip badge + scroll update
128133 */
129- export function applyHighlight ( elements , key , context ) {
134+ export function applyHighlight ( elements , key , context , options = { } ) {
135+ const severity = options . severity ?? 'error' ;
136+ const skipBadge = options . skipBadge ?? false ;
137+
130138 // Never flag elements that are part of the MageForge Toolbar itself
131139 elements = elements . filter ( el => ! el . closest ( '.mageforge-toolbar' ) ) ;
132140
133141 if ( elements . length === 0 ) {
134- context . setAuditCounterBadge ( key , '0' , 'success' ) ;
142+ if ( ! skipBadge ) context . setAuditCounterBadge ( key , '0' , 'success' ) ;
135143 return ;
136144 }
137145 const cls = `mageforge-audit-${ key } ` ;
@@ -142,11 +150,13 @@ export function applyHighlight(elements, key, context) {
142150 existing . keys . add ( key ) ;
143151 } else {
144152 overlayRegistry . set ( el , {
145- cleanup : createOverlay ( el ) ,
153+ cleanup : createOverlay ( el , severity ) ,
146154 keys : new Set ( [ key ] ) ,
147155 } ) ;
148156 }
149157 } ) ;
150- elements [ 0 ] . scrollIntoView ( { behavior : 'smooth' , block : 'center' } ) ;
151- context . setAuditCounterBadge ( key , `${ elements . length } ` , 'error' ) ;
158+ if ( ! skipBadge ) {
159+ elements [ 0 ] . scrollIntoView ( { behavior : 'smooth' , block : 'center' } ) ;
160+ context . setAuditCounterBadge ( key , `${ elements . length } ` , severity ) ;
161+ }
152162}
0 commit comments