Skip to content

Commit 8f4cc31

Browse files
authored
Merge pull request #5520 from Polymer/avoid-template-upgrade
Avoid upgrading template if no hostProps, for better perf.
2 parents ddcfc63 + c7eb7c1 commit 8f4cc31

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/utils/templatize.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,14 @@ function createTemplatizerClass(template, templateInfo, options) {
360360
}
361361

362362
/**
363+
* Adds propagate effects from the template to the template instance for
364+
* properties that the host binds to the template using the `_host_` prefix.
365+
*
363366
* @suppress {missingProperties} class.prototype is not defined for some reason
364367
*/
365368
function addPropagateEffects(template, templateInfo, options) {
366369
let userForwardHostProp = options.forwardHostProp;
367-
if (userForwardHostProp) {
370+
if (userForwardHostProp && templateInfo.hasHostProps) {
368371
// Provide data API and property effects on memoized template class
369372
let klass = templateInfo.templatizeTemplateClass;
370373
if (!klass) {
@@ -423,6 +426,11 @@ function addNotifyEffects(klass, template, templateInfo, options) {
423426
}
424427
if (options.forwardHostProp && template.__dataHost) {
425428
for (let hprop in hostProps) {
429+
// As we're iterating hostProps in this function, note whether
430+
// there were any, for an optimization in addPropagateEffects
431+
if (!templateInfo.hasHostProps) {
432+
templateInfo.hasHostProps = true;
433+
}
426434
klass.prototype._addPropertyEffect(hprop,
427435
klass.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,
428436
{fn: createNotifyHostPropEffect()});

0 commit comments

Comments
 (0)