Skip to content

Commit

Permalink
Fix ace undefined errors
Browse files Browse the repository at this point in the history
tombrunet committed Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b092268 commit 9f493d0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions accessibility-checker/src-ts/lib/ACEngineManager.ts
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ export class ACEngineManager {
config.DEBUG && console.log("[INFO] aChecker.loadEngine detected Puppeteer/Playwright");
let page = content;
if (ENGINE_LOAD_MODE === "REMOTE") {
config.DEBUG && console.log("[INFO] engineMode REMOTE");
await page.evaluate((scriptUrl) => {
try {
var ace_backup_in_ibma;
@@ -61,19 +62,21 @@ export class ACEngineManager {
}
}, `${config.rulePack}/ace.js`);
} else if (ENGINE_LOAD_MODE === "INJECT") {
await page.evaluate((engineContent) => {
config.DEBUG && console.log("[INFO] engineMode INJECT");
let aceAlreadyExists = await page.evaluate(() => { try { return 'undefined' !== typeof(ace) } catch (e) { return false; } });
await page.evaluate((engineContent, aceAlreadyExists) => {
try {
var ace_backup_in_ibma;
if ('undefined' !== typeof(ace)) {
if (aceAlreadyExists) {
if (!ace || !ace.Checker)
ace_backup_in_ibma = ace;
ace = null;
}
if ('undefined' === typeof (ace) || ace === null) {
if (!aceAlreadyExists || ace === null) {
return new Promise<void>((resolve, reject) => {
eval(engineContent);
globalThis.ace_ibma = ace;
if ('undefined' !== typeof(ace)) {
if (aceAlreadyExists) {
ace = ace_backup_in_ibma;
}
resolve();
@@ -82,7 +85,7 @@ export class ACEngineManager {
} catch (e) {
return Promise.reject(e);
}
}, ACEngineManager.engineContent);
}, ACEngineManager.engineContent, aceAlreadyExists);
}
return ACEngineManager.loadEngineLocal();
} else if (ACEngineManager.isSelenium(content)) {

0 comments on commit 9f493d0

Please sign in to comment.