Skip to content

Commit

Permalink
Silence Typescript complaining
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtaStruhar committed Jun 10, 2024
1 parent f293b3c commit ac8f5b5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ import PageLayout from "../layouts/PageLayout.astro";
let copyButton = document.getElementById("copy-output");
if (copyButton) {
copyButton.addEventListener("click", () => {
navigator.clipboard.writeText(
document.getElementById("output").innerText
);
const outputElement = document.getElementById("output");
if (outputElement) {
navigator.clipboard.writeText(outputElement.innerText);
} else {
alert("Failed to copy output to clipboard!");
}
});
}
copyButton?.style.setProperty("display", "none");
Expand All @@ -135,14 +138,14 @@ import PageLayout from "../layouts/PageLayout.astro";
data[input.name] = [];
}
input.addEventListener("change", (event) => {
let target = event.target;
let target = event.target as HTMLInputElement;
if (target) {
if (target.type == "checkbox") {
if (target.checked) {
data[target.name].push(target.value);
} else {
data[target.name] = data[target.name].filter(
(item) => item != target.value
(item) => item != target.value,
);
}
} else {
Expand Down

0 comments on commit ac8f5b5

Please sign in to comment.