Skip to content

How to use extends option from WebComponents specification #879

@alexVasylenko

Description

@alexVasylenko

Hi! I try to use lit-element in my current project and previous I use that code

class HomePageSearch extends HTMLInputElement {
 connectedCallback() {
   console.log("works");
   this.focus();
 }
}
customElements.define("homepage-search", HomePageSearch, {extends: "input"});

and then in html I can use that component like <input is="homepage-search" >. It's really important for me because in that case I can use that component without any css changes.

And now I want to convert the code to lit-element component. But I don't understand how because using that variant

import { LitElement } from "lit-element";
class HomePageSearch extends LitElement {
  connectedCallback() {
    console.log("works");
    this.focus();
  }
}
customElements.define("homepage-search", HomePageSearch, {extends: "input"});

I got the error TypeError: Class constructor bo cannot be invoked without 'new'

Thank you

Browsers Affected

  • Chrome

Versions

  • lit-element: v2.1
  • webcomponents: v1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions