Bug Tracker

Modify

Ticket #8753 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

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 3 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:2 Changed 3 years ago by rwaldron

  • Priority changed from low to blocker

comment:3 Changed 3 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)

Last edited 3 years ago by rwaldron (previous) (diff)

comment:5 Changed 3 years ago by rwaldron

Last edited 3 years ago by rwaldron (previous) (diff)

comment:6 Changed 3 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

Last edited 3 years ago by rwaldron (previous) (diff)

comment:8 Changed 3 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.

Last edited 3 years ago by rwaldron (previous) (diff)

comment:9 Changed 3 years ago by rwaldron

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

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

Last edited 3 years ago by rwaldron (previous) (diff)

comment:10 Changed 3 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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.