I spent some time looking into this.
Here's why it happens.
Prototype's strategy is to extend the DOM element classes with new behaviors, for example 'hide'. Equivalent of:
HTMLElement.prototype.hide = function(...) {...};
jQuery makes an assumption that if an element has a function with the same name as an event, then it is considered the default behavior of the element when that event is triggered. For example, this is useful for the events 'focus', 'blur', etc, where there is both an event by that name 'focus' and a matching function on the element .focus()
. When you call jQuery's event.preventDefault()
, it's not actually blocking the default behavior. Instead it's the inverse -- if you don't call event.preventDefault()
, then jQuery looks for a function with the same name as the event and then calls it if it exists.
Here's the jQuery src that manually calls the "default behavior" function:
https://github.com/jquery/jquery/blob/d837f119c3729565103005d5d7fa89e1dd8110cb/src/event.js#L338
Thus, we have our problem. Prototype extends the base HTMLElement prototype with new functions (namely, 'hide'). jQuery considers these functions to be default behaviors when an event of the same name is fired. Bootstrap's JS triggers an event of the same name ('hide'), which mistakenly causes jQuery to call Prototype's Element.hide()
function.
I am going to look into a solution based on this information. Probably something along the lines of:
jQuery(window).load(function() {
// Defer this code until after the window 'load' event finishes firing
setTimeout(function() {
window.HTMLElement &&
window.HTMLElement.prototype.hide &&
delete window.HTMLElement.prototype.hide;
}, 0);
});