From fe9233cae2ca53159a4e962ae0bceed61453cfa5 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Tue, 10 Feb 2026 03:22:25 +0100 Subject: [PATCH] refactor: Cache jQuery `html` object for consistent DOM manipulation in hooks. --- scripts/module.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/module.js b/scripts/module.js index b9569f6..e8be08d 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -51,8 +51,9 @@ Hooks.once('init', () => { // Hook to handle conditional settings in the UI Hooks.on('renderSettingsConfig', (app, html, data) => { // Search for our specific inputs with safer selectors (ending with key) - const animSelect = html.find('select[name$="critAnimation"]'); - const colorInput = html.find('input[name$="pulseColor"]'); + const $html = $(html); + const animSelect = $html.find('select[name$="critAnimation"]'); + const colorInput = $html.find('input[name$="pulseColor"]'); // Ensure we found the color input to transform it if (colorInput.length) { @@ -130,7 +131,8 @@ Hooks.on('renderChatMessage', (message, html, data) => { if (isCriticalHit(roll)) { const anim = game.settings.get('dh-immersive-crits', 'critAnimation'); if (anim && anim !== 'none') { - const content = html.find('.message-content'); + const $html = $(html); + const content = $html.find('.message-content'); content.addClass(`dh-crit-${anim}`); // Apply custom color for Pulse @@ -173,7 +175,7 @@ Hooks.on('renderChatMessage', (message, html, data) => { } // Also add a general class for easier targeting if needed - html.addClass('dh-critical-hit'); + $html.addClass('dh-critical-hit'); } } });