Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic-dialog: Fix order of actions CSP #15990

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ export class AccordionTab implements AfterContentInit, OnDestroy {

accordion: Accordion;

constructor(
@Inject(forwardRef(() => Accordion)) accordion: Accordion,
public el: ElementRef,
public changeDetector: ChangeDetectorRef
) {
constructor(@Inject(forwardRef(() => Accordion)) accordion: Accordion, public el: ElementRef, public changeDetector: ChangeDetectorRef) {
this.accordion = accordion as Accordion;
this.id = UniqueComponentId();
}
Expand Down Expand Up @@ -441,10 +437,7 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {

public tabs: AccordionTab[] = [];

constructor(
public el: ElementRef,
public changeDetector: ChangeDetectorRef
) {}
constructor(public el: ElementRef, public changeDetector: ChangeDetectorRef) {}

@HostListener('keydown', ['$event'])
onKeydown(event) {
Expand Down
6 changes: 1 addition & 5 deletions src/app/components/animate/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ export class Animate implements OnInit, AfterViewInit {

timeout: any;

constructor(
private host: ElementRef,
public el: ElementRef,
public renderer: Renderer2
) {}
constructor(private host: ElementRef, public el: ElementRef, public renderer: Renderer2) {}

ngOnInit() {
console.log('pAnimate directive is deprecated in 16.7.0 and will be removed in the future. Use pAnimateOnScroll directive instead');
Expand Down
8 changes: 1 addition & 7 deletions src/app/components/animateonscroll/animateonscroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ export class AnimateOnScroll implements OnInit, AfterViewInit {

animationEndListener: VoidFunction | undefined;

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
private host: ElementRef,
public el: ElementRef,
public renderer: Renderer2
) {}
constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, private host: ElementRef, public el: ElementRef, public renderer: Renderer2) {}

ngOnInit() {
if (isPlatformBrowser(this.platformId)) {
Expand Down
10 changes: 1 addition & 9 deletions src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,7 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
return typeof this.modelValue() === 'string' && this.optionValue;
}

constructor(
@Inject(DOCUMENT) private document: Document,
public el: ElementRef,
public renderer: Renderer2,
public cd: ChangeDetectorRef,
public config: PrimeNGConfig,
public overlayService: OverlayService,
private zone: NgZone
) {
constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) {
effect(() => {
this.filled = ObjectUtils.isNotEmpty(this.modelValue());
});
Expand Down
6 changes: 1 addition & 5 deletions src/app/components/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ export class BadgeDirective implements OnChanges, AfterViewInit {
return this.id && !this.disabled;
}

constructor(
@Inject(DOCUMENT) private document: Document,
public el: ElementRef,
private renderer: Renderer2
) {}
constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, private renderer: Renderer2) {}

public ngOnChanges({ value, size, severity, disabled }: SimpleChanges): void {
if (disabled) {
Expand Down
9 changes: 1 addition & 8 deletions src/app/components/blockui/blockui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ export class BlockUI implements AfterViewInit, OnDestroy {

contentTemplate: TemplateRef<any> | undefined;

constructor(
@Inject(DOCUMENT) private document: Document,
public el: ElementRef,
public cd: ChangeDetectorRef,
public config: PrimeNGConfig,
private renderer: Renderer2,
@Inject(PLATFORM_ID) public platformId: any
) {}
constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public cd: ChangeDetectorRef, public config: PrimeNGConfig, private renderer: Renderer2, @Inject(PLATFORM_ID) public platformId: any) {}

ngAfterViewInit() {
if (this._blocked) this.block();
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ export class ButtonDirective implements AfterViewInit, OnDestroy {

private _internalClasses: string[] = Object.values(INTERNAL_BUTTON_CLASSES);

constructor(
public el: ElementRef,
@Inject(DOCUMENT) private document: Document
) {}
constructor(public el: ElementRef, @Inject(DOCUMENT) private document: Document) {}

ngAfterViewInit() {
DomHandler.addMultipleClasses(this.htmlElement, this.getStyleClass().join(' '));
Expand Down
12 changes: 2 additions & 10 deletions src/app/components/cascadeselect/cascadeselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ export class CascadeSelectSub implements OnInit {
return this.config.getTranslation(TranslationKeys.ARIA)['listLabel'];
}

constructor(
private el: ElementRef,
public config: PrimeNGConfig
) {}
constructor(private el: ElementRef, public config: PrimeNGConfig) {}

ngOnInit() {
if (!this.root) {
Expand Down Expand Up @@ -1306,12 +1303,7 @@ export class CascadeSelect implements OnInit, AfterContentInit {
return grouped ? this.getOptionGroupLabel(processedOption.option) : this.getOptionLabel(processedOption.option);
}

constructor(
private el: ElementRef,
private cd: ChangeDetectorRef,
private config: PrimeNGConfig,
public overlayService: OverlayService
) {
constructor(private el: ElementRef, private cd: ChangeDetectorRef, private config: PrimeNGConfig, public overlayService: OverlayService) {
effect(() => {
const activeOptionPath = this.activeOptionPath();
if (ObjectUtils.isNotEmpty(activeOptionPath)) {
Expand Down
6 changes: 1 addition & 5 deletions src/app/components/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ export class UIChart implements AfterViewInit, OnDestroy {

chart: any;

constructor(
@Inject(PLATFORM_ID) private platformId: any,
public el: ElementRef,
private zone: NgZone
) {}
constructor(@Inject(PLATFORM_ID) private platformId: any, public el: ElementRef, private zone: NgZone) {}

ngAfterViewInit() {
this.initChart();
Expand Down
6 changes: 1 addition & 5 deletions src/app/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,7 @@ export class Checkbox implements ControlValueAccessor {

focused: boolean = false;

constructor(
public cd: ChangeDetectorRef,
private readonly injector: Injector,
public config: PrimeNGConfig
) {}
constructor(public cd: ChangeDetectorRef, private readonly injector: Injector, public config: PrimeNGConfig) {}

ngAfterContentInit() {
this.templates.forEach((item) => {
Expand Down
7 changes: 1 addition & 6 deletions src/app/components/chips/chips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,7 @@ export class Chips implements AfterContentInit, ControlValueAccessor {
return this.max && this.value && this.max === this.value.length;
}

constructor(
@Inject(DOCUMENT) private document: Document,
public el: ElementRef,
public cd: ChangeDetectorRef,
public config: PrimeNGConfig
) {}
constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public cd: ChangeDetectorRef, public config: PrimeNGConfig) {}

ngAfterContentInit() {
this.templates.forEach((item) => {
Expand Down
9 changes: 1 addition & 8 deletions src/app/components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,7 @@ export class ContextMenuSub {

@ViewChild('sublist') sublistViewChild: ElementRef;

constructor(
@Inject(DOCUMENT) private document: Document,
public el: ElementRef,
public renderer: Renderer2,
private cd: ChangeDetectorRef,
@Inject(forwardRef(() => ContextMenu)) public contextMenu: ContextMenu,
private ref: ViewContainerRef
) {}
constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, private cd: ChangeDetectorRef, @Inject(forwardRef(() => ContextMenu)) public contextMenu: ContextMenu, private ref: ViewContainerRef) {}

getItemProp(processedItem: any, name: string, params: any | null = null) {
return processedItem && processedItem.item ? ObjectUtils.getItemValue(processedItem.item[name], params) : undefined;
Expand Down
9 changes: 2 additions & 7 deletions src/app/components/dataview/dataview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import { DataViewLayoutChangeEvent, DataViewLazyLoadEvent, DataViewPageEvent, Da
></p-paginator>

<div class="p-dataview-content">
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: paginator ? (filteredValue || value | slice: (lazy ? 0 : first) : (lazy ? 0 : first) + rows) : filteredValue || value }"></ng-container>
<ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: paginator ? (filteredValue || value | slice : (lazy ? 0 : first) : (lazy ? 0 : first) + rows) : filteredValue || value }"></ng-container>

<div *ngIf="isEmpty() && !loading">
<div class="p-dataview-emptymessage">
Expand Down Expand Up @@ -358,12 +358,7 @@ export class DataView implements OnInit, AfterContentInit, OnDestroy, BlockableU
return this.emptyMessage || this.config.getTranslation(TranslationKeys.EMPTY_MESSAGE);
}

constructor(
public el: ElementRef,
public cd: ChangeDetectorRef,
public filterService: FilterService,
public config: PrimeNGConfig
) {}
constructor(public el: ElementRef, public cd: ChangeDetectorRef, public filterService: FilterService, public config: PrimeNGConfig) {}

ngOnInit() {
if (this.lazy && this.lazyLoadOnInit) {
Expand Down
9 changes: 1 addition & 8 deletions src/app/components/defer/defer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ export class DeferredLoader implements AfterViewInit, OnDestroy {

window: Window;

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
public el: ElementRef,
public renderer: Renderer2,
public viewContainer: ViewContainerRef,
private cd: ChangeDetectorRef
) {
constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, public el: ElementRef, public renderer: Renderer2, public viewContainer: ViewContainerRef, private cd: ChangeDetectorRef) {
this.window = this.document.defaultView as Window;
}

Expand Down
5 changes: 1 addition & 4 deletions src/app/components/dock/dock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ export class Dock implements AfterContentInit {
return this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : null;
}

constructor(
private el: ElementRef,
public cd: ChangeDetectorRef
) {
constructor(private el: ElementRef, public cd: ChangeDetectorRef) {
this.currentIndex = -3;
}

Expand Down
12 changes: 2 additions & 10 deletions src/app/components/dragdrop/dragdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ export class Draggable implements AfterViewInit, OnDestroy {

_pDraggableDisabled: boolean = false;

constructor(
public el: ElementRef,
public zone: NgZone,
private renderer: Renderer2
) {}
constructor(public el: ElementRef, public zone: NgZone, private renderer: Renderer2) {}

@Input() get pDraggableDisabled(): boolean {
return this._pDraggableDisabled;
Expand Down Expand Up @@ -199,11 +195,7 @@ export class Droppable implements AfterViewInit, OnDestroy {
*/
@Output() onDrop: EventEmitter<DragEvent> = new EventEmitter();

constructor(
public el: ElementRef,
public zone: NgZone,
private renderer: Renderer2
) {}
constructor(public el: ElementRef, public zone: NgZone, private renderer: Renderer2) {}

dragOverListener: VoidListener;

Expand Down
9 changes: 1 addition & 8 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,14 +1012,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV

editableInputValue = computed(() => this.getOptionLabel(this.selectedOption) || this.modelValue() || '');

constructor(
public el: ElementRef,
public renderer: Renderer2,
public cd: ChangeDetectorRef,
public zone: NgZone,
public filterService: FilterService,
public config: PrimeNGConfig
) {
constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig) {
effect(() => {
const modelValue = this.modelValue();
const visibleOptions = this.visibleOptions();
Expand Down
6 changes: 1 addition & 5 deletions src/app/components/dynamicdialog/dialogservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import { ObjectUtils } from 'primeng/utils';
export class DialogService {
dialogComponentRefMap: Map<DynamicDialogRef<any>, ComponentRef<DynamicDialogComponent>> = new Map();

constructor(
private appRef: ApplicationRef,
private injector: Injector,
@Inject(DOCUMENT) private document: Document
) {}
constructor(private appRef: ApplicationRef, private injector: Injector, @Inject(DOCUMENT) private document: Document) {}
/**
* Displays the dialog using the dynamic dialog object options.
* @param {*} componentType - Dynamic component for content template.
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/dynamicdialog/dynamicdialog-injector.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { InjectOptions, Injector, ProviderToken, InjectFlags } from '@angular/core';

export class DynamicDialogInjector implements Injector {
constructor(
private _parentInjector: Injector,
private _additionalTokens: WeakMap<any, any>
) {}
constructor(private _parentInjector: Injector, private _additionalTokens: WeakMap<any, any>) {}

get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions | InjectFlags): T {
const value = this._additionalTokens.get(token);
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/dynamicdialog/dynamicdialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { DynamicDialogRef } from './dynamicdialog-ref';
template: ` <h2>PrimeNG ROCKS!</h2> `
})
export class TestComponent {
constructor(
public ref: DynamicDialogRef,
public config: DynamicDialogConfig
) {}
constructor(public ref: DynamicDialogRef, public config: DynamicDialogConfig) {}
}

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/dynamicdialog/dynamicdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
if (!this.styleElement) {
this.styleElement = this.renderer.createElement('style');
this.styleElement.type = 'text/css';
DomHandler.setAttribute(this.styleElement, 'nonce', this.primeNGConfig?.csp()?.nonce);
this.renderer.appendChild(this.document.head, this.styleElement);
let innerHTML = '';
for (let breakpoint in this.breakpoints) {
Expand All @@ -309,7 +310,6 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
}

this.renderer.setProperty(this.styleElement, 'innerHTML', innerHTML);
DomHandler.setAttribute(this.styleElement, 'nonce', this.primeNGConfig?.csp()?.nonce);
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ export class Editor implements AfterContentInit, ControlValueAccessor {

private quillElements!: { editorElement: HTMLElement; toolbarElement: HTMLElement };

constructor(
public el: ElementRef,
@Inject(PLATFORM_ID) private platformId: object
) {
constructor(public el: ElementRef, @Inject(PLATFORM_ID) private platformId: object) {
/**
* Read or write the DOM once, when initializing non-Angular (Quill) library.
*/
Expand Down
24 changes: 3 additions & 21 deletions src/app/components/galleria/galleria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,7 @@ export class Galleria implements OnChanges, OnDestroy {

numVisibleLimit = 0;

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) public platformId: any,
public element: ElementRef,
public cd: ChangeDetectorRef,
public config: PrimeNGConfig
) {}
constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) public platformId: any, public element: ElementRef, public cd: ChangeDetectorRef, public config: PrimeNGConfig) {}

ngAfterContentInit() {
this.templates?.forEach((item) => {
Expand Down Expand Up @@ -509,13 +503,7 @@ export class GalleriaContent implements DoCheck {

private differ: any;

constructor(
public galleria: Galleria,
public cd: ChangeDetectorRef,
private differs: KeyValueDiffers,
public config: PrimeNGConfig,
private elementRef: ElementRef
) {
constructor(public galleria: Galleria, public cd: ChangeDetectorRef, private differs: KeyValueDiffers, public config: PrimeNGConfig, private elementRef: ElementRef) {
this.id = this.galleria.id || UniqueComponentId();
this.differ = this.differs.find(this.galleria).create();
}
Expand Down Expand Up @@ -1029,13 +1017,7 @@ export class GalleriaThumbnails implements OnInit, AfterContentChecked, AfterVie

_oldactiveIndex: number = 0;

constructor(
public galleria: Galleria,
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
private renderer: Renderer2,
private cd: ChangeDetectorRef
) {}
constructor(public galleria: Galleria, @Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, private renderer: Renderer2, private cd: ChangeDetectorRef) {}

ngOnInit() {
if (isPlatformBrowser(this.platformId)) {
Expand Down
Loading
Loading