Bug Tracker

Opened 14 years ago

Closed 14 years ago

#109 closed enhancement (fixed)

Normalize event object

Reported by: john Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:

Description

Some cross-browser normalization of the event object has already been done - it should be taken further (handling target, etc. propertly).

Change History (8)

comment:1 Changed 14 years ago by john

Milestone: 1.0
Version: 1.0

comment:2 Changed 14 years ago by john

Priority: majorminor

comment:3 Changed 14 years ago by joern

Something like this, added to event.fix:

var targ;
		if (event.target) {
			targ = event.target;
		}
		else if( event.srcElement ) {
			targ = event.srcElement;
		}
		if (targ.nodeType == 3) { // defeat Safari bug
			targ = targ.parentNode;	
		}
		event.target = targ;

comment:4 Changed 14 years ago by joern

Try again, handling target element:

if(event.srcElement) {
 event.target = event.srcElement;
} else if(e.target.nodeType == 3) {
 event.target = event.target.parentNode;
}

comment:5 Changed 14 years ago by joern

target etc. are read-only (http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html), therefore it might be a good idea to create a new object and copy properties and methods from the original object.

comment:6 Changed 14 years ago by joern

Fixed in svn.

comment:7 Changed 14 years ago by joern

Target property is now fixed for both IE and Safari.

comment:8 Changed 14 years ago by joern

Resolution: fixed
Status: newclosed

I close this. Please reopen the ticket if you find something of the event object that should be handled by jQuery, too.

Note: See TracTickets for help on using tickets.