Opened 12 years ago
Closed 12 years ago
#8742 closed bug (invalid)
Uncaught TypeError when calling $.extend on a click event object
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I'm capturing mouse clicks on my page by binding the click event of the body element. I'm wrapping up information about the event and storing it as JSON, using $.extend to perform a deep copy of the event object.
If I click an input element (in my case a radio button), $.extend then loops through the click event object and gets this error: Uncaught TypeError: Accessing selectionEnd on an input element that cannot have a selection.
I've attached a quick and dirty example based off what I'm doing:
$("body").click(function(eventData) { var click = { X: eventData.pageX, Y: eventData.pageY, timestamp: (new Date).getTime(), target: $.extend(true, {}, eventData.target) }; }); <html><body><form><input type="radio"></form></body></html>
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Version: | 1.5.1 → 1.5.2 |
You should not be using $.extend on a node. It is meant for merging plain objects and nodes cannot always be treated as such. To make copies of nodes, use http://api.jquery.com/clone/
Sorry, here's a jsFiddle example: http://jsfiddle.net/U9JCZ/