Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(ngInclude): don't break attribute bindings on ngInclude-ed element
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ngInclude's priority is now set to 1000

It's quite rare for anyone to depend on explicity directive priority,
but if a custom directive that needs to run before ngInclude exists,
it should have its priority checked and adjusted if needed.

Closes #3793
  • Loading branch information
btford authored and IgorMinar committed Sep 20, 2013
1 parent 255e8c1 commit 5eb1fb6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ng/directive/ngInclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) {
return {
restrict: 'ECA',
priority: 1000,
terminal: true,
transclude: 'element',
compile: function(element, attr, transclusion) {
Expand Down
26 changes: 26 additions & 0 deletions test/ng/directive/ngIncludeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,32 @@ describe('ngInclude', function() {
}));


it('should not break attribute bindings on the same element', inject(function($compile, $rootScope, $httpBackend) {
// regression #3793

element = $compile('<div><span foo="#/{{hrefUrl}}" ng:include="includeUrl"></span></div>')($rootScope);
$httpBackend.expect('GET', 'url1').respond('template text 1');
$rootScope.hrefUrl = 'fooUrl1';
$rootScope.includeUrl = 'url1';
$rootScope.$digest();
$httpBackend.flush();
expect(element.text()).toBe('template text 1');
expect(element.find('span').attr('foo')).toBe('#/fooUrl1');

$httpBackend.expect('GET', 'url2').respond('template text 2');
$rootScope.includeUrl = 'url2';
$rootScope.$digest();
$httpBackend.flush();
expect(element.text()).toBe('template text 2');
expect(element.find('span').attr('foo')).toBe('#/fooUrl1');

$rootScope.hrefUrl = 'fooUrl2';
$rootScope.$digest();
expect(element.text()).toBe('template text 2');
expect(element.find('span').attr('foo')).toBe('#/fooUrl2');
}));


describe('autoscoll', function() {
var autoScrollSpy;

Expand Down

0 comments on commit 5eb1fb6

Please sign in to comment.