Skip to content

Commit

Permalink
fixed bug if no image is found
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatthes committed Nov 24, 2023
1 parent e4e0a03 commit 11dedb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@leuffen/liscom-loader",
"version": "1.0.6",
"version": "1.0.7",
"description": "",
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
7 changes: 6 additions & 1 deletion src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export function initLoader() {
// Cancel interval
clearInterval(interval);

let img = document.querySelector("img").cloneNode(true) as HTMLImageElement;
let img = document.querySelector("img")?.cloneNode(true) as HTMLImageElement;

if (img === undefined) {
console.warn("[liscom-loader] No image found to use as loader.");
return;
}
let loader = ka_create_element("div", {class: "loader"});
let loaderImg = ka_create_element("div", {class: "loader-img"}, [img], loader);
img.setAttribute("class", "");
Expand Down

0 comments on commit 11dedb0

Please sign in to comment.