-
Notifications
You must be signed in to change notification settings - Fork 715
[resize-observer-1] Firing observations on insert/remove when rendered size is (0, 0) #7808
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
Comments
Yes, but these listed properties were already broken with an initial observation of [(0, 0)], e.g.
A relevant issue is #7734. If we say that an element with no box has a size of [], then
But if elements with no box are supposed to have a size of [(0, 0)], then we will need to discuss what to do with elements of 0x0 size. |
Agreed. I didn't mean to say that the change to -1,-1 is wrong, I meant to say that it doesn't handle all cases, such as insertion/removal of a 0x0 element. Based on Blink code and the current spec, it sounds like the idea was that when the element is out of the DOM, it would have a 0x0 size and when it's in the DOM and rendered, then it would have non-0x0 size. So I don't think the case of having a rendered size of 0x0 was considered in detail. I like your idea of having a [] size, which is the same as what I wrote about a nullable last size. That should fix all the issues without the need for -1,-1 initialization, right? |
Rereading #7734, the distinction is that I'm proposing the nullable state to be an internal detail and continue to expose 0x0 to the API. As you mention in the other issue, exposing an empty array is risky since there are examples where script doesn't check size |
Initializing to [] wouldn't trigger an observation when first observing an element with no box (if that also uses []). This wouldn't be consistent with IntersectionObserver.
Yes, that's a possibility. |
I think this is the list or cases where it's not obvious whether they should trigger a notification or not:
|
The CSS Working Group just discussed The full IRC log of that discussion<bramus> vmpstr: we recently resolved to set … to -1 so ro would fire when size is 0,0<bramus> vmpstr: I think that may break some of the spec because once it fires and you then remove and readd the element, the last reported size will now be 0,0 and the reinsertion wont fire again which is not what we expect <bramus> vmpstr: we expect the process to be consistent. have a proprosal to have a nullable last reported size as opposed to -1,-1 <bramus> vmpstr: when removed it would be null <bramus> vmpstr: i think oriol listed all cases to consider <bramus> oriol: best to go over issues in list <bramus> oriol: 1st question listed in issue at https://github.com//issues/7808#issuecomment-1263694781 – should we add a notification here? <bramus> astearns: maybe take the list back to the issue? unless vpmstr has a summary? <bramus> vpmstr: no strong opinion. most things listed should have a notification. ok with taking back to issue <bramus> astearns: lets do that <bramus> astearns: once we have answer to all issues we can bring a proposed resolution to the agenda <bramus> oriol: call for people to reply in issue, its been open for a while <bramus> astearns: yes, please record opinions in our issues |
Here's my thoughts on this:
Yes, this should observe a 0x0 box or empty, as resolved elsewhere
This seems mandated by this line in the spec, but I agree that it doesn't seem useful
This should probably fire an observation, since we're distinguishing no box from 0x0 box
Not sure about this :\
Yes, this should fire an observation
Not sure about inline boxes. I think the question really is whether inline boxes should be treated as "no box" or "0x0 box" from the perspective of resize observer |
In #7734 we resolved to use empty array when there is no box, so automatically it should follow that these trigger notifications, since there will be a change between
Here we keep having
Here a notification can still be achieved by initializing the array to something invalid like
And I guess these will depend on what we do for inline boxes (#6358):
I think inline boxes should just populate the array with the actual sizes, then the first 2 cases would change between empty and non-empty array, triggering a notification. The 3rd case would typically trigger a notification too, but wouldn't for a 0x0 inline (e.g. |
Uh oh!
There was an error while loading. Please reload this page.
The group resolved to initialize the initial observation to (-1, -1) here: #3664 (comment)
I don't believe this is sufficient to satisfy the following listed properties of resize observer:
(the 0,0 part of the last point would presumably change due to (-1, -1) resolution)
The way the observations are fired is through some indirection but essentially this text:
Initializing the last reported sizes to (-1, -1) means that
Although it's in the spec, I don't believe Blink implementation exposes the lastReportedSizes property. I'm not sure about other implementations. One solution would be to add a new (-1, -1) entry any time the element is removed or display: none or loses its "being rendered" status in any way. It's a little awkward. Another option if lastReportedSizes is indeed not exposed anywhere would be to rewrite the resize observer spec to only keep track of one nullable lastReportedSize, have it be null as the initial value, and reset it to null any time the element loses its box
@Loirooriol
The text was updated successfully, but these errors were encountered: