简体   繁体   中英

Programmatic custom element broken in dart polymer 0.9.5?

The earlier solution for programmatic custom element creation in polymer 0.8.5 seems to be broken in polymer 0.9.5.

If we modify the standard click-counter example to use programmatic element creation, like so:

main() {
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((LogRecord rec) {   
    print('${rec.loggerName}: ${rec.level.name}: ${rec.time}: ${rec.message}');
  });

  initPolymer();

  var clickCounter = new Element.tag('click-counter');     
  document.body.children.add(clickCounter);
}

the on-click events are correctly invoking the {{increment}} method, but the {{count}} value is not updated in the HTML.

Polymer code should be run from

import "package:polymer/polymer.dart";

main() {
  initPolymer().run(() {
    // code here works most of the time
    Polymer.onReady.then((value) {     
      // some things must wait until onReady callback is called
      // for an example look at the discussion linked below
    });
  });
}

simple tooltip working in dartium, not as javascript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM