@@ -23,12 +23,15 @@ part of angular.core.dom_internal;
23
23
class DirectiveSelector {
24
24
ElementBinderFactory _binderFactory;
25
25
DirectiveMap _directives;
26
+ Interpolate _interpolate;
27
+ FormatterMap _formatters;
28
+ ASTParser _astParser;
26
29
var elementSelector = new _ElementSelector ('' );
27
30
var attrSelector = < _ContainsSelector > [];
28
31
var textSelector = < _ContainsSelector > [];
29
32
30
33
/// Parses all the [_directives] so they can be retrieved via [matchElement]
31
- DirectiveSelector (this ._directives, this ._binderFactory) {
34
+ DirectiveSelector (this ._directives, this ._formatters, this . _binderFactory, this ._interpolate, this ._astParser ) {
32
35
_directives.forEach ((Directive annotation, Type type) {
33
36
var match;
34
37
var selector = annotation.selector;
@@ -130,8 +133,12 @@ class DirectiveSelector {
130
133
var selectorRegExp = textSelector[k];
131
134
if (selectorRegExp.regexp.hasMatch (value)) {
132
135
_directives[selectorRegExp.annotation].forEach ((type) {
136
+ // Pre-compute the AST to watch this value.
137
+ String expression = _interpolate (value);
138
+ var valueAST = _astParser (expression, formatters: _formatters);
139
+
133
140
builder.addDirective (new DirectiveRef (node, type,
134
- selectorRegExp.annotation, new Key (type), value));
141
+ selectorRegExp.annotation, new Key (type), value, valueAST ));
135
142
});
136
143
}
137
144
}
@@ -147,11 +154,24 @@ class DirectiveSelector {
147
154
@Injectable ()
148
155
class DirectiveSelectorFactory {
149
156
ElementBinderFactory _binderFactory;
157
+ Interpolate _interpolate;
158
+ ASTParser _astParser;
159
+ // TODO(deboer): Remove once the FormatterMap is a required 'selector' parameter.
160
+ FormatterMap _defaultFormatterMap;
150
161
151
- DirectiveSelectorFactory (this ._binderFactory);
162
+ DirectiveSelectorFactory (this ._binderFactory, this ._interpolate,
163
+ this ._astParser, this ._defaultFormatterMap);
152
164
153
- DirectiveSelector selector (DirectiveMap directives) =>
154
- new DirectiveSelector (directives, _binderFactory);
165
+ /**
166
+ * Create a new [DirectiveSelector] given a [DirectiveMap] and [FormatterMap]
167
+ *
168
+ * NOTE: [formatters] will become required very soon. New code must pass
169
+ * both parameters.
170
+ */
171
+ DirectiveSelector selector (DirectiveMap directives, [FormatterMap formatters]) =>
172
+ new DirectiveSelector (directives,
173
+ formatters != null ? formatters : _defaultFormatterMap,
174
+ _binderFactory, _interpolate, _astParser);
155
175
}
156
176
157
177
class _Directive {
0 commit comments