Re: [w3ctag/design-reviews] Early Design Review: document.prerendering (#613)

Hi, thank you for the responses and sorry for the delay - I've been OOO for the last two weeks.

> Is the change from prerendering==true to prerendering==false a one-time change? Or can a document go from prerendering==true back to prerendering false?

Assuming you mean "can a document go from prerendering==false to prerendering==true" - yes, that is a potential case that comes from the [portals proposal](https://github.com/WICG/portals). In that proposal, on navigation, the initial page can be "adopted" into a portal on the destination page. In that case, we would want to set `document.prerendering == true`.

> I'm also concerned with the prerendering state being a boolean. What's the possibility of there being other variants of prerendering state in the future? An enum would be more extensible.

I'm somewhat weary of using an enum given [the experience](https://github.com/jeremyroman/alternate-loading-modes/blob/main/prerendering-state.md#web-compatibility) with `document.visibilityState`. It seems that in practice, an enum that's semantically a bool will cause authors to write code like:

```
if (document.state == 'prerendering')
  doPrerender();
else
  doRegular();
```

Which will break when a new enum is introduced. Given we don't currently anticipate anything like this and, should it come up, seems like it'd be more appropriate as _additional_ information on something like a `renderingState` object as proposed below, a bool seems preferable to me.

> I'm also concerned with adding more properties to document. It may be useful to consider making a rendering state (or somesuch) object that collects this and other (future) similar properties.

That sounds reasonable to me. My only worry is there aren't additional such properties and it ends up being an object with a single property. Would it make sense to move `document.visibilityState` into that as well (and any other related properties, do we  know of more?) and then spec `document.visibilityState` to be a shorthand for `document.renderingState.visibilityState`?

I don't know...it seems like a overkill for a such a small addition but agree that most changes are small individually but can add up to a significant mass.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/613#issuecomment-809509012

Received on Monday, 29 March 2021 16:06:38 UTC