aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorIgor Minar2013-10-25 19:10:50 -0700
committerIgor Minar2013-10-28 01:11:18 -0700
commit18ae985c3a3147b589c22f6ec21bacad2f578e2b (patch)
tree8411112a847a2f8de2b6a49a87814f50840385eb /test
parent797c99eabee98fedcf01cdad4432569a9ebe8a17 (diff)
downloadangular.js-18ae985c3a3147b589c22f6ec21bacad2f578e2b.tar.bz2
fix($compile): don't instantiate controllers twice for element transclude directives
This is a fix for regression introduced last week by faf5b980. Closes #4654
Diffstat (limited to 'test')
-rwxr-xr-xtest/ng/compileSpec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 0e394640..c6cba3a4 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -3179,6 +3179,47 @@ describe('$compile', function() {
expect(log).toEqual('compile:elementTrans; compile:regularTrans; regular');
});
});
+
+
+ it('should instantiate high priority controllers only once, but low priority ones each time we transclude',
+ function() {
+ module(function() {
+ directive('elementTrans', function(log) {
+ return {
+ transclude: 'element',
+ priority: 50,
+ controller: function($transclude, $element) {
+ log('controller:elementTrans');
+ $transclude(function(clone) {
+ $element.after(clone);
+ });
+ $transclude(function(clone) {
+ $element.after(clone);
+ });
+ $transclude(function(clone) {
+ $element.after(clone);
+ });
+ }
+ };
+ });
+ directive('normalDir', function(log) {
+ return {
+ controller: function() {
+ log('controller:normalDir');
+ }
+ };
+ });
+ });
+ inject(function($compile, $rootScope, log) {
+ element = $compile('<div><div element-trans normal-dir></div></div>')($rootScope);
+ expect(log).toEqual([
+ 'controller:elementTrans',
+ 'controller:normalDir',
+ 'controller:normalDir',
+ 'controller:normalDir'
+ ]);
+ });
+ });
});