Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 + Use of this.document instead direct document
  • Loading branch information
EnricoMessall committed Mar 11, 2023
1 parent 6a49b94 commit 514e9f7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/app/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,21 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {

createLabel() {
if (this.label) {
let labelElement = document.createElement('span');
let labelElement = this.document.createElement('span');
if (this.icon && !this.label) {
labelElement.setAttribute('aria-hidden', 'true');
}

labelElement.className = 'p-button-label';
labelElement.appendChild(document.createTextNode(this.label));
labelElement.appendChild(this.document.createTextNode(this.label));

this.htmlElement.appendChild(labelElement);
}
}

createIcon() {
if (this.icon || this.loading) {
let iconElement = document.createElement('span');
let iconElement = this.document.createElement('span');
iconElement.className = 'p-button-icon';
iconElement.setAttribute('aria-hidden', 'true');
let iconPosClass = this.label ? 'p-button-icon-' + this.iconPos : null;
Expand Down
12 changes: 6 additions & 6 deletions src/app/components/confirmdialog/confirmdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class ConfirmDialog implements AfterContentInit, OnInit, OnDestroy {

appendContainer() {
if (this.appendTo) {
if (this.appendTo === 'body') document.body.appendChild(this.wrapper);
if (this.appendTo === 'body') this.document.body.appendChild(this.wrapper);
else DomHandler.appendChild(this.wrapper, this.appendTo);
}
}
Expand All @@ -388,7 +388,7 @@ export class ConfirmDialog implements AfterContentInit, OnInit, OnDestroy {

enableModality() {
if (this.option('blockScroll')) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
DomHandler.addClass(this.document.body, 'p-overflow-hidden');
}

if (this.option('dismissableMask')) {
Expand All @@ -404,7 +404,7 @@ export class ConfirmDialog implements AfterContentInit, OnInit, OnDestroy {
this.maskVisible = false;

if (this.option('blockScroll')) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
DomHandler.removeClass(this.document.body, 'p-overflow-hidden');
}

if (this.dismissableMask) {
Expand All @@ -418,9 +418,9 @@ export class ConfirmDialog implements AfterContentInit, OnInit, OnDestroy {

createStyle() {
if (!this.styleElement) {
this.styleElement = document.createElement('style');
this.styleElement = this.document.createElement('style');
this.styleElement.type = 'text/css';
document.head.appendChild(this.styleElement);
this.document.head.appendChild(this.styleElement);
let innerHTML = '';
for (let breakpoint in this.breakpoints) {
innerHTML += `
Expand Down Expand Up @@ -534,7 +534,7 @@ export class ConfirmDialog implements AfterContentInit, OnInit, OnDestroy {

destroyStyle() {
if (this.styleElement) {
document.head.removeChild(this.styleElement);
this.document.head.removeChild(this.styleElement);
this.styleElement = null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/confirmpopup/confirmpopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class ConfirmPopup implements OnDestroy {
onAnimationStart(event: AnimationEvent) {
if (event.toState === 'open') {
this.container = event.element;
document.body.appendChild(this.container);
this.document.body.appendChild(this.container);
this.align();
this.bindListeners();

Expand Down Expand Up @@ -333,7 +333,7 @@ export class ConfirmPopup implements OnDestroy {

restoreAppend() {
if (this.container) {
document.body.removeChild(this.container);
this.document.body.removeChild(this.container);
}

this.onContainerDestroy();
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/dynamicdialog/dialogservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DialogService {
this.appRef.attachView(componentRef.hostView);

const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;
document.body.appendChild(domElem);
this.document.body.appendChild(domElem);

this.dialogComponentRefMap.set(dialogRef, componentRef);

Expand Down
18 changes: 9 additions & 9 deletions src/app/components/scrollpanel/scrollpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ export class ScrollPanel implements AfterViewInit, AfterContentInit, OnDestroy {
this.lastPageY = e.pageY;
DomHandler.addClass(this.yBarViewChild.nativeElement, 'p-scrollpanel-grabbed');

DomHandler.addClass(document.body, 'p-scrollpanel-grabbed');
DomHandler.addClass(this.document.body, 'p-scrollpanel-grabbed');

document.addEventListener('mousemove', this.onDocumentMouseMove);
document.addEventListener('mouseup', this.onDocumentMouseUp);
this.document.addEventListener('mousemove', this.onDocumentMouseMove);
this.document.addEventListener('mouseup', this.onDocumentMouseUp);
e.preventDefault();
}

Expand All @@ -171,10 +171,10 @@ export class ScrollPanel implements AfterViewInit, AfterContentInit, OnDestroy {
this.lastPageX = e.pageX;
DomHandler.addClass(this.xBarViewChild.nativeElement, 'p-scrollpanel-grabbed');

DomHandler.addClass(document.body, 'p-scrollpanel-grabbed');
DomHandler.addClass(this.document.body, 'p-scrollpanel-grabbed');

document.addEventListener('mousemove', this.onDocumentMouseMove);
document.addEventListener('mouseup', this.onDocumentMouseUp);
this.document.addEventListener('mousemove', this.onDocumentMouseMove);
this.document.addEventListener('mouseup', this.onDocumentMouseUp);
e.preventDefault();
}

Expand Down Expand Up @@ -216,10 +216,10 @@ export class ScrollPanel implements AfterViewInit, AfterContentInit, OnDestroy {
onDocumentMouseUp(e: Event) {
DomHandler.removeClass(this.yBarViewChild.nativeElement, 'p-scrollpanel-grabbed');
DomHandler.removeClass(this.xBarViewChild.nativeElement, 'p-scrollpanel-grabbed');
DomHandler.removeClass(document.body, 'p-scrollpanel-grabbed');
DomHandler.removeClass(this.document.body, 'p-scrollpanel-grabbed');

document.removeEventListener('mousemove', this.onDocumentMouseMove);
document.removeEventListener('mouseup', this.onDocumentMouseUp);
this.document.removeEventListener('mousemove', this.onDocumentMouseMove);
this.document.removeEventListener('mouseup', this.onDocumentMouseUp);
this.isXBarClicked = false;
this.isYBarClicked = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/speeddial/speeddial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ export class SpeedDial implements AfterViewInit, AfterContentInit, OnDestroy {

this.isItemClicked = false;
};
document.addEventListener('click', this.documentClickListener);
this.document.addEventListener('click', this.documentClickListener);
}
}

unbindDocumentClickListener() {
if (this.documentClickListener) {
document.removeEventListener('click', this.documentClickListener);
this.document.removeEventListener('click', this.documentClickListener);
this.documentClickListener = null;
}
}
Expand Down

0 comments on commit 514e9f7

Please sign in to comment.