Skip to content

Commit b38d605

Browse files
committed
wip
1 parent ae55158 commit b38d605

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ const DEFAULT_OBSERVED_ROLES = [
3232
'treeitem',
3333
]
3434

35-
const partialMatch = <Obj extends Record<string, any>>(
36-
a: Partial<Obj>,
37-
b: Obj
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
3839
): boolean => {
39-
return Object.keys(a).every(
40-
(key) => a[key as keyof Obj] === b[key as keyof Obj]
40+
return Object.keys(partialObj).every(
41+
(key) => partialObj[key as keyof Obj] === mainObj[key as keyof Obj]
4142
)
4243
}
4344
type AttributeMutations = { [attributeName: string]: string | null }
@@ -263,7 +264,7 @@ export class MutationObservable {
263264
// if the value is the same as the last one emitted from a given element, we don't want to emit it again
264265
const prevMutations = this.prevMutationsCache.get(element)
265266
if (prevMutations) {
266-
const hasActuallyChanged = !partialMatch(mutations, prevMutations)
267+
const hasActuallyChanged = !isObjectMatch(mutations, prevMutations)
267268
if (!hasActuallyChanged) {
268269
return
269270
}

0 commit comments

Comments
 (0)