dart-archive / polymer-dart

Polymer support for Dart
https://pub.dartlang.org/packages/polymer
BSD 3-Clause "New" or "Revised" License
181 stars 33 forks source link

Discrepancy between wiki docs and runtime results #707

Closed jolleekin closed 8 years ago

jolleekin commented 8 years ago

Wiki says

Lifecycle callbacks are called on the element class first, then for each behavior in the order they are mixed in (left to right).

Runtime results

Lifecycle callbacks are called for each behavior in the order they are mixed in (left to right), then on the element class.

Console log: VM2378:1 B1.created VM2378:1 B2.created VM2378:1 B1.ready VM2378:1 B2.ready VM2378:1 MainApp.ready VM2378:1 B1.attached VM2378:1 B2.attached VM2378:1 MainApp.attached VM2378:1 MainApp.created

Code to reproduce

@behavior
abstract class B1 {
  static const name = 'B1';

  static attached(instance) {
    print('$name.attached');
  }

  static created(instance) {
    print('$name.created');
  }

  static ready(instance) {
    print('$name.ready');
  }
}

@behavior
abstract class B2 implements B1 {
  static const name = 'B2';

  static attached(instance) {
    print('$name.attached');
  }

  static created(instance) {
    print('$name.created');
  }

  static ready(instance) {
    print('$name.ready');
  }
}

/// Uses [PaperInput]
@PolymerRegister('main-app')
class MainApp extends PolymerElement with B1, B2 {
  static const name = 'MainApp';

  @property
  String text;

  /// Constructor used to create instance of MainApp.
  MainApp.created() : super.created() {
    print('$name.created');
  }

  attached() {
    print('$name.attached');
  }

  ready() {
    print('$name.ready');
  }

  @reflectable
  String reverseText(String text) {
    return text.split('').reversed.join('');
  }
}
jakemac53 commented 8 years ago

Thanks for the nice repro, updated the wiki