aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2013-08-21 00:22:40 -0700
committerIgor Minar2013-08-21 01:21:02 -0700
commit0d7f19bb620ca4f733e5c202807921501e35172c (patch)
tree4f07f070ffdefc3981fa4b4d8ce8bd6134e8146d
parent607045d5921fcd202f2d6f62428bcb2cf076fd20 (diff)
downloadangular.js-0d7f19bb620ca4f733e5c202807921501e35172c.tar.bz2
revert: fix($compile): always instantiate controllers...
fix($compile): always instantiate controllers in parent->child order This reverts commit 683fd713c41eaf5da8bfbf53b574e0176c18c518. It turns out that there is some existing code that relies on the incorrect timing. Rather than breaking these apps that depend on stable releases, we are going to keep this changeo only in master and the apps will need to migrate to the correc timing during the 1.2 upgrade.
-rw-r--r--src/ng/directive/ngTransclude.js11
-rwxr-xr-xtest/ng/compileSpec.js89
2 files changed, 3 insertions, 97 deletions
diff --git a/src/ng/directive/ngTransclude.js b/src/ng/directive/ngTransclude.js
index 668f8033..c15b77cb 100644
--- a/src/ng/directive/ngTransclude.js
+++ b/src/ng/directive/ngTransclude.js
@@ -49,14 +49,9 @@
*
*/
var ngTranscludeDirective = ngDirective({
- controller: ['$transclude', '$element', '$scope', function($transclude, $element, $scope) {
- // use evalAsync so that we don't process transclusion before directives on the parent element even when the
- // transclusion replaces the current element. (we can't use priority here because that applies only to compile fns
- // and not controllers
- $scope.$evalAsync(function() {
- $transclude(function(clone) {
- $element.append(clone);
- });
+ controller: ['$transclude', '$element', function($transclude, $element) {
+ $transclude(function(clone) {
+ $element.append(clone);
});
}]
});
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index c998cda8..b76eb132 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -2218,46 +2218,6 @@ describe('$compile', function() {
});
-
- it('should instantiate controllers in the parent->child order when transluction, templateUrl and replacement ' +
- 'are in the mix', function() {
- // When a child controller is in the transclusion that replaces the parent element that has a directive with
- // a controller, we should ensure that we first instantiate the parent and only then stuff that comes from the
- // transclusion.
- //
- // The transclusion moves the child controller onto the same element as parent controller so both controllers are
- // on the same level.
-
- module(function() {
- directive('parentDirective', function() {
- return {
- transclude: true,
- replace: true,
- templateUrl: 'parentDirective.html',
- controller: function (log) { log('parentController'); }
- };
- });
- directive('childDirective', function() {
- return {
- require: '^parentDirective',
- templateUrl: 'childDirective.html',
- controller : function(log) { log('childController'); }
- };
- });
- });
-
- inject(function($templateCache, log, $compile, $rootScope) {
- $templateCache.put('parentDirective.html', '<div ng-transclude>parentTemplateText;</div>');
- $templateCache.put('childDirective.html', '<span>childTemplateText;</span>');
-
- element = $compile('<div parent-directive><div child-directive></div>childContentText;</div>')($rootScope);
- $rootScope.$apply();
- expect(log).toEqual('parentController; childController');
- expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;')
- });
- });
-
-
it('should instantiate the controller after the isolate scope bindings are initialized (with template)', function () {
module(function () {
var Ctrl = function ($scope, log) {
@@ -2313,55 +2273,6 @@ describe('$compile', function() {
});
- it('should instantiate controllers in the parent->child->baby order when nested transluction, templateUrl and ' +
- 'replacement are in the mix', function() {
- // similar to the test above, except that we have one more layer of nesting and nested transclusion
-
- module(function() {
- directive('parentDirective', function() {
- return {
- transclude: true,
- replace: true,
- templateUrl: 'parentDirective.html',
- controller: function (log) { log('parentController'); }
- };
- });
- directive('childDirective', function() {
- return {
- require: '^parentDirective',
- transclude: true,
- replace: true,
- templateUrl: 'childDirective.html',
- controller : function(log) { log('childController'); }
- };
- });
- directive('babyDirective', function() {
- return {
- require: '^childDirective',
- templateUrl: 'babyDirective.html',
- controller : function(log) { log('babyController'); }
- };
- });
- });
-
- inject(function($templateCache, log, $compile, $rootScope) {
- $templateCache.put('parentDirective.html', '<div ng-transclude>parentTemplateText;</div>');
- $templateCache.put('childDirective.html', '<span ng-transclude>childTemplateText;</span>');
- $templateCache.put('babyDirective.html', '<span>babyTemplateText;</span>');
-
- element = $compile('<div parent-directive>' +
- '<div child-directive>' +
- 'childContentText;' +
- '<div baby-directive>babyContent;</div>' +
- '</div>' +
- '</div>')($rootScope);
- $rootScope.$apply();
- expect(log).toEqual('parentController; childController; babyController');
- expect(element.text()).toBe('parentTemplateText;childTemplateText;childContentText;babyTemplateText;')
- });
- });
-
-
it('should allow controller usage in pre-link directive functions with templateUrl', function () {
module(function () {
var Ctrl = function (log) {