Scope ModelContext to Document, and handle detached documents#177
Open
domfarolino wants to merge 1 commit into
Open
Scope ModelContext to Document, and handle detached documents#177domfarolino wants to merge 1 commit into
ModelContext to Document, and handle detached documents#177domfarolino wants to merge 1 commit into
Conversation
domfarolino
commented
May 15, 2026
| {{ModelContext}} object. | ||
|
|
||
| Upon creation of the {{Document}} object, its [=Document/associated ModelContext|associated | ||
| <code>ModelContext</code>=] must be set to a [=new=] {{ModelContext}} object created in the |
Collaborator
Author
There was a problem hiding this comment.
Hey @tabatkins, I could not for the life of me figure out how to add {{ModelContext}} or <code>ModelContext</code> to the actual linking text, so I had to settle on this super verbose [=foo|<code>foo</code>=] which is really redundant and I can't figure out if there's a way around it, so I can tighten these up. It's not blocking, so if there's no solution, that's fine.
ModelContext lifetime to Document and handle detached documents
ModelContext lifetime to Document and handle detached documentsModelContext to Document, and handle detached documents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR does two things:
ModelContextobject toDocumentinstead ofNavigator, and explains why.modelContextattribute return null when the document is detached (by checking when the Window's browsing context is null). This matches the behavior of thecontentWindowandcontentDocumentgetters—return nothing, even if those objects are allocated and kept alive by other references, in the detached document case.Note that this PR does not handle the "document not fully active" case, which covers detached documents and documents in the bf-cache. Non-fully active documents probably shouldn't impact the
modelContextgetter—it seems weird for getters like that to return different values based on whether the document is in the bf-cache—but rather need special behavior in theregisterTool()method, and the cominggetTools()andexecuteTool()methods.This PR mostly addresses #173, with the exception of considering moving the API to
self, fromnavigator. As much as I want to do this, I'm sympathetic to w3ctag/design-principles#426 (comment), so for now I'm leaning towards not moving it. So I'll say that this PR closes #173.Preview | Diff