Move mutation processing into it's own class (#223)

* Move mutation processing into it's own object.

This should stand on it's own as a refactor, but is intended as a basis
for exposing the new MutationBuffer object to further outside control e.g.
to 'mute' or batch up mutation emission when the page becomes inactive
from a https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
point of view

* The `processMutations` function needed to be bound to the `mutationBuffer` object, as otherwise `this` referred to the `MutationObserver` object itself

* Neglected to add this output of `npm run typings`

* Get around the binding problem by using Arrow function expressions

* Prettier formatting
This commit is contained in:
Eoghan Murray
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 06024b245f
commit d57cae3d51
6 changed files with 357 additions and 275 deletions

View File

@@ -166,6 +166,16 @@ export type hooksParam = {
styleSheetRule?: styleSheetRuleCallback;
};
// https://dom.spec.whatwg.org/#interface-mutationrecord
export type mutationRecord = {
type: string,
target: Node,
oldValue: string | null,
addedNodes: NodeList,
removedNodes: NodeList,
attributeName: string | null,
}
export type textCursor = {
node: Node;
value: string | null;