ReferenceError: event is not defined in FireFox
DennisKh opened this issue ยท 9 comments
ReferenceError: event is not defined
exec_elixir http://local.com/:187
event_handler_function http://local.com/:1021
I use {:drab, "~> 0.10.1"}
Explain what's wrong. Everything works in Chrome.
Has fixed it as follows. Works for me for now but it's not a right solution.
exec_elixir: function (event_handler, payload, execute_after) {
var reply_to = did();
if (!(payload !== null && typeof payload === 'object' && Array.isArray(payload) === false))
payload = {payload: payload};
var p = {};
for (var i = 0; i < Drab.additional_payloads.length; i++) {
var fx = Drab.additional_payloads[i];
/////////////// My code
var event = event
if (typeof(event) == "undefined") {
event = new Event('click');
}
//////////////
p = Object.assign(p, fx(null, event));
}
payload = Object.assign(p, payload);
if (execute_after) {
Drab.event_reply_table[reply_to] = execute_after;
}
var message = {
event_handler_function: event_handler,
payload: payload,
reply_to: reply_to
};
this.channel.push("event", message);
}
Thanks, this the well noted!
๐ I'm also running into this in Firefox. Are you looking for any help on a fix?
And thanks for all the great work on Drab! It's a ton of fun to use.
In case this is helpful, looks like it is from this commit and the fact that Firefox has the global event
variable behind a flag: https://developer.mozilla.org/en-US/docs/Web/API/Window/event.
Awesome! Thanks for the quick fix and for all your other work on Drab.
Thank you for the quick fix!
Hi @grych
You already have an event in the payload, at least if the error appears after a "drab-click" event.
Sorry that I did not had time to look thru the code to see how and when that is added to the payload and if it's added to all calls to exec_elixir, but might worth to extract the event from the payload if available first, then fallback to the "new Click" workaround provided by @DennisKh .
Cheers and thank you for all your great work on Drab,
Radu
Hi @marisradu,
what do you mean by that?