Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Should functions like getBoundingClientRect, getComputedStyle etc trigger an update? #45

Closed
rakina opened this issue Mar 8, 2019 · 3 comments

Comments

@rakina
Copy link
Member

rakina commented Mar 8, 2019

If we call functions like getBoundingClientRect() on a locked element, should they trigger an update to the element and return the newly calculated values? If not, should they always return the value when the element got locked? What if there's already an update() call previously?

It seems like some things like DevTools might need the old/currently-painted values.

cc @fergald @chrishtr @vmpstr

@chrishtr
Copy link
Collaborator

chrishtr commented Mar 8, 2019

These methods should force a lifecycle update for the document, and also force all of the work
that happens in update(), but not force a commit().

The definition of the methods like getBoundingClientRect in this situation are not defined precisely yet, but I propose that getBoundingClientRect return a rect relative to the ancestor element that holds the lock. If multiple such ancestors hold a lock, then the nearest one.

Agree that DevTools probably wants the old/currently-painted ones.

@chrishtr
Copy link
Collaborator

Also, in lock-after-append mode, calling the methods on the locked root should force outer layout
up to and including that element, but not the locked subtree.

@ojanvafai
Copy link
Member

Alternate proposal: APIs that need to crawl up the ancestor chain (i.e. positioning APIs) throw or return invalid return values (e.g. undefined). Making them relative to the locked ancestor seems like it will lead to more bugs.

In this world, things like offsetHeight, getComputedStyle, etc work fine, but offsetTop, getBoundingClientRect, etc would throw.

@vmpstr vmpstr closed this as completed Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants