File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change 5
5
* @name ng.directive:ngCsp
6
6
* @priority 1000
7
7
*
8
+ * @element html
8
9
* @description
9
10
* Enables [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) support.
10
- * This directive should be used on the root element of the application (typically the `<html>`
11
- * element or other element with the {@link ng.directive:ngApp ngApp}
12
- * directive).
13
- *
14
- * If enabled the performance of template expression evaluator will suffer slightly, so don't enable
15
- * this mode unless you need it.
16
- *
17
- * @element html
11
+ *
12
+ * This is necessary when developing things like Google Chrome Extensions.
13
+ *
14
+ * CSP forbids apps to use `eval` or `Function(string)` generated functions (among other things).
15
+ * For us to be compatible, we just need to implement the "getterFn" in $parse without violating
16
+ * any of these restrictions.
17
+ *
18
+ * AngularJS uses `Function(string)` generated functions as a speed optimization. By applying `ngCsp`
19
+ * it is be possible to opt into the CSP compatible mode. When this mode is on AngularJS will
20
+ * evaluate all expressions up to 30% slower than in non-CSP mode, but no security violations will
21
+ * be raised.
22
+ *
23
+ * In order to use this feature put `ngCsp` directive on the root element of the application.
24
+ *
25
+ * @example
26
+ * This example shows how to apply the `ngCsp` directive to the `html` tag.
27
+ <pre>
28
+ <!doctype html>
29
+ <html ng-app ng-csp>
30
+ ...
31
+ ...
32
+ </html>
33
+ </pre>
18
34
*/
19
35
20
36
var ngCspDirective = [ '$sniffer' , function ( $sniffer ) {
You can’t perform that action at this time.
0 commit comments