Re: [csswg-drafts] [cssom-view] Proposal: add Element.isRendered() to detect if element is rendered. (#6850)

I may be bikeshedding here, but I have the feeling that this method should be called something else.  
I fear that by calling this `Element.isRendered` authors will think it's just a getter with no side-effects. However no matter how it's optimized behind the scene, it will at least force a synchronous reflow like any of [these](https://gist.github.com/paulirish/5d52fb081b3570c81e3a).  
So if one were to e.g change the DOM while looping over a list of elements themselves nested deep in a complex tree doing

```js
for (const elem of list) {
  if (elem.isRendered()) {
    elem.before(newElement());
  }
}
```
the styles would get recalculated for the whole page at every iteration of the loop with sensible performance costs.  

I am really not good at naming, but maybe something like `getRenderingStatus()` would make it more obvious that something will happen when calling it, and *maybe* it could also return different values like "not-rendered", "skipped", "rendered" if the distinction is useful?

-- 
GitHub Notification of comment by Kaiido
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6850#issuecomment-987636967 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 7 December 2021 07:16:19 UTC