Skip to content

Commit

Permalink
Workaround for envjs#19: Looks like the MouseEvents are not bound
Browse files Browse the repository at this point in the history
  • Loading branch information
orslumen committed Apr 8, 2011
1 parent b294e11 commit 46cd9a5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions envjs/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ __dispatchEvent__ = function(target, event, bubbles){
if (target["on" + event.type]) {
target["on" + event.type](event);
}

// START: https://github.com/envjs/env-js/issues/19: Looks like the MouseEvents are not bound
if ((typeof target.getAttribute === 'function') && target.getAttribute("on" + event.type)) {
script = target.getAttribute("on" + event.type);
// return is not allowed within __eval__, so I am adding a temporary function around it
script = script.replace('javascript:', 'javascript:document._tmp_on_event = function(){ ')+"}";
var tmp_function = eval(script);
var returnValue = tmp_function();
if(returnValue === false){
event.stopPropagation();
}
}
// END: https://github.com/envjs/env-js/issues/19: Looks like the MouseEvents are not bound

if (bubbles && !event.cancelled){
__bubbleEvent__(target, event);
}
Expand Down

0 comments on commit 46cd9a5

Please sign in to comment.