From 166e0d63d0d3e1e4b4c9771d3046dd89a4e551af Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 21 Aug 2013 01:11:19 -0700 Subject: revert: fix($compile): correct controller instantiation... fix($compile): correct controller for async directives This reverts commit 51d32243fe8cfbdcd1b647950d4e99ed57677558 as well as commit 9c51d503188efae14b81bd4d6dd7d5a3363f050f Changing ordering of events in stable branch is not a good idea. --- src/ng/compile.js | 7 ++- test/ng/compileSpec.js | 119 ------------------------------------------------- 2 files changed, 3 insertions(+), 123 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 9e124edb..30d048d4 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1008,10 +1008,9 @@ function $CompileProvider($provide) { replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode); } - afterTemplateNodeLinkFn( - beforeTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, controller), - scope, linkNode, $rootElement, controller - ); + afterTemplateNodeLinkFn(function() { + beforeTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, controller); + }, scope, linkNode, $rootElement, controller); } linkQueue = null; }). diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index b76eb132..50aa30ef 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2216,125 +2216,6 @@ describe('$compile', function() { expect(asyncCtrlSpy).toHaveBeenCalledOnce(); }); }); - - - it('should instantiate the controller after the isolate scope bindings are initialized (with template)', function () { - module(function () { - var Ctrl = function ($scope, log) { - log('myFoo=' + $scope.myFoo); - }; - - directive('myDirective', function () { - return { - scope: { - myFoo: "=" - }, - template: '
Hello
', - controller: Ctrl - }; - }); - }); - - inject(function ($templateCache, $compile, $rootScope, log) { - $rootScope.foo = "bar"; - - element = $compile('')($rootScope); - $rootScope.$apply(); - expect(log).toEqual('myFoo=bar'); - }); - }); - - - it('should instantiate the controller after the isolate scope bindings are initialized (with templateUrl)', function () { - module(function () { - var Ctrl = function ($scope, log) { - log('myFoo=' + $scope.myFoo); - }; - - directive('myDirective', function () { - return { - scope: { - myFoo: "=" - }, - templateUrl: 'hello.html', - controller: Ctrl - }; - }); - }); - - inject(function ($templateCache, $compile, $rootScope, log) { - $templateCache.put('hello.html', 'Hello
'); - $rootScope.foo = "bar"; - - element = $compile('')($rootScope); - $rootScope.$apply(); - expect(log).toEqual('myFoo=bar'); - }); - }); - - - it('should allow controller usage in pre-link directive functions with templateUrl', function () { - module(function () { - var Ctrl = function (log) { - log('instance'); - }; - - directive('myDirective', function () { - return { - scope: true, - templateUrl: 'hello.html', - controller: Ctrl, - compile: function () { - return { - pre: function (scope, template, attr, ctrl) {}, - post: function () {} - }; - } - }; - }); - }); - - inject(function ($templateCache, $compile, $rootScope, log) { - $templateCache.put('hello.html', 'Hello
'); - - element = $compile('')($rootScope); - $rootScope.$apply(); - - expect(log).toEqual('instance'); - expect(element.text()).toBe('Hello'); - }); - }); - - - it('should allow controller usage in pre-link directive functions with a template', function () { - module(function () { - var Ctrl = function (log) { - log('instance'); - }; - - directive('myDirective', function () { - return { - scope: true, - template: 'Hello
', - controller: Ctrl, - compile: function () { - return { - pre: function (scope, template, attr, ctrl) {}, - post: function () {} - }; - } - }; - }); - }); - - inject(function ($templateCache, $compile, $rootScope, log) { - element = $compile('')($rootScope); - $rootScope.$apply(); - - expect(log).toEqual('instance'); - expect(element.text()).toBe('Hello'); - }); - }); }); -- cgit v1.2.3