Update observer-helper.js to handle mutations with multiple elements (#2635)

Update observer-helper.js to handle mutations with multiple elements
This commit is contained in:
Mihai Ionut Vilcu 2025-09-14 11:59:19 +03:00 committed by GitHub
parent e842e01cf3
commit 39c86225e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -82,11 +82,12 @@ kpxcObserverHelper.initObserver = async function() {
kpxcObserverHelper.cacheStyle(mut, styleMutations, mutations.length);
if (mut.type === 'childList') {
if (mut.addedNodes.length > 0) {
kpxcObserverHelper.handleObserverAdd(mut.addedNodes[0]);
} else if (mut.removedNodes.length > 0) {
kpxcObserverHelper.handleObserverRemove(mut.removedNodes[0]);
}
mut.addedNodes.forEach(function (node) {
kpxcObserverHelper.handleObserverAdd(node);
});
mut.removedNodes.forEach(function (node) {
kpxcObserverHelper.handleObserverRemove(node);
});
} else if (mut.type === 'attributes' && (mut.attributeName === 'class' || mut.attributeName === 'style')) {
// Only accept targets with forms
const forms = matchesWithNodeName(mut.target, 'FORM')