Permalink
Browse files

doc: Strong-Mode added

  • Loading branch information...
MikeMitterer committed Nov 15, 2016
1 parent b6f72aa commit 5e58b224c39f93dd240cfc2c456f9faa6c0e84a1
Showing with 99 additions and 75 deletions.
  1. +1 −1 .analysis_options
  2. +1 −0 lib/mdldialog.dart
  3. +2 −2 lib/mdlutils.dart
  4. +1 −1 lib/src/animation/animation.dart
  5. +2 −2 lib/src/application/components/MaterialInclude.dart
  6. +2 −2 lib/src/application/modules/DomRenderer.dart
  7. +2 −2 lib/src/application/modules/EventCompiler.dart
  8. +2 −2 lib/src/components/MaterialCheckbox.dart
  9. +2 −2 lib/src/components/MaterialDataTable.dart
  10. +2 −2 lib/src/components/MaterialLabelfield.dart
  11. +2 −2 lib/src/components/MaterialLayout.dart
  12. +4 −4 lib/src/components/MaterialMenu.dart
  13. +5 −5 lib/src/components/MaterialRadio.dart
  14. +2 −2 lib/src/components/MaterialRipple.dart
  15. +1 −1 lib/src/components/MaterialSlider.dart
  16. +2 −2 lib/src/components/MaterialSwitch.dart
  17. +3 −3 lib/src/components/MaterialTextfield.dart
  18. +1 −1 lib/src/components/MaterialTooltip.dart
  19. +4 −4 lib/src/core/ConvertValue.dart
  20. +1 −1 lib/src/dialog/MaterialAlertDialog.dart
  21. +1 −1 lib/src/dialog/MaterialConfirmDialog.dart
  22. +1 −1 lib/src/dialog/MaterialDialog.dart
  23. +2 −2 lib/src/dialog/MaterialNotification.dart
  24. +2 −2 lib/src/dialog/MaterialSnackbar.dart
  25. +3 −3 lib/src/directive/components/MaterialObserve.dart
  26. +1 −1 lib/src/directive/components/model/ModelObserver.dart
  27. +7 −5 lib/src/dnd/MaterialDropZone.dart
  28. +8 −1 lib/src/flux/action.dart
  29. +1 −1 lib/src/flux/mixin.dart
  30. +5 −0 lib/src/formatter/components/MaterialFormatter.dart
  31. +12 −5 lib/src/formatter/utils/FallbackFormatter.dart
  32. +1 −1 lib/src/observable/ObservableList.dart
  33. +3 −3 lib/src/observable/ObservableProperty.dart
  34. +1 −1 lib/src/template/MdlTemplateComponent.dart
  35. +1 −1 lib/src/template/components/MaterialRepeat.dart
  36. +2 −2 test/unit/flux/ActionBus_test.dart
  37. +4 −2 test/unit/flux/Emitter_test.dart
  38. +1 −1 test/unit/utils/observables_test.dart
  39. +1 −1 tool/grind.dart
