1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:57:44 +00:00

LibWeb: Implement ResizeObserver::unobserve()

This commit is contained in:
Aliaksandr Kalenik 2024-02-18 21:50:35 +01:00 committed by Andreas Kling
parent fcf293a8df
commit 70a0f07732
3 changed files with 66 additions and 3 deletions

View file

@ -75,11 +75,18 @@ void ResizeObserver::observe(DOM::Element& target, ResizeObserverOptions options
m_observation_targets.append(resize_observation);
}
// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-unobserve
// https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-unobserve
void ResizeObserver::unobserve(DOM::Element& target)
{
// FIXME: Implement
(void)target;
// 1. Let observation be ResizeObservation in [[observationTargets]] whose target slot is target.
auto observation = m_observation_targets.find_if([&](auto& observation) { return observation->target().ptr() == ⌖ });
// 2. If observation is not found, return.
if (observation.is_end())
return;
// 3. Remove observation from [[observationTargets]].
m_observation_targets.remove(observation.index());
}
// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-disconnect