Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sharp-lies-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rrweb/utils": patch
---

Move native Element querySelector and querySelector checks to testableMethods since they are methods
8 changes: 4 additions & 4 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
'ownerDocument',
] as const,
ShadowRoot: ['host', 'styleSheets'] as const,
Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,
Element: ['shadowRoot'] as const,
MutationObserver: [] as const,
} as const;

const testableMethods = {
Node: ['contains', 'getRootNode'] as const,
ShadowRoot: ['getSelection'],
Element: [],
Element: ['querySelector', 'querySelectorAll'],
MutationObserver: ['constructor'],
} as const;

Expand Down Expand Up @@ -218,14 +218,14 @@
}

export function querySelector(n: Element, selectors: string): Element | null {
return getUntaintedAccessor('Element', n, 'querySelector')(selectors);
return getUntaintedMethod('Element', n, 'querySelector')(selectors);
}

export function querySelectorAll(
n: Element,
selectors: string,
): NodeListOf<Element> {
return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);
return getUntaintedMethod('Element', n, 'querySelectorAll')(selectors);
}

export function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {
Expand All @@ -234,7 +234,7 @@

// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts
export function patch(
source: { [key: string]: any },

Check warning on line 237 in packages/utils/src/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/utils/src/index.ts#L237

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
name: string,
replacement: (...args: unknown[]) => unknown,
): () => void {
Expand Down
Loading