mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-16 10:43:10 +00:00
refactor($compile): move function def out of loop
This commit is contained in:
parent
8425e9fe38
commit
c785918cbd
1 changed files with 11 additions and 9 deletions
|
|
@ -927,15 +927,7 @@ function $CompileProvider($provide) {
|
||||||
childTranscludeFn = nodeLinkFn.transclude;
|
childTranscludeFn = nodeLinkFn.transclude;
|
||||||
if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) {
|
if (childTranscludeFn || (!boundTranscludeFn && transcludeFn)) {
|
||||||
nodeLinkFn(childLinkFn, childScope, node, $rootElement,
|
nodeLinkFn(childLinkFn, childScope, node, $rootElement,
|
||||||
(function(transcludeFn) {
|
createBoundTranscludeFn(scope, childTranscludeFn || transcludeFn)
|
||||||
return function(cloneFn) {
|
|
||||||
var transcludeScope = scope.$new();
|
|
||||||
transcludeScope.$$transcluded = true;
|
|
||||||
|
|
||||||
return transcludeFn(transcludeScope, cloneFn).
|
|
||||||
on('$destroy', bind(transcludeScope, transcludeScope.$destroy));
|
|
||||||
};
|
|
||||||
})(childTranscludeFn || transcludeFn)
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
nodeLinkFn(childLinkFn, childScope, node, undefined, boundTranscludeFn);
|
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
|
* Looks for directives on the given node and adds them to the directive collection which is
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue