diff options
| author | Tobias Bosch | 2013-11-14 17:09:05 -0800 | 
|---|---|---|
| committer | Vojta Jina | 2013-11-14 20:53:30 -0800 | 
| commit | c785918cbd245cc8ecf9a38e373b121c4e68a55b (patch) | |
| tree | 18125b24c5f74de7e04d48440382a1ce1b51a106 /src/ng/compile.js | |
| parent | 8425e9fe383c17f6a5589c778658c5fc0570ae8f (diff) | |
| download | angular.js-c785918cbd245cc8ecf9a38e373b121c4e68a55b.tar.bz2 | |
refactor($compile): move function def out of loop
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 20 | 
1 files changed, 11 insertions, 9 deletions
| diff --git a/src/ng/compile.js b/src/ng/compile.js index 0b818535..039c211c 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -927,15 +927,7 @@ function $CompileProvider($provide) {              childTranscludeFn = nodeLinkFn.transclude;              if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) {                nodeLinkFn(childLinkFn, childScope, node, $rootElement, -                  (function(transcludeFn) { -                    return function(cloneFn) { -                      var transcludeScope = scope.$new(); -                      transcludeScope.$$transcluded = true; - -                      return transcludeFn(transcludeScope, cloneFn). -                          on('$destroy', bind(transcludeScope, transcludeScope.$destroy)); -                    }; -                  })(childTranscludeFn || transcludeFn) +                createBoundTranscludeFn(scope, childTranscludeFn || transcludeFn)                );              } else {                nodeLinkFn(childLinkFn, childScope, node, undefined, boundTranscludeFn); @@ -947,6 +939,16 @@ function $CompileProvider($provide) {        }      } +    function createBoundTranscludeFn(scope, transcludeFn) { +      return function boundTranscludeFn(cloneFn) { +        var transcludedScope = scope.$new(), +          clone; +        transcludedScope.$$transcluded = true; +        clone = transcludeFn(transcludedScope, cloneFn); +        clone.on('$destroy', bind(transcludedScope, transcludedScope.$destroy)); +        return clone; +      }; +    }      /**       * Looks for directives on the given node and adds them to the directive collection which is | 
