Skip to content

Commit 05602fe

Browse files
Update observers to match current thinking
1 parent 506181c commit 05602fe

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

WEB-INTEGRATION.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ called once per observation. Instead, multiple observations can be batched into
377377
one single call. This means that there is not always a single JS action that causes
378378
some work that eventually triggers the observer callback; rather, there might be many.
379379

380-
Given this, for consistency it would be preferable to instead propagate the context that
381-
was active when the observer callback was registered; that is, the context in which the
382-
class is constructed.
380+
Given this, observer callbacks should always run with the empty context. This can be explained
381+
by saying that layout changes are always considered to be a browser-internal trigger, even if
382+
they were caused by changes injected into the DOM or styles through JavaScript.
383383

384384
- [`MutationObserver`](https://dom.spec.whatwg.org/#mutationobserver)
385385
[\[DOM\]](https://dom.spec.whatwg.org/)
@@ -392,12 +392,12 @@ class is constructed.
392392
- [`ReportingObserver`](https://w3c.github.io/reporting/#reportingobserver)
393393
[\[REPORTING\]](https://w3c.github.io/reporting/)
394394

395-
> [!IMPORTANT]
396-
> Due to concerns about observers leading to memory leaks, an alternative
397-
> option is to not use the context from when the observer was created, and instead call the observer's
398-
> callback with the empty context. This is coherent with the general design direction
399-
> of using the dispatch context, except that we would say that these observers are always
400-
> triggered as consequences of browser-internal code.
395+
> [!NOTE]
396+
> An older version of this proposal suggested to capture the context at the time the observer
397+
> is create, and use it to run the callback. This has been removed due to memory leak concerns.
398+
>
399+
> It's under discussion wether observers should use the same mechanism as events (see below)
400+
> to define a scoped fallback value for some `AsyncContext.Variable`s.
401401
402402
In some cases it might be useful to expose the causal context for individual
403403
observations, by exposing an `AsyncContext.Snapshot` property on the observation

0 commit comments

Comments
 (0)