Ticket #8753 (closed enhancement: fixed)
jQuery 1.6: jQuery.Event contstructor to support setting properties
| Reported by: | rwaldron | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.6 |
| Component: | event | Version: | 1.5.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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
comment:1 Changed 2 years ago by rwaldron
- Owner set to rwaldron
- Priority changed from undecided to low
- Status changed from new to assigned
- Component changed from unfiled to event
- Milestone changed from 1.next to 1.6
comment:3 Changed 2 years ago by rwaldron
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)
comment:4 Changed 2 years ago by rwaldron
Draft: https://github.com/rwldrn/jquery/commits/eventprops.1.6v2
Proof of concept: http://dl.dropbox.com/u/3531958/8753.html
comment:5 Changed 2 years ago by rwaldron
Usage and explanation of syntax:
comment:6 Changed 2 years ago by rwaldron
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
comment:7 Changed 2 years ago by rwaldron
comment:8 Changed 2 years ago by rwaldron
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.
comment:9 Changed 2 years ago by rwaldron
Nix everything above. Simplified version here, does exactly and only what the proposal requested:
comment:10 Changed 2 years ago by john
- Status changed from assigned to closed
- Resolution set to fixed
Landed.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
