From 31ea071f2ef84e7043f737cd842adb8e7aea0e3f Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Mon, 9 Apr 2018 10:20:50 +0200 Subject: [PATCH] docs($compile): add known issues with replace:true Closes #16523 Related #2573 Related #5695 Related #9837 Related #10612 --- src/ng/compile.js | 60 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 9d636b89c5e9..9607a922fa69 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -506,9 +506,10 @@ * $sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}. * * - * #### `replace` (*DEPRECATED*) - * - * `replace` will be removed in next major release - i.e. v2.0). + * #### `replace` + *
+ * **Note:** `replace` is deprecated in AngularJS and has been removed in the new Angular (v2+). + *
* * Specifies what the template should replace. Defaults to `false`. * @@ -958,6 +959,59 @@ compiled again. This is an undesired effect and can lead to misbehaving directives, performance issues, and memory leaks. Refer to the Compiler Guide {@link guide/compiler#double-compilation-and-how-to-avoid-it section on double compilation} for an in-depth explanation and ways to avoid it. + + * @knownIssue + + ### Issues with `replace: true` + * + *
+ * **Note**: {@link $compile#-replace- `replace: true`} is deprecated and not recommended to use, + * mainly due to the issues listed here. It has been completely removed in the new Angular. + *
+ * + * #### Attribute values are not merged + * + * When a `replace` directive encounters the same attribute on the original and the replace node, + * it will simply deduplicate the attribute and join the values with a space or with a `;` in case of + * the `style` attribute. + * ```html + * Original Node: + * Replace Template: + * Result: + * ``` + * + * That means attributes that contain AngularJS expressions will not be merged correctly, e.g. + * {@link ngShow} or {@link ngClass} will cause a {@link $parse} error: + * + * ```html + * Original Node: + * Replace Template: + * Result: + * ``` + * + * See issue [#5695](https://github.com/angular/angular.js/issues/5695). + * + * #### Directives are not deduplicated before compilation + * + * When the original node and the replace template declare the same directive(s), they will be + * {@link guide/compiler#double-compilation-and-how-to-avoid-it compiled twice} because the compiler + * does not deduplicate them. In many cases, this is not noticable, but e.g. {@link ngModel} will + * attach `$formatters` and `$parsers` twice. + * + * See issue [#2573](https://github.com/angular/angular.js/issues/2573). + * + * #### `transclude: element` in the replace template root can have + * unexpected effects + * + * When the replace template has a directive at the root node that uses + * {@link $compile#-transclude- `transclude: element`}, e.g. + * {@link ngIf} or {@link ngRepeat}, the DOM structure or scope inheritance can be incorrect. + * See the following issues: + * + * - Incorrect scope on replaced element: + * [#9837](https://github.com/angular/angular.js/issues/9837) + * - Different DOM between `template` and `templateUrl`: + * [#10612](https://github.com/angular/angular.js/issues/14326) * */