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

Commit 1362f00

Browse files
vicbtravis@travis-ci.org
authored and
travis@travis-ci.org
committed
doc(selector): improve api doc
Closes #1038
1 parent 88832c1 commit 1362f00

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

lib/core_dom/element_binder_builder.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ElementBinderFactory {
1919
new ElementBinder(_perf, _expando, _parser, _componentFactory,
2020
_transcludingComponentFactory, _shadowDomComponentFactory,
2121
b.component, b.decorators, b.onEvents, b.bindAttrs, b.childMode);
22+
2223
TemplateElementBinder templateBinder(ElementBinderBuilder b, ElementBinder transclude) =>
2324
new TemplateElementBinder(_perf, _expando, _parser, _componentFactory,
2425
_transcludingComponentFactory, _shadowDomComponentFactory,
@@ -34,20 +35,29 @@ class ElementBinderBuilder {
3435

3536
ElementBinderFactory _factory;
3637

38+
/// "on-*" attribute names and values, added by a [DirectiveSelector]
3739
final onEvents = <String, String>{};
40+
/// "bind-*" attribute names and values, added by a [DirectiveSelector]
3841
final bindAttrs = <String, String>{};
3942

4043
var decorators = <DirectiveRef>[];
4144
DirectiveRef template;
42-
ViewFactory templateViewFactory;
43-
4445
DirectiveRef component;
4546

4647
// Can be either COMPILE_CHILDREN or IGNORE_CHILDREN
4748
String childMode = Directive.COMPILE_CHILDREN;
4849

4950
ElementBinderBuilder(this._factory);
5051

52+
/**
53+
* Adds [DirectiveRef]s to this [ElementBinderBuilder].
54+
*
55+
* [addDirective] gets called from [Selector.matchElement] for each directive triggered by the
56+
* element.
57+
*
58+
* When the [Directive] annotation defines a `map`, the attribute mappings are added to the
59+
* [DirectiveRef].
60+
*/
5161
addDirective(DirectiveRef ref) {
5262
var annotation = ref.annotation;
5363
var children = annotation.children;
@@ -78,14 +88,9 @@ class ElementBinderBuilder {
7888
});
7989
}
8090

91+
/// Creates an returns an [ElementBinder] or a [TemplateElementBinder]
8192
ElementBinder get binder {
82-
if (template != null) {
83-
var transclude = _factory.binder(this);
84-
return _factory.templateBinder(this, transclude);
85-
86-
} else {
87-
return _factory.binder(this);
88-
}
89-
93+
var elBinder = _factory.binder(this);
94+
return template == null ? elBinder : _factory.templateBinder(this, elBinder);
9095
}
9196
}

lib/core_dom/selector.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
part of angular.core.dom_internal;
22

33
/**
4-
* DirectiveSelector is a function which given a node it will return a
5-
* list of [DirectiveRef]s which are triggered by this node.
4+
* [DirectiveSelector] is used by the [Compiler] during the template walking to extract the
5+
* [DirectiveRef]s.
66
*
7-
* DirectiveSelector is used by the [Compiler] during the template walking
8-
* to extract the [DirectiveRef]s.
7+
* [DirectiveSelector] can be created using the [DirectiveSelectorFactory].
98
*
10-
* DirectiveSelector can be created using the [DirectiveSelectorFactory].
11-
*
12-
* The DirectiveSelector supports CSS selectors which do not cross
13-
* element boundaries only. The selectors can have any mix of element-name,
14-
* class-names and attribute-names.
9+
* The DirectiveSelector supports CSS selectors which do not cross element boundaries only. The
10+
* selectors can have any mix of element-name, class-names and attribute-names.
1511
*
1612
* Examples:
1713
*
1814
* * element
1915
* * .class
2016
* * [attribute]
2117
* * [attribute=value]
18+
* * [wildcard-*]
2219
* * element[attribute1][attribute2=value]
2320
* * :contains(/abc/)
21+
* * [*=/abc/]
2422
*/
2523
class DirectiveSelector {
2624
ElementBinderFactory _binderFactory;
@@ -29,6 +27,7 @@ class DirectiveSelector {
2927
var attrSelector;
3028
var textSelector;
3129

30+
/// Parses all the [_directives] so they can be retrieved via [matchElement]
3231
DirectiveSelector(this._directives, this._binderFactory) {
3332
elementSelector = new _ElementSelector('');
3433
attrSelector = <_ContainsSelector>[];
@@ -54,6 +53,10 @@ class DirectiveSelector {
5453
});
5554
}
5655

56+
/**
57+
* [matchElement] returns an [ElementBinder] or a [TemplateElementBinder] configured with all the
58+
* directives triggered by the `node`.
59+
*/
5760
ElementBinder matchElement(dom.Node node) {
5861
assert(node is dom.Element);
5962

@@ -143,8 +146,7 @@ class DirectiveSelector {
143146
return builder.binder;
144147
}
145148

146-
ElementBinder matchComment(dom.Node node) =>
147-
_binderFactory.builder().binder;
149+
ElementBinder matchComment(dom.Node node) => _binderFactory.builder().binder;
148150
}
149151

150152
/**

0 commit comments

Comments
 (0)