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; contentChanged = contentChanged || contentFinalChanged;
childListChanged = childListChanged || isChildListType; childListChanged = childListChanged || isChildListType;
} }
// else if is target observer and target attr changed // if is target observer and target attr changed
else if (attributeChanged && !ignoreTargetChange(mutationTarget, attributeName!, oldValue, attributeValue as string | null)) { if (
!isContentObserver &&
targetIsMutationTarget &&
attributeChanged &&
!ignoreTargetChange(mutationTarget, attributeName!, oldValue, attributeValue as string | null)
) {
push(targetChangedAttrs, attributeName!); push(targetChangedAttrs, attributeName!);
targetStyleChanged = targetStyleChanged || styleChangingAttrChanged; targetStyleChanged = targetStyleChanged || styleChangingAttrChanged;
} }
@@ -239,8 +244,8 @@ export const createDOMObserver = <ContentObserver extends boolean>(
); );
} }
if (isContentObserver && contentChanged) { if (isContentObserver) {
(callback as DOMContentObserverCallback)(contentChanged); contentChanged && (callback as DOMContentObserverCallback)(contentChanged);
} else if (!isEmptyArray(targetChangedAttrs) || targetStyleChanged) { } else if (!isEmptyArray(targetChangedAttrs) || targetStyleChanged) {
(callback as DOMTargetObserverCallback)(targetChangedAttrs, targetStyleChanged); (callback as DOMTargetObserverCallback)(targetChangedAttrs, targetStyleChanged);
} }
@@ -438,6 +438,8 @@ const addRemoveImgElmsFn = async () => {
['img', 'something2'], ['img', 'something2'],
['img', null], ['img', null],
['img', undefined], ['img', undefined],
[null, null],
[undefined, undefined],
['img', () => 'hi'], ['img', () => 'hi'],
['img', () => null], ['img', () => null],
['img', () => undefined], ['img', () => undefined],