@@ -4852,6 +4852,70 @@ describe('$compile', function() {
4852
4852
4853
4853
expect ( element . text ( ) ) . toBe ( '-->|x|' ) ;
4854
4854
} ) ) ;
4855
+
4856
+
4857
+ it ( "should pass transclusion through to template of a 'replace' directive" , function ( ) {
4858
+
4859
+ // So the problem here appears to be if you have:
4860
+ // - a templateUrl+replace directive (info) inside an async transclusion directive (trans)
4861
+ // - and the info directive also has a transclusion-based directive at its root (transSync)
4862
+ // In this scenario, the transcludeFn is not passed to the transSync nodeLinkFn at link time.
4863
+ //
4864
+ // (The trans directive is simulating what ng-if does, which is call its transludeFn during a
4865
+ // subsequent digest if its value evaluates to true)
4866
+ //
4867
+ // If the trans directive is not async then the transcludeFn does get passed.
4868
+ //
4869
+ // In debugging you can see that the delayedNodeLinkFn is not passing the transcludeFn down
4870
+ // to the afterTemplateNodeLinkFn
4871
+
4872
+ module ( function ( ) {
4873
+ directive ( 'transSync' , function ( ) {
4874
+ return {
4875
+ transclude : true ,
4876
+ link : function ( scope , element , attr , ctrl , transclude ) {
4877
+
4878
+ expect ( transclude ) . toEqual ( jasmine . any ( Function ) ) ;
4879
+
4880
+ console . warn ( 'transSync link' , scope && scope . $id , transclude ) ;
4881
+ var child = transclude ( ) ;
4882
+ element . after ( child ) ;
4883
+ }
4884
+ } ;
4885
+ } ) ;
4886
+
4887
+ directive ( 'trans' , function ( $timeout ) {
4888
+ return {
4889
+ transclude : true ,
4890
+ link : function ( scope , element , attrs , ctrl , transclude ) {
4891
+
4892
+ console . warn ( 'trans link' , scope && scope . $id , transclude ) ;
4893
+
4894
+ $timeout ( function doTransclusion ( ) {
4895
+ console . warn ( 'trans - timeout' , scope && scope . $id , transclude ) ;
4896
+ var child = transclude ( ) ;
4897
+ element . after ( child ) ;
4898
+ } ) ;
4899
+ }
4900
+ } ;
4901
+ } ) ;
4902
+
4903
+ directive ( 'info' , function ( ) {
4904
+ return {
4905
+ //template: '<div trans>hi (cached)</div>',
4906
+ templateUrl : "info.html" ,
4907
+ replace : true
4908
+ } ;
4909
+ } ) ;
4910
+ } ) ;
4911
+ inject ( function ( $compile , $rootScope , $templateCache , $timeout ) {
4912
+ $templateCache . put ( 'info.html' , '<div trans-sync>hi (cached)</div>' ) ;
4913
+
4914
+ element = $compile ( '<div><div trans><div info></div></div></div>' ) ( $rootScope ) ;
4915
+ $timeout . flush ( ) ;
4916
+ } ) ;
4917
+
4918
+ } ) ;
4855
4919
} ) ;
4856
4920
4857
4921
0 commit comments