View
@@ -1,5 +1,5 @@
analyzer:
# strong-mode: true
strong-mode: true
exclude:
- lib/_templates/**
View
@@ -23,6 +23,7 @@ import 'dart:html' as dom;
import 'dart:async';
import 'package:logging/logging.dart';
import 'package:mustache/mustache.dart';
import 'package:validate/validate.dart';
import 'package:di/di.dart' as di;
View
@@ -108,12 +108,12 @@ class _DataValue {
return _value;
// IntelliJ needs the "as String" to support autocompletion...
} else if((_value.toString() as String).toLowerCase() == "true" ||
} else if(_value.toString().toLowerCase() == "true" ||
_value.toString() == "1" || _value.toString() == "yes" ) {
return true;
} else if((_value.toString() as String).isEmpty) {
} else if(_value.toString().isEmpty) {
return handleEmptyStringAs;
}
@@ -317,7 +317,7 @@ class MdlAnimation {
completer.complete();
};
subscription = element.on["animationend"].listen(_onAnimationEnd);
subscription = element.on["animationend"].listen(_onAnimationEnd) as StreamSubscription<dom.EventListener>;
}
});
@@ -60,7 +60,7 @@ class MaterialInclude extends MdlComponent {
MaterialInclude.fromElement(final dom.HtmlElement element,final di.Injector injector)
: _renderer = injector.get(DomRenderer), super(element,injector) {
onLoadEnd = _controller.stream;
onLoadEnd = _controller.stream as Stream<MaterialContentEvent>;
_init();
}
@@ -92,7 +92,7 @@ class MaterialInclude extends MdlComponent {
/// loads the given {url} and returns the content
Future<String> _load(final String url) {
final Completer completer = new Completer();
final Completer<String> completer = new Completer<String>();
final dom.HttpRequest request = new dom.HttpRequest();
request.open("GET", url);
@@ -60,7 +60,7 @@ class DomRenderer {
_logger.fine("Start with rendering process...");
final Completer completer = new Completer();
final Completer<dom.Element> completer = new Completer<dom.Element>();
// add the render-function to the list where the "new Future" can pick it
_renderFunctions.insert(0, () {
@@ -128,7 +128,7 @@ class DomRenderer {
//_logger.info("Content: $content");
final Completer completer = new Completer();
final Completer<dom.Element> completer = new Completer<dom.Element>();
// add the render-function to the list where the "new Future" can pick it
_renderFunctions.insert(0, () {
@@ -28,7 +28,7 @@ typedef _EventHandler(final dom.Element element,invoke(final dom.Event event));
*/
@di.Injectable()
class EventCompiler {
final Logger _logger = new Logger('mdlapplication.EventCompiler');
static final Logger _logger = new Logger('mdlapplication.EventCompiler');
static final Map<String,_EventHandler> datasets = {
'mdl-abort': _onAbort,
@@ -377,7 +377,7 @@ class EventCompiler {
/// Same as {EventCompiler} but uses MdlComponent as basis.
/// {MdlComponent} already brings it's dom.Element
class MdlEventCompiler extends EventCompiler {
final Logger _logger = new Logger('mdltemplatecomponents.MdlEventCompiler');
static final Logger _logger = new Logger('mdltemplatecomponents.MdlEventCompiler');
Future compile(final MdlComponent component) async {
final dom.Element element = component.element;
@@ -121,14 +121,14 @@ class MaterialCheckbox extends MdlComponent with FallbackFormatter {
Validate.notNull(v);
final dom.HtmlElement _label = element.querySelector(".${_cssClasses.LABEL}");
_label?.text = formatterFor(_label).format(v.trim());
_label?.text = formatterFor(_label,element).format(v.trim());
}
String get value => (inputElement != null ? inputElement.value.trim() : "");
void set value(final String value) {
Validate.notNull(value);
inputElement.value = formatterFor(inputElement).format(value);
inputElement.value = formatterFor(inputElement,element).format(value);
}
//- private -----------------------------------------------------------------------------------
@@ -125,12 +125,12 @@ class MaterialDataTable extends MdlComponent {
checkbox.checked = row.classes.contains(_cssClasses.IS_SELECTED);
// .addEventListener('change', -- .onChange.listen(<Event>);
checkbox.onChange.listen( _selectRow(checkbox, row, null));
checkbox.onChange.listen( (_) => _selectRow(checkbox, row, null));
} else if (optRows != null && optRows.isNotEmpty) {
// .addEventListener('change', -- .onChange.listen(<Event>);
checkbox.onChange.listen( _selectRow(checkbox, null, optRows));
checkbox.onChange.listen( (_) => _selectRow(checkbox, null, optRows));
}
label.append(checkbox);
@@ -52,7 +52,7 @@ class MaterialLabelfield extends MdlComponent with FallbackFormatter {
Validate.notNull(v);
final dom.HtmlElement _label = element.querySelector(".${_cssClasses.LABEL}");
_label?.text = formatterFor(_label).format(v.trim());
_label?.text = formatterFor(_label,element).format(v.trim());
}
String get value {
@@ -65,7 +65,7 @@ class MaterialLabelfield extends MdlComponent with FallbackFormatter {
Validate.notNull(v);
final dom.HtmlElement _text = element.querySelector(".${_cssClasses.TEXT}");
_text?.text = formatterFor(_text).format(v);
_text?.text = formatterFor(_text,element).format(v);
}
// - EventHandler -----------------------------------------------------------------------------
@@ -185,8 +185,8 @@ class MaterialLayout extends MdlComponent {
}
});
dom.window.onPageShow.listen( (final dom.PageTransitionEvent event) {
if(event.persisted) {
dom.window.onPageShow.listen( (final dom.Event event) {
if(event is dom.PageTransitionEvent && event.persisted) {
// when page is loaded from back/forward cache
// trigger repaint to let layout scroll in safari
element.style.overflowY = 'hidden';
@@ -64,7 +64,7 @@ class MaterialMenu extends MdlComponent {
dom.DivElement _outline;
dom.Element _forElement;
StreamSubscription _animationStream = null;
StreamSubscription<dom.TransitionEvent> _animationStream = null;
dom.Element get forElement {
if(_forElement == null) {
@@ -88,8 +88,8 @@ class MaterialMenu extends MdlComponent {
if (element != null && _container != null && _outline != null ) {
// Measure the inner element.
final height = element.getBoundingClientRect().height as num;
final width = element.getBoundingClientRect().width as num;
final num height = element.getBoundingClientRect().height;
final num width = element.getBoundingClientRect().width;
// Apply the inner element's size to the container and outline.
_container.style.width = "${width}px";
@@ -461,7 +461,7 @@ class MaterialMenu extends MdlComponent {
void _addAnimationEndListener() {
/// Cleanup function to remove animation listeners.
final _removeAnimationEndListener = (_) {
final _removeAnimationEndListener = (final dom.TransitionEvent event) {
if(_animationStream != null) {
_animationStream.cancel();
_animationStream = null;
@@ -117,14 +117,14 @@ class MaterialRadio extends MdlComponent with FallbackFormatter {
Validate.notNull(v);
final dom.HtmlElement _label = element.querySelector(".${_cssClasses.LABEL}");
_label?.text = formatterFor(_label).format(v.trim());
_label?.text = formatterFor(_label,element).format(v.trim());
}
String get value => inputElement.value;
void set value(final String value) {
Validate.notNull(value);
inputElement.value = formatterFor(inputElement).format(value);
inputElement.value = formatterFor(inputElement,element).format(value);
}
//- private -----------------------------------------------------------------------------------
@@ -317,7 +317,7 @@ class MaterialRadioGroup extends MdlComponent {
bool get hasValue {
bool _hasValue = false;
element.children.forEach((final dom.HtmlElement child) {
element.children.forEach((final dom.Element child) {
final MaterialRadio radio = MaterialRadio.widget(child.querySelector(".${_cssClasses.INPUT}"));
if(radio != null && radio.checked) {
_hasValue = true;
@@ -328,7 +328,7 @@ class MaterialRadioGroup extends MdlComponent {
String get value {
String _value = "";
element.children.forEach((final dom.HtmlElement child) {
element.children.forEach((final dom.Element child) {
final MaterialRadio radio = MaterialRadio.widget(child.querySelector(".${_cssClasses.INPUT}"));
if(radio != null && radio.checked) {
@@ -340,7 +340,7 @@ class MaterialRadioGroup extends MdlComponent {
}
void set value(final String val) {
element.children.forEach((final dom.HtmlElement child) {
element.children.forEach((final dom.Element child) {
final MaterialRadio radio = MaterialRadio.widget(child.querySelector(".${_cssClasses.INPUT}"));
if(radio != null) {
@@ -189,8 +189,8 @@ class MaterialRipple extends MdlComponent {
if (event == dom.MouseEvent &&
(event as dom.MouseEvent).client.x == 0 && (event as dom.MouseEvent).client.y == 0) {
x = ((bound.width / 2) as double).round();
y = ((bound.height / 2) as double).round();
x = (bound.width / 2).round();
y = (bound.height / 2).round();
} else {
@@ -187,7 +187,7 @@ class MaterialSlider extends MdlComponent {
relatedTarget: event.target,
button: 0,
clientX: event.client.x.toInt(),
clientY: (element.getBoundingClientRect().topLeft.y as num).toInt());
clientY: element.getBoundingClientRect().topLeft.y.toInt());
element.dispatchEvent(newEvent);
}
@@ -112,15 +112,15 @@ class MaterialSwitch extends MdlComponent with FallbackFormatter {
Validate.notNull(v);
final dom.HtmlElement _label = element.querySelector(".${_cssClasses.LABEL}");
_label?.text = formatterFor(_label).format(v.trim());
_label?.text = formatterFor(_label,element).format(v.trim());
}
/// Returns the value for the given [inputElement]
String get value => inputElement.value.trim();
void set value(final String value) {
Validate.notNull(value);
inputElement.value = formatterFor(inputElement).format(value);
inputElement.value = formatterFor(inputElement,element).format(value);
}
//- private -----------------------------------------------------------------------------------
@@ -110,7 +110,7 @@ class MaterialTextfield extends MdlComponent with FallbackFormatter {
Validate.notNull(v);
final dom.HtmlElement _label = labelElement;
_label?.text = formatterFor(_label).format(v.trim());
_label?.text = formatterFor(_label,element).format(v.trim());
}
/// Returns text field value
@@ -202,9 +202,9 @@ class MaterialTextfield extends MdlComponent with FallbackFormatter {
/// Handle input being entered.
void _onKeyDown(final dom.KeyboardEvent event) {
final input = element;
//final input = element;
final currentRowCount = input.value.split('\n').length;
final currentRowCount = value.split('\n').length;
if (event.keyCode == 13) {
if (currentRowCount >= _maxRows) {
event.preventDefault();
@@ -118,7 +118,7 @@ class MaterialTooltip extends MdlComponent {
if (element.classes.contains(_cssClasses.LEFT) || element.classes.contains(_cssClasses.RIGHT)) {
left = (props.width / 2);
left = (props.width ~/ 2);
if (top + marginTop < 0) {
element.style.top = "0";
element.style.marginTop = "0";
@@ -29,11 +29,11 @@ class ConvertValue {
}
if(value is bool) {
return value as bool;
return value;
}
if(value is num) {
return (value as num).toInt() == 1;
return value.toInt() == 1;
}
final String stringvalue = "$value".toLowerCase();
return stringvalue == "true" || stringvalue == "on" || stringvalue == "1" || stringvalue == "yes";
@@ -44,7 +44,7 @@ class ConvertValue {
return value;
}
if(value is num) {
return (value as num).toInt();
return value.toInt();
}
final String stringvalue = "$value".toLowerCase();
return int.parse(stringvalue);
@@ -55,7 +55,7 @@ class ConvertValue {
return value;
}
if(value is num) {
return (value as num).toDouble();
return value.toDouble();
}
final String stringvalue = "$value".toLowerCase();
return double.parse(stringvalue);
@@ -2,7 +2,7 @@ part of mdldialog;
@MdlComponentModel @di.Injectable()
class MaterialAlertDialog extends MaterialDialog {
final Logger _logger = new Logger('mdldialog.MaterialAlertDialog');
static final Logger _logger = new Logger('mdldialog.MaterialAlertDialog');
static const String _DEFAULT_OK_BUTTON = "OK";
@@ -2,7 +2,7 @@ part of mdldialog;
@MdlComponentModel @di.Injectable()
class MdlConfirmDialog extends MaterialDialog {
final Logger _logger = new Logger('mdldialog.MdlConfirmDialog');
static final Logger _logger = new Logger('mdldialog.MdlConfirmDialog');
static const String _DEFAULT_YES_BUTTON = "Yes";
static const String _DEFAULT_NO_BUTTON = "No";
@@ -88,7 +88,7 @@ class DialogConfig {
/// HTML-Part of MdlDialog.
abstract class MaterialDialog extends Object with TemplateComponent, MdlEventListener implements ScopeAware {
final Logger _logger = new Logger('mdldialog.DialogElement');
static final Logger _logger = new Logger('mdldialog.DialogElement');
static const _MaterialDialogCssClasses _cssClasses = const _MaterialDialogCssClasses();
@@ -30,7 +30,7 @@ enum NotificationType {
/// MaterialNotification
@MdlComponentModel @di.Injectable()
class MaterialNotification extends MaterialDialog {
final Logger _logger = new Logger('mdldialog.MaterialNotification');
static final Logger _logger = new Logger('mdldialog.MaterialNotification');
static const int LONG_DELAY = 10000;
static const int SHORT_DELAY = 6500;
@@ -102,7 +102,7 @@ class MaterialNotification extends MaterialDialog {
// - private ----------------------------------------------------------------------------------
String _notificationType(_) {
String _notificationType(final LambdaContext _) {
switch(type) {
case NotificationType.DEBUG:
@@ -39,7 +39,7 @@ class SnackbarPosition {
/// MaterialSnackbarComponent
@MdlComponentModel @di.Injectable()
class MaterialSnackbar extends MaterialDialog {
final Logger _logger = new Logger('mdldialog.MaterialSnackbar');
static final Logger _logger = new Logger('mdldialog.MaterialSnackbar');
static const String DEFAULT_CONFIRM_BUTTON = "OK";
@@ -136,7 +136,7 @@ class MaterialSnackbar extends MaterialDialog {
_confirmationID = "";
}
String _snackbarClasses(_) {
String _snackbarClasses(final LambdaContext _) {
final List<String> classes = new List<String>();
void _addIf(final List<String> classes,final bool check,final String classToAdd) {
Oops, something went wrong.

0 comments on commit 5e58b22

Please sign in to comment.