JSFiddle - React, Tailwind, and code Playground
HTML
<p id="hello">Fail!</p>
JavaScript
$(document).ready(function () {
$('#hello').hover(function () {
$(this).text("It works!");
}, function () {
$(this).text("should not be seen in testcase");
});
$('#hello').mouseover();
});
/* Analysis + Fix by Henrik Hjelte (henrik.hjelte at gmail)
This works with jquery up to and including 1.5, starts breaking with 1.5.1
The problem is on line 2788 of dist/jquery.js
Modified jquery.js
2788
- if ( parent !== document && !parent.parentNode ) {
+ if ( parent !== document && (parent && !parent.parentNode )) {
The problem is that since event.relatedTarget is optional,
the check for parent.parentNode might break if event is null/undefined.
var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
// Chrome does something similar, the parentNode property
// can be accessed but is null.
if ( parent !== document && !parent.parentNode ) { // THIS FAILS
if ( parent !== document && (parent && !parent.parentNode )) { // THIS WORKS return;
}
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
}
if ( parent !== this ) {
// set the correct event type
event.type = event.data;
// handle event if we actually just moused on to a non sub-element
jQuery.event.handle.apply( this, arguments );
}
// assuming we've left the element since we most likely mousedover a xul element
} catch(e) { }
},*/