lit / lit-element

LEGACY REPO. This repository is for maintenance of the legacy LitElement library. The LitElement base class is now part of the Lit library, which is developed in the lit monorepo.
https://lit-element.polymer-project.org
BSD 3-Clause "New" or "Revised" License
4.49k stars 319 forks source link

Should not be necessary to copy TemplateResult #1195

Closed Sofie-Bergqvist closed 3 years ago

Sofie-Bergqvist commented 3 years ago

We are having some trouble with the TemplateResult rendering, it should not be necessary to copy the TemplateResult Object and return a new TemplateResult to get the proper output.

This method seems to make the TemplateResult render fine.

private copyTemplateResult(data: TemplateResult): TemplateResult {
        let { strings, values, type, processor } = data;
        return new TemplateResult(strings, values, type, processor);
    }

However this method returns [Object] [Object]

private copyTemplateResult(data: TemplateResult): TemplateResult {
        return data;
    }

Here is one example of what we have tested: This method renders fine

private func(): TemplateResult {
        return this.getTemplateResultFromProperty;
    }

However, this method does not work. We think the output of these two should not differ.

    private func2(): TemplateResult {
        return html`${this.getTemplateResultFromProperty}´;
    }

The above method (func2) returns an error:
Uncaught (in promise) TypeError: Cannot read property 'split' of null at new Template (template.js:87)