Skip to content

Commit a82d775

Browse files
Add Firefox support to labs
Add support for Firefox. The code was using the Set class's "difference" method. This is in Firefox nightly, but is not yet released. So we add a few lines to compute it ourselves. Now it works on Firefox. Signed-off-by: David A. Wheeler <[email protected]>
1 parent 2d09418 commit a82d775

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/labs/checker.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ function escapeHTML(unsafe) {
6666
.replace(/\'/g, "&#039;"));
6767
}
6868

69+
/* Compute Set difference lhs \ rhs.
70+
* @lhs - Set to start with
71+
* @rhs - Set to remove from the lhs
72+
* Set difference is in Firefox nightly, but is not yet released.
73+
* So we compute it ourselves. This is equivalent to lhs.difference(rhs)
74+
*/
75+
function setDifference(lhs, rhs) {
76+
let lhsArray = Array.from(lhs);
77+
let result = lhsArray.filter((x) => {!rhs.has(x)});
78+
return new Set(result);
79+
}
80+
6981
/*
7082
* Show debug output in debug region and maybe via alert box
7183
* @debugOutput - the debug information to show
@@ -253,7 +265,7 @@ function processHints(requestedHints) {
253265

254266
// Complain about unknown fields
255267
let usedFields = new Set(Object.keys(hint));
256-
let forbiddenFields = usedFields.difference(allowedHintFields);
268+
let forbiddenFields = setDifference(usedFields, allowedHintFields);
257269
if (forbiddenFields.size != 0) {
258270
showDebugOutput(
259271
`Unknown field(s) in hint[${i}]: ` +
@@ -306,7 +318,7 @@ function processInfo(configurationInfo) {
306318
'hints', 'successes', 'failures', 'correct', 'expected',
307319
'debug']);
308320
let usedFields = new Set(Object.keys(info));
309-
let forbiddenFields = usedFields.difference(allowedInfoFields);
321+
let forbiddenFields = setDifference(usedFields, allowedInfoFields);
310322
if (forbiddenFields.size != 0) {
311323
showDebugOutput(
312324
`Unknown field(s) in info: ` +

0 commit comments

Comments
 (0)