Change if statement block

This commit is contained in:
newtextdoc1111
2025-05-10 00:35:47 +09:00
parent e8385184dd
commit 5d1b227217
2 changed files with 21 additions and 21 deletions
+20 -20
View File
@@ -50,30 +50,30 @@ function initializeEventHandlers() {
};
}
// Fallback and for dynamically added elements not caught by widget override: MutationObserver
const targetSelectors = [
'.comfy-multiline-input',
// Add other selectors if needed
];
if (settingValues._useFallbackAttachmentForEventListener) {
// Fallback and for dynamically added elements not caught by widget override: MutationObserver
const targetSelectors = [
'.comfy-multiline-input',
// Add other selectors if needed
];
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
targetSelectors.forEach(selector => {
// Check if the added node itself matches or contains matching elements
if (node.matches(selector)) {
attachListeners(node);
} else {
node.querySelectorAll(selector).forEach(attachListeners);
}
});
}
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
targetSelectors.forEach(selector => {
// Check if the added node itself matches or contains matching elements
if (node.matches(selector)) {
attachListeners(node);
} else {
node.querySelectorAll(selector).forEach(attachListeners);
}
});
}
});
});
});
});
if (settingValues._useFallbackAttachmentForEventListener) {
// Initial scan for existing elements
targetSelectors.forEach(selector => {
document.querySelectorAll(selector).forEach(attachListeners);
+1 -1
View File
@@ -11,7 +11,7 @@ export const settingValues = {
// Internal logic settings
_useFallbackAttachmentForEventListener: false, // Fallback to attach event listener if not using jQuery
_useFallbackAttachmentForEventListener: false, // Fallback to attach event listener when somthing goes wrong
// Debugging settings (use internally)
_hideWhenOutofFocus: false, // Hide UI when the input is out of focus