Skip to content

Clean up compatibility code for MutationObserver #51309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ void NativeMutationObserver::observe(
mutationObserverId, shadowNode, subtree, uiManager);
}

// TODO: remove in the next version
void NativeMutationObserver::unobserve(
jsi::Runtime& /*runtime*/,
MutationObserverId mutationObserverId,
jsi::Object targetShadowNode) {
// This will not be used but cannot be removed yet because the compatibility
// check does not allow it.
}

void NativeMutationObserver::unobserveAll(
jsi::Runtime& runtime,
MutationObserverId mutationObserverId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ class NativeMutationObserver
jsi::Runtime& runtime,
NativeMutationObserverObserveOptions options);

// TODO: remove in the next version
[[deprecated("use unobserveAll instead")]]
void unobserve(
jsi::Runtime& runtime,
MutationObserverId mutationObserverId,
jsi::Object targetShadowNode);

void unobserveAll(
jsi::Runtime& runtime,
MutationObserverId mutationObserverId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@ export default class MutationObserver {

const mutationObserverId = this._getOrCreateMutationObserverId();

const didStartObserving = MutationObserverManager.observe({
MutationObserverManager.observe({
mutationObserverId,
target,
subtree: Boolean(options?.subtree),
});

if (didStartObserving && !MutationObserverManager.unobserveAll) {
this._observationTargets.add(target);
}
}

/**
Expand All @@ -139,17 +135,7 @@ export default class MutationObserver {
return;
}

if (MutationObserverManager.unobserveAll) {
MutationObserverManager.unobserveAll(mutationObserverId);
} else if (MutationObserverManager.unobserve) {
for (const target of this._observationTargets.keys()) {
nullthrows(MutationObserverManager.unobserve)(
mutationObserverId,
target,
);
}
this._observationTargets.clear();
}
MutationObserverManager.unobserveAll(mutationObserverId);

MutationObserverManager.unregisterObserver(mutationObserverId);
this._mutationObserverId = null;
Expand Down
Loading
Loading