summaryrefslogtreecommitdiff
path: root/lib/scripts/compatibility.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts/compatibility.js')
-rw-r--r--lib/scripts/compatibility.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/scripts/compatibility.js b/lib/scripts/compatibility.js
index 46cb6ccc2..ea52153c5 100644
--- a/lib/scripts/compatibility.js
+++ b/lib/scripts/compatibility.js
@@ -187,8 +187,29 @@ function prependChild(parent,element) {
}
function addEvent(element, type, handler) {
- DEPRECATED('Use jQuery.bind() instead.');
- jQuery(element).bind(type,{},handler);
+ DEPRECATED('Use jQuery.bind() instead. Note that jQuery’s behaviour' +
+ ' when a handler returns false differs from addEvent’s');
+ jQuery(element).bind(type,{},function (e) {
+ // returning false in an addEvent event handler did not prevent
+ // bubbling but just canceled handlers on this node and prevented
+ // default behavior, so wrap the handler call and mimic that behavior.
+ //
+ // Refer to jQuery.event.handle().
+ var ret = handler.apply(this, Array.prototype.slice.call(arguments, 0));
+ if (typeof ret !== 'undefined') {
+ if ( ret !== false ) {
+ return ret;
+ }
+ // What jQuery does.
+ e.result = ret;
+ e.preventDefault();
+ // Not what jQuery does. This would be: event.stopPropagation();
+ // Hack it so that immediate propagation (other event handlers on
+ // this element) appears stopped without stopping the actual
+ // propagation (bubbling)
+ e.isImmediatePropagationStopped = function () { return true; };
+ }
+ });
}
function removeEvent(element, type, handler) {