lit-analyzer icon indicating copy to clipboard operation
lit-analyzer copied to clipboard

lit-html 2.0 support

Open justinfagnani opened this issue 3 years ago • 3 comments

We're working on lit-html 2.0 right now in a branch here: https://github.com/Polymer/lit-html/tree/lit-next It's also published to npm with the @next-major tag: https://www.npmjs.com/package/lit-html/v/2.0.0-pre.3

There aren't a great many changes that would effect analysis of templates. I think the biggest change is in directives, which are class-based and might be generically analyzable now based on their render method.

Some very small things:

  • Symbols can no longer be passed to attribute and text bindings, they have to be converted to strings first.
  • Arrays passed to attributes are not joined with a space. Authors need to convert them to strings.
  • Dynamic template tags are not allowed. It was extremely rare anyway.
  • TemplateResult is no longer a class. It's an object differentiated with a special property.
  • DirectiveResult is now a thing and similar to TemplateResult. It includes a reference to the Directive class

Bigger:

  • We're probably going to allow "element" or "spread" bindings, but just with directives, like
html`<div ${ref()}></div>` 

(TBD on the ref part, but that would be a directive)

  • We're probably going to add static "bindings", which are interpolated into the template before bindings. These can't be updated, so should usually be const module variables.
  • Directives are classes. Their signature is derived from a render() methods (name might change) that returns another lit-html type. ie, a directive for a text binding can now return a template result.

Opening this issue to let you know and track anything that might need to be done.

Thanks!

justinfagnani avatar Sep 25 '20 17:09 justinfagnani

<vaadin-text-field ${field(this.binder.model.name)}></vaadin-text-field> now works with lit 2.0.0-pre.1 but from this plugin I get

Unknown attribute '________________________________'.

would be cool to get lit 2 support

Artur- avatar Mar 04 '21 14:03 Artur-

Maybe a new rule for for lit 2.0 would be nice to make people aware of legacy imports like

import {html} from 'lit-html' or import {LitElement} from 'lit-element'

and change it to import {LitElement, html} from 'lit.

Christian24 avatar Apr 23 '21 14:04 Christian24

Directives should be partially addressed in #172

e111077 avatar May 20 '21 01:05 e111077