Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#5249 closed bug (worksforme)

clipboardData (and other new properties) not copied to new event object

Reported by: paulschreiber Owned by:
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:


When jQuery creates a new event object, the clipboardData property is not copied to the new object.

This means that when you try and bind a paste event, it won't be very useful, as event.clipboardData is empty, so you can't process the contents of the clipboard.

STEPS TO REPRODUCE Here's a small example:

$(document).ready(function () {
    $(this).bind("paste", foo);
    this.addEventListener("paste", bar, false);

function foo(e) {
  alert("foo:" + e.clipboardData);
  alert("foo: clipboard text is:" + e.clipboardData.getData("text/plain"));
function bar(e) {
  alert("bar:" + e.clipboardData.getData("text/plain"));
  alert("bar: clipboard text is:" + e.clipboardData.getData("text/plain"));

Here's a working example of the reduction: http://pastie.org/pastes/618082

WORKAROUND Insert this line before running any of your code: jQuery.event.props.push('clipboardData');

Change History (1)

comment:1 Changed 13 years ago by dmethvin

Component: unfiledevent
Resolution: worksforme
Status: newclosed

There is a high cost to copying and normalizing event properties, so only a small subset of properties are processed.

The event.originalEvent object has the complete original event object, and you should be able to get the data from there.

Note: See TracTickets for help on using tickets.