#365 closed defect (fixed)
dojo.html.getEventTarget acts differently in Safari
Reported by: | 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, [email protected]… or [email protected]…
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)
Change History (5)
Changed 15 years ago by
Attachment: | safari.html added |
---|
comment:1 Changed 15 years ago by
Milestone: | 0.2.2release → 0.3release |
---|
targeting to correct milestone
comment:2 Changed 15 years ago by
Owner: | changed from anonymous to sjmiles |
---|
Example html which displays the problem described in the ticket