if (!isSolid && isFontAwesome6Free()) {
const [, styles] = window.getFontAwesome6IconMetadata(name)!;
if (!styles.includes("regular")) {
+ // Font Awesome 6 Free only includes solid icons with the
+ // the exception to some special icons that use the weight
+ // to differentiate two related icons. One such example is
+ // the `bell` icon that comes in `solid` and `regular` flavor.
return false;
}
}
root.append(codepoint);
}
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
- switch (name) {
- case "name":
- if (newValue !== null && this.isValidIconName(newValue)) {
- this.updateIcon();
- }
- break;
- }
- }
-
get solid(): boolean {
return this.hasAttribute("solid");
}
}
set name(name: string) {
+ if (!this.isValidIconName(name)) {
+ throw new Error(`Refused to set the unknown icon name '${name}'.`);
+ }
+
this.setAttribute("name", name);
+ this.updateIcon();
}
get size(): IconSize {
this.setAttribute("size", size.toString());
}
-
- static get observedAttributes() {
- return ["name"];
- }
}
window.customElements.define("fa-icon", FaIcon);
if (!isSolid && isFontAwesome6Free()) {
const [, styles] = window.getFontAwesome6IconMetadata(name);
if (!styles.includes("regular")) {
+ // Font Awesome 6 Free only includes solid icons with the
+ // the exception to some special icons that use the weight
+ // to differentiate two related icons. One such example is
+ // the `bell` icon that comes in `solid` and `regular` flavor.
return false;
}
}
const [codepoint] = window.getFontAwesome6IconMetadata(this.name);
root.append(codepoint);
}
- attributeChangedCallback(name, oldValue, newValue) {
- switch (name) {
- case "name":
- if (newValue !== null && this.isValidIconName(newValue)) {
- this.updateIcon();
- }
- break;
- }
- }
get solid() {
return this.hasAttribute("solid");
}
return this.getAttribute("name") || "";
}
set name(name) {
+ if (!this.isValidIconName(name)) {
+ throw new Error(`Refused to set the unknown icon name '${name}'.`);
+ }
this.setAttribute("name", name);
+ this.updateIcon();
}
get size() {
const size = this.getAttribute("size");
}
this.setAttribute("size", size.toString());
}
- static get observedAttributes() {
- return ["name"];
- }
}
window.customElements.define("fa-icon", FaIcon);
})();