Skip to content

Commit 470fae9

Browse files
tboschjamesdaily
authored andcommitted
refactor($compile): move function def out of loop
1 parent 5334631 commit 470fae9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/ng/compile.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -927,15 +927,7 @@ function $CompileProvider($provide) {
927927
childTranscludeFn = nodeLinkFn.transclude;
928928
if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) {
929929
nodeLinkFn(childLinkFn, childScope, node, $rootElement,
930-
(function(transcludeFn) {
931-
return function(cloneFn) {
932-
var transcludeScope = scope.$new();
933-
transcludeScope.$$transcluded = true;
934-
935-
return transcludeFn(transcludeScope, cloneFn).
936-
on('$destroy', bind(transcludeScope, transcludeScope.$destroy));
937-
};
938-
})(childTranscludeFn || transcludeFn)
930+
createBoundTranscludeFn(scope, childTranscludeFn || transcludeFn)
939931
);
940932
} else {
941933
nodeLinkFn(childLinkFn, childScope, node, undefined, boundTranscludeFn);
@@ -947,6 +939,16 @@ function $CompileProvider($provide) {
947939
}
948940
}
949941

942+
function createBoundTranscludeFn(scope, transcludeFn) {
943+
return function boundTranscludeFn(cloneFn) {
944+
var transcludedScope = scope.$new(),
945+
clone;
946+
transcludedScope.$$transcluded = true;
947+
clone = transcludeFn(transcludedScope, cloneFn);
948+
clone.on('$destroy', bind(transcludedScope, transcludedScope.$destroy));
949+
return clone;
950+
};
951+
}
950952

951953
/**
952954
* Looks for directives on the given node and adds them to the directive collection which is

0 commit comments

Comments
 (0)