Skip to content

Commit

Permalink
fix: recommandations
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter authored May 4, 2024
1 parent 5f13e00 commit 2f774ce
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/dom/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,20 +803,18 @@ export class Element extends Node {

toggleAttribute(rawName: string, force?: boolean) {
const name = String(rawName?.toLowerCase());
switch (this.hasAttribute(name)) {
case true:
if ((force === undefined) || (force === false)) {
this.removeAttribute(name);
return false;
}
return true;
case false:
if ((force === undefined) || (force === true)) {
this.setAttribute(name, "");
return true;
}
if (this.hasAttribute(name)) {
if ((force === undefined) || (force === false)) {
this.removeAttribute(name);
return false;
}
return true;
}
if ((force === undefined) || (force === true)) {
this.setAttribute(name, "");
return true;
}
return false;
}

hasAttribute(name: string): boolean {
Expand Down

0 comments on commit 2f774ce

Please sign in to comment.