aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTobias Bosch2013-12-10 16:46:29 -0800
committerTobias Bosch2013-12-12 17:18:44 -0800
commit30a8b7d0b5d4882c2bf3b20eb696a02f5b667726 (patch)
tree0c40067e5142a8a1dc71df8b03b39fb3e05b2878 /test
parentf8944efe70b81e02704df9b53ea2546c80c73d3b (diff)
downloadangular.js-30a8b7d0b5d4882c2bf3b20eb696a02f5b667726.tar.bz2
fix(ngInclude): Add template to DOM before linking other directives
The template needs to be added to the DOM before other directives at the same element as `ngInclude` are linked. Fixes #5247.
Diffstat (limited to 'test')
-rw-r--r--test/ng/directive/ngIncludeSpec.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js
index 2d115e8b..9e0a47b0 100644
--- a/test/ng/directive/ngIncludeSpec.js
+++ b/test/ng/directive/ngIncludeSpec.js
@@ -524,6 +524,46 @@ describe('ngInclude and transcludes', function() {
});
});
+
+ it('should link directives on the same element after the content has been loaded', function() {
+ var contentOnLink;
+ module(function() {
+ directive('test', function() {
+ return {
+ link: function(scope, element) {
+ contentOnLink = element.text();
+ }
+ };
+ });
+ });
+ inject(function($compile, $rootScope, $httpBackend) {
+ $httpBackend.expectGET('include.html').respond('someContent');
+ element = $compile('<div><div ng-include="\'include.html\'" test></div>')($rootScope);
+ $rootScope.$apply();
+ $httpBackend.flush();
+ expect(contentOnLink).toBe('someContent');
+ });
+ });
+
+ it('should add the content to the element before compiling it', function() {
+ var root;
+ module(function() {
+ directive('test', function() {
+ return {
+ link: function(scope, element) {
+ root = element.parent().parent();
+ }
+ };
+ });
+ });
+ inject(function($compile, $rootScope, $httpBackend) {
+ $httpBackend.expectGET('include.html').respond('<span test></span>');
+ element = $compile('<div><div ng-include="\'include.html\'"></div>')($rootScope);
+ $rootScope.$apply();
+ $httpBackend.flush();
+ expect(root[0]).toBe(element[0]);
+ });
+ });
});
describe('ngInclude animations', function() {