G
Garrett Smith
I want to set the toElement property on a custom event, however it
cannot be done automatically. If what I read is correct, the reason for
this is that the property is a reference.
Here is a demonstration of the problem.
<html>
<head>
<title>blah</title>
</head>
<body>
<script type="text/jscript">
document.body.onmouseout = function () {
var from = event.fromElement;
from = from && from.nodeName;
alert("fromElement: " + from);
};
document.body.fireEvent("onmouseout" /*,
{fromElement: document.documentElement}*/);</script>
</body>
</html>
I have noticed that if the event is generated by the user, then the
toElement property is set. I have also noticed that if the argument to
createEventObject is an event object with a toElement property, that the
toElement reference is used.
The problem is that the toElement property seem only to be set from a
user-generated event.
Is there any code that will cause IE to set the toElement property?
The reason I want this to work is to test my "getRelatedTarget"
function. I believe the function works (it seems to work as I am using
it), but the unit tests are failing because in IE, the `toElement`
property is null, and not the object that the test is expecting it to be.
cannot be done automatically. If what I read is correct, the reason for
this is that the property is a reference.
Here is a demonstration of the problem.
<html>
<head>
<title>blah</title>
</head>
<body>
<script type="text/jscript">
document.body.onmouseout = function () {
var from = event.fromElement;
from = from && from.nodeName;
alert("fromElement: " + from);
};
document.body.fireEvent("onmouseout" /*,
{fromElement: document.documentElement}*/);</script>
</body>
</html>
I have noticed that if the event is generated by the user, then the
toElement property is set. I have also noticed that if the argument to
createEventObject is an event object with a toElement property, that the
toElement reference is used.
The problem is that the toElement property seem only to be set from a
user-generated event.
Is there any code that will cause IE to set the toElement property?
The reason I want this to work is to test my "getRelatedTarget"
function. I believe the function works (it seems to work as I am using
it), but the unit tests are failing because in IE, the `toElement`
property is null, and not the object that the test is expecting it to be.