View Full Version : [UNKNOWN][3.0 CORE / 2.x] Ext.Element.setXY bug in IE

26 Jun 2009, 4:46 AM
As i said in 2.x bugs.

Generally if you has not set css left property intentionally of a absolute positioned element ,
the browser which can not get the css left property numerically goes wrong ,because the
margin of the positioned element is not considered when using the offsetLeft property of dom
node .

here is a test code : ( Ext.get("x").setX(Ext.get("x").getX()) the position of x changed )

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>setXY bug</title>

<script type="text/javascript" src="ext-base.js"></script>
<script type="text/javascript" src="ext-core.js"></script>
<script type="text/javascript" src="ext-core-3.0.js"></script>


<div id="test1" style="position:relative;width:100px;height:100px;border:1px solid green;padding:20px;">

<div id="test2" style="position:absolute;width:50px;height:50px;margin:10px;border:1px solid red;">

<script type="text/javascript">
alert("getBoundingClientRect of test2 : "+document.getElementById('test2').getBoundingClientRect().left);
alert("offsetLeft of test2 : "+document.getElementById('test2').offsetLeft);

alert("getBoundingClientRect of test2's parent : "+document.getElementById('test1').getBoundingClientRect().left);

//if fixed by myself
//Ext.get('test2').setX(Ext.get('test2').getX() - parseInt(Ext.get('test2').getStyle("margin-left"),10));

alert("after current getBoundingClientRect of test2 : "+document.getElementById('test2').getBoundingClientRect().left);



26 Jun 2009, 9:07 AM
[ deleted duplicate 2.x bug report and updated this thread's title ]