Skip to content

ref(utils): Remove optional chaining #4289

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

Merged
merged 2 commits into from
Dec 15, 2021
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
9 changes: 5 additions & 4 deletions packages/utils/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ function _htmlElementAsString(el: unknown, keyAttrs?: string[]): string {
out.push(elem.tagName.toLowerCase());

// Pairs of attribute keys defined in `serializeAttribute` and their values on element.
const keyAttrPairs = keyAttrs?.length
? keyAttrs.filter(keyAttr => elem.getAttribute(keyAttr)).map(keyAttr => [keyAttr, elem.getAttribute(keyAttr)])
: null;
const keyAttrPairs =
keyAttrs && keyAttrs.length
? keyAttrs.filter(keyAttr => elem.getAttribute(keyAttr)).map(keyAttr => [keyAttr, elem.getAttribute(keyAttr)])
: null;

if (keyAttrPairs?.length) {
if (keyAttrPairs && keyAttrPairs.length) {
keyAttrPairs.forEach(keyAttrPair => {
out.push(`[${keyAttrPair[0]}="${keyAttrPair[1]}"]`);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function addExceptionMechanism(event: Event, newMechanism?: Partial<Mecha
exceptionValue0.mechanism = { ...defaultMechanism, ...currentMechanism, ...newMechanism };

if (newMechanism && 'data' in newMechanism) {
const mergedData = { ...currentMechanism?.data, ...newMechanism.data };
const mergedData = { ...(currentMechanism && currentMechanism.data), ...newMechanism.data };
exceptionValue0.mechanism.data = mergedData;
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ export function stripUrlQueryAndFragment(urlPath: string): string {
*/
export function checkOrSetAlreadyCaught(exception: unknown): boolean {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if ((exception as any)?.__sentry_captured__) {
if (exception && (exception as any).__sentry_captured__) {
return true;
}

Expand Down