From d82840b17fa41e1eb1c1ebba8024ee255e555714 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 4 Nov 2015 16:07:31 -0800 Subject: [PATCH] rename host functions fix typos afterFirstRender is now raf+setTimeout dom-repeat: remove cruft --- polymer-mini.html | 6 +++--- polymer.html | 6 +++--- src/lib/bind/accessors.html | 17 +++++++++++++---- src/lib/collection.html | 6 +++--- src/lib/dom-api.html | 7 +------ src/lib/render-status.html | 9 ++------- src/lib/style-util.html | 2 +- src/lib/template/dom-repeat.html | 21 +++++++++------------ src/lib/template/templatizer.html | 29 +++++------------------------ src/micro/attributes.html | 5 ++++- src/micro/behaviors.html | 7 +++++-- src/micro/properties.html | 8 +++++++- src/mini/ready.html | 6 +++--- src/mini/shady.html | 1 + src/standard/annotations.html | 12 ++++++------ src/standard/configure.html | 5 ----- src/standard/effectBuilder.html | 5 +---- src/standard/styling.html | 4 ++-- src/standard/x-styling.html | 5 +++-- 19 files changed, 72 insertions(+), 89 deletions(-) diff --git a/polymer-mini.html b/polymer-mini.html index cfd2b47c98..cf03ceffe2 100644 --- a/polymer-mini.html +++ b/polymer-mini.html @@ -41,16 +41,16 @@ }, _initFeatures: function() { - this._calcHost(); + this._registerHost(); if (this._template) { // manage local dom this._poolContent(); // host stack - this._beginHost(); + this._beginHosting(); // instantiate template this._stampTemplate(); // host stack - this._popHost(); + this._endHosting(); } // install host attributes this._marshalHostAttributes(); diff --git a/polymer.html b/polymer.html index 46b62ff91e..3510433a04 100644 --- a/polymer.html +++ b/polymer.html @@ -63,16 +63,16 @@ this._setupStyleProperties(); // setup debouncers this._setupDebouncers(); - this._calcHost(); + this._registerHost(); if (this._template) { // manage local dom this._poolContent(); // host stack - this._beginHost(); + this._beginHosting(); // instantiate template this._stampTemplate(); // host stack - this._popHost(); + this._endHosting(); // concretize template references this._marshalAnnotationReferences(); } diff --git a/src/lib/bind/accessors.html b/src/lib/bind/accessors.html index 1b854b982e..4704c2b41e 100644 --- a/src/lib/bind/accessors.html +++ b/src/lib/bind/accessors.html @@ -248,13 +248,22 @@ // Property listeners: // .on.-changed: = e.detail.value //console.log('[_setupBindListener]: [%s][%s] listening for [%s][%s-changed]', this.localName, info.path, info.id || info.index, info.property); - this._addNotifyListener(inst._nodes[info.index], inst, info); + // + // TODO(sorvell): fix templatizer to support this before uncommenting + // Optimization: only add bind listeners if the bound property is notifying... + var node = inst._nodes[info.index]; + //var p = node._propertyInfo && node._propertyInfo[info.property]; + //if (node._prepParentProperties || !node._propertyInfo || (p && p.notify)) { + this._addNotifyListener(node, inst, info.event, info.changedFn); + //} }; }, - _addNotifyListener: function(element, context, info) { - element.addEventListener(info.event, function(e) { - return context._notifyListener(info.changedFn, e); + // TODO(sorvell): note, adding these synchronously may impact performance, + // measure and consider if we can defer until after first paint in some cases at least. + _addNotifyListener: function(element, context, event, changedFn) { + element.addEventListener(event, function(e) { + return context._notifyListener(changedFn, e); }); } }; diff --git a/src/lib/collection.html b/src/lib/collection.html index 3a8ebd6a7f..71cd691336 100644 --- a/src/lib/collection.html +++ b/src/lib/collection.html @@ -131,14 +131,14 @@ // corresponding to the added/removed items _applySplices: function(splices) { // Dedupe added and removed keys to a final added/removed map - var keyMap = {}, key, i; + var keyMap = {}, key; for (var i=0, s; (i> 1; var midKey = this._instances[mid].__key__; - var cmp = sortFn(c.getItem(midKey), item); + var cmp = this._sortFn(c.getItem(midKey), item); if (cmp < 0) { start = mid + 1; } else if (cmp > 0) { diff --git a/src/lib/template/templatizer.html b/src/lib/template/templatizer.html index b8bf0c7bb7..1adc6834dd 100644 --- a/src/lib/template/templatizer.html +++ b/src/lib/template/templatizer.html @@ -248,16 +248,16 @@ Polymer.Bind._createAccessors(proto, parentProp, effects); } } + // capture this reference for use below + var self = this; // Instance setup if (template != this) { Polymer.Bind.prepareInstance(template); - var self = this; template._forwardParentProp = function(source, value) { self._forwardParentProp(source, value); } } this._extendTemplate(template, proto); - var self = this; template._pathEffector = function(path, value, fromAbove) { return self._pathEffectorImpl(path, value, fromAbove); } @@ -332,12 +332,12 @@ _constructorImpl: function(model, host) { this._rootDataHost = host._getRootDataHost(); this._setupConfigure(model); - this._calcHost(host); - this._beginHost(); + this._registerHost(host); + this._beginHosting(); this.root = this.instanceTemplate(this._template); this.root.__noContent = !this._notes._hasContent; this.root.__styleScoped = true; - this._popHost(); + this._endHosting(); this._marshalAnnotatedNodes(); this._marshalInstanceEffects(); this._marshalAnnotatedListeners(); @@ -450,25 +450,6 @@ } } - // TODO(sorvell): note, using the template as host is ~5-10% faster if - // elements have no default values. - // _constructorImpl: function(model, host) { - // this._setupConfigure(model); - // host._beginHost(); - // this.root = this.instanceTemplate(this._template); - // host._popHost(); - // this._marshalTemplateContent(); - // this._marshalAnnotatedNodes(); - // this._marshalInstanceEffects(); - // this._marshalAnnotatedListeners(); - // this._ready(); - // }, - - // stamp: function(model) { - // return new this.ctor(model, this.dataHost); - // } - - }; diff --git a/src/micro/attributes.html b/src/micro/attributes.html index 73eadb16e0..2f68da485c 100644 --- a/src/micro/attributes.html +++ b/src/micro/attributes.html @@ -60,6 +60,7 @@ Polymer.Base._addFeature({ + // prototype time _addHostAttributes: function(attributes) { if (!this._aggregatedAttributes) { this._aggregatedAttributes = {}; @@ -69,6 +70,7 @@ } }, + // instance time _marshalHostAttributes: function() { if (this._aggregatedAttributes) { this._applyAttributes(this, this._aggregatedAttributes); @@ -88,7 +90,7 @@ // if necessary, add this value to configuration... if (!this._clientsReadied && this._propertyInfo[n] && (this._config[n] === undefined)) { - this._config[n] = v; + this._configValue(n, v); } } } @@ -114,6 +116,7 @@ if (!this._serializing) { var property = property || Polymer.CaseMap.dashToCamelCase(attribute); // fallback to property lookup + // TODO(sorvell): check for _propertyInfo existence because of dom-bind info = info || (this._propertyInfo && this._propertyInfo[property]); if (info && !info.readOnly) { var v = this.getAttribute(attribute); diff --git a/src/micro/behaviors.html b/src/micro/behaviors.html index 160df13579..ad4945b033 100644 --- a/src/micro/behaviors.html +++ b/src/micro/behaviors.html @@ -97,7 +97,7 @@ _mixinBehavior: function(b) { var n$ = Object.getOwnPropertyNames(b); for (var i=0, n; (i