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

Allow ?disabled to be set to AsyncDirective #341

Open
nmattia opened this issue Jan 8, 2024 · 1 comment
Open

Allow ?disabled to be set to AsyncDirective #341

nmattia opened this issue Jan 8, 2024 · 1 comment

Comments

@nmattia
Copy link

nmattia commented Jan 8, 2024

It looks like lit-analyzer disallows setting ?disabled to an async directive. It will throw no-invalid-directive-binding:

    The 'asyncReplace' directive can only be used within a text binding.
    56:  ?disabled=${asyncReplace(shouldDisable)}
    no-invalid-directive-binding

In practice lit (and lit-html) do not seem to have an issue with this, as shown by this playground example:

import {html, LitElement} from 'lit';
import {customElement} from 'lit/decorators.js';
import {asyncReplace} from 'lit/directives/async-replace.js';

async function *toggle() {
  let value = false;
  while (true) {
    yield value;
    value = !value;
    await new Promise(resolve => setTimeout(resolve, 1000));
  }
}

@customElement('toggle-button')
export class Toggle extends LitElement {
  render() {
    return html`<button ?disabled=${asyncReplace(toggle())}>click me</button>`;
  }
}

out

nmattia added a commit to dfinity/internet-identity that referenced this issue Jan 8, 2024
This adds a lit-analyzer lint check. This ensures we make correct use of
lit templates.

We disable three rules which currently appear to be overrestrictive:
* runem/lit-analyzer#341
* runem/lit-analyzer#342
* runem/lit-analyzer#343
nmattia added a commit to dfinity/internet-identity that referenced this issue Jan 8, 2024
This adds a lit-analyzer lint check. This ensures we make correct use of
lit templates.

We disable three rules which currently appear to be overrestrictive:
* runem/lit-analyzer#341
* runem/lit-analyzer#342
* runem/lit-analyzer#343
github-merge-queue bot pushed a commit to dfinity/internet-identity that referenced this issue Jan 8, 2024
This adds a lit-analyzer lint check. This ensures we make correct use of
lit templates.

We disable three rules which currently appear to be overrestrictive:
* runem/lit-analyzer#341
* runem/lit-analyzer#342
* runem/lit-analyzer#343
@AndrewJakubowicz
Copy link
Contributor

This is a great issue. I can definitely investigate this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants