Skip to content

Commit

Permalink
fix: merge two constructors in footerlink
Browse files Browse the repository at this point in the history
  • Loading branch information
DaleSeo committed Jun 11, 2024
1 parent 4714ac9 commit 1290e2a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions components/footer-link/footer-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,23 @@ class FooterLink extends HTMLElement {
super();
const shadow = this.attachShadow({ mode: "open" });
shadow.appendChild(template.content.cloneNode(true));
this.linkElement = shadow.getElementById("link");
this.updateLink(this.getAttribute("href"));
}

static get observedAttributes() {
return ["href"];
}

constructor() {
this.linkElement = shadow.getElementById("link");
this.updateLink(this.getAttribute("href"));
}

attributeChangedCallback(name, oldValue, newValue) {
if (name === "href") {
this.updateLinkHref(newValue);
}
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === "href") {
this.updateLink(newValue);
}
}

updateLink(href) {
this.linkElement.setAttribute("href", href);
}
updateLink(href) {
this.linkElement.setAttribute("href", href);
}
}

window.customElements.define("footer-link", FooterLink);

0 comments on commit 1290e2a

Please sign in to comment.