circlingthesun / angular-foundation-6

Foundation 6 directives for Angular 1.5+
http://circlingthesun.github.io/angular-foundation-6/
Other
95 stars 50 forks source link

fix(modal): Fix modal to work when Content Security Policy is enabled #67

Closed farrago closed 7 years ago

farrago commented 7 years ago

Overview

Updates modal directive so that it works with CSP enabled.

Details

Due to the use of inline styles, the modal does not work when CSP is enabled (at least without unsafe-inline which is obviously unsafe).

This is fixed by:

Backwards Compatibility

Replacing backdrop.html inline style with style applied via JS

The ideal replacement for the inline style would be a class with associated css so it could be over-ridden in end-user templates.

However, angular-foundation-6 doesn't include it's own css and it would be a breaking change to to require apps pull that for a new version.

So the options were:

  1. apply the style in js using .css() (which is csp safe)
  2. leave the inline style in place, and require that the end-user overrides the template with their own one which uses a class and css to achieve CSP support.
  3. as (1), but offer a new attribute to disable that behaviour

Option (1) was chosen in the PR because:

This may be a breaking change for a very small number of users, but I find it unlikely and makes it more likely to just work for future users.

Other changes

The other changes should not affect backwards compatibility in any way. Obviously it doesn't fix any inline styles in users' own templates that they may have copied prior to this version.

Test Plan

(Using the CSP testing updates from the previous PR)

farrago commented 7 years ago

Please especially check that you are happy with my choice in the backwards compatibility section. If you think one of the other choices would be more appropriate then I'm happy to make the change.

I also expect to have PR soon with fixes for the menus: I think that is purely with the demo html having an inline style, and the menu directive itself is ok.

circlingthesun commented 7 years ago

Looks good to me. 👍