Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid upgrading template if no hostProps, for better perf. #5520

Merged
merged 3 commits into from
Apr 13, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/utils/templatize.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function createTemplatizerClass(template, templateInfo, options) {
*/
function addPropagateEffects(template, templateInfo, options) {
let userForwardHostProp = options.forwardHostProp;
if (userForwardHostProp) {
if (userForwardHostProp && templateInfo.hasHostProps) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment here or perhaps just in the doc for the function explaining what this does so it's clear why it's only related to hostProps.

// Provide data API and property effects on memoized template class
let klass = templateInfo.templatizeTemplateClass;
if (!klass) {
Expand Down Expand Up @@ -423,6 +423,9 @@ function addNotifyEffects(klass, template, templateInfo, options) {
}
if (options.forwardHostProp && template.__dataHost) {
for (let hprop in hostProps) {
if (!templateInfo.hasHostProps) {
templateInfo.hasHostProps = true;
}
klass.prototype._addPropertyEffect(hprop,
klass.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,
{fn: createNotifyHostPropEffect()});
Expand Down