Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a proper example of originalEvent, discourage use of jQuery.event.props #405

Closed
dmethvin opened this issue Dec 23, 2013 · 10 comments
Closed
Milestone

Comments

@dmethvin
Copy link
Member

Docs at http://api.jquery.com/category/events/event-object/ say to use originalEvent and then show the unadvisable practice of pushing additional properties on jQuery.event.props to be copied to the event object. Copying lots of properties slows down each delivered event.

@JonathanThiyagarajan
Copy link

Are you telling jQuery isn't passing the touches property on in its custom event object. As described in the event object's documentation, you can use event.originalEvent in your first example to access the "special properties" it has while still getting the benefits of the jQuery normalized event object, e.g.

$('.image').bind('touchstart', function(event) {
  alert(event.originalEvent.touches.length);
}); 

Or you can use the following jquery code jQuery.event.props.push("touches");

@DavidAustin
Copy link

originalEvent needs to be properly documented. The line "Certain events may have properties specific to them" is weak and doesn't lead the reader to conclude that originalEvent is useful.

Certainly examples should be given.

@dmethvin
Copy link
Member Author

dmethvin commented Sep 1, 2015

Since this is tagged as help wanted, we'd be glad to consider a pull request. Everyone here is a volunteer.

@mgol
Copy link
Member

mgol commented May 10, 2016

See jquery/jquery#3112. As @silverwind pointed out, we've now removed jQuery.event.props completely in jquery/jquery@e61fccb so this snippet is now not only not advised but will break in jQuery 3.0.0. We need to remove it ASAP and certainly before jQuery 3.0.0 comes out.

@mgol mgol added this to the 3.0.0 milestone May 10, 2016
@mgol
Copy link
Member

mgol commented May 10, 2016

I've added the 3.0.0 milestone.

@silverwind
Copy link
Contributor

Might be good to make a changelog entry too for the removal of jQuery.event.props.

@mgol
Copy link
Member

mgol commented May 10, 2016

@silverwind What changelog do you have in mind?

@mgol
Copy link
Member

mgol commented May 10, 2016

Ah, you probably mean the Version subsection. We have an in-progress branch at https://github.com/jquery/api.jquery.com/tree/v3.0.0-docs that will land when jQuery 3.0.0 comes but I see it's quite out of date (and doesn't even compile on my machine anymore). @AurelioDeRosa do you know what's the state of that?

@silverwind
Copy link
Contributor

I see you're not keeping a formal changelog. I meant the blog posts, like this one.

@mgol
Copy link
Member

mgol commented May 10, 2016

@silverwind OK. :) We've already added the description to the upgrade guide; there are no links to this page yet, we'll include one in the blog post summarizing the 3.0.0 release.

silverwind added a commit to silverwind/api.jquery.com that referenced this issue May 10, 2016
silverwind added a commit to silverwind/api.jquery.com that referenced this issue May 10, 2016
jQuery.event.props has been removed, so it necessary to access
event.originalEvent for non-common properties.

Fixes: jquery#405
@mgol mgol closed this as completed in e378db8 May 11, 2016
Alkarex added a commit to Alkarex/FreshRSS that referenced this issue Aug 6, 2016
stefanor added a commit to CTPUG/wafer that referenced this issue Nov 9, 2016
event.props was removed in jquery 3 (jquery/api.jquery.com#405).

It looks like this wasn't doing anything useful, and broke the schedule
editor.
javerous pushed a commit to javerous/FreshRSS that referenced this issue Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants