Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 28f9ee4

Browse files
vicbjbdeboer
authored andcommitted
fix(metadata_extractor): Do not try to guess the selector
The dynamic version of angular mandates that the selector is specified. This commit makes the static vesion consistent with that behavior, the selector must always be explicitely specified.
1 parent a981feb commit 28f9ee4

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

lib/tools/source_metadata_extractor.dart

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import 'package:analyzer/src/generated/ast.dart';
44
import 'package:angular/tools/source_crawler.dart';
55
import 'package:angular/tools/common.dart';
66

7-
const String _COMPONENT = '-component';
8-
const String _DIRECTIVE = '-directive';
9-
String _ATTR_DIRECTIVE = '-attr' + _DIRECTIVE;
107
RegExp _ATTR_SELECTOR_REGEXP = new RegExp(r'\[([^\]]+)\]');
118
const List<String> _specs = const ['=>!', '=>', '<=>', '@', '&'];
129
const Map<String, String> _attrAnnotationsToSpec = const {
@@ -70,27 +67,9 @@ class SourceMetadataExtractor {
7067

7168
// No explicit selector specified on the directive, compute one.
7269
var className = meta.className;
70+
7371
if (dirInfo.selector == null) {
74-
if (meta.type == COMPONENT) {
75-
if (className.endsWith(_COMPONENT)) {
76-
dirInfo.selector = className.
77-
substring(0, className.length - _COMPONENT.length);
78-
} else {
79-
throw "Directive name '$className' must end with $_DIRECTIVE, "
80-
"$_ATTR_DIRECTIVE, $_COMPONENT or have a \$selector field.";
81-
}
82-
} else {
83-
if (className.endsWith(_ATTR_DIRECTIVE)) {
84-
var attrName = className.
85-
substring(0, className.length - _ATTR_DIRECTIVE.length);
86-
dirInfo.selector = '[$attrName]';
87-
} else if (className.endsWith(_DIRECTIVE)) {
88-
dirInfo.selector = className.
89-
substring(0, className.length - _DIRECTIVE.length);
90-
} else {
91-
throw "Directive name '$className' must have a \$selector field.";
92-
}
93-
}
72+
throw new ArgumentError('Missing selector annotation for $className');
9473
}
9574
var reprocessedAttrs = <String>[];
9675
dirInfo.expressionAttrs.forEach((String attr) {

0 commit comments

Comments
 (0)