ampproject / ampproject/amphtml

`isDocumentReady` predicate always returns true

Open
#36,320 2 comments 0 reactions 1 assignee Claimed by @rcebulko View on GitHub
Stale
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

In `#core/document/ready`, we check if `document.readyState` is either `loading` or `uninitialized`. According to https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState, only the first is possible (TypeScript surfaced this error). `uninitialized` isn't even one of the custom ready states (defined in `#core/constants/ready-state`) used in `custom-element`. As far as I can tell, `Document#readyState` is a `readonly` property, so unless we're doing something really weird, we should drop the second half of this conditional, which I'm guessing is old dead code.

https://github.com/ampproject/amphtml/blob/main/src/core/document/ready.js#L7

/cc @jridgewell to tell me if I'm missing something.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.