mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
avoid configuration work when unnecessary
This commit is contained in:
parent
66df196696
commit
e0fbfbe688
@ -27,8 +27,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
_registerFeatures: function() {
|
||||
// identity
|
||||
this._prepIs();
|
||||
// attributes
|
||||
this._prepAttributes();
|
||||
// shared behaviors
|
||||
this._prepBehaviors();
|
||||
// factory
|
||||
|
@ -24,8 +24,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
_registerFeatures: function() {
|
||||
// identity
|
||||
this._prepIs();
|
||||
// attributes
|
||||
this._prepAttributes();
|
||||
// shared behaviors
|
||||
this._prepBehaviors();
|
||||
// factory
|
||||
@ -43,14 +41,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
_initFeatures: function() {
|
||||
// manage local dom
|
||||
this._poolContent();
|
||||
// host stack
|
||||
this._pushHost();
|
||||
// instantiate template
|
||||
this._stampTemplate();
|
||||
// host stack
|
||||
this._popHost();
|
||||
this._calcHost();
|
||||
if (this._template) {
|
||||
// manage local dom
|
||||
this._poolContent();
|
||||
// host stack
|
||||
this._beginHost();
|
||||
// instantiate template
|
||||
this._stampTemplate();
|
||||
// host stack
|
||||
this._popHost();
|
||||
}
|
||||
// install host attributes
|
||||
this._marshalHostAttributes();
|
||||
// setup debouncers
|
||||
|
33
polymer.html
33
polymer.html
@ -28,8 +28,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
_registerFeatures: function() {
|
||||
// identity
|
||||
this._prepIs();
|
||||
// attributes
|
||||
this._prepAttributes();
|
||||
// factory
|
||||
this._prepConstructor();
|
||||
// template
|
||||
@ -59,37 +57,42 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
_initFeatures: function() {
|
||||
// manage local dom
|
||||
this._poolContent();
|
||||
// manage configuration
|
||||
this._setupConfigure();
|
||||
// setup style properties
|
||||
this._setupStyleProperties();
|
||||
// host stack
|
||||
this._pushHost();
|
||||
// instantiate template
|
||||
this._stampTemplate();
|
||||
// host stack
|
||||
this._popHost();
|
||||
// concretize template references
|
||||
this._marshalAnnotationReferences();
|
||||
// setup debouncers
|
||||
this._setupDebouncers();
|
||||
this._calcHost();
|
||||
if (this._template) {
|
||||
// manage local dom
|
||||
this._poolContent();
|
||||
// host stack
|
||||
this._beginHost();
|
||||
// instantiate template
|
||||
this._stampTemplate();
|
||||
// host stack
|
||||
this._popHost();
|
||||
// concretize template references
|
||||
this._marshalAnnotationReferences();
|
||||
}
|
||||
// concretize effects on instance
|
||||
this._marshalInstanceEffects();
|
||||
// acquire instance behaviors
|
||||
this._marshalBehaviors();
|
||||
// install host attributes
|
||||
this._marshalHostAttributes();
|
||||
// acquire initial instance attribute values
|
||||
this._marshalAttributes();
|
||||
// install host attributes
|
||||
this._marshalHostAttributes();
|
||||
// top-down initial distribution, configuration, & ready callback
|
||||
this._tryReady();
|
||||
},
|
||||
|
||||
_marshalBehavior: function(b) {
|
||||
// establish listeners on instance
|
||||
this._listenListeners(b.listeners);
|
||||
if (b.listeners) {
|
||||
this._listenListeners(b.listeners);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -288,14 +288,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// Similar to Polymer.Base.extend, but retains any previously set instance
|
||||
// values (_propertySetter back on instance once accessor is installed)
|
||||
_extendTemplate: function(template, proto) {
|
||||
Object.getOwnPropertyNames(proto).forEach(function(n) {
|
||||
var n$ = Object.getOwnPropertyNames(proto);
|
||||
for (var i=0, n; (i<n$.length) && (n=n$[i]); i++) {
|
||||
var val = template[n];
|
||||
var pd = Object.getOwnPropertyDescriptor(proto, n);
|
||||
Object.defineProperty(template, n, pd);
|
||||
if (val !== undefined) {
|
||||
template._propertySetter(n, val);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Extension points for Templatizer sub-classes
|
||||
@ -331,7 +332,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
_constructorImpl: function(model, host) {
|
||||
this._rootDataHost = host._getRootDataHost();
|
||||
this._setupConfigure(model);
|
||||
this._pushHost(host);
|
||||
this._calcHost(host);
|
||||
this._beginHost();
|
||||
this.root = this.instanceTemplate(this._template);
|
||||
this.root.__noContent = !this._notes._hasContent;
|
||||
this.root.__styleScoped = true;
|
||||
|
@ -56,24 +56,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// In order not to over-emphaisize this technical difference, we expose
|
||||
// one concept to the user and it maps to the dom-related meaning of host.
|
||||
//
|
||||
// 1. set this element's `host` and push this element onto the `host`'s
|
||||
// set this element's `host` and push this element onto the `host`'s
|
||||
// list of `client` elements
|
||||
// 2. establish this element as the current hosting element (allows
|
||||
// any elements we stamp to easily set host to us).
|
||||
_pushHost: function(host) {
|
||||
// this.dataHost reflects the parent element who manages
|
||||
// any bindings for the element. Only elements originally
|
||||
// stamped from Polymer templates have a dataHost, and this
|
||||
// never changes
|
||||
_calcHost: function(host) {
|
||||
// NOTE: The `dataHost` of an element never changes.
|
||||
this.dataHost = host = host ||
|
||||
this.dataHost = host = host ||
|
||||
Polymer.Base._hostStack[Polymer.Base._hostStack.length-1];
|
||||
// this.dataHost reflects the parent element who manages
|
||||
// any bindings for the element. Only elements originally
|
||||
// stamped from Polymer templates have a dataHost, and this
|
||||
// never changes
|
||||
if (host && host._clients) {
|
||||
host._clients.push(this);
|
||||
}
|
||||
this._beginHost();
|
||||
},
|
||||
|
||||
// establish this element as the current hosting element (allows
|
||||
// any elements we stamp to easily set host to us).
|
||||
_beginHost: function() {
|
||||
Polymer.Base._hostStack.push(this);
|
||||
if (!this._clients) {
|
||||
@ -99,9 +98,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
_ready: function() {
|
||||
// extension point
|
||||
this._beforeClientsReady();
|
||||
// prepare root
|
||||
this._setupRoot();
|
||||
this._readyClients();
|
||||
if (this._template) {
|
||||
// prepare root
|
||||
this._setupRoot();
|
||||
this._readyClients();
|
||||
}
|
||||
this._clientsReadied = true;
|
||||
this._clients = null;
|
||||
// extension point
|
||||
this._afterClientsReady();
|
||||
this._readySelf();
|
||||
@ -112,8 +115,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
this._beginDistribute();
|
||||
// now fully prepare localChildren
|
||||
var c$ = this._clients;
|
||||
for (var i=0, l= c$.length, c; (i<l) && (c=c$[i]); i++) {
|
||||
c._ready();
|
||||
if (c$) {
|
||||
for (var i=0, l= c$.length, c; (i<l) && (c=c$[i]); i++) {
|
||||
c._ready();
|
||||
}
|
||||
}
|
||||
// perform actual dom composition
|
||||
this._finishDistribute();
|
||||
@ -123,8 +128,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// if (!Polymer.Settings.useNativeCustomElements) {
|
||||
// CustomElements.takeRecords();
|
||||
// }
|
||||
this._clientsReadied = true;
|
||||
this._clients = null;
|
||||
},
|
||||
|
||||
// mark readied and call `ready`
|
||||
|
@ -102,7 +102,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// this is the new _config, which are the final values to be applied
|
||||
this._config = config;
|
||||
// pass configuration data to bindings
|
||||
this._distributeConfig(this._config);
|
||||
if (this._clients && this._clients.length) {
|
||||
this._distributeConfig(this._config);
|
||||
}
|
||||
},
|
||||
|
||||
_configureProperties: function(properties, config) {
|
||||
|
Loading…
Reference in New Issue
Block a user