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
Component: | unfiled → event |
---|---|
Milestone: | 1.next → 1.6 |
Owner: | set to Rick Waldron |
Priority: | undecided → low |
Status: | new → assigned |
comment:2 Changed 12 years ago by
Priority: | low → blocker |
---|
comment:4 Changed 12 years ago by
Draft: https://github.com/rwldrn/jquery/commits/eventprops.1.6v2
Proof of concept: http://dl.dropbox.com/u/3531958/8753.html
comment:5 Changed 12 years ago by
Usage and explanation of syntax:
comment:6 Changed 12 years ago by
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 12 years ago by
comment:8 Changed 12 years ago by
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 12 years ago by
Nix everything above. Simplified version here, does exactly and only what the proposal requested:
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)