Skip to content

Commit 6185301

Browse files
committed
wip
1 parent b38d605 commit 6185301

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/signals/signals/src/core/signal-generators/dom-gen/helpers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ export const cleanText = (str: string): string => {
55
.replace(/\u00A0/g, ' ') // Replace non-breaking spaces with a regular space
66
.trim() // Trim leading and trailing spaces
77
}
8+
9+
// Check if a subset object is a partial match of another object
10+
export const isObjectMatch = <Obj extends Record<string, any>>(
11+
partialObj: Partial<Obj>,
12+
mainObj: Obj
13+
): boolean => {
14+
return Object.keys(partialObj).every(
15+
(key) => partialObj[key as keyof Obj] === mainObj[key as keyof Obj]
16+
)
17+
}

packages/signals/signals/src/core/signal-generators/dom-gen/mutation-observer.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Emitter } from '@segment/analytics-generic-utils'
22
import { exists } from '../../../lib/exists'
33
import { debounceWithKey } from '../../../lib/debounce'
44
import { logger } from '../../../lib/logger'
5+
import { isObjectMatch } from './helpers'
56

67
const DEFAULT_OBSERVED_ATTRIBUTES = [
78
'aria-pressed',
@@ -32,15 +33,6 @@ const DEFAULT_OBSERVED_ROLES = [
3233
'treeitem',
3334
]
3435

35-
// Check if a subset object is a partial match of another object
36-
const isObjectMatch = <Obj extends Record<string, any>>(
37-
partialObj: Partial<Obj>,
38-
mainObj: Obj
39-
): boolean => {
40-
return Object.keys(partialObj).every(
41-
(key) => partialObj[key as keyof Obj] === mainObj[key as keyof Obj]
42-
)
43-
}
4436
type AttributeMutations = { [attributeName: string]: string | null }
4537
export type AttributeChangedEvent = {
4638
element: HTMLElement

0 commit comments

Comments
 (0)