refactor: Cache jQuery html object for consistent DOM manipulation in hooks.
This commit is contained in:
parent
64463504d5
commit
fe9233cae2
1 changed files with 6 additions and 4 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue