Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#365 closed defect (fixed)

dojo.html.getEventTarget acts differently in Safari

Reported by: breischl@… Owned by: sjmiles
Priority: high Milestone:
Component: General Version: 0.2
Keywords: getEventTarget safari Cc:
Blocked By: Blocking:

Description

In Moz & IE, clicking on a plaintext node sends the click event to the containing element (for instance a <div> or <span>). In Safari the event goes to the text node itself. This causes the dojo.html.getEventTarget() function to give different results in the different browsers.

I have a simple HTML file that displays this behavior, but I can't figure out how to attach it. Please email me if you want it, breischl@… or brianr@…

In order to equalize the results, getEventTarget() should check the nodeType of event.srcElement. If the nodeType == 3, then event.srcElement.parentNode should be returned instead. Example code:

function getEventTargetSafariSafe(evt){
	if(!evt) { evt = window.event || {} };
	if(evt.srcElement) {
		return (evt.srcElement.nodeType == 3 ? evt.srcElement.parentNode : evt.srcElement);
	} else if(evt.target) {
		return evt.target;
	}
	return null;
}

Attachments (1)

safari.html (1.3 KB) - added by breischl@… 14 years ago.
Example html which displays the problem described in the ticket

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by breischl@…

Attachment: safari.html added

Example html which displays the problem described in the ticket

comment:1 Changed 13 years ago by alex

Milestone: 0.2.2release0.3release

targeting to correct milestone

comment:2 Changed 13 years ago by alex

Owner: changed from anonymous to sjmiles

comment:3 Changed 13 years ago by sjmiles

Resolution: fixed
Status: newclosed

rev #3677

comment:4 Changed 12 years ago by (none)

Milestone: 0.3release

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.