From 28f9ee48a204c251f45f0d6a6dae6eaeecf5a665 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 5 Aug 2014 09:37:14 +0200 Subject: [PATCH] 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. --- lib/tools/source_metadata_extractor.dart | 25 ++---------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/lib/tools/source_metadata_extractor.dart b/lib/tools/source_metadata_extractor.dart index 90045ec70..1194db557 100644 --- a/lib/tools/source_metadata_extractor.dart +++ b/lib/tools/source_metadata_extractor.dart @@ -4,9 +4,6 @@ import 'package:analyzer/src/generated/ast.dart'; import 'package:angular/tools/source_crawler.dart'; import 'package:angular/tools/common.dart'; -const String _COMPONENT = '-component'; -const String _DIRECTIVE = '-directive'; -String _ATTR_DIRECTIVE = '-attr' + _DIRECTIVE; RegExp _ATTR_SELECTOR_REGEXP = new RegExp(r'\[([^\]]+)\]'); const List _specs = const ['=>!', '=>', '<=>', '@', '&']; const Map _attrAnnotationsToSpec = const { @@ -70,27 +67,9 @@ class SourceMetadataExtractor { // No explicit selector specified on the directive, compute one. var className = meta.className; + if (dirInfo.selector == null) { - if (meta.type == COMPONENT) { - if (className.endsWith(_COMPONENT)) { - dirInfo.selector = className. - substring(0, className.length - _COMPONENT.length); - } else { - throw "Directive name '$className' must end with $_DIRECTIVE, " - "$_ATTR_DIRECTIVE, $_COMPONENT or have a \$selector field."; - } - } else { - if (className.endsWith(_ATTR_DIRECTIVE)) { - var attrName = className. - substring(0, className.length - _ATTR_DIRECTIVE.length); - dirInfo.selector = '[$attrName]'; - } else if (className.endsWith(_DIRECTIVE)) { - dirInfo.selector = className. - substring(0, className.length - _DIRECTIVE.length); - } else { - throw "Directive name '$className' must have a \$selector field."; - } - } + throw new ArgumentError('Missing selector annotation for $className'); } var reprocessedAttrs = []; dirInfo.expressionAttrs.forEach((String attr) {