PhilCodeEx / base2

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

IE throws "Unspecified Error" when calling some methods or accessing some properties of elements not attached to a document #137

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Note: this is not really a bug in base2, but more like a bug in IE.  However it 
will be nice if base2 provides a workaround where no exception is thrown (like 
for example testing in function getBoundingClientRect whether the element is 
attached to the document).

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 type="text/javascript">
function test()
{
    var div = document.createElement('div');
    alert(base2.dom.ElementView.getBoundingClientRect(div));
}
window.onload = test;
    </script>
  </head>
  <body></body>
</html>

2. Open the page in IE browser (tested with versions 6, 7 and 8).

What is the expected output? What do you see instead?
Expected: alert dialog with the text representation of the returned object.
Instead: the browser throws "Unspecified Error"

What version of the product are you using? On what operating system?
1.1 (alpha1)

Please provide any additional information below.
The same error is thrown if an attempt to read the offsetParent property of 
element which is not attached to the document is made.  This most probably is 
related with the fact that for some (COM?) properties IE returns typeof 
"unknown" which is not official return value for this operator (see 
http://robertnyman.com/2005/12/21/what-is-typeof-unknown/).  This also means 
that a simple object detection like "if (element.offsetParent)" has to be 
converted to "if (typeof element.offsetParent == "object")" (which does not 
throw exception when the element is not attached yet to the document).

Original issue reported on code.google.com by mdimitrov@gmail.com on 10 Mar 2011 at 9:16