Skip to content

Chaining .on() broken for null handlers in jQuery 2.2.0 (inconsistency with 1.12.0) #2812

@dwilson6

Description

@dwilson6

It looks like a bug was introduced in jquery 2.2.0 with the 'on' function.

If you have code that registers a bunch of handlers in a chain and one of the callbacks is null, the on function will return the window object when the callback is null which causes the chaining to fail. This works with jquery 2.1.4. After a little investigation, it looks like the 'on' method was refactored to be global within jquery's scope and returns this (which used to be the jquery object but now is window).

//example from jquery impromptu plugin
$('.selector').on("keydown",keyDownEventHandler)
.on('impromptu:loaded', opts.loaded)
.on('impromptu:close', opts.close)
.on('impromptu:statechanging', opts.statechanging)
.on('impromptu:statechanged', opts.statechanged);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions