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

Can LargestContentfulPaint's element attribute be null? #16

Closed
foolip opened this issue Jul 23, 2019 · 5 comments
Closed

Can LargestContentfulPaint's element attribute be null? #16

foolip opened this issue Jul 23, 2019 · 5 comments

Comments

@foolip
Copy link
Member

foolip commented Jul 23, 2019

https://wicg.github.io/largest-contentful-paint/#sec-largest-contentful-paint-interface says:

interface LargestContentfulPaint : PerformanceEntry {
    readonly attribute DOMHighResTimeStamp renderTime;
    readonly attribute DOMHighResTimeStamp loadTime;
    readonly attribute unsigned long size;
    readonly attribute DOMString id;
    readonly attribute DOMString url;
    readonly attribute Element? element;
};

However, https://wicg.github.io/largest-contentful-paint/#sec-processing-model is the only place that creates instances of LargestContentfulPaint, and there element cannot be null.

If it can't be null the ? can be removed from the Web IDL and readers need not wonder :)

@npm1
Copy link
Collaborator

npm1 commented Jul 23, 2019

If the Element is disconnected then 'element' attribute getter should return null. Note that the 'element' attribute getter is NOT defined to just be the 'value it was initialized to'.

@npm1 npm1 closed this as completed Jul 23, 2019
@foolip
Copy link
Member Author

foolip commented Jul 23, 2019

Thanks, that explains why it could return null. Still, why is it like this? One still has to hold old to the element internally and the getter can start returning it again later. Is exposing "is it connected to the same document as before" the direct purpose, or is some optimization made possible this way?

@npm1
Copy link
Collaborator

npm1 commented Jul 23, 2019

The reason is to not hold on to the element forever. The LargestContentfulPaint entry could live after the Element is removed from the DOM tree, so the idea is that we keep exposing some properties of it but the user agent will be allowed to garbage-collect the Element (we should not block garbage collection of Elements on these entries).

@foolip
Copy link
Member Author

foolip commented Jul 24, 2019

I see, not keeping the Element alive was the motivation. I've filed #29 and a similar issue on Element Timing since it looks like the spec doesn't quite achieve this, but it's complex so I'm not entirely sure.

@foolip
Copy link
Member Author

foolip commented Jul 24, 2019

Closing this since it has been answered and there's a more specific issue filed.

@foolip foolip closed this as completed Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants