diff --git a/ts/output/chtml/Usage.ts b/ts/output/chtml/Usage.ts index 3f53a6e26..1a4cc92b5 100644 --- a/ts/output/chtml/Usage.ts +++ b/ts/output/chtml/Usage.ts @@ -23,14 +23,13 @@ /** * Class used for tracking usage of font characters or wrappers - * (should extend Set, but that doesn't work for compiling to ES2015). */ export class Usage { /** * The used items. */ - protected used: Set = new Set(); + protected used: Set = new Set(); /** * The items marked as used since last update. @@ -41,10 +40,11 @@ export class Usage { * @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); } /** @@ -52,7 +52,7 @@ export class Usage { * @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)); } /**