Skip to content

Commit b47ceaf

Browse files
ref(utils): Remove optional chaining (#4289)
Co-authored-by: Armin Ronacher <[email protected]>
1 parent 30ea755 commit b47ceaf

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/utils/src/browser.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ function _htmlElementAsString(el: unknown, keyAttrs?: string[]): string {
7777
out.push(elem.tagName.toLowerCase());
7878

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

84-
if (keyAttrPairs?.length) {
85+
if (keyAttrPairs && keyAttrPairs.length) {
8586
keyAttrPairs.forEach(keyAttrPair => {
8687
out.push(`[${keyAttrPair[0]}="${keyAttrPair[1]}"]`);
8788
});

packages/utils/src/misc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export function addExceptionMechanism(event: Event, newMechanism?: Partial<Mecha
142142
exceptionValue0.mechanism = { ...defaultMechanism, ...currentMechanism, ...newMechanism };
143143

144144
if (newMechanism && 'data' in newMechanism) {
145-
const mergedData = { ...currentMechanism?.data, ...newMechanism.data };
145+
const mergedData = { ...(currentMechanism && currentMechanism.data), ...newMechanism.data };
146146
exceptionValue0.mechanism.data = mergedData;
147147
}
148148
}
@@ -261,7 +261,7 @@ export function stripUrlQueryAndFragment(urlPath: string): string {
261261
*/
262262
export function checkOrSetAlreadyCaught(exception: unknown): boolean {
263263
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
264-
if ((exception as any)?.__sentry_captured__) {
264+
if (exception && (exception as any).__sentry_captured__) {
265265
return true;
266266
}
267267

0 commit comments

Comments
 (0)