diff --git a/packages/signals/signals/src/core/signal-generators/dom-gen/helpers.ts b/packages/signals/signals/src/core/signal-generators/dom-gen/helpers.ts index 4383aa3cb..8030d3143 100644 --- a/packages/signals/signals/src/core/signal-generators/dom-gen/helpers.ts +++ b/packages/signals/signals/src/core/signal-generators/dom-gen/helpers.ts @@ -5,3 +5,13 @@ export const cleanText = (str: string): string => { .replace(/\u00A0/g, ' ') // Replace non-breaking spaces with a regular space .trim() // Trim leading and trailing spaces } + +// Check if a subset object is a partial match of another object +export const isObjectMatch = >( + partialObj: Partial, + mainObj: Obj +): boolean => { + return Object.keys(partialObj).every( + (key) => partialObj[key as keyof Obj] === mainObj[key as keyof Obj] + ) +} diff --git a/packages/signals/signals/src/core/signal-generators/dom-gen/mutation-observer.ts b/packages/signals/signals/src/core/signal-generators/dom-gen/mutation-observer.ts index e7fd8e6b0..905914ebd 100644 --- a/packages/signals/signals/src/core/signal-generators/dom-gen/mutation-observer.ts +++ b/packages/signals/signals/src/core/signal-generators/dom-gen/mutation-observer.ts @@ -2,6 +2,7 @@ import { Emitter } from '@segment/analytics-generic-utils' import { exists } from '../../../lib/exists' import { debounceWithKey } from '../../../lib/debounce' import { logger } from '../../../lib/logger' +import { isObjectMatch } from './helpers' const DEFAULT_OBSERVED_ATTRIBUTES = [ 'aria-pressed', @@ -32,15 +33,6 @@ const DEFAULT_OBSERVED_ROLES = [ 'treeitem', ] -// Check if a subset object is a partial match of another object -const isObjectMatch = >( - partialObj: Partial, - mainObj: Obj -): boolean => { - return Object.keys(partialObj).every( - (key) => partialObj[key as keyof Obj] === mainObj[key as keyof Obj] - ) -} type AttributeMutations = { [attributeName: string]: string | null } export type AttributeChangedEvent = { element: HTMLElement