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

$compile + ngRepeat + replace templates (fix #2151) #2155

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion test/ng/directive/ngRepeatSpec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict';

describe('ngRepeat', function() {
var element, $compile, scope;
var element, $compile, scope, $compileProvider;

beforeEach(module(function(_$compileProvider_) {
$compileProvider = _$compileProvider_;
}));


beforeEach(inject(function(_$compile_, $rootScope) {
Expand Down Expand Up @@ -364,6 +368,75 @@ describe('ngRepeat', function() {
});


describe('nesting in replaced directive templates', function() {

// TODO: THIS TEST IS STILL FAILING BUT CAUSES STACK OVERFLOW SO IT'S DISABLED
xit('should work when placed on a root element of attr directive with SYNC replaced template',
inject(function($templateCache, $compile, $rootScope) {
$compileProvider.directive('replaceMeWithRepeater', function() {
return {
replace: true,
template: '<span ng-repeat="i in [1,2,3]">{{i}}</span>'
}
});
element = $compile('<div replace-me-with-repeater></div>')($rootScope);
expect(element.text()).toBe('');
$rootScope.$apply();
expect(element.text()).toBe('123');
}));


// TODO: THIS TEST IS STILL FAILING BUT CAUSES INFINITE LOOP SO IT'S DISABLED
xit('should work when placed on a root element of attr directive with ASYNC replaced template',
inject(function($templateCache, $compile, $rootScope) {
$compileProvider.directive('replaceMeWithRepeater', function() {
return {
replace: true,
templateUrl: 'replace-me-with-repeater.html'
}
});
$templateCache.put('replace-me-with-repeater.html', '<div ng-repeat="i in [1,2,3]">{{i}}</div>');
element = $compile('<span replace-me-with-repeater></span>')($rootScope);
expect(element.text()).toBe('');
$rootScope.$apply();
expect(element.text()).toBe('123');
}));


iit('should work when placed on a root element of element directive with SYNC replaced template',
inject(function($templateCache, $compile, $rootScope) {
$compileProvider.directive('replaceMeWithRepeater', function() {
return {
restrict: 'E',
replace: true,
template: '<div ng-repeat="i in [1,2,3]">{{i}}</div>'
}
});
element = $compile('<div><replace-me-with-repeater></replace-me-with-repeater></div>')($rootScope);
expect(element.text()).toBe('');
$rootScope.$apply();
expect(element.text()).toBe('123');
}));


iit('should work when placed on a root element of element directive with ASYNC replaced template',
inject(function($templateCache, $compile, $rootScope) {
$compileProvider.directive('replaceMeWithRepeater', function() {
return {
restrict: 'E',
replace: true,
templateUrl: 'replace-me-with-repeater.html'
}
});
$templateCache.put('replace-me-with-repeater.html', '<div ng-repeat="i in [1,2,3]">{{i}}</div>');
element = $compile('<div><replace-me-with-repeater></replace-me-with-repeater></div>')($rootScope);
expect(element.text()).toBe('');
$rootScope.$apply();
expect(element.text()).toBe('123');
}));
});


describe('stability', function() {
var a, b, c, d, lis;

Expand Down