Skip to content

Commit

Permalink
Merge pull request #5520 from Polymer/avoid-template-upgrade
Browse files Browse the repository at this point in the history
Avoid upgrading template if no hostProps, for better perf.
  • Loading branch information
kevinpschaaf authored Apr 13, 2019
2 parents ddcfc63 + c7eb7c1 commit 8f4cc31
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/utils/templatize.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,14 @@ function createTemplatizerClass(template, templateInfo, options) {
}

/**
* Adds propagate effects from the template to the template instance for
* properties that the host binds to the template using the `_host_` prefix.
*
* @suppress {missingProperties} class.prototype is not defined for some reason
*/
function addPropagateEffects(template, templateInfo, options) {
let userForwardHostProp = options.forwardHostProp;
if (userForwardHostProp) {
if (userForwardHostProp && templateInfo.hasHostProps) {
// Provide data API and property effects on memoized template class
let klass = templateInfo.templatizeTemplateClass;
if (!klass) {
Expand Down Expand Up @@ -423,6 +426,11 @@ function addNotifyEffects(klass, template, templateInfo, options) {
}
if (options.forwardHostProp && template.__dataHost) {
for (let hprop in hostProps) {
// As we're iterating hostProps in this function, note whether
// there were any, for an optimization in addPropagateEffects
if (!templateInfo.hasHostProps) {
templateInfo.hasHostProps = true;
}
klass.prototype._addPropertyEffect(hprop,
klass.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,
{fn: createNotifyHostPropEffect()});
Expand Down

0 comments on commit 8f4cc31

Please sign in to comment.