localvoid / uix

[UNMAINTAINED] Dart Web UI library
BSD 2-Clause "Simplified" License
77 stars 4 forks source link

Wrong private fields on Component class #8

Open cgarciae opened 9 years ago

cgarciae commented 9 years ago

This

  /// Protected property that contains data input.
  P data_;

  /// Protected property that contains children input.
  List<VNode> children_;

should be like this

  /// Protected property that contains data input.
  P _data;

  /// Protected property that contains children input.
  List<VNode> _children;

Wrong side of the underscore for private fields.

localvoid commented 9 years ago

They are "protected", not private. Dart doesn't support protected properties, so I just added _ suffix to make it possible to reuse them when overriding data setter, for example:

class LineView extends Component<RichLine> {
  List<VNode> _fragments;

  set data(RichLine newData) {
    if (identical(data, newData)) {
      if (data.isNewer(this)) {
        invalidate();
      }
    } else {
      data_ = newData;
      invalidate();
    }
  }
  ...
}