Skip to content

Commit

Permalink
Merge pull request #796 from mathjax/fix-chtml-css
Browse files Browse the repository at this point in the history
Prevent CHTML adaptice CSS from adding character CSS multiple times
  • Loading branch information
dpvc authored May 1, 2022
2 parents d671f3e + dbf22bf commit c0ee273
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ts/output/chtml/Usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@

/**
* Class used for tracking usage of font characters or wrappers
* (should extend Set<T>, but that doesn't work for compiling to ES2015).
*/
export class Usage<T> {

/**
* The used items.
*/
protected used: Set<T> = new Set<T>();
protected used: Set<string> = new Set<string>();

/**
* The items marked as used since last update.
Expand All @@ -41,18 +40,19 @@ export class Usage<T> {
* @param {T} item The item that has been used
*/
public add(item: T) {
if (!this.used.has(item)) {
const name = JSON.stringify(item);
if (!this.used.has(name)) {
this.needsUpdate.push(item);
}
this.used.add(item);
this.used.add(name);
}

/**
* @param {T} item The item to check for being used
* @return {boolean} True if the item has been used
*/
public has(item: T): boolean {
return this.used.has(item);
return this.used.has(JSON.stringify(item));
}

/**
Expand Down

0 comments on commit c0ee273

Please sign in to comment.