Skip to content
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

[resize-observer] Behavior when the callback modifies depth #3704

Open
smfr opened this issue Mar 4, 2019 · 2 comments
Open

[resize-observer] Behavior when the callback modifies depth #3704

smfr opened this issue Mar 4, 2019 · 2 comments

Comments

@smfr
Copy link
Contributor

smfr commented Mar 4, 2019

https://drafts.csswg.org/resize-observer-1/#html-event-loop

Calculate depth for node happens each time the "Gather active observations at depth" steps are run.

This implies that callback that changes the depth can trigger that observer getting called multiple times in one set of ResizeObserver notifications. For example, a call back could modify the DOM to add an element in its ancestor chain. This could lead to the steps never exiting.

One way to avoid this would be to compute the depth once per element at the start of firing ResizeObserver notifications.

@atotic
Copy link
Contributor

atotic commented Mar 12, 2019

I do not think this edge case is a problem.
For each additional loop, callback would have to add an Element to ancestor chain. This is unlikely to happen by accident. If it happens intentionally, user agent will be in an infinite loop, and also run out of memory,

@smfr
Copy link
Contributor Author

smfr commented Mar 18, 2019

Computing depth at the start of the algorithm would avoid this, though, and seems simple.

@gregwhitworth gregwhitworth added this to To do in resize-observer May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants