Skip to content

Commit 2204029

Browse files
committed
refactor($compile): move function def out of loop
1 parent dfe6400 commit 2204029

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/ng/compile.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -926,15 +926,7 @@ function $CompileProvider($provide) {
926926
childTranscludeFn = nodeLinkFn.transclude;
927927
if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) {
928928
nodeLinkFn(childLinkFn, childScope, node, $rootElement,
929-
(function(transcludeFn) {
930-
return function(cloneFn) {
931-
var transcludeScope = scope.$new();
932-
transcludeScope.$$transcluded = true;
933-
934-
return transcludeFn(transcludeScope, cloneFn).
935-
on('$destroy', bind(transcludeScope, transcludeScope.$destroy));
936-
};
937-
})(childTranscludeFn || transcludeFn)
929+
createBoundTranscludeFn(scope, childTranscludeFn || transcludeFn)
938930
);
939931
} else {
940932
nodeLinkFn(childLinkFn, childScope, node, undefined, boundTranscludeFn);
@@ -943,11 +935,22 @@ function $CompileProvider($provide) {
943935
childLinkFn(scope, node.childNodes, undefined, boundTranscludeFn);
944936
}
945937
}
938+
946939
}
947940
}
948941

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+
}
949952

950-
/**
953+
/**
951954
* Looks for directives on the given node and adds them to the directive collection which is
952955
* sorted.
953956
*

0 commit comments

Comments
 (0)