This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Issue #1941 - This fixes an issue that can break $observe when using a directive with a templateUrl. #3408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
http://plnkr.co/edit/xJNt918gEpuXR026VuZB?p=preview illustrates the issue that this pull request addresses.
When a node is cloned because the beforeTemplateLinkNode !== beforeTemplateCompileNode condition was met, then this would cause the link functions to create a new attrs object, but by setting their last argument to "true" below we force them to keep the same attrs object. Without this flag the $$observers is put on the afterTemplateNodeLinkFn version of attrs and the $set is called on the beforeTemplateNodeLinkFn version of the attrs whenever we make a cloned linkNode above, thus breaking $observe. See github issue #1941
I have not contributed to angular before so I imagine some testing and review is needed but I wanted to offer this patch (which resolved the problem) as a starting point.
Thanks.