Skip to content

Commit d3f52cf

Browse files
authored
feat(v8/core): Deprecate getDomElement method (#14799)
Backported deprecation of #14797
1 parent 01a2571 commit d3f52cf

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

packages/browser/src/tracing/browserTracingIntegration.ts

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ export function getMetaContent(metaName: string): string | undefined {
465465
// Can't specify generic to `getDomElement` because tracing can be used
466466
// in a variety of environments, have to disable `no-unsafe-member-access`
467467
// as a result.
468+
// eslint-disable-next-line deprecation/deprecation
468469
const metaTag = getDomElement(`meta[name=${metaName}]`);
469470
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
470471
return metaTag ? metaTag.getAttribute('content') : undefined;

packages/core/src/utils-hoist/browser.ts

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ export function getLocationHref(): string {
155155
* `const element = getDomElement<Element>('selector');`
156156
*
157157
* @param selector the selector string passed on to document.querySelector
158+
*
159+
* @deprecated This method is deprecated and will be removed in the next major version.
158160
*/
159161
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160162
export function getDomElement<E = any>(selector: string): E | null {

packages/core/src/utils-hoist/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ export { applyAggregateErrorsToEvent } from './aggregate-errors';
22
// eslint-disable-next-line deprecation/deprecation
33
export { flatten } from './array';
44
export { getBreadcrumbLogLevelFromHttpStatusCode } from './breadcrumb-log-level';
5-
export { getComponentName, getDomElement, getLocationHref, htmlTreeAsString } from './browser';
5+
export {
6+
getComponentName,
7+
// eslint-disable-next-line deprecation/deprecation
8+
getDomElement,
9+
getLocationHref,
10+
htmlTreeAsString,
11+
} from './browser';
612
export { dsnFromString, dsnToString, makeDsn } from './dsn';
713
export { SentryError } from './error';
814
export { GLOBAL_OBJ, getGlobalSingleton } from './worldwide';

packages/core/test/utils-hoist/browser.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('htmlTreeAsString', () => {
7878
describe('getDomElement', () => {
7979
it('returns the element for a given query selector', () => {
8080
document.head.innerHTML = '<div id="mydiv">Hello</div>';
81+
// eslint-disable-next-line deprecation/deprecation
8182
const el = getDomElement('div#mydiv');
8283
expect(el).toBeDefined();
8384
expect(el?.tagName).toEqual('DIV');

packages/svelte/src/sdk.ts

+1
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ export function detectAndReportSvelteKit(): void {
5555
* @see https://github.com/sveltejs/kit/issues/307 for more information
5656
*/
5757
export function isSvelteKitApp(): boolean {
58+
// eslint-disable-next-line deprecation/deprecation
5859
return getDomElement('div#svelte-announcer') !== null;
5960
}

packages/utils/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ export const resolve = resolve_imported;
560560
export const getComponentName = getComponentName_imported;
561561

562562
/** @deprecated Import from `@sentry/core` instead. */
563+
// eslint-disable-next-line deprecation/deprecation
563564
export const getDomElement = getDomElement_imported;
564565

565566
/** @deprecated Import from `@sentry/core` instead. */

0 commit comments

Comments
 (0)