IE thinks that window and document.body are really the same thing -- even

though one has a style property and the other doesn't. This means that when
we pass in 'window' to pagePosition, it blows up, but it didin't before a 
recent reorganization. Here, we create a short term preventative measure to
ensure that old apps don't break -- this should be fixed in 2.6. 
(See #1034, #1051)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4783 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-10-03 16:15:43 +00:00
parent 61bd874785
commit 3d71b4ff4e
2 changed files with 13 additions and 1 deletions

View File

@@ -991,7 +991,12 @@ OpenLayers.Util.pagePosition = function(forElement) {
while(element) { while(element) {
if(element == document.body) { if(element == document.body) {
if(OpenLayers.Element.getStyle(child, 'position') == 'absolute') { // FIXME: IE, when passed 'window' as the forElement, treats it as
// equal to document.body, but window.style fails, so getStyle
// fails, so we are paranoid and check this here. This check should
// probably move into element.getStyle in 2.6.
if(child && child.style &&
OpenLayers.Element.getStyle(child, 'position') == 'absolute') {
break; break;
} }
} }

View File

@@ -19,6 +19,13 @@
OpenLayers.Util.removeItem(array, 3); OpenLayers.Util.removeItem(array, 3);
t.eq( array.toString(), "1,2,4,5", "Util.removeItem works"); t.eq( array.toString(), "1,2,4,5", "Util.removeItem works");
} }
function test_03_Util_pagePosition(t) {
t.plan( 1 );
var pp = OpenLayers.Util.pagePosition(window);
t.eq( pp.toString(), "0,0", "Page position doesn't bail if passed 'window'")
}
function test_04_Util_createDiv(t) { function test_04_Util_createDiv(t) {
t.plan( 24 ); t.plan( 24 );