Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid checking UXP version for featur detection #2

Merged
merged 1 commit into from Jun 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/main.js
Expand Up @@ -146,8 +146,10 @@ function supersededFixes(service) {
// If possible, decied based on the UXP platform, not the application or version
// Keep entries in each block in the same order as in evaluateFix's switch statement
const superseded = new Set();
if (service.isPlatform51Up) {
if (service.hasqueueMicrotask) {
superseded.add("std-queueMicrotask");
}
if (service.hasOptionalChainingOperator) {
superseded.add("dhl-optchain");
superseded.add("tmx-optchain");
}
Expand Down Expand Up @@ -550,7 +552,16 @@ class PolyfillService {
constructor() {
this.isSeaMonkey = Services.appinfo.name == "SeaMonkey";
this.isPaleMoon = Services.appinfo.name == "Pale Moon";
this.isPlatform51Up = Services.vc.compare(Services.appinfo.platformVersion, "4.8.5") >= 0;

// Detect available platform features
// - queueMicrotask
this.hasqueueMicrotask = typeof queueMicrotask === "function";
// - Optional Chaining Operator (?.)
var code = "this?.fourtytwo";
var valid = true;
try { new Function(code); } catch(exc) { valid = false; }
this.hasOptionalChainingOperator = valid;

this.fixCache = new Map();
this.rules = new RuleEngine();
this.exclusion = new RuleEngine();
Expand Down