@@ -5558,6 +5558,42 @@ describe('$compile', function() {
5558
5558
} ) ;
5559
5559
5560
5560
5561
+ it ( 'should throw badrestrict on first compilation when restrict is invalid' , function ( ) {
5562
+ module ( function ( $compileProvider , $exceptionHandlerProvider ) {
5563
+ $compileProvider . directive ( 'invalidRestrictBadString' , valueFn ( { restrict : '"' } ) ) ;
5564
+ $compileProvider . directive ( 'invalidRestrictFalse' , valueFn ( { restrict : false } ) ) ;
5565
+ $compileProvider . directive ( 'invalidRestrictTrue' , valueFn ( { restrict : true } ) ) ;
5566
+ $compileProvider . directive ( 'invalidRestrictObject' , valueFn ( { restrict : { } } ) ) ;
5567
+ $compileProvider . directive ( 'invalidRestrictZero' , valueFn ( { restrict : 0 } ) ) ;
5568
+
5569
+ // We need to test with the exceptionHandler not rethrowing...
5570
+ $exceptionHandlerProvider . mode ( 'log' ) ;
5571
+ } ) ;
5572
+
5573
+ inject ( function ( $exceptionHandler , $compile , $rootScope ) {
5574
+ $compile ( '<div invalid-restrict-false>' ) ( $rootScope ) ;
5575
+ expect ( $exceptionHandler . errors . length ) . toBe ( 1 ) ;
5576
+ expect ( $exceptionHandler . errors [ 0 ] ) . toMatch ( / \$ c o m p i l e .* b a d r e s t r i c t .* ' f a l s e ' / ) ;
5577
+
5578
+ $compile ( '<div invalid-restrict-true>' ) ( $rootScope ) ;
5579
+ expect ( $exceptionHandler . errors . length ) . toBe ( 2 ) ;
5580
+ expect ( $exceptionHandler . errors [ 1 ] ) . toMatch ( / \$ c o m p i l e .* b a d r e s t r i c t .* ' t r u e ' / ) ;
5581
+
5582
+ $compile ( '<div invalid-restrict-bad-string>' ) ( $rootScope ) ;
5583
+ expect ( $exceptionHandler . errors . length ) . toBe ( 3 ) ;
5584
+ expect ( $exceptionHandler . errors [ 2 ] ) . toMatch ( / \$ c o m p i l e .* b a d r e s t r i c t .* ' \" ' / ) ;
5585
+
5586
+ $compile ( '<div invalid-restrict-object invalid-restrict-zero>' ) ( $rootScope ) ;
5587
+ expect ( $exceptionHandler . errors . length ) . toBe ( 5 ) ;
5588
+ expect ( $exceptionHandler . errors [ 3 ] ) . toMatch ( / \$ c o m p i l e .* b a d r e s t r i c t .* ' { } ' / ) ;
5589
+ expect ( $exceptionHandler . errors [ 4 ] ) . toMatch ( / \$ c o m p i l e .* b a d r e s t r i c t .* ' 0 ' / ) ;
5590
+
5591
+ $compile ( '<div invalid-restrict-true invalid-restrict-zero>' ) ( $rootScope ) ;
5592
+ expect ( $exceptionHandler . errors . length ) . toBe ( 5 ) ;
5593
+ } ) ;
5594
+ } ) ;
5595
+
5596
+
5561
5597
it ( 'should throw noident when missing controllerAs directive property' , function ( ) {
5562
5598
module ( function ( $compileProvider ) {
5563
5599
$compileProvider . directive ( 'noIdent' , valueFn ( {
0 commit comments