Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 66f2eaa

Browse files
committed
few fixes about flags to compile css class and comment directives conditionally
1 parent 4bde767 commit 66f2eaa

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

docs/content/guide/production.ngdoc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,23 @@ For more information, see the
7777

7878
## Disable comment and css class directives
7979

80-
By default AngularJS compiles and executes all directives inside comments and element classes. In order to perform this task, angular compiler must look for directives by:
80+
By default AngularJS compiles and executes all directives inside comments and element classes.
81+
In order to perform this task, angular compiler must look for directives by:
8182

8283
- Parse all your application element classes.
8384

8485
- Parse all your application html comments.
8586

86-
Nowadays most of the Angular projects are using only element and attribute directives, and in such projects there is no need to compile comments and classes.
87+
Nowadays most of the Angular projects are using only element and attribute directives,
88+
and in such projects there is no need to compile comments and classes.
8789

88-
If you are sure that your project only use element directives and attribute directives, and you are not using any 3rd part library that uses directives inside element classes or html comments, you can disable.
89-
This results in a compilation performance gain, as the compiler does not have to check comments and element classes looking for directives.
90+
If you are sure that your project only uses element and attribute directives,
91+
and you are not using any 3rd part library that uses
92+
directives inside element classes or html comments,
93+
you can disable the compilation of directives on element classes and comments
94+
for the whole application.
95+
This results in a compilation performance gain,
96+
as the compiler does not have to check comments and element classes looking for directives.
9097

9198
To disable comment and css class directives use the `$compileProvider`:
9299

@@ -95,5 +102,8 @@ $compileProvider.commentDirectivesEnabled(false);
95102
$compileProvider.cssClassDirectivesEnabled(false);
96103
```
97104

98-
For more see the docs pages on {@link ng.$compileProvider#commentDirectivesEnabled `$compileProvider.commentDirectivesEnabled`} and {@link ng.$compileProvider#cssClassDirectivesEnabled `$compileProvider.cssClassDirectivesEnabled`}.
105+
For more see the docs pages on
106+
{@link ng.$compileProvider#commentDirectivesEnabled `$compileProvider.commentDirectivesEnabled`}
107+
and
108+
{@link ng.$compileProvider#cssClassDirectivesEnabled `$compileProvider.cssClassDirectivesEnabled`}.
99109

src/ng/compile.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
13861386
return TTL;
13871387
};
13881388

1389-
var COMMENT_DIRECTIVES_ENABLED = true;
1389+
var commentDirectivesEnabledConfig = true;
13901390
/**
13911391
* @ngdoc method
13921392
* @name $compileProvider#commentDirectivesEnabled
@@ -1400,28 +1400,22 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
14001400
* on comments for the whole application.
14011401
* This results in a compilation performance gain,
14021402
* as the compiler doesn't have to check comments when looking for directives.
1403-
* This should however only be used if you are sure that no comment directives are used in the application
1404-
* (including any 3rd party directives).
1403+
* This should however only be used if you are sure that no comment directives are used in
1404+
* the application (including any 3rd party directives).
14051405
*
1406-
* Example:
1407-
*
1408-
* ```
1409-
* $compileProvider.commentDirectivesEnabled(false);
1410-
* ```
1411-
*
1412-
* @param {boolean} false if the compiler may ignore directives on comments
1413-
* @returns {number|object} the current value (or `this` if called as a setter for chaining)
1406+
* @param {boolean} enabled `false` if the compiler may ignore directives on comments
1407+
* @returns {boolean|object} the current value (or `this` if called as a setter for chaining)
14141408
*/
14151409
this.commentDirectivesEnabled = function(value) {
14161410
if (arguments.length) {
1417-
COMMENT_DIRECTIVES_ENABLED = value;
1411+
commentDirectivesEnabledConfig = value;
14181412
return this;
14191413
}
1420-
return COMMENT_DIRECTIVES_ENABLED;
1414+
return commentDirectivesEnabledConfig;
14211415
};
14221416

14231417

1424-
var CSS_CLASS_DIRECTIVES_ENABLED = true;
1418+
var cssClassDirectivesEnabledConfig = true;
14251419
/**
14261420
* @ngdoc method
14271421
* @name $compileProvider#cssClassDirectivesEnabled
@@ -1435,24 +1429,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
14351429
* on element classes for the whole application.
14361430
* This results in a compilation performance gain,
14371431
* as the compiler doesn't have to check element classes when looking for directives.
1438-
* This should however only be used if you are sure that no class directives are used in the application
1439-
* (including any 3rd party directives).
1440-
*
1441-
* Example:
1442-
*
1443-
* ```
1444-
* $compileProvider.cssClassDirectivesEnabled(false);
1445-
* ```
1432+
* This should however only be used if you are sure that no class directives are used in
1433+
* the application (including any 3rd party directives).
14461434
*
1447-
* @param {boolean} false if the compiler may ignore directives on element classes
1448-
* @returns {number|object} the current value (or `this` if called as a setter for chaining)
1435+
* @param {boolean} enabled `false` if the compiler may ignore directives on element classes
1436+
* @returns {boolean|object} the current value (or `this` if called as a setter for chaining)
14491437
*/
14501438
this.cssClassDirectivesEnabled = function(value) {
14511439
if (arguments.length) {
1452-
CSS_CLASS_DIRECTIVES_ENABLED = value;
1440+
cssClassDirectivesEnabledConfig = value;
14531441
return this;
14541442
}
1455-
return CSS_CLASS_DIRECTIVES_ENABLED;
1443+
return cssClassDirectivesEnabledConfig;
14561444
};
14571445

14581446
this.$get = [
@@ -1465,8 +1453,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
14651453
var specialAttrHolder = window.document.createElement('div');
14661454

14671455

1468-
var commentDirectivesEnabled = COMMENT_DIRECTIVES_ENABLED;
1469-
var cssClassDirectivesEnabled = CSS_CLASS_DIRECTIVES_ENABLED;
1456+
var commentDirectivesEnabled = commentDirectivesEnabledConfig;
1457+
var cssClassDirectivesEnabled = cssClassDirectivesEnabledConfig;
14701458

14711459

14721460
var onChangesTtl = TTL;

0 commit comments

Comments
 (0)