diff options
| author | Misko Hevery | 2013-11-05 15:50:53 -0800 | 
|---|---|---|
| committer | Igor Minar | 2013-11-07 22:08:05 -0800 | 
| commit | 97c7a4e3791d7cb05c3317cc5f0c49ab93810bf6 (patch) | |
| tree | 0708f7dd550334d8209f4d5bc59a565a676aecd6 /src/ng/compile.js | |
| parent | d0efd5eefcc0aaf167c766513e152b74dd31bafe (diff) | |
| download | angular.js-97c7a4e3791d7cb05c3317cc5f0c49ab93810bf6.tar.bz2 | |
fix($compile): replaced element has isolate scope
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 37 | 
1 files changed, 24 insertions, 13 deletions
| diff --git a/src/ng/compile.js b/src/ng/compile.js index 7616aa07..42b37a2d 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1237,16 +1237,16 @@ function $CompileProvider($provide) {              // combine directives from the original node and from the template:              // - take the array of directives for this element -            // - split it into two parts, those that were already applied and those that weren't -            // - collect directives from the template, add them to the second group and sort them -            // - append the second group with new directives to the first group -            directives = directives.concat( -                collectDirectives( -                    compileNode, -                    directives.splice(i + 1, directives.length - (i + 1)), -                    newTemplateAttrs -                ) -            ); +            // - split it into two parts, those that already applied (processed) and those that weren't (unprocessed) +            // - collect directives from the template and sort them by priority +            // - combine directives as: processed + template + unprocessed +            var templateDirectives = collectDirectives(compileNode, [], newTemplateAttrs); +            var unprocessedDirectives = directives.splice(i + 1, directives.length - (i + 1)); + +            if (newIsolateScopeDirective) { +              markDirectivesAsIsolate(templateDirectives); +            } +            directives = directives.concat(templateDirectives).concat(unprocessedDirectives);              mergeTemplateAttributes(templateAttrs, newTemplateAttrs);              ii = directives.length; @@ -1303,13 +1303,13 @@ function $CompileProvider($provide) {          if (pre) {            if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd);            pre.require = directive.require; -          if (newIsolateScopeDirective === directive) pre.isolateScope = true; +          if (newIsolateScopeDirective === directive || directive.$$isolateScope) pre.isolateScope = true;            preLinkFns.push(pre);          }          if (post) {            if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd);            post.require = directive.require; -          if (newIsolateScopeDirective === directive) post.isolateScope = true; +          if (newIsolateScopeDirective === directive || directive.$$isolateScope) post.isolateScope = true;            postLinkFns.push(post);          }        } @@ -1501,6 +1501,12 @@ function $CompileProvider($provide) {        }      } +    function markDirectivesAsIsolate(directives) { +      // mark all directives as needing isolate scope. +      for (var j = 0, jj = directives.length; j < jj; j++) { +        directives[j] = inherit(directives[j], {$$isolateScope: true}); +      } +    }      /**       * looks up the directive and decorates it with exception handling and proper parameters. We @@ -1616,7 +1622,12 @@ function $CompileProvider($provide) {              tempTemplateAttrs = {$attr: {}};              replaceWith($rootElement, $compileNode, compileNode); -            collectDirectives(compileNode, directives, tempTemplateAttrs); +            var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs); + +            if (isObject(origAsyncDirective.scope)) { +              markDirectivesAsIsolate(templateDirectives); +            } +            directives = templateDirectives.concat(directives);              mergeTemplateAttributes(tAttrs, tempTemplateAttrs);            } else {              compileNode = beforeTemplateCompileNode; | 
