diff options
| author | Misko Hevery | 2012-04-03 14:15:42 -0700 |
|---|---|---|
| committer | Misko Hevery | 2012-04-03 16:02:20 -0700 |
| commit | 7e86eacf301934335c22908ec6dbd1a083d88fab (patch) | |
| tree | 9d10c77b967ee845e6a2fa0588893d82487a7975 /test/ng/compilerSpec.js | |
| parent | 15c1fe392942b70e456f10afbdfd9c3329249a43 (diff) | |
| download | angular.js-7e86eacf301934335c22908ec6dbd1a083d88fab.tar.bz2 | |
fix($compile): relax the restriction that directives can not add siblings
Relax the restriction that directives can not add siblings
Diffstat (limited to 'test/ng/compilerSpec.js')
| -rw-r--r-- | test/ng/compilerSpec.js | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/test/ng/compilerSpec.js b/test/ng/compilerSpec.js index 55479396..f9d8d301 100644 --- a/test/ng/compilerSpec.js +++ b/test/ng/compilerSpec.js @@ -242,16 +242,39 @@ describe('$compile', function() { }); - it('should prevent changing of structure', inject( - function($compile, $rootScope){ - element = jqLite("<div><div log></div></div>"); - var linkFn = $compile(element); - element.append("<div></div>"); - expect(function() { - linkFn($rootScope); - }).toThrow('Template changed structure!'); - } - )); + it('should allow changing the template structure after the current node', function() { + module(function($compileProvider){ + $compileProvider.directive('after', valueFn({ + compile: function(element) { + element.after('<span log>B</span>'); + } + })); + }); + inject(function($compile, $rootScope, log){ + element = jqLite("<div><div after>A</div></div>"); + $compile(element)($rootScope); + expect(element.text()).toBe('AB'); + expect(log).toEqual('LOG'); + }); + }); + + + it('should allow changing the template structure after the current node inside ngRepeat', function() { + module(function($compileProvider){ + $compileProvider.directive('after', valueFn({ + compile: function(element) { + element.after('<span log>B</span>'); + } + })); + }); + inject(function($compile, $rootScope, log){ + element = jqLite('<div><div ng-repeat="i in [1,2]"><div after>A</div></div></div>'); + $compile(element)($rootScope); + $rootScope.$digest(); + expect(element.text()).toBe('ABAB'); + expect(log).toEqual('LOG; LOG'); + }); + }); }); describe('compiler control', function() { |
