@@ -242,16 +242,39 @@ describe('$compile', function() {
242242 } ) ;
243243
244244
245- it ( 'should prevent changing of structure' , inject (
246- function ( $compile , $rootScope ) {
247- element = jqLite ( "<div><div log></div></div>" ) ;
248- var linkFn = $compile ( element ) ;
249- element . append ( "<div></div>" ) ;
250- expect ( function ( ) {
251- linkFn ( $rootScope ) ;
252- } ) . toThrow ( 'Template changed structure!' ) ;
253- }
254- ) ) ;
245+ it ( 'should allow changing the template structure after the current node' , function ( ) {
246+ module ( function ( $compileProvider ) {
247+ $compileProvider . directive ( 'after' , valueFn ( {
248+ compile : function ( element ) {
249+ element . after ( '<span log>B</span>' ) ;
250+ }
251+ } ) ) ;
252+ } ) ;
253+ inject ( function ( $compile , $rootScope , log ) {
254+ element = jqLite ( "<div><div after>A</div></div>" ) ;
255+ $compile ( element ) ( $rootScope ) ;
256+ expect ( element . text ( ) ) . toBe ( 'AB' ) ;
257+ expect ( log ) . toEqual ( 'LOG' ) ;
258+ } ) ;
259+ } ) ;
260+
261+
262+ it ( 'should allow changing the template structure after the current node inside ngRepeat' , function ( ) {
263+ module ( function ( $compileProvider ) {
264+ $compileProvider . directive ( 'after' , valueFn ( {
265+ compile : function ( element ) {
266+ element . after ( '<span log>B</span>' ) ;
267+ }
268+ } ) ) ;
269+ } ) ;
270+ inject ( function ( $compile , $rootScope , log ) {
271+ element = jqLite ( '<div><div ng-repeat="i in [1,2]"><div after>A</div></div></div>' ) ;
272+ $compile ( element ) ( $rootScope ) ;
273+ $rootScope . $digest ( ) ;
274+ expect ( element . text ( ) ) . toBe ( 'ABAB' ) ;
275+ expect ( log ) . toEqual ( 'LOG; LOG' ) ;
276+ } ) ;
277+ } ) ;
255278 } ) ;
256279
257280 describe ( 'compiler control' , function ( ) {
0 commit comments