-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change KeywordSet to use
Set().has(item.toLowerCase())
- Loading branch information
Bart Veneman
committed
Aug 6, 2024
1 parent
3088ea1
commit 491cd80
Showing
1 changed file
with
3 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import { strEquals } from "./string-utils.js" | ||
|
||
/** | ||
* @description A Set-like construct to search CSS keywords in a case-insensitive way | ||
*/ | ||
export class KeywordSet { | ||
|
||
/** @param {string[]} items */ | ||
constructor(items) { | ||
/** @type {string[]} */ | ||
this.set = items | ||
/** @type {Set<string>} */ | ||
this.set = new Set(items) | ||
} | ||
|
||
/** @param {string} item */ | ||
has(item) { | ||
let len = this.set.length | ||
|
||
for (let index = 0; index < len; index++) { | ||
if (strEquals(this.set[index], item)) { | ||
return true | ||
} | ||
} | ||
return false | ||
return this.set.has(item.toLowerCase()) | ||
} | ||
} |