Workaround spidermonkey bug so dictionary data loads
We need to make a copy of the iteration variable in the for-of loop so that the distinct values are available in the callback.
This commit is contained in:
parent
b4fe1f1fa6
commit
5e0ac4e8ea
@ -46,8 +46,17 @@ class Translator {
|
|||||||
|
|
||||||
const pendingLoads = [];
|
const pendingLoads = [];
|
||||||
for (let key of files) {
|
for (let key of files) {
|
||||||
|
/*
|
||||||
|
Spidermonkey does not implement lexical bindings for for-of loop
|
||||||
|
(see https://bugzilla.mozilla.org/show_bug.cgi?id=449811)
|
||||||
|
so we need to manually make a new declaration for key.
|
||||||
|
Otherwise key will always remain the same in the callback to loadData
|
||||||
|
and the dictionary data will not be set correctly
|
||||||
|
*/
|
||||||
|
let key_ = key;
|
||||||
pendingLoads.push(key);
|
pendingLoads.push(key);
|
||||||
Translator.loadData(this.paths[key], (response) => {
|
Translator.loadData(this.paths[key], (response) => {
|
||||||
|
let key = key_
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'rules':
|
case 'rules':
|
||||||
this.deinflector.setRules(JSON.parse(response));
|
this.deinflector.setRules(JSON.parse(response));
|
||||||
|
Loading…
Reference in New Issue
Block a user