kevcjones / ngx-simple-modal

A simple unopinionated framework to implement simple modal based behaviour in angular (v2+) projects.
MIT License
52 stars 28 forks source link

Use ngStyle to support CSP #31

Closed thesam closed 6 years ago

thesam commented 6 years ago

Problem If a strict Content Security Policy (CSP) is enabled, it will block modals from being opened because the template in simple-modal-wrapper.component.ts contains an inline style.

Workaround: Allow "unsafe-inline" for styles in the CSP.

Proposed solution in this PR: Use [ngStyle] instead of style=. [ngStyle] is not blocked by the browser even with a strict CSP.

Possible drawbacks: [ngStyle] cannot set !important.

kevcjones-archived commented 6 years ago

I'll check this in the Stackblitz demo later today but actually seems like a good change AND the !important inside the style was a hangover from the original project I think