Skip to content

Commit

Permalink
ReferenceError: document is not defined is thrown on an attempt to ge…
Browse files Browse the repository at this point in the history
…nerate a SurveyModel on a server-side fix #7855
  • Loading branch information
andrewtelnov committed Feb 12, 2024
1 parent 368f734 commit dbcae3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/dropdownListModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export class DropdownListModel extends Base {
}

private cleanHtml(html: string): string {
if(!this.htmlCleanerElement) return "";
this.htmlCleanerElement.innerHTML = html;
return this.htmlCleanerElement.textContent;
}
Expand Down Expand Up @@ -347,7 +348,9 @@ export class DropdownListModel extends Base {
};
constructor(protected question: Question, protected onSelectionChanged?: (item: IAction, ...params: any[]) => void) {
super();
this.htmlCleanerElement = document.createElement("div");
if ("undefined" !== typeof document) {
this.htmlCleanerElement = document.createElement("div");
}
question.onPropertyChanged.add(this.qustionPropertyChangedHandler);
this.showInputFieldComponent = this.question.showInputFieldComponent;

Expand Down
2 changes: 1 addition & 1 deletion src/popup-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class PopupBaseViewModel extends Base {
this.resetComponentElement();
}
public initializePopupContainer(): void {
if (!this.container) {
if (!this.container && ("undefined" !== typeof document)) {
const container: HTMLElement = document.createElement("div");
this.createdContainer = container;
getElement(settings.environment.popupMountContainer).appendChild(container);
Expand Down
3 changes: 2 additions & 1 deletion src/question_signaturepad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export class QuestionSignaturePadModel extends QuestionFileModelBase {
this.signaturePad.fromDataURL(data, { width: this.canvas.width * this.scale, height: this.canvas.height * this.scale });
}

private fromUrl(url: string) {
private fromUrl(url: string): void {
if ("undefined" === typeof document) return;
const img = document.createElement("img");
img.crossOrigin = "anonymous";
img.src = url;
Expand Down

0 comments on commit dbcae3f

Please sign in to comment.