Skip to content

Commit

Permalink
Expose an lazierRegister flag to defer additional work until first …
Browse files Browse the repository at this point in the history
…create time. This change requires that a behavior not implement a custom constructor or set the element's `is` property.
  • Loading branch information
Steven Orvell committed Jun 4, 2016
1 parent adef722 commit 5c5b18e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/lib/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@

// `this` context is a prototype, not an instance
registerCallback: function() {
// TODO(sjmiles): perhaps this method should be called from polymer-bootstrap?
this._desugarBehaviors(); // abstract
this._doBehavior('beforeRegister'); // abstract
if (!settings.lazierRegister) {
this._desugarBehaviors(); // abstract
this._doBehavior('beforeRegister'); // abstract
}
this._registerFeatures(); // abstract
if (!settings.lazyRegister) {
this.ensureRegisterFinished();
Expand Down Expand Up @@ -62,6 +63,13 @@

_ensureRegisterFinished: function(proto) {
if (proto.__hasRegisterFinished !== proto.is) {
// TODO(sorvell): moving all behavior work here means that
// custom constructor and is cannot be done in a behavior.
// This probably means we need another flag for this
if (settings.lazierRegister) {
proto._desugarBehaviors(); // abstract
proto._doBehavior('beforeRegister'); // abstract
}
proto.__hasRegisterFinished = proto.is;
if (proto._finishRegisterFeatures) {
proto._finishRegisterFeatures();
Expand Down

0 comments on commit 5c5b18e

Please sign in to comment.