Skip to content

Unable to pass event object when firing a native key(up|down) event #72

Open

Description

@afbobak

Basically I'm trying to do this:

$("input").fire("keydown", {
  type: "keydown",
  keyCode: 191
});

If I read the code correctly it should fix the half-baked event I pass in as a second argument and then go through all the listeners and call the handler with the fixed event.

In practice fire() prepends the boolean false (line 517) to the arguments which then gets passed to the nativeHandler's handler (line 334) but the handler expects the argument "event" as the first argument, which now is always false and thus always fixes the wrong event object.

When I change the nativeHandler's handler to

handler = function (f, event)

then things work with no apparent side-effects.

What's the reason the false prepended?

Activity

  1. rvagg commented on Aug 18, 2012

    @rvagg
    Collaborator

    The 'args' are meant to be additional arguments to the event handler rather than the Event object itself. There is scope though to implement proper Event object handling but it's not in there at the moment.
    It's possible that we could squeeze something into the upcoming 1.0 release since it would likely be an API breaking change, or at a minimum we could make room for it in 1.0 for implementation in 1.1 perhaps.
    If you feel like contributing, the 1.0 code is in the 0.5-wip branch, there's a write-up here about what's in it and the API breakages: http://rod.vagg.org/2012/08/bean_v1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions