|
506 | 506 | * $sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}.
|
507 | 507 | *
|
508 | 508 | *
|
509 |
| - * #### `replace` (*DEPRECATED*) |
510 |
| - * |
511 |
| - * `replace` will be removed in next major release - i.e. v2.0). |
| 509 | + * #### `replace` |
| 510 | + * <div class="alert alert-danger"> |
| 511 | + * **Note:** `replace` is deprecated in AngularJS and has been removed in the new Angular (v2+). |
| 512 | + * </div> |
512 | 513 | *
|
513 | 514 | * Specifies what the template should replace. Defaults to `false`.
|
514 | 515 | *
|
|
958 | 959 | compiled again. This is an undesired effect and can lead to misbehaving directives, performance issues,
|
959 | 960 | and memory leaks. Refer to the Compiler Guide {@link guide/compiler#double-compilation-and-how-to-avoid-it
|
960 | 961 | section on double compilation} for an in-depth explanation and ways to avoid it.
|
| 962 | +
|
| 963 | + * @knownIssue |
| 964 | +
|
| 965 | + ### Issues with `replace: true` |
| 966 | + * |
| 967 | + * <div class="alert alert-danger"> |
| 968 | + * **Note**: {@link $compile#-replace- `replace: true`} is deprecated and not recommended to use, |
| 969 | + * mainly due to the issues listed here. It has been completely removed in the new Angular. |
| 970 | + * </div> |
| 971 | + * |
| 972 | + * #### Attribute values are not merged |
| 973 | + * |
| 974 | + * When a `replace` directive encounters the same attribute on the original and the replace node, |
| 975 | + * it will simply deduplicate the attribute and join the values with a space or with a `;` in case of |
| 976 | + * the `style` attribute. |
| 977 | + * ```html |
| 978 | + * Original Node: <span class="original" style="color: red;"></span> |
| 979 | + * Replace Template: <span class="replaced" style="background: blue;"></span> |
| 980 | + * Result: <span class="original replaced" style="color: red; background: blue;"></span> |
| 981 | + * ``` |
| 982 | + * |
| 983 | + * That means attributes that contain AngularJS expressions will not be merged correctly, e.g. |
| 984 | + * {@link ngShow} or {@link ngClass} will cause a {@link $parse} error: |
| 985 | + * |
| 986 | + * ```html |
| 987 | + * Original Node: <span ng-class="{'something': something}" ng-show="!condition"></span> |
| 988 | + * Replace Template: <span ng-class="{'else': else}" ng-show="otherCondition"></span> |
| 989 | + * Result: <span ng-class="{'something': something} {'else': else}" ng-show="!condition otherCondition"></span> |
| 990 | + * ``` |
| 991 | + * |
| 992 | + * See issue [#5695](https://github.com/angular/angular.js/issues/5695). |
| 993 | + * |
| 994 | + * #### Directives are not deduplicated before compilation |
| 995 | + * |
| 996 | + * When the original node and the replace template declare the same directive(s), they will be |
| 997 | + * {@link guide/compiler#double-compilation-and-how-to-avoid-it compiled twice} because the compiler |
| 998 | + * does not deduplicate them. In many cases, this is not noticable, but e.g. {@link ngModel} will |
| 999 | + * attach `$formatters` and `$parsers` twice. |
| 1000 | + * |
| 1001 | + * See issue [#2573](https://github.com/angular/angular.js/issues/2573). |
| 1002 | + * |
| 1003 | + * #### `transclude: element` in the replace template root can have |
| 1004 | + * unexpected effects |
| 1005 | + * |
| 1006 | + * When the replace template has a directive at the root node that uses |
| 1007 | + * {@link $compile#-transclude- `transclude: element`}, e.g. |
| 1008 | + * {@link ngIf} or {@link ngRepeat}, the DOM structure or scope inheritance can be incorrect. |
| 1009 | + * See the following issues: |
| 1010 | + * |
| 1011 | + * - Incorrect scope on replaced element: |
| 1012 | + * [#9837](https://github.com/angular/angular.js/issues/9837) |
| 1013 | + * - Different DOM between `template` and `templateUrl`: |
| 1014 | + * [#10612](https://github.com/angular/angular.js/issues/14326) |
961 | 1015 | *
|
962 | 1016 | */
|
963 | 1017 |
|
|
0 commit comments