Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit abe497a

Browse files
Merge pull request #2 from SimplrJS/hotfix/head-check
Throwing falsy error fixed.
2 parents 39071dc + 364c5f7 commit abe497a

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

dist/abstractions/loader-base.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/abstractions/loader-base.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,25 @@ export abstract class LoaderBase<TProps extends BaseProps, TState> extends React
7474
* @param props {TProps} props of loader component.
7575
*/
7676
protected AppendStyles(styles: string, props: TProps) {
77-
if (props.useDefaultStyle === false) {
77+
if (props.useDefaultStyle === false || typeof (document) === "undefined") {
7878
return;
7979
}
8080

8181
const head = document.getElementsByTagName("head")[0];
82-
if (head != null && document.getElementById(this.LoaderId) == null) {
82+
83+
if (head == null) {
84+
throw new Error("--SimplrLoaders-- <head> tag not found.");
85+
}
86+
87+
const loaderStyle = document.getElementById(this.LoaderId);
88+
89+
if (loaderStyle == null) {
8390
const style = document.createElement("style");
8491
style.setAttribute("id", this.LoaderId);
8592
const textNode = document.createTextNode(styles);
8693

8794
style.appendChild(textNode);
8895
head.appendChild(style);
89-
} else {
90-
throw new Error("--SimplrLoaders-- <head> tag not found.");
9196
}
9297
}
9398

0 commit comments

Comments
 (0)