Fix ApplicationV2 jQuery parameter handling in _onRender methods
- Fixed TypeError in PlayerPrivacyPanel._onRender: element.querySelector is not a function - Root cause: FoundryVTT v14 ApplicationV2 passes jQuery objects to _onRender, not plain HTMLElements - Solution: Normalize parameter to element with querySelector method: - If HTMLElement, use directly - If jQuery (has [0]), use html[0] - Otherwise, use as-is (for test mocks) - Applied fix to: - PlayerPrivacyPanel._onRender - PresetSaveDialog._onRender - PresetLoadDialog._onRender - All 900 unit tests passing Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -89,9 +89,16 @@ export class PresetLoadDialog extends _AppBase {
|
||||
|
||||
/**
|
||||
* Sets up event handlers after rendering.
|
||||
* @param {HTMLElement} element - The dialog element.
|
||||
* @param {HTMLElement|JQuery|object} html - The dialog element, jQuery object, or plain object with querySelector.
|
||||
*/
|
||||
_onRender(element) {
|
||||
_onRender(html) {
|
||||
// Normalize html to element with querySelector
|
||||
// FoundryVTT ApplicationV2 passes jQuery object, tests pass plain objects
|
||||
const element = html instanceof HTMLElement
|
||||
? html
|
||||
: (html?.[0] ?? html);
|
||||
if (!element || typeof element.querySelector !== 'function') return;
|
||||
|
||||
// Set up load button handlers for each preset
|
||||
const loadButtons = element.querySelectorAll('[data-action="load"]');
|
||||
loadButtons.forEach((btn) => {
|
||||
|
||||
@@ -86,9 +86,16 @@ export class PresetSaveDialog extends _AppBase {
|
||||
|
||||
/**
|
||||
* Sets up event handlers after rendering.
|
||||
* @param {HTMLElement} element - The dialog element.
|
||||
* @param {HTMLElement|JQuery|object} html - The dialog element, jQuery object, or plain object with querySelector.
|
||||
*/
|
||||
_onRender(element) {
|
||||
_onRender(html) {
|
||||
// Normalize html to element with querySelector
|
||||
// FoundryVTT ApplicationV2 passes jQuery object, tests pass plain objects
|
||||
const element = html instanceof HTMLElement
|
||||
? html
|
||||
: (html?.[0] ?? html);
|
||||
if (!element || typeof element.querySelector !== 'function') return;
|
||||
|
||||
// Cache the name input
|
||||
this._nameInput = element.querySelector('[name="presetName"]');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user