Skip to content

Commit

Permalink
feat(v8/core): Deprecate getDomElement method
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Dec 19, 2024
1 parent b6c84fa commit d660f1f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/browser/src/tracing/browserTracingIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ export function getMetaContent(metaName: string): string | undefined {
// Can't specify generic to `getDomElement` because tracing can be used
// in a variety of environments, have to disable `no-unsafe-member-access`
// as a result.
// eslint-disable-next-line deprecation/deprecation
const metaTag = getDomElement(`meta[name=${metaName}]`);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return metaTag ? metaTag.getAttribute('content') : undefined;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/utils-hoist/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export function getLocationHref(): string {
* `const element = getDomElement<Element>('selector');`
*
* @param selector the selector string passed on to document.querySelector
*
* @deprecated This method is deprecated and will be removed in the next major version.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getDomElement<E = any>(selector: string): E | null {
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/utils-hoist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ export { applyAggregateErrorsToEvent } from './aggregate-errors';
// eslint-disable-next-line deprecation/deprecation
export { flatten } from './array';
export { getBreadcrumbLogLevelFromHttpStatusCode } from './breadcrumb-log-level';
export { getComponentName, getDomElement, getLocationHref, htmlTreeAsString } from './browser';
export {
getComponentName,
// eslint-disable-next-line deprecation/deprecation
getDomElement,
getLocationHref,
htmlTreeAsString,
} from './browser';
export { dsnFromString, dsnToString, makeDsn } from './dsn';
export { SentryError } from './error';
export { GLOBAL_OBJ, getGlobalSingleton } from './worldwide';
Expand Down
1 change: 1 addition & 0 deletions packages/core/test/utils-hoist/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('htmlTreeAsString', () => {
describe('getDomElement', () => {
it('returns the element for a given query selector', () => {
document.head.innerHTML = '<div id="mydiv">Hello</div>';
// eslint-disable-next-line deprecation/deprecation
const el = getDomElement('div#mydiv');
expect(el).toBeDefined();
expect(el?.tagName).toEqual('DIV');
Expand Down
1 change: 1 addition & 0 deletions packages/svelte/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ export function detectAndReportSvelteKit(): void {
* @see https://github.com/sveltejs/kit/issues/307 for more information
*/
export function isSvelteKitApp(): boolean {
// eslint-disable-next-line deprecation/deprecation
return getDomElement('div#svelte-announcer') !== null;
}
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ export const resolve = resolve_imported;
export const getComponentName = getComponentName_imported;

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

/** @deprecated Import from `@sentry/core` instead. */
Expand Down

0 comments on commit d660f1f

Please sign in to comment.