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

Add support for lazy template function in legacy _template field #5660

Closed
kevinpschaaf opened this issue May 14, 2020 · 0 comments · Fixed by #5661
Closed

Add support for lazy template function in legacy _template field #5660

kevinpschaaf opened this issue May 14, 2020 · 0 comments · Fixed by #5661

Comments

@kevinpschaaf
Copy link
Member

Description

The static get template() { ... } field on Polymer 3's class syntax is lazy; i.e. it won't invoke the function (which normally does the template parsing) until the element is instanced, which is a performance optimization when element definitions are loaded but not immediately instanced.

However the legacy Polymer({ _template: ... }) field basically requires providing a concrete template. Unfortunately, implementing a get _template() { ... } getter is not sufficient, since for legacy reasons Polymer sets the finalized template back to prototype._template, hence it also needs a setter that overrides the original value. This becomes rather cumbersome to author.

This issue is to make a minor change to the legacy Polymer template processing to allow setting a function to _template on the Polymer info object. The type of the value will be checked, and if it is a function it will be run once and the return value will be used.

Versions

  • Polymer: v3/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant