makeMutationCallback

A factory to generate our Mutation Observer callback. The core of our auto-tracking and validation logic.

The callback orchestrates events handling and triggering, plus tagging validation based on the type of mutations it receives.

const makeMutationCallback = (
console?: TrackerConsole
) => MutationCallback

Parameters

typedefault value
optionalconsoleTrackerConsole

New nodes mutation

For each new node we invoke trackNewElements, which:

Removed nodes mutation

Nodes attributes mutation

SPA URL changes

  • On every DOM change we double-check the URL. If the last URL is different from the current we trigger a URL change event.