@@ -3238,6 +3238,14 @@ describe('$compile', function() {
3238
3238
expect ( element . text ( ) ) . toBe ( '3' ) ;
3239
3239
} ) ;
3240
3240
} ) ;
3241
+
3242
+ it ( 'should throw multilink error when linking the same element more then once' , function ( ) {
3243
+ var linker = $compile ( '<div>' ) ;
3244
+ linker ( $rootScope ) . remove ( ) ;
3245
+ expect ( function ( ) {
3246
+ linker ( $rootScope ) ;
3247
+ } ) . toThrowMinErr ( '$compile' , 'multilink' , 'This element has already been linked.' ) ;
3248
+ } ) ;
3241
3249
} ) ;
3242
3250
3243
3251
@@ -6022,6 +6030,22 @@ describe('$compile', function() {
6022
6030
} ) ;
6023
6031
} ) ;
6024
6032
6033
+ it ( 'should throw if a transcluded node is transcluded again' , function ( ) {
6034
+ module ( function ( ) {
6035
+ directive ( 'trans' , valueFn ( {
6036
+ transclude : true ,
6037
+ link : function ( scope , element , attr , ctrl , $transclude ) {
6038
+ $transclude ( ) ;
6039
+ $transclude ( ) ;
6040
+ }
6041
+ } ) ) ;
6042
+ } ) ;
6043
+ inject ( function ( $rootScope , $compile ) {
6044
+ expect ( function ( ) {
6045
+ $compile ( '<trans></trans>' ) ( $rootScope ) ;
6046
+ } ) . toThrowMinErr ( '$compile' , 'multilink' , 'This element has already been linked.' ) ;
6047
+ } ) ;
6048
+ } ) ;
6025
6049
6026
6050
it ( 'should not leak if two "element" transclusions are on the same element (with debug info)' , function ( ) {
6027
6051
if ( jQuery ) {
@@ -6163,7 +6187,7 @@ describe('$compile', function() {
6163
6187
'</div>' +
6164
6188
'</div>' +
6165
6189
'</div>' ) ;
6166
- element = template ( $rootScope ) ;
6190
+ element = template ( $rootScope , noop ) ;
6167
6191
$rootScope . $digest ( ) ;
6168
6192
$timeout . flush ( ) ;
6169
6193
$httpBackend . flush ( ) ;
@@ -6173,10 +6197,11 @@ describe('$compile', function() {
6173
6197
$templateCache . removeAll ( ) ;
6174
6198
var destroyedScope = $rootScope . $new ( ) ;
6175
6199
destroyedScope . $destroy ( ) ;
6176
- var clone = template ( destroyedScope ) ;
6200
+ var clone = template ( destroyedScope , noop ) ;
6177
6201
$rootScope . $digest ( ) ;
6178
6202
$timeout . flush ( ) ;
6179
6203
expect ( linkFn ) . not . toHaveBeenCalled ( ) ;
6204
+ clone . remove ( ) ;
6180
6205
} ) ;
6181
6206
} ) ;
6182
6207
0 commit comments