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

Commit 0385409

Browse files
vicbtravis@travis-ci.org
authored andcommitted
style: code cleanup
1 parent e4f7e34 commit 0385409

9 files changed

+125
-124
lines changed

lib/core_dom/dom_util.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ List<dom.Node> allNodesBetween(List<dom.Node> nodes) {
3838
// Not every element is sequential if the list of nodes only
3939
// includes the elements. Removing a view also includes
4040
// removing non-element nodes in-between.
41-
for (var j = 0, jj = nodes.length; j < jj; j++) {
41+
for (var j = 0; j < nodes.length; j++) {
4242
dom.Node current = nodes[j];
4343
dom.Node next = j + 1 < nodes.length ? nodes[j + 1] : null;
4444

lib/core_dom/element_binder.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ElementBinder {
8383
bool get hasDirectivesOrEvents =>
8484
_usableDirectiveRefs.isNotEmpty || onEvents.isNotEmpty;
8585

86-
_bindTwoWay(tasks, expression, scope, dstPathFn, controller, formatters, dstExpression) {
86+
void _bindTwoWay(tasks, expression, scope, dstPathFn, controller, formatters, dstExpression) {
8787
var taskId = tasks.registerTask();
8888
Expression expressionFn = _parser(expression);
8989

@@ -120,11 +120,13 @@ class ElementBinder {
120120
}, formatters: formatters);
121121
}
122122

123-
_bindCallback(dstPathFn, controller, expression, scope) {
123+
void _bindCallback(dstPathFn, controller, expression, scope) {
124124
dstPathFn.assign(controller, _parser(expression).bind(scope.context, ScopeLocals.wrapper));
125125
}
126126

127-
_createAttrMappings(directive, scope, List<MappingParts> mappings, nodeAttrs, formatters, tasks) {
127+
128+
void _createAttrMappings(directive, scope, List<MappingParts> mappings, nodeAttrs, formatters,
129+
tasks) {
128130
mappings.forEach((MappingParts p) {
129131
var attrName = p.attrName;
130132
var dstExpression = p.dstExpression;
@@ -199,7 +201,7 @@ class ElementBinder {
199201
});
200202
}
201203

202-
_link(nodeInjector, probe, scope, nodeAttrs, formatters) {
204+
void _link(nodeInjector, probe, scope, nodeAttrs, formatters) {
203205
_usableDirectiveRefs.forEach((DirectiveRef ref) {
204206
var linkTimer;
205207
try {
@@ -245,8 +247,8 @@ class ElementBinder {
245247
});
246248
}
247249

248-
_createDirectiveFactories(DirectiveRef ref, nodeModule, node, nodesAttrsDirectives, nodeAttrs,
249-
visibility) {
250+
void _createDirectiveFactories(DirectiveRef ref, nodeModule, node, nodesAttrsDirectives, nodeAttrs,
251+
visibility) {
250252
if (ref.type == TextMustache) {
251253
nodeModule.bind(TextMustache, toFactory: (Injector injector) {
252254
return new TextMustache(node, ref.value, injector.get(Interpolate),
@@ -281,7 +283,7 @@ class ElementBinder {
281283
}
282284

283285
// Overridden in TemplateElementBinder
284-
_registerViewFactory(node, parentInjector, nodeModule) {
286+
void _registerViewFactory(node, parentInjector, nodeModule) {
285287
nodeModule..bind(ViewPort, toValue: null)
286288
..bind(ViewFactory, toValue: null)
287289
..bind(BoundViewFactory, toValue: null);
@@ -348,7 +350,7 @@ class ElementBinder {
348350
* Private class used for managing controller.attach() calls
349351
*/
350352
class _TaskList {
351-
var onDone;
353+
Function onDone;
352354
final List _tasks = [];
353355
bool isDone = false;
354356

@@ -371,7 +373,7 @@ class _TaskList {
371373
}
372374
}
373375

374-
doneRegistering() {
376+
void doneRegistering() {
375377
completeTask(registerTask());
376378
}
377379
}
@@ -396,7 +398,7 @@ class TaggedTextBinder {
396398
final int offsetIndex;
397399

398400
TaggedTextBinder(this.binder, this.offsetIndex);
399-
toString() => "[TaggedTextBinder binder:$binder offset:$offsetIndex]";
401+
String toString() => "[TaggedTextBinder binder:$binder offset:$offsetIndex]";
400402
}
401403

402404
// Used for the tagging compiler
@@ -414,6 +416,8 @@ class TaggedElementBinder {
414416
textBinders.add(tagged);
415417
}
416418

419+
bool get isDummy => binder == null && textBinders == null && !isTopLevel;
420+
417421
String toString() => "[TaggedElementBinder binder:$binder parentBinderOffset:"
418422
"$parentBinderOffset textBinders:$textBinders]";
419423
}

lib/core_dom/element_binder_builder.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ElementBinderFactory {
3131
* building ElementBinders.
3232
*/
3333
class ElementBinderBuilder {
34-
static RegExp _MAPPING = new RegExp(r'^(\@|=\>\!|\=\>|\<\=\>|\&)\s*(.*)$');
34+
static final RegExp _MAPPING = new RegExp(r'^(@|=>!|=>|<=>|&)\s*(.*)$');
3535

3636
ElementBinderFactory _factory;
3737

@@ -40,7 +40,7 @@ class ElementBinderBuilder {
4040
/// "bind-*" attribute names and values, added by a [DirectiveSelector]
4141
final bindAttrs = <String, String>{};
4242

43-
var decorators = <DirectiveRef>[];
43+
final decorators = <DirectiveRef>[];
4444
DirectiveRef template;
4545
DirectiveRef component;
4646

@@ -74,18 +74,20 @@ class ElementBinderBuilder {
7474
childMode = annotation.children;
7575
}
7676

77-
if (annotation.map != null) annotation.map.forEach((attrName, mapping) {
78-
Match match = _MAPPING.firstMatch(mapping);
79-
if (match == null) {
80-
throw "Unknown mapping '$mapping' for attribute '$attrName'.";
81-
}
82-
var mode = match[1];
83-
var dstPath = match[2];
77+
if (annotation.map != null) {
78+
annotation.map.forEach((attrName, mapping) {
79+
Match match = _MAPPING.firstMatch(mapping);
80+
if (match == null) {
81+
throw "Unknown mapping '$mapping' for attribute '$attrName'.";
82+
}
83+
var mode = match[1];
84+
var dstPath = match[2];
8485

85-
String dstExpression = dstPath.isEmpty ? attrName : dstPath;
86+
String dstExpression = dstPath.isEmpty ? attrName : dstPath;
8687

87-
ref.mappings.add(new MappingParts(attrName, mode, dstExpression, mapping));
88-
});
88+
ref.mappings.add(new MappingParts(attrName, mode, dstExpression, mapping));
89+
});
90+
}
8991
}
9092

9193
/// Creates an returns an [ElementBinder] or a [TemplateElementBinder]

0 commit comments

Comments
 (0)