MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / _initGlobalObserver

Method _initGlobalObserver

src/core/runtime/reactivity.js:344–366  ·  view source on GitHub ↗

* Set up the single global MutationObserver and delegated input/change * listeners that power attribute, property, and query tracking.

()

Source from the content-addressed store, hash-verified

342 * listeners that power attribute, property, and query tracking.
343 */
344 _initGlobalObserver() {
345 if (typeof document === "undefined") return;
346
347 if (!this._observer) {
348 var reactivity = this;
349 this._observer = new MutationObserver(function (mutations) {
350 reactivity._handleMutations(mutations);
351 });
352 this._inputHandler = function (e) { reactivity._handleDOMEvent(e); };
353 this._changeHandler = function (e) { reactivity._handleDOMEvent(e); };
354 }
355
356 // observe() replaces any prior observation on this target
357 this._observer.observe(document, {
358 attributes: true,
359 childList: true,
360 subtree: true
361 });
362
363 // addEventListener is idempotent for the same listener+capture combo
364 document.addEventListener("input", this._inputHandler, true);
365 document.addEventListener("change", this._changeHandler, true);
366 }
367
368 /**
369 * Handle MutationObserver callbacks. Dispatches to attribute and query

Callers 1

_subscribeEffectMethod · 0.45

Calls 2

_handleMutationsMethod · 0.45
_handleDOMEventMethod · 0.45

Tested by

no test coverage detected