notify documents of a tool change computes the set of documents to notify as:
index.bs:192
Let |navigablesToNotify| be |tool owner|'s node navigable's traversable navigable's descendant navigables.
descendant navigables does not include the document's own navigable, so the top-level / tool-owning document is never iterated and never receives toolchange.
This contradicts the spec's own example block immediately below the algorithm:
index.bs:213–:232
document.modelContext.ontoolchange = e => console.log('Parent toolchange');
iframe.contentDocument.modelContext.ontoolchange = e => console.log('Child toolchange');
const p = document.modelContext.registerTool({ /* ... */ });
// Parent toolchange will always log before Child toolchange ...
The example asserts the registering (parent) document logs Parent toolchange, but with descendant navigables the parent is excluded and would never fire. The PR that introduced this algorithm (#179) describes its intent as firing toolchange "in all documents in the tree that a tool changes in" — which includes the tool owner.
It's also inconsistent with perform an observation, which uses inclusive descendant navigables (self-inclusive) for the equivalent traversal.
Suggested fix: use the self-inclusive variant.
Let |navigablesToNotify| be |tool owner|'s node navigable's traversable navigable's active document's inclusive descendant navigables.
Introduced in #179
notify documents of a tool change computes the set of documents to notify as:
index.bs:192
Let |navigablesToNotify| be |tool owner|'s node navigable's traversable navigable's descendant navigables.
descendant navigables does not include the document's own navigable, so the top-level / tool-owning document is never iterated and never receives toolchange.
This contradicts the spec's own example block immediately below the algorithm:
index.bs:213–:232
document.modelContext.ontoolchange = e => console.log('Parent toolchange');
iframe.contentDocument.modelContext.ontoolchange = e => console.log('Child toolchange');
const p = document.modelContext.registerTool({ /* ... */ });
//
Parent toolchangewill always log beforeChild toolchange...The example asserts the registering (parent) document logs Parent toolchange, but with descendant navigables the parent is excluded and would never fire. The PR that introduced this algorithm (#179) describes its intent as firing toolchange "in all documents in the tree that a tool changes in" — which includes the tool owner.
It's also inconsistent with perform an observation, which uses inclusive descendant navigables (self-inclusive) for the equivalent traversal.
Suggested fix: use the self-inclusive variant.
Let |navigablesToNotify| be |tool owner|'s node navigable's traversable navigable's active document's inclusive descendant navigables.
Introduced in #179