Skip to content

Commit

Permalink
fix: Change replaceChildren access to safe (#94)
Browse files Browse the repository at this point in the history
This PR removes the defined assertion from a couple lines of code and
optional chains the param in case it doesn't exist
  • Loading branch information
ajay-sentry authored Nov 19, 2024
1 parent 662b957 commit 863eecc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/content/github/pr/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async function main() {
document.addEventListener("soft-nav:end", execute);
await execute();
} catch (e) {
Sentry.captureException(e)
throw e
Sentry.captureException(e);
throw e;
}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ const handleToggleClick: React.MouseEventHandler = (event) => {
};

function updateContainer(head: number, patch: number, change: number) {
const parent = document.getElementById("coverage-report-data")!;
const parent = document.getElementById("coverage-report-data");

const element = (
<div className="codecov-flex codecov-items-center">
Expand All @@ -119,17 +119,17 @@ function updateContainer(head: number, patch: number, change: number) {
</div>
);

parent.replaceChildren(element);
parent?.replaceChildren(element);
}

function showError() {
const parent = document.getElementById("coverage-report-data")!;
const parent = document.getElementById("coverage-report-data");

const element = (
<div className="my-auto mr-6">Coverage report not available</div>
);

parent.replaceChildren(element);
parent?.replaceChildren(element);
}

function transformReport(filesReport: any) {
Expand Down

0 comments on commit 863eecc

Please sign in to comment.