grych / drab

Remote controlled frontend framework for Phoenix.
https://tg.pl/drab
MIT License
873 stars 43 forks source link

ReferenceError: event is not defined in FireFox #184

Open DennisKh opened 5 years ago

DennisKh commented 5 years ago
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.

DennisKh commented 5 years ago

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);
    }
grych commented 5 years ago

Thanks, this the well noted!

albaer commented 5 years ago

👍 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.

albaer commented 5 years ago

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.

grych commented 5 years ago

Hi Annie, please check the version form the master, should be fixed.

On 6 Mar 2019, at 19:50, Annie Kiley notifications@github.com wrote:

👍 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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grych/drab/issues/184#issuecomment-470228779, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGK3kOLFP1Vc1K4_PnVJmrVemeq36NDks5vUA4FgaJpZM4bWiD1.

albaer commented 5 years ago

Awesome! Thanks for the quick fix and for all your other work on Drab.

DennisKh commented 5 years ago

Thank you for the quick fix!

marisradu commented 5 years ago

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

grych commented 5 years ago

Hi @marisradu, what do you mean by that?