jim-jim-jim / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

base2.jsb.eventDispatcher fails to dispatch (delegated?) events under IE9 #138

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create the following test html page:
<html>
  <head>
    <script src="/path_to_base2/base2.js" type="text/javascript"></script>
    <script src="/path_to_base2/base2-dom.js" type="text/javascript"></script>
    <script src="/path_to_base2/base2-jsb.js" type="text/javascript"></script>
    <script type="text/javascript">
new jsb.Rule('div', jsb.behavior.extend({
    onmouseover: function(element, event)
    {
        element.innerHTML = 'MOUSEOVER';
    },

    onmouseout: function(element, event)
    {
        element.innerHTML = 'MOUSEOUT';
    }
}));
    </script>
  </head>
  <body>
    <div>HOVER ME</div>
  </body>
</html>

2. Open the page in IE 9 browser and move the mouse cursor over and out of the 
"HOVER ME" text.

What is the expected output? What do you see instead?
The content of the DIV element must change with the mouse cursor moving over or 
out of it.

What version of the product are you using? On what operating system?
JSB 0.9.6

Please provide any additional information below.
This is caused by incorrect call to "detect" function in file 
base2/jsb/eventDispatcher.js on line 59.  The call there is:

detect("element.dispatchEvent")

which is wrong as this makes a "browser sniffing" detection instead of the 
intended object detection:

detect("(element.dispatchEvent)")

Until now this worked for IE 8 and below, because they did not support 
dispatchEvent so the call detect("(element.dispatchEvent)") would have anyway 
return false.  Probably this same dispatch mechanism (with property changes) 
should have worked also in IE 9, but for some reason (I did not dig into it) 
the onpropertychange event is not fired for the special element attached to the 
document head.  As IE 9 supports dispatchEvent it is anyway better to use it 
and the fix for the detection will result into exactly this.

Original issue reported on code.google.com by mdimitrov@gmail.com on 4 Apr 2011 at 8:26