Skip to content

Commit 1eb8e09

Browse files
btfordIgorMinar
authored andcommitted
fix(ngInclude): don't break attribute bindings on ngInclude-ed element
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
1 parent bcbd604 commit 1eb8e09

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/ng/directive/ngInclude.js

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
153153
function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) {
154154
return {
155155
restrict: 'ECA',
156+
priority: 1000,
156157
terminal: true,
157158
transclude: 'element',
158159
compile: function(element, attr, transclusion) {

test/ng/directive/ngIncludeSpec.js

+26
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,32 @@ describe('ngInclude', function() {
286286
}));
287287

288288

289+
it('should not break attribute bindings on the same element', inject(function($compile, $rootScope, $httpBackend) {
290+
// regression #3793
291+
292+
element = $compile('<div><span foo="#/{{hrefUrl}}" ng:include="includeUrl"></span></div>')($rootScope);
293+
$httpBackend.expect('GET', 'url1').respond('template text 1');
294+
$rootScope.hrefUrl = 'fooUrl1';
295+
$rootScope.includeUrl = 'url1';
296+
$rootScope.$digest();
297+
$httpBackend.flush();
298+
expect(element.text()).toBe('template text 1');
299+
expect(element.find('span').attr('foo')).toBe('#/fooUrl1');
300+
301+
$httpBackend.expect('GET', 'url2').respond('template text 2');
302+
$rootScope.includeUrl = 'url2';
303+
$rootScope.$digest();
304+
$httpBackend.flush();
305+
expect(element.text()).toBe('template text 2');
306+
expect(element.find('span').attr('foo')).toBe('#/fooUrl1');
307+
308+
$rootScope.hrefUrl = 'fooUrl2';
309+
$rootScope.$digest();
310+
expect(element.text()).toBe('template text 2');
311+
expect(element.find('span').attr('foo')).toBe('#/fooUrl2');
312+
}));
313+
314+
289315
describe('autoscoll', function() {
290316
var autoScrollSpy;
291317

0 commit comments

Comments
 (0)