uix icon indicating copy to clipboard operation
uix copied to clipboard

Wrong private fields on Component class

Open cgarciae opened this issue 10 years ago • 1 comments
trafficstars

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.

cgarciae avatar Apr 23 '15 04:04 cgarciae

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();
    }
  }
  ...
}

localvoid avatar Apr 24 '15 10:04 localvoid