diff options
| author | Igor Minar | 2013-11-07 16:18:06 -0800 | 
|---|---|---|
| committer | Igor Minar | 2013-11-07 22:08:05 -0800 | 
| commit | b5af198f0d5b0f2b3ddb31ea12f700f3e0616271 (patch) | |
| tree | 0b199a02d5874083c6680de736a86a300f4e9987 /src | |
| parent | 3fe4491a6bf57ddeb312b8a30cf1706f6f1d2355 (diff) | |
| download | angular.js-b5af198f0d5b0f2b3ddb31ea12f700f3e0616271.tar.bz2 | |
fix($compile): don't leak isolate scope state when replaced directive is used multiple times
When an isolate scope directive is also a "replace" directive and at the root of its template
it has other directives, we need to keep track remember to use isolate scope when linking
these.
This commit fixes the leakage of this state when this directive is used again later inside
or outside of the isolate directive template.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/compile.js | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/src/ng/compile.js b/src/ng/compile.js index 5fefdaaa..7513fc7e 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1303,13 +1303,17 @@ function $CompileProvider($provide) {          if (pre) {            if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd);            pre.require = directive.require; -          if (newIsolateScopeDirective === directive || directive.$$isolateScope) pre.isolateScope = true; +          if (newIsolateScopeDirective === directive || directive.$$isolateScope) { +            pre = cloneAndAnnotateFn(pre, {isolateScope: true}); +          }            preLinkFns.push(pre);          }          if (post) {            if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd);            post.require = directive.require; -          if (newIsolateScopeDirective === directive || directive.$$isolateScope) post.isolateScope = true; +          if (newIsolateScopeDirective === directive || directive.$$isolateScope) { +            post = cloneAndAnnotateFn(post, {isolateScope: true}); +          }            postLinkFns.push(post);          }        } @@ -1830,6 +1834,11 @@ function $CompileProvider($provide) {        elementsToRemove[0] = newNode;        elementsToRemove.length = 1;      } + + +    function cloneAndAnnotateFn(fn, annotation) { +      return extend(function() { return fn.apply(null, arguments); }, fn, annotation); +    }    }];  } | 
