javascript - How to register Polymer behavior with ES6? -
if
polymer({ is: 'pp-app', behaviors: [playplan.helperbehavior], scrollpagetotop() { document.getelementbyid('maincontainer').scrolltop = 0; }, ondatarouteclick() { var drawerpanel = document.queryselector('#paperdrawerpanel'); if (drawerpanel.narrow) { drawerpanel.closedrawer(); } } });
the behavior here works fine, in es6
class playplanapp { beforeregister() { this.is = 'pp-app'; this.properties = {}; this.behaviors = [playplan.helperbehavior]; } scrollpagetotop() { document.getelementbyid('maincontainer').scrolltop = 0; } ondatarouteclick() { var drawerpanel = document.queryselector('#paperdrawerpanel'); if (drawerpanel.narrow) { drawerpanel.closedrawer(); } } } polymer(playplanapp);
the behavior not works, how specify behaviors when using es6 ?
this caused
registercallback: function() { // todo(sjmiles): perhaps method should called polymer-bootstrap? this._desugarbehaviors(); // abstract this._dobehavior('beforeregister'); // abstract this._registerfeatures(); // abstract this._dobehavior('registered'); // abstract }
_dobehavior('beforeregister')
after _desugarbehaviors
, here work around:
get behaviors() { return [playplan.helperbehavior]; }
btw, not work, because constructor never called(commented in polymer.base)
constructor() { return [playplan.helperbehavior]; }
Comments
Post a Comment