Skip to content

Commit

Permalink
perf: add component attribute when custom named
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Jul 26, 2024
1 parent 63c0b29 commit 9e87be8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/auro-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,27 @@ export class AuroBadge extends LitElement {
return iconHtml;
}

/**
* If component is registered as a custom name,
* this function will add an attribute to the element
* with the default name. This is so that other parent
* components can still this the element.
* @private
* @param {string} name - The default tag name.
* @param {HTMLElement} elem - The element to add the attribute to.
* @returns {void}
*/
handleCustomTagName(name, elem) {
if (name.toLowerCase() !== elem.tagName.toLowerCase()) {
elem.setAttribute(name, true);
}
}

connectedCallback() {
super.connectedCallback();
this.handleCustomTagName('auro-badge', this);
}

firstUpdated() {
// Finds slotted content and adds string to button value
if (this.target) {
Expand Down

0 comments on commit 9e87be8

Please sign in to comment.