fix domobserver bug

This commit is contained in:
Rene
2021-04-18 16:08:02 +02:00
parent 9a9aea5bfe
commit c827cf8e7e
2 changed files with 11 additions and 4 deletions
@@ -222,8 +222,13 @@ export const createDOMObserver = <ContentObserver extends boolean>(
contentChanged = contentChanged || contentFinalChanged;
childListChanged = childListChanged || isChildListType;
}
// else if is target observer and target attr changed
else if (attributeChanged && !ignoreTargetChange(mutationTarget, attributeName!, oldValue, attributeValue as string | null)) {
// if is target observer and target attr changed
if (
!isContentObserver &&
targetIsMutationTarget &&
attributeChanged &&
!ignoreTargetChange(mutationTarget, attributeName!, oldValue, attributeValue as string | null)
) {
push(targetChangedAttrs, attributeName!);
targetStyleChanged = targetStyleChanged || styleChangingAttrChanged;
}
@@ -239,8 +244,8 @@ export const createDOMObserver = <ContentObserver extends boolean>(
);
}
if (isContentObserver && contentChanged) {
(callback as DOMContentObserverCallback)(contentChanged);
if (isContentObserver) {
contentChanged && (callback as DOMContentObserverCallback)(contentChanged);
} else if (!isEmptyArray(targetChangedAttrs) || targetStyleChanged) {
(callback as DOMTargetObserverCallback)(targetChangedAttrs, targetStyleChanged);
}
@@ -438,6 +438,8 @@ const addRemoveImgElmsFn = async () => {
['img', 'something2'],
['img', null],
['img', undefined],
[null, null],
[undefined, undefined],
['img', () => 'hi'],
['img', () => null],
['img', () => undefined],