On 15. mai. 2006, at 14.25, Johan Sundström wrote:

>
>> If I have an element with position: relative; and then create in that
>> element a button with position: absolute, and then try to
>> getElementPosition on that button, it seems to be wrong.
>
> It certainly sounds like MochiKit miscalculates the position there.
> Quoting http://browservulsel.blogspot.com/2006/01/positioning- 
> elements-inserted-by-user.html
> (I know, not a standards document, so I'm sure it might be somewhat
> short of Absolute Truth :-): "you need to position [an] absolute
> positioned element relative to the root elements or the first
> non-static positioned parent node".

Yes, that seems to be what happens.
=== MochiKit/Style.js
==================================================================
--- MochiKit/Style.js   (revision 1008)
+++ MochiKit/Style.js   (local)
@@ -249,7 +249,14 @@
              parent.tagName != 'HTML') {
              c.x -= parent.scrollLeft;
              c.y -= parent.scrollTop;
-            if (parent.parentNode) {
+            logDebug(self.computedStyle(parent, 'position'),  
parent.id);
+            if (self.computedStyle(parent, 'position') == 'relative') {
+                logDebug('breaking on ', parent.id)
+                /* We break here */
+                c.x -= parent.offsetLeft;
+                c.y -= parent.offsetTop;
+                parent = null;
+            } else if (parent.parentNode) {
                  parent = parent.parentNode;
              } else {
                  parent = null;


Seems to fix it, but I have no idea if its the correct fix or not..  
Neither do I understand properly how to write tests for theese kind  
of situations.


andreas


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to