I think, I've found a bug in MochiKit.Style.getElementPosition on Opera.

When selecting the position of an element, contained in a table cell,
the position isn't calculated correctly.
Quirksmode findPos function gets the right result, for reference:
http://www.quirksmode.org/js/findpos.html

Test below:
<html>
  <head>
    <title>getElementPosition vs Opera</title>
        <script type="text/javascript" src="mochikit.js"></script>
        <style type="text/css">
        html, body { margin:0; padding:0; }
        </style>

<script type="text/javascript">
quirksmode = {};
quirksmode.findPos = function(obj) {
        var curleft = curtop = 0;
        if (obj.offsetParent) {
                curleft = obj.offsetLeft
                curtop = obj.offsetTop
                while (obj = obj.offsetParent) {
                        curleft += obj.offsetLeft
                        curtop += obj.offsetTop
                }
        }
        return {x: curleft, y: curtop, __repr__:
MochiKit.Style.Coordinates.prototype.__repr__ };
}

addLoadEvent(function() {
        $("debug").innerHTML = repr(getElementPosition($("street")));
        $("debug").innerHTML += "<br>";
        $("debug").innerHTML += repr(quirksmode.findPos($("street")));
});
</script>
  </head>
  <body>

    <table>
                <tbody>
                  <tr><td style="height:100px">&nbsp;</td></tr>
                  <tr><td><img src="#" id="street" alt="Element to get position
from" /></td></tr>
                </tbody>
    </table>

<div id="debug" style="font-size:100pt;font-family:'trebuchet ms'"></div>

<div 
style="height:100px;width:10px;background-color:red;position:absolute;top:0;right:0;">&nbsp;</div>
  </body>
</html>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to