This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -214,11 +214,13 @@ DirectiveSelector directiveSelectorFactory(DirectiveMap directives) {
214
214
_ElementSelector elementSelector = new _ElementSelector ('' );
215
215
List <_ContainsSelector > attrSelector = [];
216
216
List <_ContainsSelector > textSelector = [];
217
-
218
217
directives.forEach ((NgAnnotation annotation, Type type) {
219
218
var match;
220
219
var selector = annotation.selector;
221
220
List <_SelectorPart > selectorParts;
221
+ if (selector == null ) {
222
+ throw new ArgumentError ('Missing selector annotation for $type ' );
223
+ }
222
224
223
225
if ((match = _CONTAINS_REGEXP .firstMatch (selector)) != null ) {
224
226
textSelector.add (new _ContainsSelector (annotation, match.group (1 )));
Original file line number Diff line number Diff line change @@ -442,6 +442,24 @@ main() => describe('dte.compiler', () {
442
442
expect (element.textWithShadow ()).toEqual ('WORKED' );
443
443
})));
444
444
});
445
+
446
+ describe ('invalid components' , () {
447
+ beforeEach (module ((Module module) {
448
+ module
449
+ ..type (MissingSelector );
450
+ return (Injector _injector) {
451
+ injector = _injector;
452
+ $compile = injector.get (Compiler );
453
+ $rootScope = injector.get (Scope );
454
+ };
455
+ }));
456
+
457
+ it ('should throw a useful error message' , () {
458
+ expect (() {
459
+ inject ((Compiler c) { });
460
+ }).toThrow ('Missing selector annotation for MissingSelector' );
461
+ });
462
+ });
445
463
});
446
464
447
465
@@ -720,3 +738,10 @@ class MyController {
720
738
}
721
739
}
722
740
741
+ @NgComponent (
742
+ template: 'boo'
743
+ )
744
+ class MissingSelector {
745
+
746
+ }
747
+
You can’t perform that action at this time.
0 commit comments