Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v8/core): Deprecate getDomElement method #14799

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
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
Loading