Skip to content

Commit

Permalink
fix(ngView): ensure ngClass works with together with ngView's transcl…
Browse files Browse the repository at this point in the history
…usion behavior

Closes: angular#3727
  • Loading branch information
matsko committed Sep 3, 2013
1 parent 1ec92b1 commit 1889361
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ngRoute/directive/ngView.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller,
return {
restrict: 'ECA',
terminal: true,
priority: 1000,
transclude: 'element',
compile: function(element, attr, linker) {
return function(scope, $element, attr) {
Expand Down
40 changes: 40 additions & 0 deletions test/ngRoute/directive/ngViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,46 @@ describe('ngView animations', function() {
expect(itemA).not.toEqual(itemB);
var itemB = $animate.flushNext('enter').element;
}));

it('should render ngClass on ngView',
inject(function($compile, $rootScope, $templateCache, $animate, $location, $timeout) {

var item;
$rootScope.tpl = 'one';
$rootScope.klass = 'classy';
element = $compile(html('<div><div ng-view ng-class="klass"></div></div>'))($rootScope);
$rootScope.$digest();

$location.path('/foo');
$rootScope.$digest();

item = $animate.flushNext('enter').element;

$animate.flushNext('addClass').element;
$animate.flushNext('addClass').element;

expect(item.hasClass('classy')).toBe(true);

$rootScope.klass = 'boring';
$rootScope.$digest();

$animate.flushNext('removeClass').element;
$animate.flushNext('addClass').element;

expect(item.hasClass('classy')).toBe(false);
expect(item.hasClass('boring')).toBe(true);

$location.path('/bar');
$rootScope.$digest();

$animate.flushNext('leave').element;
item = $animate.flushNext('enter').element;

$animate.flushNext('addClass').element;
$animate.flushNext('addClass').element;

expect(item.hasClass('boring')).toBe(true);
}));
});

it('should not double compile when the route changes', function() {
Expand Down

0 comments on commit 1889361

Please sign in to comment.