From 6185301129ec2bb1e8b4d31554effd608dacba5f Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:38:48 -0600 Subject: [PATCH] wip --- .../src/core/signal-generators/dom-gen/helpers.ts | 10 ++++++++++ .../signal-generators/dom-gen/mutation-observer.ts | 10 +--------- 2 files changed, 11 insertions(+), 9 deletions(-) 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