Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a73d71

Browse files
ProLoserpetebacondarwin
authored andcommitted
1 parent 73aaca0 commit 9a73d71

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/ng/directive/ngCsp.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,32 @@
55
* @name ng.directive:ngCsp
66
* @priority 1000
77
*
8+
* @element html
89
* @description
910
* 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>
1834
*/
1935

2036
var ngCspDirective = ['$sniffer', function($sniffer) {

0 commit comments

Comments
 (0)