8000 [lit-html] warn when binding primitive values into element position · Issue #5007 · lit/lit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[lit-html] warn when binding primitive values into element position #5007
Open
@rictic

Description

@rictic

Should this be an RFC?

  • This is not a substantial change

Which package is this a feature request for?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

This code doesn't do what it looks like it does:

import {html, css, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';

@customElement('simple-greeting')
export class SimpleGreeting extends LitElement {
  static styles = css`p { color: red } p.bar { color: green }`;

  render() {
    return html`<p ${'class="bar"'}>Why isn't this green</p>`;
  }
}

Playground

The expression is silently dropped in client side rendering, and I believe it's mangled in server side rendering. In dev mode, we should log a warning for this case.

Alternatives and Workarounds

The lit analyzer does warn for this currently, which helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0