Change if statement block
This commit is contained in:
+20
-20
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user