Changeset 7888
- Timestamp:
- 08/28/08 20:46:45 (3 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/BaseTypes/Element.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Util.js (modified) (1 diff)
- trunk/openlayers/tests/BaseTypes/Element.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/BaseTypes/Element.js
r7627 r7888 216 216 getStyle: function(element, style) { 217 217 element = OpenLayers.Util.getElement(element); 218 var value = element.style[OpenLayers.String.camelize(style)]; 219 if (!value) { 220 if (document.defaultView && 221 document.defaultView.getComputedStyle) { 222 223 var css = document.defaultView.getComputedStyle(element, null); 224 value = css ? css.getPropertyValue(style) : null; 225 } else if (element.currentStyle) { 226 value = element.currentStyle[OpenLayers.String.camelize(style)]; 218 219 var value = null; 220 if (element && element.style) { 221 value = element.style[OpenLayers.String.camelize(style)]; 222 if (!value) { 223 if (document.defaultView && 224 document.defaultView.getComputedStyle) { 225 226 var css = document.defaultView.getComputedStyle(element, null); 227 value = css ? css.getPropertyValue(style) : null; 228 } else if (element.currentStyle) { 229 value = element.currentStyle[OpenLayers.String.camelize(style)]; 230 } 227 231 } 228 }229 230 var positions = ['left', 'top', 'right', 'bottom'];231 if (window.opera&&232 (OpenLayers.Util.indexOf(positions,style) != -1) &&233 (OpenLayers.Element.getStyle(element, 'position') == 'static')) {234 value = 'auto';232 233 var positions = ['left', 'top', 'right', 'bottom']; 234 if (window.opera && 235 (OpenLayers.Util.indexOf(positions,style) != -1) && 236 (OpenLayers.Element.getStyle(element, 'position') == 'static')) { 237 value = 'auto'; 238 } 235 239 } 236 240 trunk/openlayers/lib/OpenLayers/Util.js
r7684 r7888 1067 1067 1068 1068 if(element == document.body) { 1069 // FIXME: IE, when passed 'window' as the forElement, treats it as 1070 // equal to document.body, but window.style fails, so getStyle 1071 // fails, so we are paranoid and check this here. This check should 1072 // probably move into element.getStyle in 2.6. 1073 if(child && child.style && 1074 OpenLayers.Element.getStyle(child, 'position') == 'absolute') { 1069 if(OpenLayers.Element.getStyle(child, 'position') == 'absolute') { 1075 1070 break; 1076 1071 } trunk/openlayers/tests/BaseTypes/Element.html
r7579 r7888 220 220 221 221 function test_Element_getStyle(t) { 222 t.plan( 4);222 t.plan(5); 223 223 224 224 //tests for this function are not 100% complete... there is some funky … … 227 227 // but I cant seem to find a good way to test them. 228 228 // 229 t.ok(OpenLayers.Element.getStyle(null, null) == null, "passing null values in to getStyle() doesnt bomb, returns null"); 229 230 230 231 var elem = document.getElementById("elemID");
