Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8753 closed enhancement (fixed)

jQuery 1.6: jQuery.Event contstructor to support setting properties

Reported by: Rick Waldron Owned by: Rick Waldron
Priority: blocker Milestone: 1.6
Component: event Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:

Description

Copied directly from jQuery 1.6 Roadmap:

Fix $.Event contstructor to support setting properties on the new event (not just pushing them into the originalEvent), something like $.Event({ type: "keydown", keyCode: 64 })

I couldn't find a ticket for this, if anyone knows of one that exists, please cross-ref

Change History (10)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledevent
Milestone: 1.next1.6
Owner: set to Rick Waldron
Priority: undecidedlow
Status: newassigned

comment:2 Changed 12 years ago by Rick Waldron

Priority: lowblocker

comment:3 Changed 12 years ago by Rick Waldron

Found References:

http://bugs.jquery.com/ticket/7900

http://bugs.jquery.com/ticket/7808

From 7808, updated:

http://jsfiddle.net/rwaldron/65Zjp/3/

(use: http://jsfiddle.net/rwaldron/65Zjp/3/show/ - In a browser that supports native drag/drop, drop a file from your desktop into the box)

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:5 Changed 12 years ago by Rick Waldron

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:6 Changed 12 years ago by Rick Waldron

The resulting enhancement subsequently provides a means to "fix" an event object as well as override event object properties

A case that will be directly benefit from this:

https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.widget.js#L324-353

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:8 Changed 12 years ago by Rick Waldron

In summation, this will allow us to depart from recommending that specified event properties (that can be found on event.originalEvent) be added by calling jQuery.event.props.push(prop). By calling jQuery.Event( type, props ), props will be available directly from the event object argument, with a value either specified by the dev (props) or copied from event.originalEvent. This "property adoption" will only be granted to the specified event type, saving all other event types from being required to copy any more properties than is actually needed of them.

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:9 Changed 12 years ago by Rick Waldron

Nix everything above. Simplified version here, does exactly and only what the proposal requested:

https://github.com/jquery/jquery/pull/301

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:10 Changed 12 years ago by john

Resolution: fixed
Status: assignedclosed

Landed.

Note: See TracTickets for help on using tickets.