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

Fixed #15998 - Inline style not compliant with strict CSP #16005

Merged
merged 26 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b2a4495
Use ngStyle attribute instead of style | Chart
mehmetcetin01140 Jul 11, 2024
9e095e3
Use ngStyle attribute instead of style | Dialog
mehmetcetin01140 Jul 11, 2024
73e3725
Use ngStyle attribute instead of style | DynamicDialog
mehmetcetin01140 Jul 11, 2024
80a49b1
Use ngStyle attribute instead of style | Progressbar
mehmetcetin01140 Jul 11, 2024
c5285ea
Use ngStyle attribute instead of style | Table
mehmetcetin01140 Jul 11, 2024
e40983f
Use ngStyle attribute instead of style | Tree
mehmetcetin01140 Jul 11, 2024
019f8bc
Use ngStyle attribute instead of style | TreeTable
mehmetcetin01140 Jul 11, 2024
93598fc
Use ngStyle attribute instead of style | Accordion
mehmetcetin01140 Jul 11, 2024
1b357bc
Use ngStyle attribute instead of style | AutoComplete
mehmetcetin01140 Jul 11, 2024
93986fe
Use ngStyle attribute instead of style | ContextMenu
mehmetcetin01140 Jul 11, 2024
b365f76
Use ngStyle attribute instead of style | Dropdown
mehmetcetin01140 Jul 11, 2024
4f5af0d
Use ngStyle attribute instead of style | Listbox
mehmetcetin01140 Jul 11, 2024
dfba775
Use ngStyle attribute instead of style | MegaMenu
mehmetcetin01140 Jul 11, 2024
8e780ff
Use ngStyle attribute instead of style | Menubar
mehmetcetin01140 Jul 11, 2024
0aff1bd
Use ngStyle attribute instead of style | multiselect
mehmetcetin01140 Jul 11, 2024
67a6fb7
Use ngStyle attribute instead of style | SlideMenu
mehmetcetin01140 Jul 11, 2024
4596d28
Use ngStyle attribute instead of style | SpeedDial
mehmetcetin01140 Jul 11, 2024
6cb958d
Use ngStyle attribute instead of style | TieredMenu
mehmetcetin01140 Jul 11, 2024
066c7b7
Use ngStyle attribute instead of style | Tree
mehmetcetin01140 Jul 11, 2024
40ebd40
Use ngStyle attribute instead of style | TreeTable
mehmetcetin01140 Jul 11, 2024
3aff4fa
refactor | Table
mehmetcetin01140 Jul 11, 2024
946256a
refactor | tree
mehmetcetin01140 Jul 11, 2024
27e031d
refactor | megamenu
mehmetcetin01140 Jul 11, 2024
154d30f
revert tree processedNodeStyle
mehmetcetin01140 Jul 11, 2024
2c2938f
Merge remote-tracking branch 'origin' into issue-15998
mehmetcetin01140 Jul 11, 2024
57bc637
Resolved merge conflicts
mehmetcetin01140 Jul 11, 2024
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
2 changes: 1 addition & 1 deletion src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { UniqueComponentId } from 'primeng/utils';
<div class="p-accordion-header" role="heading" [attr.aria-level]="headerAriaLevel" [class.p-highlight]="selected" [class.p-disabled]="disabled" [attr.data-p-disabled]="disabled" [attr.data-pc-section]="'header'">
<a
[ngClass]="headerStyleClass"
[style]="headerStyle"
[ngStyle]="headerStyle"
role="button"
class="p-accordion-header-link"
(click)="toggle($event)"
Expand Down
9 changes: 8 additions & 1 deletion src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const AUTOCOMPLETE_VALUE_ACCESSOR: any = {
(onAnimationStart)="onOverlayAnimationStart($event)"
(onHide)="hide()"
>
<div [ngClass]="panelClass" [style.max-height]="virtualScroll ? 'auto' : scrollHeight" [ngStyle]="panelStyle" [class]="panelStyleClass">
<div [ngClass]="panelClass" [ngStyle]="panelStyles" [class]="panelStyleClass">
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
<p-scroller
*ngIf="virtualScroll"
Expand Down Expand Up @@ -825,6 +825,13 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
};
}

get panelStyles() {
return {
'max-height': this.virtualScroll ? 'auto' : this.scrollHeight,
...this.panelStyle
};
}

get inputClass() {
return {
'p-autocomplete-input p-inputtext p-component': !this.multiple,
Expand Down
25 changes: 22 additions & 3 deletions src/app/components/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@ import Chart from 'chart.js/auto';
@Component({
selector: 'p-chart',
template: `
<div style="position:relative" [style.width]="responsive && !width ? null : width" [style.height]="responsive && !height ? null : height">
<canvas role="img" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledBy" [attr.width]="responsive && !width ? null : width" [attr.height]="responsive && !height ? null : height" (click)="onCanvasClick($event)"></canvas>
<div
[ngStyle]="{
position: 'relative',
width: responsive && !width ? null : width,
height: responsive && !height ? null : height
}"
>
<canvas
role="img"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledBy"
[ngStyle]="{
width: responsive && !width ? null : width,
height: responsive && !height ? null : height
}"
(click)="onCanvasClick($event)"
></canvas>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -92,7 +107,11 @@ 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
2 changes: 1 addition & 1 deletion src/app/components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils';
<li
*ngIf="isItemVisible(processedItem) && getItemProp(processedItem, 'separator')"
[attr.id]="getItemId(processedItem)"
[style]="getItemProp(processedItem, 'style')"
[ngStyle]="getItemProp(processedItem, 'style')"
[ngClass]="getSeparatorItemClass(processedItem)"
role="separator"
[attr.data-pc-section]="'separator'"
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const hideAnimation = animation([animate('{{transition}}', style({ transform: '{
<div
*ngIf="maskVisible"
[class]="maskStyleClass"
[style]="maskStyle"
[ngStyle]="maskStyle"
[ngClass]="{
'p-dialog-mask': true,
'p-component-overlay p-component-overlay-enter': this.modal,
Expand Down Expand Up @@ -267,7 +267,7 @@ export class Dialog implements AfterContentInit, OnInit, OnDestroy {
* Style of the mask.
* @group Props
*/
@Input() maskStyle: string | undefined;
@Input() maskStyle: { [klass: string]: any } | null | undefined;
/**
* Whether to show the header or not.
* @group Props
Expand Down
19 changes: 16 additions & 3 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,13 @@ export class DropdownItem {
</div>
</ng-template>
</div>
<div class="p-dropdown-items-wrapper" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'" tabindex="0">
<div
class="p-dropdown-items-wrapper"
[ngStyle]="{
'max-height': virtualScroll ? 'auto' : scrollHeight || 'auto'
}"
tabindex="0"
>
<p-scroller
*ngIf="virtualScroll"
#scroller
Expand All @@ -294,7 +300,7 @@ export class DropdownItem {
</ng-container>

<ng-template #buildInItems let-items let-scrollerOptions="options">
<ul #items [attr.id]="id + '_list'" [attr.aria-label]="listLabel" class="p-dropdown-items" [ngClass]="scrollerOptions.contentStyleClass" [style]="scrollerOptions.contentStyle" role="listbox">
<ul #items [attr.id]="id + '_list'" [attr.aria-label]="listLabel" class="p-dropdown-items" [ngClass]="scrollerOptions.contentStyleClass" [ngStyle]="scrollerOptions.contentStyle" role="listbox">
<ng-template ngFor let-option [ngForOf]="items" let-i="index">
<ng-container *ngIf="isOptionGroup(option)">
<li class="p-dropdown-item-group" [attr.id]="id + '_' + getOptionIndex(i, scrollerOptions)" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
Expand Down Expand Up @@ -1012,7 +1018,14 @@ 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
12 changes: 9 additions & 3 deletions src/app/components/dynamicdialog/dynamicdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const hideAnimation = animation([animate('{{transition}}', style({ transform: '{
<div
#container
[ngClass]="{ 'p-dialog p-dynamic-dialog p-component': true, 'p-dialog-rtl': config.rtl, 'p-dialog-resizable': config.resizable, 'p-dialog-draggable': config.draggable, 'p-dialog-maximized': maximized }"
[ngStyle]="config.style"
[ngStyle]="containerStyle"
[class]="config.styleClass"
[@animation]="{ value: 'visible', params: { transform: transformOptions, transition: config.transitionOptions || '150ms cubic-bezier(0, 0, 0.2, 1)' } }"
(@animation.start)="onAnimationStart($event)"
Expand All @@ -67,8 +67,6 @@ const hideAnimation = animation([animate('{{transition}}', style({ transform: '{
*ngIf="visible"
pFocusTrap
[pFocusTrapDisabled]="config.focusTrap === false"
[style.width]="config.width"
[style.height]="config.height"
[attr.aria-labelledby]="ariaLabelledBy"
[attr.aria-modal]="true"
>
Expand Down Expand Up @@ -274,6 +272,14 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
return dynamicDialogCount;
}

get containerStyle() {
return {
...this.config.style,
'width': this.config.width,
'height': this.config.height
};
}

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
Expand Down
19 changes: 16 additions & 3 deletions src/app/components/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ export const LISTBOX_VALUE_ACCESSOR: any = {
</span>
</ng-template>
</div>
<div [ngClass]="'p-listbox-list-wrapper'" [ngStyle]="listStyle" [class]="listStyleClass" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'">
<div
[ngClass]="'p-listbox-list-wrapper'"
[ngStyle]="listStyle"
[class]="listStyleClass"
[ngStyle]="{
'max-height': virtualScroll ? 'auto' : scrollHeight || 'auto'
}"
>
<p-scroller
#scroller
*ngIf="virtualScroll"
Expand Down Expand Up @@ -151,7 +158,7 @@ export const LISTBOX_VALUE_ACCESSOR: any = {
[tabindex]="-1"
[attr.aria-multiselectable]="true"
[ngClass]="scrollerOptions.contentStyleClass"
[style]="scrollerOptions.contentStyle"
[ngStyle]="scrollerOptions.contentStyle"
[attr.aria-activedescendant]="focused ? focusedOptionId : undefined"
[attr.aria-label]="ariaLabel"
[attr.aria-multiselectable]="multiple"
Expand Down Expand Up @@ -671,7 +678,13 @@ export class Listbox implements AfterContentInit, OnInit, ControlValueAccessor,
} else return filterValue ? this.filterService.filter(options, this.searchFields, filterValue, this.filterMatchMode, this.filterLocale) : options;
});

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

ngOnInit() {
this.id = this.id || UniqueComponentId();
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/megamenu/megamenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ import { ObjectUtils, UniqueComponentId } from 'primeng/utils';
(focus)="menuFocus.emit($event)"
(blur)="menuBlur.emit($event)"
>
<li *ngIf="submenu" [ngClass]="getSubmenuHeaderClass(submenu)" [style]="getItemProp(submenu, 'style')" role="presentation">{{ getItemLabel(submenu) }}</li>
<li *ngIf="submenu" [ngClass]="getSubmenuHeaderClass(submenu)" [ngStyle]="getItemProp(submenu, 'style')" role="presentation">{{ getItemLabel(submenu) }}</li>
<ng-template ngFor let-processedItem [ngForOf]="items" let-index="index">
<li
*ngIf="isItemVisible(processedItem) && getItemProp(processedItem, 'separator')"
[attr.id]="getItemId(processedItem)"
[style]="getItemProp(processedItem, 'style')"
[ngStyle]="getItemProp(processedItem, 'style')"
[ngClass]="getSeparatorItemClass(processedItem)"
role="separator"
[attr.data-pc-section]="'separator'"
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/menubar/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class MenubarService {
<li
*ngIf="isItemVisible(processedItem) && getItemProp(processedItem, 'separator')"
[attr.id]="getItemId(processedItem)"
[style]="getItemProp(processedItem, 'style')"
[ngStyle]="getItemProp(processedItem, 'style')"
[ngClass]="getSeparatorItemClass(processedItem)"
role="separator"
[attr.data-pc-section]="'separator'"
Expand Down
15 changes: 11 additions & 4 deletions src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
Renderer2,
Signal,
signal,
SimpleChanges,
TemplateRef,
ViewChild,
ViewEncapsulation
Expand Down Expand Up @@ -346,7 +345,7 @@ export class MultiSelectItem {
</button>
</ng-template>
</div>
<div class="p-multiselect-items-wrapper" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'">
<div class="p-multiselect-items-wrapper" [ngStyle]="{ 'max-height': virtualScroll ? 'auto' : scrollHeight || 'auto' }">
<p-scroller
*ngIf="virtualScroll"
#scroller
Expand All @@ -373,7 +372,7 @@ export class MultiSelectItem {
</ng-container>

<ng-template #buildInItems let-items let-scrollerOptions="options">
<ul #items class="p-multiselect-items p-component" [ngClass]="scrollerOptions.contentStyleClass" [style]="scrollerOptions.contentStyle" role="listbox" aria-multiselectable="true" [attr.aria-label]="listLabel">
<ul #items class="p-multiselect-items p-component" [ngClass]="scrollerOptions.contentStyleClass" [ngStyle]="scrollerOptions.contentStyle" role="listbox" aria-multiselectable="true" [attr.aria-label]="listLabel">
<ng-template ngFor let-option [ngForOf]="items" let-i="index">
<ng-container *ngIf="isOptionGroup(option)">
<li [attr.id]="id + '_' + getOptionIndex(i, scrollerOptions)" class="p-multiselect-item-group" [ngStyle]="{ height: scrollerOptions.itemSize + 'px' }" role="option">
Expand Down Expand Up @@ -1189,7 +1188,15 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
return ObjectUtils.isNotEmpty(this.maxSelectedLabels) && this.modelValue() && this.modelValue().length > this.maxSelectedLabels ? this.modelValue().slice(0, this.maxSelectedLabels) : this.modelValue();
});

constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig, public overlayService: OverlayService) {
constructor(
public el: ElementRef,
public renderer: Renderer2,
public cd: ChangeDetectorRef,
public zone: NgZone,
public filterService: FilterService,
public config: PrimeNGConfig,
public overlayService: OverlayService
) {
effect(() => {
const modelValue = this.modelValue();

Expand Down
29 changes: 26 additions & 3 deletions src/app/components/progressbar/progressbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,37 @@ import { QueryList } from '@angular/core';
[attr.data-pc-section]="'root'"
[ngClass]="{ 'p-progressbar p-component': true, 'p-progressbar-determinate': mode === 'determinate', 'p-progressbar-indeterminate': mode === 'indeterminate' }"
>
<div *ngIf="mode === 'determinate'" class="p-progressbar-value p-progressbar-value-animate" [style.width]="value + '%'" style="display:flex" [style.background]="color" [attr.data-pc-section]="'value'">
<div
*ngIf="mode === 'determinate'"
class="p-progressbar-value p-progressbar-value-animate"
[ngStyle]="{
width: value + '%',
display: 'flex',
background: color
}"
[attr.data-pc-section]="'value'"
>
<div class="p-progressbar-label">
<div *ngIf="showValue && !contentTemplate" [style.display]="value != null && value !== 0 ? 'flex' : 'none'" [attr.data-pc-section]="'label'">{{ value }}{{ unit }}</div>
<div
*ngIf="showValue && !contentTemplate"
[ngStyle]="{
display: value != null && value !== 0 ? 'flex' : 'none'
}"
[attr.data-pc-section]="'label'"
>
{{ value }}{{ unit }}
</div>
<ng-container *ngTemplateOutlet="contentTemplate; context: { $implicit: value }"></ng-container>
</div>
</div>
<div *ngIf="mode === 'indeterminate'" class="p-progressbar-indeterminate-container" [attr.data-pc-section]="'container'">
<div class="p-progressbar-value p-progressbar-value-animate" [style.background]="color" [attr.data-pc-section]="'value'"></div>
<div
class="p-progressbar-value p-progressbar-value-animate"
[ngStyle]="{
background: color
}"
[attr.data-pc-section]="'value'"
></div>
</div>
</div>
`,
Expand Down
Loading
Loading