diff --git a/lib/change_detection/dirty_checking_change_detector.dart b/lib/change_detection/dirty_checking_change_detector.dart index 82cc87100..37be9f29b 100644 --- a/lib/change_detection/dirty_checking_change_detector.dart +++ b/lib/change_detection/dirty_checking_change_detector.dart @@ -793,7 +793,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { if (collection is List) { List list = collection; - for(int index = 0; index < list.length; index++) { + for (int index = 0; index < list.length; index++) { var item = list[index]; if (record == null || !identical(item, record.item)) { record = mismatch(record, item, index); @@ -806,7 +806,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { } } else { int index = 0; - for(var item in collection) { + for (var item in collection) { if (record == null || !identical(item, record.item)) { record = mismatch(record, item, index); maybeDirty = true; diff --git a/lib/core/interpolate.dart b/lib/core/interpolate.dart index 9a976019d..28d09bee7 100644 --- a/lib/core/interpolate.dart +++ b/lib/core/interpolate.dart @@ -11,7 +11,7 @@ class Interpolation { String call(List parts, [_]) { if (parts == null) return seperators.join(''); var str = []; - for(var i = 0, ii = parts.length; i < ii; i++) { + for (var i = 0; i < parts.length; i++) { str.add(seperators[i]); var value = parts[i]; str.add(value == null ? '' : '$value'); @@ -47,7 +47,7 @@ class Interpolate { * - `startSymbol`: The symbol to start interpolation. '{{' by default. * - `endSymbol`: The symbol to end interpolation. '}}' by default. */ - Interpolation call(String template, [bool mustHaveExpression = false, + Interpolation call(String template, [bool mustHaveExpression = false, String startSymbol = '{{', String endSymbol = '}}']) { int startSymbolLength = startSymbol.length; int endSymbolLength = endSymbol.length; diff --git a/lib/core/parser/eval.dart b/lib/core/parser/eval.dart index 5ef3f0e9b..aa0e1aef7 100644 --- a/lib/core/parser/eval.dart +++ b/lib/core/parser/eval.dart @@ -11,7 +11,7 @@ class Chain extends syntax.Chain { Chain(List expressions) : super(expressions); eval(scope, [FilterMap filters]) { var result; - for (int i = 0, length = expressions.length; i < length; i++) { + for (int i = 0; i < expressions.length; i++) { var last = expressions[i].eval(scope, filters); if (last != null) result = last; } diff --git a/lib/core/parser/utils.dart b/lib/core/parser/utils.dart index dfb386fdc..45535acff 100644 --- a/lib/core/parser/utils.dart +++ b/lib/core/parser/utils.dart @@ -21,7 +21,7 @@ class EvalError { /// Evaluate the [list] in context of the [scope]. List evalList(scope, List list, [FilterMap filters]) { int length = list.length; - for(int cacheLength = _evalListCache.length; cacheLength <= length; cacheLength++) { + for (int cacheLength = _evalListCache.length; cacheLength <= length; cacheLength++) { _evalListCache.add(new List(cacheLength)); } List result = _evalListCache[length]; diff --git a/lib/core/scope.dart b/lib/core/scope.dart index 1ab469663..bf8f7d4fa 100644 --- a/lib/core/scope.dart +++ b/lib/core/scope.dart @@ -341,7 +341,7 @@ class Scope { }); childScope = childScope._next; } - if(!_mapEqual(counts, typeCounts)) { + if (!_mapEqual(counts, typeCounts)) { throw 'Streams actual: $counts != bookkeeping: $typeCounts\n' 'Offending scope: [scope: ${this.hashCode}]\n' '${log.join('')}'; @@ -585,7 +585,7 @@ class _Streams { scope = queue.removeFirst(); scopeStreams = scope._streams; assert(scopeStreams._scope == scope); - if(scopeStreams._streams.containsKey(name)) { + if (scopeStreams._streams.containsKey(name)) { var stream = scopeStreams._streams[name]; event._currentScope = scope; stream._fire(event); @@ -702,7 +702,7 @@ class ScopeStream extends async.Stream { } void _fire(ScopeEvent event) { - for(ScopeStreamSubscription subscription in subscriptions) { + for (ScopeStreamSubscription subscription in subscriptions) { try { subscription._onData(event); } catch (e, s) { @@ -844,7 +844,7 @@ class ExpressionVisitor implements Visitor { List values = _toAst(exp.values); assert(keys.length == values.length); var kv = []; - for(var i = 0; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { kv.add('${keys[i]}: ${values[i]}'); } ast = new PureFunctionAST('{${kv.join(', ')}}', new MapFn(keys), values); @@ -951,7 +951,7 @@ class _FilterWrapper extends FunctionApply { argsWatches = new List(length); apply(List values) { - for(var i=0; i < values.length; i++) { + for (var i=0; i < values.length; i++) { var value = values[i]; var lastValue = args[i]; if (!identical(value, lastValue)) { diff --git a/lib/core_dom/block.dart b/lib/core_dom/block.dart index c3241259b..45018f0ba 100644 --- a/lib/core_dom/block.dart +++ b/lib/core_dom/block.dart @@ -78,9 +78,9 @@ class Block implements ElementWrapper { bool preventDefault = false; Function removeDomElements = () { - for(var j = 0, jj = elements.length; j < jj; j++) { + for (var j = 0; j < elements.length; j++) { dom.Node current = elements[j]; - dom.Node next = j+1 < jj ? elements[j+1] : null; + dom.Node next = j+1 < elements.length ? elements[j+1] : null; while(next != null && current.nextNode != next) { current.nextNode.remove(); diff --git a/lib/core_dom/block_factory.dart b/lib/core_dom/block_factory.dart index 982f804ed..c48af151a 100644 --- a/lib/core_dom/block_factory.dart +++ b/lib/core_dom/block_factory.dart @@ -55,7 +55,7 @@ class BlockFactory { var preRenderedIndexOffset = 0; var directiveDefsByName = {}; - for (int i = 0, ii = directivePositions.length; i < ii;) { + for (int i = 0; i < directivePositions.length;) { int index = directivePositions[i++]; List directiveRefs = directivePositions[i++]; @@ -140,7 +140,7 @@ class BlockFactory { nodeModule.factory(NgAttrMustacheDirective, (Injector injector) { var scope = injector.get(Scope); var interpolate = injector.get(Interpolate); - for(var ref in nodesAttrsDirectives) { + for (var ref in nodesAttrsDirectives) { new NgAttrMustacheDirective(nodeAttrs, ref.value, interpolate, scope, injector.get(AstParser), injector.get(FilterMap)); } @@ -209,7 +209,7 @@ class BlockFactory { } } } - for(var map in ref.mappings) { + for (var map in ref.mappings) { var notify; if (attachDelayStatus != null) { var index = attachDelayStatus.length; diff --git a/lib/core_dom/compiler.dart b/lib/core_dom/compiler.dart index 961fa6dfd..6a52ac8d1 100644 --- a/lib/core_dom/compiler.dart +++ b/lib/core_dom/compiler.dart @@ -26,7 +26,7 @@ class Compiler { cursorAlreadyAdvanced = false; - for (var j = 0, jj = declaredDirectiveRefs.length; j < jj; j++) { + for (var j = 0; j < declaredDirectiveRefs.length; j++) { DirectiveRef directiveRef = declaredDirectiveRefs[j]; NgAnnotation annotation = directiveRef.annotation; var blockFactory = null; @@ -42,11 +42,11 @@ class Compiler { domCursor, templateCursor, directiveRef, remainingDirectives, directives); - j = jj; // stop processing further directives since they belong to transclusion; - } - if (usableDirectiveRefs == null) { - usableDirectiveRefs = []; + // stop processing further directives since they belong to + // transclusion + j = declaredDirectiveRefs.length; } + if (usableDirectiveRefs == null) usableDirectiveRefs = []; directiveRef.blockFactory = blockFactory; createMappings(directiveRef); usableDirectiveRefs.add(directiveRef); @@ -178,7 +178,7 @@ class Compiler { scope.watch( dstExpression, (outboundValue, _) { - if(!blockOutbound) { + if (!blockOutbound) { blockInbound = true; scope.rootScope.runAsync(() => blockInbound = false); expressionFn.assign(scope.context, outboundValue); diff --git a/lib/core_dom/node_cursor.dart b/lib/core_dom/node_cursor.dart index 33fefd2d4..2405fe0a4 100644 --- a/lib/core_dom/node_cursor.dart +++ b/lib/core_dom/node_cursor.dart @@ -12,7 +12,7 @@ class NodeCursor { cursorSize() => 1; macroNext() { - for(var i = 0, ii = cursorSize(); i < ii; i++, index++){} + for (var i = 0, ii = cursorSize(); i < ii; i++, index++){} return this.isValid(); } @@ -75,7 +75,7 @@ class NodeCursor { remove() { var nodes = nodeList(); - for (var i = 0, ii = nodes.length; i < ii; i++) { + for (var i = 0; i < nodes.length; i++) { // NOTE(deboer): If elements is a list of child nodes on a node, then // calling Node.remove() may also remove it from the list. Thus, we // call elements.removeAt first so only one node is removed. diff --git a/lib/core_dom/selector.dart b/lib/core_dom/selector.dart index 83c69ac66..2492d0608 100644 --- a/lib/core_dom/selector.dart +++ b/lib/core_dom/selector.dart @@ -289,7 +289,7 @@ DirectiveSelector directiveSelectorFactory(DirectiveMap directives) { // Select .name if ((element.classes) != null) { - for(var name in element.classes) { + for (var name in element.classes) { classes[name] = true; partialSelection = elementSelector.selectClass(directiveRefs, partialSelection, element, name); @@ -299,7 +299,7 @@ DirectiveSelector directiveSelectorFactory(DirectiveMap directives) { // Select [attributes] element.attributes.forEach((attrName, value) { attrs[attrName] = value; - for(var k = 0; k < attrSelector.length; k++) { + for (var k = 0; k < attrSelector.length; k++) { _ContainsSelector selectorRegExp = attrSelector[k]; if (selectorRegExp.regexp.hasMatch(value)) { // this directive is matched on any attribute name, and so @@ -333,7 +333,7 @@ DirectiveSelector directiveSelectorFactory(DirectiveMap directives) { break; case 3: // Text Node var value = node.nodeValue; - for(var k = 0; k < textSelector.length; k++) { + for (var k = 0; k < textSelector.length; k++) { var selectorRegExp = textSelector[k]; if (selectorRegExp.regexp.hasMatch(value)) { diff --git a/lib/directive/input_select.dart b/lib/directive/input_select.dart index d74e1ef94..af568b30a 100644 --- a/lib/directive/input_select.dart +++ b/lib/directive/input_select.dart @@ -140,8 +140,8 @@ class _SelectMode { get _options => select.querySelectorAll('option'); _forEachOption(fn, [quiteOnReturn = false]) { - for(var os = _options, i = 0, ii = os.length; i < ii; i++) { - var retValue = fn(os[i], i); + for (var i = 0; i < _options.length; i++) { + var retValue = fn(_options[i], i); if (quiteOnReturn && retValue != null) return retValue; } return null; diff --git a/lib/directive/ng_model.dart b/lib/directive/ng_model.dart index 42388645d..712bc7783 100644 --- a/lib/directive/ng_model.dart +++ b/lib/directive/ng_model.dart @@ -18,7 +18,7 @@ class NgModel extends NgControl implements NgAttachAware { BoundGetter getter = ([_]) => null; BoundSetter setter = (_, [__]) => null; - var _lastValue; + var _lastValue; String _exp; final _validators = []; @@ -206,7 +206,7 @@ class InputTextLikeDirective { ..onChange.listen(processValue) ..onInput.listen(processValue) ..onBlur.listen((e) { - if(ngModel.touched == null || ngModel.touched == false) { + if (ngModel.touched == null || ngModel.touched == false) { ngModel.touched = true; } }); @@ -228,9 +228,9 @@ class InputTextLikeDirective { * * * Model: - * + * * num myModel; - * + * * This creates a two-way binding between the input and the named model property * (e.g., myModel in the example above). When processing the input, its value is * read as a [num], via the [dom.InputElement.valueAsNumber] field. If the input @@ -248,21 +248,21 @@ class InputNumberLikeDirective { num get typedValue => inputElement.valueAsNumber; void set typedValue(num value) { - // [chalin, 2014-02-16] This post + // [chalin, 2014-02-16] This post // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-January/024829.html // suggests that setting `valueAsNumber` to null should clear the field, but // it does not. [TODO: put BUG/ISSUE number here]. We implement a // workaround by setting `value`. Clean-up once the bug is fixed. if (value == null) { inputElement.value = null; - } else { + } else { inputElement.valueAsNumber = value; } } InputNumberLikeDirective(dom.Element this.inputElement, this.ngModel, this.scope) { ngModel.render = (value) { - if (value != typedValue + if (value != typedValue && (value == null || value is num && !value.isNaN)) { typedValue = value; } diff --git a/lib/directive/ng_repeat.dart b/lib/directive/ng_repeat.dart index 8fc0e0b04..603b413c1 100644 --- a/lib/directive/ng_repeat.dart +++ b/lib/directive/ng_repeat.dart @@ -107,6 +107,7 @@ class NgRepeatDirective extends AbstractNgRepeatDirective { * digest cycle and will not update on changes to the model. * */ +@deprecated @NgDirective( children: NgAnnotation.TRANSCLUDE_CHILDREN, selector: '[ng-shallow-repeat]', @@ -120,7 +121,7 @@ class NgShallowRepeatDirective extends AbstractNgRepeatDirective { AstParser astParser) : super(blockHole, boundBlockFactory, scope, parser, astParser) { - print('DEPRICATED: [ng-shallow-repeat] use [ng-repeat]'); + print('DEPRECATED: [ng-shallow-repeat] use [ng-repeat]'); } } @@ -218,7 +219,7 @@ abstract class AbstractNgRepeatDirective { } } // remove existing items - _rows.forEach((key, row){ + _rows.forEach((key, row) { row.block.remove(); row.scope.destroy(); }); @@ -236,7 +237,7 @@ abstract class AbstractNgRepeatDirective { List<_Row> newRowOrder = _computeNewRows(collection, trackById); - for (var index = 0, length = collection.length; index < length; index++) { + for (var index = 0; index < collection.length; index++) { var value = collection.elementAt(index); _Row row = newRowOrder[index]; @@ -263,14 +264,14 @@ abstract class AbstractNgRepeatDirective { childContext[_valueIdentifier] = value; } var first = (index == 0); - var last = (index == (length - 1)); + var last = (index == collection.length - 1); childContext - ..[r'$index'] = index - ..[r'$first'] = (index == 0) - ..[r'$last'] = (index == (length - 1)) - ..[r'$middle'] = !first && !last - ..[r'$odd'] = index & 1 == 1 - ..[r'$even'] = index & 1 == 0; + ..[r'$index'] = index + ..[r'$first'] = first + ..[r'$last'] = last + ..[r'$middle'] = !first && !last + ..[r'$odd'] = index & 1 == 1 + ..[r'$even'] = index & 1 == 0; if (row.startNode == null) { var block = _boundBlockFactory(childScope); diff --git a/lib/mock/test_bed.dart b/lib/mock/test_bed.dart index d0e23b49b..ac1b5ddc8 100644 --- a/lib/mock/test_bed.dart +++ b/lib/mock/test_bed.dart @@ -36,7 +36,7 @@ class TestBed { */ Element compile(html, {Scope scope, DirectiveMap directives}) { var injector = this.injector; - if(scope != null) { + if (scope != null) { injector = injector.createChild([new Module()..value(Scope, scope)]); } if (html is String) { @@ -63,7 +63,7 @@ class TestBed { var div = new DivElement(); div.setInnerHtml(html, treeSanitizer: new NullTreeSanitizer()); var nodes = []; - for(var node in div.nodes) { + for (var node in div.nodes) { nodes.add(node); } return nodes; diff --git a/test/_specs.dart b/test/_specs.dart index 5e79467da..88b46e6e9 100644 --- a/test/_specs.dart +++ b/test/_specs.dart @@ -83,7 +83,7 @@ class Expect { toEqualSelect(options) { var actualOptions = []; - for(var option in actual.querySelectorAll('option')) { + for (var option in actual.querySelectorAll('option')) { if (option.selected) { actualOptions.add([option.value]); } else { diff --git a/test/change_detection/dirty_checking_change_detector_spec.dart b/test/change_detection/dirty_checking_change_detector_spec.dart index 23c0a0a26..0d732f2dc 100644 --- a/test/change_detection/dirty_checking_change_detector_spec.dart +++ b/test/change_detection/dirty_checking_change_detector_spec.dart @@ -545,7 +545,7 @@ class CollectionRecordMatcher extends Matcher { var equals = true; if (collection != null) { CollectionItem collectionItem = changeRecord.collectionHead; - for(var item in collection) { + for (var item in collection) { if (collectionItem == null) { equals = false; diffs.add('collection too short: $item'); @@ -569,7 +569,7 @@ class CollectionRecordMatcher extends Matcher { var equals = true; if (additions != null) { AddedItem addedItem = changeRecord.additionsHead; - for(var item in additions) { + for (var item in additions) { if (addedItem == null) { equals = false; diffs.add('additions too short: $item'); @@ -593,7 +593,7 @@ class CollectionRecordMatcher extends Matcher { var equals = true; if (moves != null) { MovedItem movedItem = changeRecord.movesHead; - for(var item in moves) { + for (var item in moves) { if (movedItem == null) { equals = false; diffs.add('moves too short: $item'); @@ -617,7 +617,7 @@ class CollectionRecordMatcher extends Matcher { var equals = true; if (removals != null) { RemovedItem removedItem = changeRecord.removalsHead; - for(var item in removals) { + for (var item in removals) { if (removedItem == null) { equals = false; diffs.add('removes too short: $item'); @@ -678,7 +678,7 @@ class MapRecordMatcher extends Matcher { var equals = true; if (map != null) { KeyValue mapKeyValue = changeRecord.mapHead; - for(var item in map) { + for (var item in map) { if (mapKeyValue == null) { equals = false; diffs.add('map too short: $item'); @@ -702,7 +702,7 @@ class MapRecordMatcher extends Matcher { var equals = true; if (additions != null) { AddedKeyValue addedKeyValue = changeRecord.additionsHead; - for(var item in additions) { + for (var item in additions) { if (addedKeyValue == null) { equals = false; diffs.add('additions too short: $item'); @@ -726,7 +726,7 @@ class MapRecordMatcher extends Matcher { var equals = true; if (changes != null) { ChangedKeyValue movedKeyValue = changeRecord.changesHead; - for(var item in changes) { + for (var item in changes) { if (movedKeyValue == null) { equals = false; diffs.add('changes too short: $item'); @@ -750,7 +750,7 @@ class MapRecordMatcher extends Matcher { var equals = true; if (removals != null) { RemovedKeyValue removedKeyValue = changeRecord.removalsHead; - for(var item in removals) { + for (var item in removals) { if (removedKeyValue == null) { equals = false; diffs.add('rechanges too short: $item'); diff --git a/test/core/scope_spec.dart b/test/core/scope_spec.dart index 15554f4e9..efe87fc11 100644 --- a/test/core/scope_spec.dart +++ b/test/core/scope_spec.dart @@ -362,7 +362,7 @@ main() => describe('scope', () { List listeners; List steps; var random = new Random(); - for(var i = 0; i < 1000; i++) { + for (var i = 0; i < 1000; i++) { if (i % 10 == 0) { scopes = [root.createChild(null)]; listeners = []; diff --git a/test/core_dom/cookies_spec.dart b/test/core_dom/cookies_spec.dart index e2d2ab36c..c4c2d2aa5 100644 --- a/test/core_dom/cookies_spec.dart +++ b/test/core_dom/cookies_spec.dart @@ -96,7 +96,7 @@ main() => describe('cookies', () { inject((ExceptionHandler exceptionHandler) { var i, longVal = '', cookieStr; - for(i=0; i<4083; i++) { + for (i=0; i<4083; i++) { longVal += 'r'; // Can't do + due to dartbug.com/14281 } diff --git a/test/core_dom/selector_spec.dart b/test/core_dom/selector_spec.dart index f77975d3c..da45baa83 100644 --- a/test/core_dom/selector_spec.dart +++ b/test/core_dom/selector_spec.dart @@ -212,7 +212,7 @@ class DirectiveInfosMatcher extends Matcher { bool matches(directiveRefs, matchState) { var pass = expected.length == directiveRefs.length; if (pass) { - for(var i = 0, ii = expected.length; i < ii; i++) { + for (var i = 0, ii = expected.length; i < ii; i++) { DirectiveRef directiveRef = directiveRefs[i]; var expectedMap = expected[i]; diff --git a/test/jasmine_syntax.dart b/test/jasmine_syntax.dart index cc019cdf7..13def2068 100644 --- a/test/jasmine_syntax.dart +++ b/test/jasmine_syntax.dart @@ -1,4 +1,4 @@ -library jamine; +library jasmine; import 'package:unittest/unittest.dart' as unit; import 'package:angular/utils.dart' as utils;