Use getContexts to manage offscreen document lifecycle (recommended from docs) #1514
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the documentation for maintaining an offscreen document, the recommendation is to do the heavy lifting in the parameters that can be passed to
getContexts
:But in some of the functional examples showing offscreen documents, we don't follow that recommendation:
In this PR, I've made the above edit to the
offscreen-dom
cookbook, along with 1 other edit: I've removed the check for document that we do before trying to close the document. Instead, I've just put in a warning if our attempt to close the document fails:Does this look OK? Should we add it to the other 2 offscreen examples? (clipboard-write and
geolocation- nvm already there!)