docs: add guide for supporting pop-out windows #192
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.
This is a preliminary PR for adding a brief guide on how to use proper APIs to support pop-out windows. The guide itself is mainly based on the blog post written by Licat when the feature was first added.
Some of the notable changes include:
This PR is ready to merge, but it might be useful to add some pointers for proper API usage. When searching around for existing plugins making use of these API's, I was wondering what the actual 'proper' usage is of them.
Adding listeners on
window
/document
I found some plugins that makes use of the following construction (e.g. found in a View construction):
However, I feel like this isn't entirely correct. Aside from the fact that some of the plugin never even unregister the listener, there are also some other problems:
Is it possible to get the previous window in
onWindowMigrate
? That way, the event listener can be correctly removed.Guideline for correct
window
/document
accessThis question is more about devising a good guideline for when to use which
document
/window
accessor API:element.doc
/element.win
orevent.doc
/event.win
: Use this if you need something to happen on the correctwindow
/document
activeDocument
/activeWindow
: Use this for timers likesetTimeout
document
/window
: Use this for everything else(Updated based on Licat's comments)