From e6521e7491242504250b57dd0ee66af49e653c33 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Thu, 21 Nov 2013 21:54:59 -0800 Subject: fix(ngView): Don't throw when the ngView element contains content with directives. Fixes #5069 --- test/ngRoute/directive/ngViewSpec.js | 42 +++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/ngRoute/directive/ngViewSpec.js b/test/ngRoute/directive/ngViewSpec.js index 533f0b53..f4b28058 100644 --- a/test/ngRoute/directive/ngViewSpec.js +++ b/test/ngRoute/directive/ngViewSpec.js @@ -515,12 +515,23 @@ describe('ngView', function() { }); describe('ngView and transcludes', function() { + var element, directive; + + beforeEach(module('ngRoute', function($compileProvider) { + element = null; + directive = $compileProvider.directive; + })); + + afterEach(function() { + if (element) { + dealoc(element); + } + }); + it('should allow access to directive controller from children when used in a replace template', function() { var controller; - module('ngRoute'); - module(function($compileProvider, $routeProvider) { + module(function($routeProvider) { $routeProvider.when('/view', {templateUrl: 'view.html'}); - var directive = $compileProvider.directive; directive('template', function() { return { template: '
', @@ -542,14 +553,35 @@ describe('ngView and transcludes', function() { }); inject(function($compile, $rootScope, $httpBackend, $location) { $httpBackend.expectGET('view.html').respond('
'); - var element = $compile('
')($rootScope); + element = $compile('
')($rootScope); $location.url('/view'); $rootScope.$apply(); $httpBackend.flush(); expect(controller.flag).toBe(true); - dealoc(element); }); }); + + it("should compile it's content correctly (although we remove it later)", function() { + var testElement; + module(function($compileProvider, $routeProvider) { + $routeProvider.when('/view', {template: ' '}); + var directive = $compileProvider.directive; + directive('test', function() { + return { + link: function(scope, element) { + testElement = element; + } + }; + }); + }); + inject(function($compile, $rootScope, $location) { + element = $compile('
')($rootScope); + $location.url('/view'); + $rootScope.$apply(); + expect(testElement[0].nodeName).toBe('DIV'); + }); + + }); }); describe('ngView animations', function() { -- cgit v1.2.3