mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-16 18:51:06 +00:00
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
This commit is contained in:
parent
255e8c13cf
commit
5eb1fb6cb2
2 changed files with 27 additions and 0 deletions
|
|
@ -153,6 +153,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
|
||||||
function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) {
|
function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) {
|
||||||
return {
|
return {
|
||||||
restrict: 'ECA',
|
restrict: 'ECA',
|
||||||
|
priority: 1000,
|
||||||
terminal: true,
|
terminal: true,
|
||||||
transclude: 'element',
|
transclude: 'element',
|
||||||
compile: function(element, attr, transclusion) {
|
compile: function(element, attr, transclusion) {
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
describe('autoscoll', function() {
|
||||||
var autoScrollSpy;
|
var autoScrollSpy;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue