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

Commit 68e21a6

Browse files
committed
Fixed some more issues
1 parent 82dd42d commit 68e21a6

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

lib/directive/ng_model.dart

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class NgModel extends NgControl implements AttachAware {
4545

4646
NgModel(this._scope, NgElement element, Injector injector, NodeAttrs attrs,
4747
Animate animate)
48-
: super(element, injector, animate)
48+
: super(element, injector, animate)
4949
{
5050
_expression = attrs["ng-model"];
5151
watchCollection = false;
@@ -355,7 +355,8 @@ class InputTextLike {
355355
if (value == null) value = '';
356356

357357
var currentValue = typedValue;
358-
if (value != currentValue && !(value is num && currentValue is num && value.isNaN && currentValue.isNaN)) {
358+
if (value != currentValue && !(value is num && currentValue is num &&
359+
value.isNaN && currentValue.isNaN)) {
359360
typedValue = value;
360361
}
361362
});
@@ -480,7 +481,9 @@ class NgBindTypeForDateLike {
480481
@NgAttr('ng-bind-type')
481482
void set idlAttrKind(final String _kind) {
482483
String kind = _kind == null ? DEFAULT : _kind.toLowerCase();
483-
if (!VALID_VALUES.contains(kind)) throw "Unsupported ng-bind-type attribute value '$_kind'; " "it should be one of $VALID_VALUES";
484+
if (!VALID_VALUES.contains(kind))
485+
throw "Unsupported ng-bind-type attribute value '$_kind'; "
486+
"it should be one of $VALID_VALUES";
484487
_idlAttrKind = kind;
485488
}
486489

@@ -583,14 +586,16 @@ class NgBindTypeForDateLike {
583586
@Decorator(selector: 'input[type=month][ng-model]', module: InputDateLike.moduleFactory)
584587
@Decorator(selector: 'input[type=week][ng-model]', module: InputDateLike.moduleFactory)
585588
class InputDateLike {
586-
static Module moduleFactory() => new Module()..factory(NgBindTypeForDateLike, (Injector i) => new NgBindTypeForDateLike(i.get(dom.Element)));
589+
static Module moduleFactory() => new Module()..factory(NgBindTypeForDateLike,
590+
(Injector i) => new NgBindTypeForDateLike(i.get(dom.Element)));
587591
final dom.InputElement inputElement;
588592
final NgModel ngModel;
589593
final NgModelOptions ngModelOptions;
590594
final Scope scope;
591595
NgBindTypeForDateLike ngBindType;
592596

593-
InputDateLike(dom.Element this.inputElement, this.ngModel, this.scope, this.ngBindType, this.ngModelOptions) {
597+
InputDateLike(dom.Element this.inputElement, this.ngModel, this.scope,
598+
this.ngBindType, this.ngModelOptions) {
594599
if (inputElement.type == 'datetime-local') {
595600
ngBindType.idlAttrKind = NgBindTypeForDateLike.NUMBER;
596601
}
@@ -744,14 +749,17 @@ class NgFalseValue {
744749
* `009`, `00A`, `00Z`, `010`, and so on using more than 3 characters for the
745750
* name when the counter overflows.
746751
*/
747-
@Decorator(selector: 'input[type=radio][ng-model]', module: NgValue.moduleFactory)
752+
@Decorator(
753+
selector: 'input[type=radio][ng-model]',
754+
module: NgValue.moduleFactory)
748755
class InputRadio {
749756
final dom.RadioButtonInputElement radioButtonElement;
750757
final NgModel ngModel;
751758
final NgValue ngValue;
752759
final Scope scope;
753760

754-
InputRadio(dom.Element this.radioButtonElement, this.ngModel, this.scope, this.ngValue, NodeAttrs attrs) {
761+
InputRadio(dom.Element this.radioButtonElement, this.ngModel,
762+
this.scope, this.ngValue, NodeAttrs attrs) {
755763
// If there's no "name" set, we'll set a unique name. This ensures
756764
// less surprising behavior about which radio buttons are grouped together.
757765
if (attrs['name'] == '' || attrs['name'] == null) {

lib/directive/ng_model_options.dart

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,48 @@ class NgModelOptions {
77
int _debounceChangeValue = null;
88
int _debounceInputValue = null;
99

10-
static const String DEBOUNCE_DEFAULT_KEY = "default";
11-
static const String DEBOUNCE_BLUR_KEY = "blur";
12-
static const String DEBOUNCE_CHANGE_KEY = "change";
13-
static const String DEBOUNCE_INPUT_KEY = "input";
10+
static const String _DEBOUNCE_DEFAULT_KEY = "default";
11+
static const String _DEBOUNCE_BLUR_KEY = "blur";
12+
static const String _DEBOUNCE_CHANGE_KEY = "change";
13+
static const String _DEBOUNCE_INPUT_KEY = "input";
1414

1515
NgModelOptions(NodeAttrs attrs) {
1616
Map options = convert.JSON.decode(attrs["ng-model-options"].replaceFirst("debounce", "'debounce'").replaceAll("'", "\""));
1717

18-
if (options["debounce"].containsKey(DEBOUNCE_DEFAULT_KEY)) _debounceDefaultValue = options["debounce"][DEBOUNCE_DEFAULT_KEY];
19-
_debounceBlurValue = options["debounce"][DEBOUNCE_BLUR_KEY];
20-
_debounceChangeValue = options["debounce"][DEBOUNCE_CHANGE_KEY];
21-
_debounceInputValue = options["debounce"][DEBOUNCE_INPUT_KEY];
18+
if (options["debounce"].containsKey(_DEBOUNCE_DEFAULT_KEY)){
19+
_debounceDefaultValue = options["debounce"][_DEBOUNCE_DEFAULT_KEY];
20+
}
21+
_debounceBlurValue = options["debounce"][_DEBOUNCE_BLUR_KEY];
22+
_debounceChangeValue = options["debounce"][_DEBOUNCE_CHANGE_KEY];
23+
_debounceInputValue = options["debounce"][_DEBOUNCE_INPUT_KEY];
2224
}
2325

2426
async.Timer _blurTimer;
2527
void executeBlurFunc(func()) {
2628
var delay = _debounceBlurValue == null ? _debounceDefaultValue : _debounceBlurValue;
27-
_runFuncDebounced(delay, func, (timer)=>_blurTimer = timer,_blurTimer);
29+
_blurTimer = _runFuncDebounced(delay, func,_blurTimer);
2830
}
2931

3032
async.Timer _changeTimer;
3133
void executeChangeFunc(func()) {
3234
var delay = _debounceChangeValue == null ? _debounceDefaultValue : _debounceChangeValue;
33-
_runFuncDebounced(delay, func, (timer)=>_changeTimer = timer, _changeTimer);
35+
_changeTimer = _runFuncDebounced(delay, func, _changeTimer);
3436
}
3537

3638
async.Timer _inputTimer;
3739
void executeInputFunc(func()) {
3840
var delay = _debounceInputValue == null ? _debounceDefaultValue : _debounceInputValue;
39-
_runFuncDebounced(delay, func, (timer) => _inputTimer = timer, _inputTimer);
41+
_inputTimer = _runFuncDebounced(delay, func, _inputTimer);
4042
}
4143

42-
void _runFuncDebounced(int delay, func(), setTimer(async.Timer timer), async.Timer timer){
44+
async.Timer _runFuncDebounced(int delay, func(), async.Timer timer){
4345
if (timer != null && timer.isActive) timer.cancel();
4446

4547
if(delay == 0){
4648
func();
47-
}
48-
else{
49-
setTimer(new async.Timer(new Duration(milliseconds: delay), func));
49+
return null;
50+
} else {
51+
return new async.Timer(new Duration(milliseconds: delay), func);
5052
}
5153
}
5254
}

0 commit comments

Comments
 (0)