fix(collapsible): moved binding to constructor

This commit is contained in:
joquitch 2022-02-07 09:01:29 +01:00 committed by GitHub
parent 28bf12f9eb
commit 0bd47f8d6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,6 +43,7 @@ export class LionCollapsible extends LitElement {
constructor() {
super();
this.opened = false;
this.toggle = this.toggle.bind(this);
}
connectedCallback() {
@ -51,7 +52,7 @@ export class LionCollapsible extends LitElement {
const uid = uuid();
if (this._invokerNode) {
this._invokerNode.addEventListener('click', this.toggle.bind(this));
this._invokerNode.addEventListener('click', this.toggle);
this._invokerNode.setAttribute('aria-expanded', `${this.opened}`);
this._invokerNode.setAttribute('id', `collapsible-invoker-${uid}`);
this._invokerNode.setAttribute('aria-controls', `collapsible-content-${uid}`);