Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
refactor($compile): move function def out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tbosch authored and vojtajina committed Nov 15, 2013
1 parent 8425e9f commit c785918
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit c785918

Please sign in to comment.